--- /dev/null
+from unfold.plugin import Plugin
+
+class UnivbrisVtam (Plugin):
+ def __init__ (self, query=None, query_all=None, sync_query=None,
+ checkboxes=False, columns=None,
+ init_key=None,
+ datatables_options={}, **settings):
+ Plugin.__init__ (self, **settings)
+ self.query = query
+ self.query_uuid = query.query_uuid if query else None
+ # Until we have a proper way to access queries in Python
+ self.query_all = query_all
+ self.query_all_uuid = query_all.query_uuid if query_all else None
+ self.sync_query_uuid = sync_query.query_uuid if sync_query else None
+ self.checkboxes = checkboxes
+ # XXX We need to have some hidden columns until we properly handle dynamic queries
+ if columns is not None:
+ self.columns=columns
+ self.hidden_columns = []
+ elif self.query:
+ self.columns = list (['Testbed', 'Virtualization Server', 'VM name', 'Delete'])
+ #replace production
+ #self.columns = self.query.fields
+ if query_all:
+ #replace production
+ self.hidden_columns = []
+ # We need a list because sets are not JSON-serializable
+ #self.hidden_columns = #list(self.query_all.fields - self.query.fields)
+ else:
+ self.hidden_columns = []
+ else:
+ self.columns = []
+ self.hidden_columns = []
+
+ self.columns = list (['Testbed', 'Virtualization Server', 'VM name', 'Delete'])
+ self.init_key=init_key
+ self.datatables_options=datatables_options
+ # if checkboxes were required, we tell datatables about this column's type
+ # so that sorting can take place on a selected-first basis (or -last of course)
+ # this relies on the template exposing the checkboxes 'th' with class 'checkbox'
+ if self.checkboxes:
+ # we use aoColumnDefs rather than aoColumns -- ignore user-provided aoColumns
+ if 'aoColumns' in self.datatables_options:
+ print 'WARNING: querytable uses aoColumnDefs, your aoColumns spec. is discarded'
+ del self.datatables_options['aoColumns']
+ # set aoColumnDefs in datatables_options - might already have stuff in there
+ aoColumnDefs = self.datatables_options.setdefault ('aoColumnDefs',[])
+ # here 'checkbox' is the class that we give to the <th> dom elem
+ # dom-checkbox is a sorting type that we define in querytable.js
+ aoColumnDefs.append ( {'aTargets': ['checkbox'], 'sSortDataType': 'dom-checkbox' } )
+
+ def template_file (self):
+ return "univbrisvtamplugin.html"
+
+ def template_env (self, request):
+ env={}
+ env.update(self.__dict__)
+ env['columns']=self.columns
+ return env
+
+ def requirements (self):
+ reqs = {
+ 'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js",
+ "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js", "js/jquery.jeditable.js",
+ "js/manifold.js", "js/manifold-query.js",
+ "js/unfold-helper.js",
+ "js/univbrisvtam.js",
+ ] ,
+ 'css_files': [ "css/dataTables.bootstrap.css",
+ "css/dataTables.full_numbers.css",
+ "css/univbrisvtam.css",
+ ],
+ }
+ return reqs
+
+ def json_settings_list (self):
+ return ['plugin_uuid', 'domid',
+ 'query_uuid', 'query_all_uuid', 'sync_query_uuid',
+ 'checkboxes', 'datatables_options',
+ 'hidden_columns', 'init_key',]
--- /dev/null
+
+/* the bottom of the datatable needs more space */
+div.UnivbrisVtam-spacer { padding: 8px 4px 15px 4px; }
+
+div.UnivbrisVtam table.dataTable th {
+ font: bold 12px/22px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ color: #4f6b72;
+ border-right: 1px solid #C1DAD7;
+ border-bottom: 1px solid #C1DAD7;
+ border-top: 1px solid #C1DAD7;
+ letter-spacing: 1px;
+ text-transform: uppercase;
+ text-align: left;
+ padding: 8px 12px 4px 20px;
+ vertical-align:middle;
+/* background: #CAE8EA url(../img/tablesort-header.jpg) no-repeat; */
+}
+
+div.UnivbrisVtam table.dataTable th.checkbox {
+ padding-left: 14px;
+}
+
+div.UnivbrisVtam table.dataTable td, div.UnivbrisVtam table.dataTable textarea, div.UnivbrisVtam table.dataTable input [type="text"] {
+ font: bold 12px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ color: #660099;
+ border-right: 1px solid #C1DAD7;
+ border-bottom: 1px solid #C1DAD7;
+}
+div.UnivbrisVtam table.dataTable td {
+ padding: 4px 8px 4px 8px;
+ /* this applies on even rows only, odd ones have a setting in bootstrap of rbg 249.249.249 */
+ background-color: #f4f4f4;
+ color: #660099;
+}
+div.UnivbrisVtam table.dataTable td a {
+ font-weight:normal;
+}
+/* these come from bootstrap */
+div.UnivbrisVtam div.dataTables_info {
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+
+/* one could think or using repeat-x here but that's not working because of the arrows
+ * we might need to make these wider some day
+ * and/or to add background-color: #caebea
+ * which would look less conspicuous in case of overflow
+*/
+
+div.UnivbrisVtam table.dataTable thead .sorting { background: url('../img/tablesort-header-sortable.png') no-repeat; }
+div.UnivbrisVtam table.dataTable thead .sorting_asc { background: url('../img/tablesort-header-up.png') no-repeat; }
+div.UnivbrisVtam table.dataTable thead .sorting_desc { background: url('../img/tablesort-header-down.png') no-repeat; }
+/* this icons set does not have that exact equivalent - using an approximation for now */
+div.UnivbrisVtam table.dataTable thead .sorting_asc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+div.UnivbrisVtam table.dataTable thead .sorting_desc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+
+/* the footers are not active */
+div.UnivbrisVtam table.dataTable tfoot {
+ background: url('../img/tablesort-header.png') repeat-x;
+ background-color: #caebea;
+}
+/* and when sorting is turned off it's useful to set this on header too */
+div.UnivbrisVtam table.dataTable thead {
+ background: url('../img/tablesort-header.png') repeat-x;
+ background-color: #caebea;
+}
+
+div.UnivbrisVtam table.tbbuttons{
+ background-color:#A9E2F3;
+}
+
+
+div.UnivbrisVtam table.tbbuttons td{
+ padding-top: 7px;
+ /*padding-left: 7px*/
+ /*padding-left: 7px*/
+ padding-bottom: 7px;
+ background-color:#A9E2F3;
+}
+
+div.UnivbrisVtam table.tbbuttons tr{
+ background-color:#A9E2F3;
+}
+
+
--- /dev/null
+these styling elements come from plekit with a simple transition to png
+they're currently not all used in myslice
--- /dev/null
+/**
+ * Description: display a query result in a datatables-powered <table>
+ * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA
+ * License: GPLv3
+ */
+
+(function($){
+
+ var debug=false;
+ debug=true
+
+ pk_flowspace_index=0;
+ opt_flowspace_index=0;
+ pk_mode=0;
+ fvf_add=1;
+ fvf_nrow=0;
+
+
+ var UnivbrisVtam = Plugin.extend({
+
+
+ init: function(options, element) {
+ this.classname="univbrisvtam";
+ this._super(options, element);
+
+ this.elmt().on('show', this, this.on_show);
+ this.elmt().on('shown.bs.tab', this, this.on_show);
+ this.elmt().on('resize', this, this.on_resize);
+
+ // We need to remember the active filter for datatables filtering
+ this.filters = Array();
+
+ // an internal buffer for records that are 'in' and thus need to be checked
+ this.buffered_records_to_check = [];
+ // an internal buffer for keeping lines and display them in one call to fnAddData
+ this.buffered_lines = [];
+
+ var keys = manifold.metadata.get_key(this.object);
+ this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
+ this.init_key = this.options.init_key;
+ // have init_key default to canonical_key
+ this.init_key = this.init_key || this.canonical_key;
+ // sanity check
+ if ( ! this.init_key ) messages.warning ("UnivbrisVtam : cannot find init_key");
+ if ( ! this.canonical_key ) messages.warning ("UnivbrisVtam : cannot find canonical_key");
+ if (debug) messages.debug("UnivbrisVtam: canonical_key="+this.canonical_key+" init_key="+this.init_key);
+
+ /* GUI setup and event binding */
+ this.initialize_table();
+
+ },
+
+ /* PLUGIN EVENTS */
+
+ on_show: function(e) {
+ if (debug) messages.debug("UnivbrisVtam.on_show");
+ var self = e.data;
+ self.table.fnAdjustColumnSizing();
+ },
+
+ on_resize: function(e) {
+ if (debug) messages.debug("UnivbrisVtam.on_resize");
+ var self = e.data;
+ self.table.fnAdjustColumnSizing();
+ },
+
+ /* GUI EVENTS */
+
+ /* GUI MANIPULATION */
+
+ initialize_table: function()
+ {
+
+
+ /* Transforms the table into DataTable, and keep a pointer to it */
+ var self = this;
+ //alert(self.options);
+ var actual_options = {
+ // Customize the position of Datatables elements (length,filter,button,...)
+ // we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
+ //sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
+ sDom: "<'row'<'col-xs-5'l><'col-xs-5'r><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>><'buttons'>",
+ //sDom: "<'row'<'col-xs-9'r>t<'buttons'>",
+ // XXX as of sept. 2013, I cannot locate a bootstrap3-friendly mode for now
+ // hopefully this would come with dataTables v1.10 ?
+ // in any case, search for 'sPaginationType' all over the code for more comments
+ sPaginationType: 'bootstrap',
+ // Handle the null values & the error : Datatables warning Requested unknown parameter
+ // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
+ aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
+ // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
+ // sScrollX: '100%', /* Horizontal scrolling */
+ bProcessing: true, /* Loading */
+ fnDrawCallback: function() { self._querytable_draw_callback.call(self);}
+ //fnFooterCallback: function() {self._UnivbrisVtam_footer_callback.call(self,nFoot, aData, iStart, iEnd, aiDisplay)};}
+ // XXX use $.proxy here !
+ };
+ // the intention here is that options.datatables_options as coming from the python object take precedence
+ // xxx DISABLED by jordan: was causing errors in datatables.js
+ // xxx turned back on by Thierry - this is the code that takes python-provided options into account
+ // check your datatables_options tag instead
+ // however, we have to accumulate in aoColumnDefs from here (above)
+ // and from the python wrapper (checkboxes management, plus any user-provided aoColumnDefs)
+ if ( 'aoColumnDefs' in this.options.datatables_options) {
+ actual_options['aoColumnDefs']=this.options.datatables_options['aoColumnDefs'].concat(actual_options['aoColumnDefs']);
+ delete this.options.datatables_options['aoColumnDefs'];
+ }
+ $.extend(actual_options, this.options.datatables_options );
+
+
+ this.table = $("#univbris_vtam__table").dataTable(actual_options);
+
+
+
+ //alert(this.table.$("name"));
+
+ /* Setup the SelectAll button in the dataTable header */
+ /* xxx not sure this is still working */
+ var oSelectAll = $('#datatableSelectAll-'+ this.options.plugin_uuid);
+ oSelectAll.html("<span class='glyphicon glyphicon-ok' style='float:right;display:inline-block;'></span>Select All");
+ oSelectAll.button();
+ oSelectAll.css('font-size','11px');
+ oSelectAll.css('float','right');
+ oSelectAll.css('margin-right','15px');
+ oSelectAll.css('margin-bottom','5px');
+ oSelectAll.unbind('click');
+ oSelectAll.click(this._selectAll);
+
+ /* Add a filtering function to the current table
+ * Note: we use closure to get access to the 'options'
+ */
+ $.fn.dataTableExt.afnFiltering.push(function( oSettings, aData, iDataIndex ) {
+ /* No filtering if the table does not match */
+ if (oSettings.nTable.id != self.options.plugin_uuid + '__table')
+ return true;
+ return self._querytable_filter.call(self, oSettings, aData, iDataIndex);
+ });
+
+ /* Processing hidden_columns */
+ $.each(this.options.hidden_columns, function(i, field) {
+ //manifold.raise_event(self.options.query_all_uuid, FIELD_REMOVED, field);
+ //alert (field);
+ self.hide_column(field);
+ //self.hide_column(field);
+ });
+
+
+ this._querytable_draw_callback();
+
+ }, // initialize_table
+
+
+ fnCreateVms:function(e){
+ console.log("building json to send to backend");
+
+ var testbeds=[];
+
+
+ try{
+ var rows = $("#univbris_vtam__table").dataTable().fnGetNodes();
+ if (rows.length<=0){
+ throw("no vm specified");
+ }
+ else{
+ for(var i=0;i<rows.length;i++){
+ //console.log(rows[i].cells[2].outerHTML.text());
+ var htmlStr=rows[i].cells[2].outerHTML;
+ var parser=new DOMParser();
+ var htmlDoc=parser.parseFromString(htmlStr, "text/html");
+ var para=htmlDoc.getElementsByTagName('p');
+ //console.log(para.item(0).id);
+
+ //build row json
+ var tp_row=para.item(0).id.split(",");
+ var d_row={};
+ for (var a=0;a<tp_row.length;a++){
+ var tp=tp_row[a].split(":");
+ d_row[tp[0]]=tp[1];
+ }
+
+ function findTestbedIndex( _testbeds, _name){
+ var index=-1;
+ for(var a=0;a<_testbeds.length;a++){
+ if(_testbeds[a].name==_name){
+ index=a;
+ }
+ }
+ return index;
+ }
+
+ function findServerIndex( _testbeds, _testbedindex, _name){
+ var index=-1;
+ for(var a=0;a<_testbeds[_testbedindex].vt_servers.length;a++){
+ if(_testbeds[_testbedindex].vt_servers[a].name==_name){
+ index=a;
+ }
+ }
+ return index;
+ }
+
+ var testbedindex=findTestbedIndex(testbeds,d_row['testbed']);
+ if (testbedindex!=-1){
+ var serverindex=findServerIndex(testbeds,testbedindex,d_row['vt_server']);
+ if (serverindex!=-1){
+ //console.log("server:",serverindex);
+ //console.log(testbeds[testbedindex].vt_servers[serverindex].vm_names);
+ testbeds[testbedindex].vt_servers[serverindex].vm_names.push(d_row['vm_name']);
+ }
+ else{
+ var vt_server={};
+ vt_server['name']=d_row['vt_server'];
+ vt_server['vm_names']=[];
+ vt_server['vm_names'].push(d_row['vm_name']);
+ testbeds[testbedindex].vt_servers.push(vt_server);
+ }
+
+ }
+ else{
+ var testbed={};
+ testbed['name']=d_row['testbed'];
+ testbed['vt_servers']=[];
+ var vt_server={};
+ vt_server['name']=d_row['vt_server'];
+ vt_server['vm_names']=[];
+ vt_server['vm_names'].push(d_row['vm_name']);
+ testbed['vt_servers'].push(vt_server);
+ testbeds.push(testbed);
+ }
+
+ }
+
+ var rspecs = JSON.stringify(testbeds);
+ console.log(rspecs);
+ }
+
+ }
+ catch(err){
+ alert(err)
+ }
+ },
+
+
+
+ fnAddVm:function(e){
+ //this.hideFvfError(e);
+ $('#uob_vm_name').removeClass('error');
+ $("#uob_vm_name").val("");
+ jQuery('#uob_vm_name_error').hide();
+ jQuery("#univbris_vtam").hide();
+ jQuery("#univbris_vtam_form").show();
+ },
+
+
+
+
+
+
+
+
+ fnDelete:function(e){
+ e.preventDefault();
+ var nRow = $(this).parents('tr')[0];
+ this.table = $("#univbris_vtam__table").dataTable();
+ this.table.fnDeleteRow( nRow );
+ },
+
+
+
+
+
+
+ /**
+ * @brief Determine index of key in the table columns
+ * @param key
+ * @param cols
+ */
+ getColIndex: function(key, cols) {
+ var tabIndex = $.map(cols, function(x, i) { if (x.sTitle == key) return i; });
+ return (tabIndex.length > 0) ? tabIndex[0] : -1;
+ }, // getColIndex
+
+
+
+
+ new_record: function(record)
+ {
+
+ },
+
+ clear_table: function()
+ {
+ this.table.fnClearTable();
+ },
+
+ redraw_table: function()
+ {
+ this.table.fnDraw();
+ },
+
+ show_column: function(field)
+ {
+ var oSettings = this.table.fnSettings();
+ var cols = oSettings.aoColumns;
+ var index = this.getColIndex(field,cols);
+ if (index != -1)
+ this.table.fnSetColumnVis(index, true);
+ },
+
+ hide_column: function(field)
+ {
+ var oSettings = this.table.fnSettings();
+ var cols = oSettings.aoColumns;
+ var index = this.getColIndex(field,cols);
+ //index=-1;
+ //alert(field + ": index: " + index );
+ if (index != -1)
+ //alert(field + ": hidden with index: " + index );
+ this.table.fnSetColumnVis(index, false);
+ },
+
+ // this is used at init-time, at which point only init_key can make sense
+ // (because the argument record, if it comes from query, might not have canonical_key set
+ set_checkbox_from_record: function (record, checked) {
+ if (checked === undefined) checked = true;
+ var init_id = record[this.init_key];
+ if (debug) messages.debug("UnivbrisVtam.set_checkbox_from_record, init_id="+init_id);
+ // using table.$ to search inside elements that are not visible
+ var element = this.table.$('[init_id="'+init_id+'"]');
+ element.attr('checked',checked);
+ },
+
+ // id relates to canonical_key
+ set_checkbox_from_data: function (id, checked) {
+ if (checked === undefined) checked = true;
+ if (debug) messages.debug("UnivbrisVtam.set_checkbox_from_data, id="+id);
+ // using table.$ to search inside elements that are not visible
+ var element = this.table.$("[id='"+id+"']");
+ element.attr('checked',checked);
+ },
+
+ /*************************** QUERY HANDLER ****************************/
+
+ on_filter_added: function(filter)
+ {
+ this.filters.push(filter);
+ this.redraw_table();
+ },
+
+ on_filter_removed: function(filter)
+ {
+ // Remove corresponding filters
+ this.filters = $.grep(this.filters, function(x) {
+ return x != filter;
+ });
+ this.redraw_table();
+ },
+
+ on_filter_clear: function()
+ {
+ // XXX
+ this.redraw_table();
+ },
+
+ on_field_added: function(field)
+ {
+ this.show_column(field);
+ },
+
+ on_field_removed: function(field)
+ {
+ this.hide_column(field);
+ },
+
+ on_field_clear: function()
+ {
+ alert('UnivbrisVtam::clear_fields() not implemented');
+ },
+
+ /* XXX TODO: make this generic a plugin has to subscribe to a set of Queries to avoid duplicated code ! */
+ /*************************** ALL QUERY HANDLER ****************************/
+
+ on_all_filter_added: function(filter)
+ {
+ // XXX
+ this.redraw_table();
+ },
+
+ on_all_filter_removed: function(filter)
+ {
+ // XXX
+ this.redraw_table();
+ },
+
+ on_all_filter_clear: function()
+ {
+ // XXX
+ this.redraw_table();
+ },
+
+ on_all_field_added: function(field)
+ {
+ this.show_column(field);
+ },
+
+ on_all_field_removed: function(field)
+ {
+ this.hide_column(field);
+ },
+
+ on_all_field_clear: function()
+ {
+ alert('UnivbrisVtam::clear_fields() not implemented');
+ },
+
+
+ /*************************** RECORD HANDLER ***************************/
+
+ on_new_record: function(record)
+ {
+ },
+
+ on_clear_records: function()
+ {
+ },
+
+ // Could be the default in parent
+ on_query_in_progress: function()
+ {
+ this.spin();
+ },
+
+ on_query_done: function()
+ {
+ this.received_query = true;
+ // unspin once we have received both
+ if (this.received_all_query && this.received_query) this.unspin();
+ },
+
+ on_field_state_changed: function(data)
+ {
+ switch(data.request) {
+ case FIELD_REQUEST_ADD:
+ case FIELD_REQUEST_ADD_RESET:
+ this.set_checkbox_from_data(data.value, true);
+ break;
+ case FIELD_REQUEST_REMOVE:
+ case FIELD_REQUEST_REMOVE_RESET:
+ this.set_checkbox_from_data(data.value, false);
+ break;
+ default:
+ break;
+ }
+ },
+
+ /* XXX TODO: make this generic a plugin has to subscribe to a set of Queries to avoid duplicated code ! */
+ // all
+ on_all_field_state_changed: function(data)
+ {
+ switch(data.request) {
+ case FIELD_REQUEST_ADD:
+ case FIELD_REQUEST_ADD_RESET:
+ this.set_checkboxfrom_data(data.value, true);
+ break;
+ case FIELD_REQUEST_REMOVE:
+ case FIELD_REQUEST_REMOVE_RESET:
+ this.set_checkbox_from_data(data.value, false);
+ break;
+ default:
+ break;
+ }
+ },
+
+ on_all_new_record: function(record)
+ {
+ this.new_record(record);
+ },
+
+ on_all_clear_records: function()
+ {
+ this.clear_table();
+
+ },
+
+ on_all_query_in_progress: function()
+ {
+ // XXX parent
+ this.spin();
+ }, // on_all_query_in_progress
+
+ on_all_query_done: function()
+ {
+ if (debug) messages.debug("1-shot initializing dataTables content with " + this.buffered_lines.length + " lines");
+
+
+ //this.table.fnAddData (this.buffered_lines);
+ this.buffered_lines=[];
+
+ var self = this;
+ // if we've already received the slice query, we have not been able to set
+ // checkboxes on the fly at that time (dom not yet created)
+ $.each(this.buffered_records_to_check, function(i, record) {
+ if (debug) messages.debug ("querytable delayed turning on checkbox " + i + " record= " + record);
+ self.set_checkbox_from_record(record, true);
+ });
+ this.buffered_records_to_check = [];
+
+ this.received_all_query = true;
+ // unspin once we have received both
+ if (this.received_all_query && this.received_query) this.unspin();
+
+ }, // on_all_query_done
+
+ /************************** PRIVATE METHODS ***************************/
+
+ /**
+ * @brief QueryTable filtering function
+ */
+ _querytable_filter: function(oSettings, aData, iDataIndex)
+ {
+ var ret = true;
+ $.each (this.filters, function(index, filter) {
+ /* XXX How to manage checkbox ? */
+ var key = filter[0];
+ var op = filter[1];
+ var value = filter[2];
+
+ /* Determine index of key in the table columns */
+ var col = $.map(oSettings.aoColumns, function(x, i) {if (x.sTitle == key) return i;})[0];
+
+ /* Unknown key: no filtering */
+ if (typeof(col) == 'undefined')
+ return;
+
+ col_value=unfold.get_value(aData[col]);
+ /* Test whether current filter is compatible with the column */
+ if (op == '=' || op == '==') {
+ if ( col_value != value || col_value==null || col_value=="" || col_value=="n/a")
+ ret = false;
+ }else if (op == '!=') {
+ if ( col_value == value || col_value==null || col_value=="" || col_value=="n/a")
+ ret = false;
+ } else if(op=='<') {
+ if ( parseFloat(col_value) >= value || col_value==null || col_value=="" || col_value=="n/a")
+ ret = false;
+ } else if(op=='>') {
+ if ( parseFloat(col_value) <= value || col_value==null || col_value=="" || col_value=="n/a")
+ ret = false;
+ } else if(op=='<=' || op=='≤') {
+ if ( parseFloat(col_value) > value || col_value==null || col_value=="" || col_value=="n/a")
+ ret = false;
+ } else if(op=='>=' || op=='≥') {
+ if ( parseFloat(col_value) < value || col_value==null || col_value=="" || col_value=="n/a")
+ ret = false;
+ }else{
+ // How to break out of a loop ?
+ alert("filter not supported");
+ return false;
+ }
+
+ });
+ return ret;
+ },
+
+ _querytable_draw_callback: function()
+ {
+ /*
+ * Handle clicks on checkboxes: reassociate checkbox click every time
+ * the table is redrawn
+ */
+ this.elts('querytable-checkbox').unbind('click').click(this, this._check_click);
+ $("#add_vm").unbind('click').click(this, this.fnAddVm);
+ $("#submit_vms").unbind('click').click(this, this.fnCreateVms);
+ $('#univbris_vtam__table .delete').unbind('click').click(this, this.fnDelete);
+ /*var edits=this.elts.all.find('.edit');
+ edits.each(function(){
+ this.unbind('click').click(this,this.fnEdit);
+ }
+ */
+ if (!this.table)
+ return;
+
+ /* Remove pagination if we show only a few results */
+ var wrapper = this.table; //.parent().parent().parent();
+ var rowsPerPage = this.table.fnSettings()._iDisplayLength;
+ var rowsToShow = this.table.fnSettings().fnRecordsDisplay();
+ var minRowsPerPage = this.table.fnSettings().aLengthMenu[0];
+
+ if ( rowsToShow <= rowsPerPage || rowsPerPage == -1 ) {
+ $('.querytable_paginate', wrapper).css('visibility', 'hidden');
+ } else {
+ $('.querytable_paginate', wrapper).css('visibility', 'visible');
+ }
+
+ if ( rowsToShow <= minRowsPerPage ) {
+ $('.querytable_length', wrapper).css('visibility', 'hidden');
+ } else {
+ $('.querytable_length', wrapper).css('visibility', 'visible');
+ }
+
+
+
+
+ },
+
+
+
+ _check_click: function(e)
+ {
+ e.stopPropagation();
+
+ var self = e.data;
+ var id=this.id;
+
+ // this.id = key of object to be added... what about multiple keys ?
+ if (debug) messages.debug("querytable._check_click key="+this.canonical_key+"->"+id+" checked="+this.checked);
+ //manifold.raise_event(self.options.query_uuid, this.checked?SET_ADD:SET_REMOVED, id);
+ //return false; // prevent checkbox to be checked, waiting response from manifold plugin api
+
+ },
+
+ _selectAll: function()
+ {
+ // requires jQuery id
+ var uuid=this.id.split("-");
+ var oTable=$("#querytable-"+uuid[1]).dataTable();
+ // Function available in QueryTable 1.9.x
+ // Filter : displayed data only
+ var filterData = oTable._('tr', {"filter":"applied"});
+ /* TODO: WARNING if too many nodes selected, use filters to reduce nuber of nodes */
+ if(filterData.length<=100){
+ $.each(filterData, function(index, obj) {
+ var last=$(obj).last();
+ var key_value=unfold.get_value(last[0]);
+ if(typeof($(last[0]).attr('checked'))=="undefined"){
+ $.publish('selected', 'add/'+key_value);
+ }
+ });
+ }
+ },
+
+ });
+
+
+
+ $.plugin('UnivbrisVtam', UnivbrisVtam);
+
+ /* define the 'dom-checkbox' type for sorting in datatables
+ http://datatables.net/examples/plug-ins/dom_sort.html
+ using trial and error I found that the actual column number
+ was in fact given as a third argument, and not second
+ as the various online resources had it - go figure */
+ $.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, _, iColumn ) {
+ return $.map( oSettings.oApi._fnGetTrNodes(oSettings), function (tr, i) {
+ return result=$('td:eq('+iColumn+') input', tr).prop('checked') ? '1' : '0';
+ } );
+ }
+
+
+
+})(jQuery);
+
+
+
--- /dev/null
+<div id='main-{{ domid }}' class='univbrisvtam-spacer'>
+ <form id="uob_vtam">
+ <table class='table table-striped table-bordered dataTable' id='{{domid}}__table'>
+ <thead>
+ <tr>
+ {% for column in columns %} <th>{{ column }}</th> {% endfor %}
+ {% for column in hidden_columns %} <th>{{ column }}</th> {% endfor %}
+ </tr>
+ </thead>
+ <tbody>
+ </tbody>
+ <tfoot>
+ <tr>
+ {% for column in columns %} <th>{{ column }}</th> {% endfor %}
+ {% for column in hidden_columns %} <th>{{ column }}</th> {% endfor %}
+ </tr>
+ </tfoot>
+ </table>
+ <table class = 'table tbbuttons' align="center" id='uob_fv_form_buttons'>
+ <tr>
+ <td align="center"><button id="add_vm" type="button" style="height: 25px; width: 300px;" onclick="fnAddVm()">add another VM to request</button></td>
+ <tr>
+
+ </tr>
+ <td align="center"><button id="submit_vms" type="button" style="height: 25px; width: 300px" onclick="fnCreateVms()">Create VMs (submit to AM)</button></td>
+ </tr>
+</table>
+ </form>
+</div>
--- /dev/null
+from unfold.plugin import Plugin
+
+class UnivbrisVtamForm (Plugin):
+
+ def __init__ (self, query=None, query_all=None,
+ checkboxes=False, columns=None,
+ init_key=None,
+ datatables_options={}, **settings):
+ Plugin.__init__(self, **settings)
+ self.query = query
+ self.query.uuid = query.query_uuid if query else None
+ self.query_all = query_all
+ self.query_all_uuid = query_all.query_uuid if query_all else None
+
+
+ def template_file (self):
+ return "univbrisvtamform.html"
+
+ def template_env (self, request):
+ env={}
+ env.update(self.__dict__)
+ return env
+
+ def requirements (self):
+ reqs = {
+ 'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js",
+ "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
+ "js/manifold.js", "js/manifold-query.js",
+ "js/unfold-helper.js",
+ "js/univbrisvtamform.js",
+ ] ,
+ 'css_files': [ "css/dataTables.bootstrap.css",
+ "css/dataTables.full_numbers.css",
+ "css/univbrisvtamform.css",
+ ],
+ }
+ return reqs
+
+ def json_settings_list (self):
+ return ['plugin_uuid', 'domid',
+ 'query_uuid', 'query_all_uuid',
+ 'checkboxes', 'datatables_options',
+ 'hidden_columns', 'init_key',]
--- /dev/null
+
+/* the bottom of the datatable needs more space */
+div.univbrisvtamform-spacer { padding: 8px 4px 15px 4px; }
+
+div.UnivbrisVtamForm table.dataTable th {
+ font: bold 12px/22px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ color: #4f6b72;
+ border-right: 1px solid #C1DAD7;
+ border-bottom: 1px solid #C1DAD7;
+ border-top: 1px solid #C1DAD7;
+ letter-spacing: 1px;
+ text-transform: uppercase;
+ text-align: left;
+ padding: 8px 12px 4px 20px;
+ vertical-align:middle;
+/* background: #CAE8EA url(../img/tablesort-header.jpg) no-repeat; */
+}
+
+div.UnivbrisVtamForm table.dataTable th.checkbox {
+ padding-left: 14px;
+}
+
+div.UnivbrisVtamForm table.dataTable td, div.UnivbrisVtamForm table.dataTable textarea, div.UnivbrisVtamForm table.dataTable input [type="text"] {
+ font: bold 12px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ color: #660099;
+ border-right: 1px solid #C1DAD7;
+ border-bottom: 1px solid #C1DAD7;
+}
+div.UnivbrisVtamForm table.dataTable td {
+ padding: 4px 8px 4px 8px;
+ /* this applies on even rows only, odd ones have a setting in bootstrap of rbg 249.249.249 */
+ background-color: #f4f4f4;
+ color: #660099;
+}
+div.UnivbrisVtamForm table.dataTable td a {
+ font-weight:normal;
+}
+/* these come from bootstrap */
+div.UnivbrisVtamForm div.dataTables_info {
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+
+/* one could think or using repeat-x here but that's not working because of the arrows
+ * we might need to make these wider some day
+ * and/or to add background-color: #caebea
+ * which would look less conspicuous in case of overflow
+*/
+
+div.UnivbrisVtamForm table.dataTable thead .sorting { background: url('../img/tablesort-header-sortable.png') no-repeat; }
+div.UnivbrisVtamForm table.dataTable thead .sorting_asc { background: url('../img/tablesort-header-up.png') no-repeat; }
+div.UnivbrisVtamForm table.dataTable thead .sorting_desc { background: url('../img/tablesort-header-down.png') no-repeat; }
+/* this icons set does not have that exact equivalent - using an approximation for now */
+div.UnivbrisVtamForm table.dataTable thead .sorting_asc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+div.UnivbrisVtamForm table.dataTable thead .sorting_desc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+
+/* the footers are not active */
+div.UnivbrisVtamForm table.dataTable tfoot {
+ background: url('../img/tablesort-header.png') repeat-x;
+ background-color: #caebea;
+}
+/* and when sorting is turned off it's useful to set this on header too */
+div.UnivbrisVtamForm table.dataTable thead {
+ background: url('../img/tablesort-header.png') repeat-x;
+ background-color: #caebea;
+}
--- /dev/null
+these styling elements come from plekit with a simple transition to png
+they're currently not all used in myslice
--- /dev/null
+/**
+ * Description: display a query result in a datatables-powered <table>
+ * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA
+ * License: GPLv3
+ */
+
+(function($){
+
+ vt_servers_list=[];
+ testbeds_list=[];
+
+ var UnivbrisVtamForm = Plugin.extend({
+
+ init: function(options, element) {
+ //console.log("hello....................");
+ this._super(options, element);
+ this.filters = Array();
+
+ // an internal buffer for records that are 'in' and thus need to be checked
+ this.buffered_records_to_check = [];
+ // an internal buffer for keeping lines and display them in one call to fnAddData
+ this.buffered_lines = [];
+
+
+
+
+ //var keys = manifold.metadata.get_key(this.object);
+ //this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
+ //
+ //this.init_key = this.options.init_key;
+ // have init_key default to canonical_key
+ //this.init_key = this.init_key || this.canonical_key;
+ // sanity check
+ //if ( ! this.init_key ) messages.warning ("UnivbrisVtamForm : cannot find init_key");
+ //if ( ! this.canonical_key ) messages.warning ("UnivbrisVtamForm : cannot find canonical_key");
+ //if (debug) messages.debug("UnivbrisVtamForm: canonical_key="+this.canonical_key+" init_key="+this.init_key);
+
+ /* Setup query and record handlers */
+ this.listen_query(options.query_uuid);
+ // this.listen_query(options.query_all_uuid, 'all');
+
+ /* GUI setup and event binding */
+
+
+ $('<button id="cancelvtamform" type="button" style="height: 25px; width: 200px" onclick="fnCancelVtamForm()">Cancel</button>').appendTo('#vtam_form_buttons');
+ $("#cancelvtamform").unbind('click').click(this, this.fnCancelVtamForm);
+
+ $('<button id="addvtamform" type="button" style="height: 25px; width: 200px" onclick="fnAddVtamForm()">Add VM</button>').appendTo('#vtam_form_buttons');
+ $("#addvtamform").unbind('click').click(this, this.fnAddVtamForm);
+
+ jQuery("#univbris_vtam_form").hide();
+
+ $('#uob_testbed_name').on("change", this.testbedChanged);
+
+ //this.on_new_record("urn:publicid:IDN+i2cat:vtam+node+Rodoreda");
+ //this.on_new_record("urn:publicid:IDN+bristol:vtam+node+March");
+ //this.on_new_record("urn:publicid:IDN+brazil:vtam+node+Verdaguer");
+ //this.on_query_done();
+
+ // console.log("after");
+ },
+
+ testbedChanged: function(e){
+ console.log($('#uob_testbed_name option:selected').text());
+
+ $('#uob_virtualization_server')
+ .find('option')
+ .remove()
+ .end();
+
+ for(var i=0;i<vt_servers_list.length;i++){
+ if(vt_servers_list[i].testbed==$('#uob_testbed_name option:selected').text()){
+ $('#uob_virtualization_server')
+ .append($("<option></option>")
+ .attr("value",vt_servers_list[i].name)
+ .text(vt_servers_list[i].name));
+ }
+ }
+ },
+
+
+ fnCancelVtamForm:function(e){
+ jQuery("#univbris_vtam_form").hide();
+ jQuery("#univbris_vtam").show();
+ console.log("cancel vtam form");
+ },
+
+ fnAddVtamForm:function(e){
+ console.log("add vtam form");
+ var vmNameVal = /^[a-zA-Z0-9]+$/;
+ //console.log($("#uob_vm_name").val());
+ if (vmNameVal.test($("#uob_vm_name").val())){
+ //build form string
+ var vtam="testbed:"+$('#uob_testbed_name option:selected').text();
+ vtam +=",vt_server:"+$('#uob_virtualization_server option:selected').text();
+ vtam +=",vm_name:"+$("#uob_vm_name").val();
+ var vm_name="<p id='"+vtam+"'>"+$("#uob_vm_name").val()+"</p>";
+ var vtamtable = $("#univbris_vtam__table").dataTable();
+ vtamtable.fnAddData([$('#uob_testbed_name option:selected').text(),$('#uob_virtualization_server option:selected').text(), vm_name,'<a class="delete" href="">Delete</a>']);
+ jQuery("#univbris_vtam_form").hide();
+ jQuery("#univbris_vtam").show();
+ }
+ else{
+ $('#uob_vm_name').addClass('error');
+ jQuery('#uob_vm_name_error').show();
+ }
+ },
+
+ /* PLUGIN EVENTS */
+
+ on_show: function(e) {
+ },
+
+ on_resize: function(e) {
+ },
+
+ /* GUI EVENTS */
+
+ /* GUI MANIPULATION */
+
+ new_record: function(record)
+ {
+ var urn = record['urn'];
+ var pos = urn.search('vtam');
+ if (pos!=-1){
+ ///line =new Array();
+ var vt_server={};
+ var com_ay=urn.split("+");
+ vt_server['name']=com_ay[com_ay.length-1];
+ var testbed_ay=com_ay[1].split(":");
+ vt_server['testbed']=testbed_ay[0];
+ this.add_new_vt_server(vt_server);
+ this.add_new_testbed(testbed_ay[0]);
+ //this.vt_servers_list.push(vt_server);
+ }
+ },
+
+ clear_table: function()
+ {
+ },
+
+ redraw_table: function()
+ {
+ },
+
+
+ add_new_vt_server:function(vt_server){
+ var found=false;
+ for(var i=0;i<vt_servers_list.length;i++){
+ if(vt_servers_list[i].name==vt_server.name && vt_servers_list[i].testbed==vt_server.testbed){
+ found=true;
+ break;
+ }
+ }
+
+ //console.log(found);
+
+ if (found==false){
+ vt_servers_list.push(vt_server);
+ }
+ },
+
+ add_new_testbed:function(testbed){
+ var found=false;
+ for(var i=0;i<testbeds_list.length;i++){
+ if(testbeds_list[i]==testbed){
+ found=true;
+ break;
+ }
+ }
+
+ //console.log(found);
+
+ if (found==false){
+ testbeds_list.push(testbed);
+ }
+ },
+
+
+
+
+
+ /*************************** QUERY HANDLER ****************************/
+
+ on_filter_added: function(filter)
+ {
+ },
+
+ on_filter_removed: function(filter)
+ {
+ },
+
+ on_filter_clear: function()
+ {
+ this.redraw_table();
+ },
+
+ on_field_added: function(field)
+ {
+ this.show_column(field);
+ },
+
+ on_field_removed: function(field)
+ {
+ this.hide_column(field);
+ },
+
+ on_field_clear: function()
+ {
+ },
+
+
+ /*************************** ALL QUERY HANDLER ****************************/
+
+ on_all_filter_added: function(filter)
+ {
+ },
+
+ on_all_filter_removed: function(filter)
+ {
+
+ },
+
+ on_all_filter_clear: function()
+ {
+ },
+
+ on_all_field_added: function(field)
+ {
+ },
+
+ on_all_field_removed: function(field)
+ {
+ },
+
+ on_all_field_clear: function()
+ {
+ },
+
+
+ /*************************** RECORD HANDLER ***************************/
+
+ on_new_record: function(record)
+ {
+ //alert("record:")
+ console.log(record.hostname);
+ if (this.received_all_query) {
+
+ } else {
+ this.buffered_records_to_check.push(record);
+ }
+ },
+
+ on_clear_records: function()
+ {
+ },
+
+ // Could be the default in parent
+ on_query_in_progress: function()
+ {
+ this.spin();
+ },
+
+ on_query_done: function()
+ {
+ this.received_query = true;
+ for(var i=0;i<this.buffered_records_to_check.length;i++){
+ this.new_record(this.buffered_records_to_check[i]);
+ }
+
+
+ /*$.each(vt_servers_list, function(key, value) {
+ $('#uob_testbed_name')
+ .append($("<option></option>")
+ .attr("value",key)
+ .text(value.testbed));
+ });*/
+
+ $('#uob_testbed_name')
+ .find('option')
+ .remove()
+ .end()
+
+ for(var t=0;t<testbeds_list.length;t++){
+ $('#uob_testbed_name')
+ .append($("<option></option>")
+ .attr("value",testbeds_list[t])
+ .text(testbeds_list[t]));
+ }
+
+ $('#uob_virtualization_server')
+ .find('option')
+ .remove()
+ .end()
+
+ for(var i=0;i<vt_servers_list.length;i++){
+ if(vt_servers_list[i].testbed==$('#uob_testbed_name option:selected').text()){
+ $('#uob_virtualization_server')
+ .append($("<option></option>")
+ .attr("value",vt_servers_list[i].name)
+ .text(vt_servers_list[i].name));
+ }
+ }
+
+ this.unspin();
+ },
+
+ on_field_state_changed: function(data)
+ {
+
+ },
+
+ }); //close plugin extend
+
+ $.plugin('UnivbrisVtamForm', UnivbrisVtamForm);
+
+})(jQuery);
+
+
+
+
--- /dev/null
+<style>
+.multiselect {
+ width:40em;
+ height:5em;
+ border:solid 1px #c0c0c0;
+ overflow:auto;
+}
+
+.multiselect label {
+ display:block;
+}
+
+.multiselect-on {
+ color:#ffffff;
+ background-color:#000099;
+}
+
+.error{
+border:2px solid red;
+}
+
+</style>
+
+<form id="uob_vtam_form">
+ <table id='uob_vtam_table'>
+ <tr>
+ <th><strong>Testbed</strong></th>
+ <td>
+ <select id="uob_testbed_name" name="uob_testbed_name" maxlength="20" title="Testbed Name"/>
+ </td>
+ <td>
+ </td>
+ </tr>
+
+ <tr>
+ <th><strong>Virtualization Server</strong></th>
+ <td>
+
+ <label for="uob_virtualization_server"></label>
+ <select id="uob_virtualization_server" name="uob_virtualization_server" maxlength="20" title="Virtualization Server of VM" />
+ </td>
+ <td>
+ </td>
+ </tr>
+
+
+ <tr>
+ <th><strong>VM Name</strong></th>
+ <td>
+
+ <label for="uob_vm_name"></label>
+ <input id="uob_vm_name" type="text" name="uob_vm_name" maxlength="20" title="Name of VM" />
+ </td>
+ <td>
+ <p id="uob_vm_name_error" >name of VM should be alphanumeric</p>
+ </td>
+ </tr>
+
+ </table>
+ </form>
+<div id="vtam_form_buttons"></div>
+
from plugins.univbrisfvf import UnivbrisFvf
from plugins.univbrisfvfo import UnivbrisFvfo
from plugins.univbristopo import UnivbrisTopo
-
+from plugins.univbrisvtam import UnivbrisVtam as UnivbrisVtamPlugin
+from plugins.univbrisvtamform import UnivbrisVtamForm
from plugins.columns_editor import ColumnsEditor
from plugins.sladialog import SlaDialog
},
)
- #plugin which allows the definition the match criteria on a single OPTICAL flowspace
-
- univbrisofvform = UnivbrisFvfo(
+ #plugin which allows the definition the match criteria on a single OPTICAL flowspace
+ univbrisofvform = UnivbrisFvfo(
page = page,
title = 'univbris_oflowspace_form',
domid = 'univbris_oflowspace_form',
title = 'univbris_topology',
domid = 'univbris_topology',
query = query_resource_all,
- #query = query_resource_all,
)
-
+
+ # --------------------------------------------------------------------------
+ # Ofelia VTAM Plugin
+ # Bristol Plugin
+
+ #plugin which display a table where an experimenter will add VMs to according to his needs
+ univbrisvtamplugin = UnivbrisVtamPlugin(
+ page = page,
+ title = 'univbris_vtam',
+ domid = 'univbris_vtam',
+ query = None,
+ )
+
+ #plugin which display a form where an experimenter will specify where a
+ univbrisvtamform = UnivbrisVtamForm(
+ page = page,
+ title = 'univbris_vtam_form',
+ domid = 'univbris_vtam_form',
+ query = query_resource_all,
+ query_all = None,
+ datatables_options = {
+ 'iDisplayLength': 3,
+ 'bLengthChange' : True,
+ 'bAutoWidth' : True,
+ },
+ )
+
# --------------------------------------------------------------------------
# SLA View and accept dialog
template_env['oflowspaces_form'] = univbrisofvform.render(self.request)
template_env['flowspaces_form'] = univbrisfvform.render(self.request)
template_env['topology'] = univbristopology.render(self.request)
-
+ template_env['vms_list'] = univbrisvtamplugin.render(self.request)
+ template_env['vm_form'] = univbrisvtamform.render(self.request)
+
# template_env['pending_resources'] = pending_resources.render(self.request)
template_env['sla_dialog'] = '' # sla_dialog.render(self.request)
template_env["theme"] = self.theme
<ul class="nav nav-tabs">
<li class="active"><a href="#resourcelist" role="tab" data-toggle="tab">Table</a></li>
<li> <a href="#resourcemap" role="tab" data-toggle="tab">Map</a></li>
+ <li> <a href="#openflowcontroller" role="tab" data-toggle="tab">OpenFlow Controller</a></li>
<li> <a href="#resourceflowspace" role="tab" data-toggle="tab">Flowspace</a></li>
<li> <a href="#resourcescheduler" role="tab" data-toggle="tab">Scheduler</a></li>
</ul>
<div class="tab-pane" id="resourcemap">
{{map_resources}}
</div>
- <div class="tab-pane" id="resourceflowspace">
+ <div class="tab-pane" id="openflowcontroller">
+ <p>{{vms_list}}</p>
+ <p>{{vm_form}}</p>
+
+ <p>{{below_table}}</p>
+ </div>
+ <div class="tab-pane" id="resourceflowspace">
<p>{{welcome}}</p>
<p>{{flowspaces}}</p>
<p>{{flowspaces_form}}</p>
<p>{{resources}}</p>
<p>{{below_table}}</p>
-
</div>
+
<div class="tab-pane" id="resourcescheduler">
{{scheduler}}
</div>
--- /dev/null
+{% extends "layout-unfold1.html" %}
+
+{% block head %}
+{% endblock %}
+
+{% block unfold_main %}
+
+<center><h1>Create New Virtual Machines</h1></center>
+
+<p>{{vms_list}}</p>
+<p>{{vm_form}}</p>
+
+<p>{{below_table}}</p>
+
+{% endblock %}
--- /dev/null
+import json
+from manifold.core.query import Query
+from manifoldapi.manifoldapi import execute_query
+
+from unfold.page import Page
+
+from plugins.lists.testbedlist import TestbedList
+from plugins.lists.slicelist import SliceList
+
+from unfold.loginrequired import FreeAccessView
+from unfold.loginrequired import LoginRequiredAutoLogoutView
+
+from ui.topmenu import topmenu_items_live, the_user
+from plugins.lists.staticlist import StaticList
+from plugins.lists.slicelist import SliceList
+from plugins.messages import Messages
+from plugins.querytable import QueryTable
+from plugins.univbrisfoam import UnivbrisFoam
+from plugins.univbrisfv import UnivbrisFv
+from plugins.univbrisvtam import UnivbrisVtam as UnivbrisVtamPlugin
+from plugins.univbrisvtamform import UnivbrisVtamForm
+
+#This view requires login
+class UnivbrisVtam (LoginRequiredAutoLogoutView):
+ template_name = "univbrisvtam.html"
+
+ def get_context_data(self, **kwargs):
+
+ page = Page(self.request)
+ #print "UNIVBRIS page"
+
+ #create new query to manifold----query is not called yet
+ #need to modify to get i2cat of resources also
+ univbrisvtamform_query=Query().get('ofelia-i2cat-vt:resource').select('hostname')
+ #print univbrisfoam_query #.select('urn')
+
+ #queue the query
+ page.enqueue_query(univbrisvtamform_query)
+ page.expose_js_metadata()
+
+
+ #plugin which display a table where an experimenter will add VMs to according to his needs
+ univbrisvtamplugin = UnivbrisVtamPlugin(
+ page = page,
+ title = 'univbris_vtam',
+ domid = 'univbris_vtam',
+ query = None,
+ )
+
+ #plugin which display a form where an experimenter will specify where a
+ univbrisvtamform = UnivbrisVtamForm(
+ page = page,
+ title = 'univbris_vtam_form',
+ domid = 'univbris_vtam_form',
+ query = univbrisvtamform_query,
+ query_all = None,
+ datatables_options = {
+ 'iDisplayLength': 3,
+ 'bLengthChange' : True,
+ 'bAutoWidth' : True,
+ },
+ )
+
+ #render plugins in each context within a single page, but not all plugins are visible at all time.
+ context = super(UnivbrisVtam, self).get_context_data(**kwargs)
+ context['person'] = self.request.user
+ #context['welcome'] = univbriswelcome.render(self.request)
+ #context['resources'] = univbrisfoamlist.render(self.request)
+ context['vms_list']= univbrisvtamplugin.render(self.request)
+ context['vm_form']= univbrisvtamform.render(self.request)
+ #context['oflowspaces_form']= univbrisofvform.render(self.request)
+ #context['flowspaces_form']= univbrisfvform.render(self.request)
+ #context['topology']=univbristopology.render(self.request)
+
+
+ # XXX This is repeated in all pages
+ # more general variables expected in the template
+ context['title'] = 'Create New Virtual Machines'
+ # the menu items on the top
+ context['topmenu_items'] = topmenu_items_live('univbris', page)
+ # so we can sho who is logged
+ context['username'] = the_user(self.request)
+
+ context.update(page.prelude_env())
+ page.expose_js_metadata()
+
+
+ # the page header and other stuff
+ context.update(page.prelude_env())
+
+ context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"
+
+ return context
+
#from portal.experimentview import ExperimentView
from portal.termsview import TermsView
from portal.univbrisview import UnivbrisView
+from portal.univbrisvtam import UnivbrisVtam
+
from portal.manualdelegationview import ManualDelegationView
-from portal.servicedirectory import ServiceDirectoryView
+from portal.servicedirectory import ServiceDirectoryView
from portal.documentationview import DocumentationView
from portal.supportview import SupportView
from portal.emailactivationview import ActivateEmailView
# hopefully these should move in dedicated source files too
-from portal.views import PresViewView, pres_view_static, pres_view_methods, pres_view_animation
-from portal.django_passresetview import password_reset, password_reset_done, password_reset_confirm, password_reset_complete
+from portal.views import PresViewView, pres_view_static, pres_view_methods, pres_view_animation
+from portal.django_passresetview import password_reset, password_reset_done, password_reset_confirm, password_reset_complete
# DEPRECATED #named_register_forms = (
# DEPRECATED # ("step1", RegisterUserForm),
'portal.django_passresetview.password_reset_complete'),
url(r'^univbris/?$', UnivbrisView.as_view(), name='univbris'),
-
+ url(r'^univbrisvtam/?$', UnivbrisVtam.as_view(), name='univbrisvtam'),
+
url(r'^servicedirectory/?$', ServiceDirectoryView.as_view(), name='servicedirectory'),
)