From: Rezende & Pedro & Carlos & Raphael Date: Tue, 14 Jul 2015 18:26:50 +0000 (-0300) Subject: Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=refs%2Fheads%2Ffibre;hp=22d09f122df0baa7f9d033e687b0422ea12b0e07;p=myslice.git Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre Conflicts: portal/homeview.py --- diff --git a/activity/__init__.py b/activity/__init__.py index 6157bae7..d2a9e94f 100644 --- a/activity/__init__.py +++ b/activity/__init__.py @@ -56,21 +56,23 @@ def logWrite(request, action, message, objects = None): "apikey" : apikey, "signature" : sign(secret, "%s%s%s%s" % (timestamp, ip, request.user, action)), "slice" : None, - "resource" : None + "resource" : None, + "resource_type" : None, + "facility" : None, + "testbed" : None, } - if objects and 'slice' in objects : - log['slice'] = objects['slice'] - - if objects and 'resource' in objects : - log['resource'] = objects['resource'] + for o in objects : + if (o in log) : + log[o] = objects[o] try : result = urllib2.urlopen(server, urllib.urlencode(log)) - print "===============>> activity: " + action + " <" + request.user + "> " + message + print "===============>> activity: %s <%s> %s" % (action, request.user,message) content = result.read() except urllib2.URLError as e: print "===============>> activity: connection to " + server + " impossible, could not log action" + print "==>> " + e.strerror def log(request, action, message, objects = None): # Create a new thread in Daemon mode to send the log entry diff --git a/manifoldapi/manifoldproxy.py b/manifoldapi/manifoldproxy.py index 433a854b..9897b506 100644 --- a/manifoldapi/manifoldproxy.py +++ b/manifoldapi/manifoldproxy.py @@ -13,6 +13,9 @@ from manifoldresult import ManifoldException from manifold.util.log import Log from myslice.configengine import ConfigEngine +# register activity +import activity.slice + debug=False #debug=True @@ -78,7 +81,26 @@ with the query passed using POST""" if 'description' in result and result['description'] \ and isinstance(result['description'], (tuple, list, set, frozenset)): result [ 'description' ] = [ ResultValue.to_html (x) for x in result['description'] ] - + + print "=> MANIFOLD PROXY executing: " + manifold_query.action.lower() + # + # register activity + # + # resource reservation + if (manifold_query.action.lower() == 'update') : + print result['value'][0] + if 'resource' in result['value'][0] : + for resource in result['value'][0]['resource'] : + activity.slice.resource(request, + { + 'slice' : result['value'][0]['slice_hrn'], + 'resource' : resource['hostname'], + 'resource_type' : resource['type'], + 'facility' : resource['facility_name'], + 'testbed' : resource['testbed_name'] + } + ) + json_answer=json.dumps(result) return HttpResponse (json_answer, mimetype="application/json") diff --git a/manifoldapi/static/js/manifold.js b/manifoldapi/static/js/manifold.js index 31d4b000..01b48f51 100644 --- a/manifoldapi/static/js/manifold.js +++ b/manifoldapi/static/js/manifold.js @@ -786,6 +786,7 @@ var manifold = { switch (this_type) { case TYPE_VALUE: case TYPE_LIST_OF_VALUES: + case TYPE_LIST_OF_RECORDS: if (this_value != other_value) return false; break; @@ -793,6 +794,9 @@ var manifold = { if (!(_record_equals(this_value, other_value, key_fields))) return false; break; + /* + XXX WARNING = disabled for OpenFlow plugin !!! + case TYPE_LIST_OF_RECORDS: if (this_value.length != other_value.length) return false; @@ -800,6 +804,7 @@ var manifold = { if (!(_record_equals(this_value[j], other_value[j], key_fields))) return false; break; + */ } } return true; @@ -1111,6 +1116,9 @@ var manifold = { * otherwise, publish the main object as well as subqueries * XXX how much recursive are we ? */ + if (records == null){ + records = Array(); + } if (manifold.pubsub_debug) messages.debug (">>>>> publish_result_rec " + query.object); if (manifold.query_expects_unique_result(query)) { @@ -1224,6 +1232,11 @@ var manifold = { } key = manifold.metadata.get_key(new_object); + if (!key){ + console.log("object type: " + new_object + " has no key"); + console.log(record); + return; + } record.hashCode = manifold.record_hashcode(key.sort()); record.equals = manifold.record_equals(key); diff --git a/plugins/univbrisfv/__init__.py b/plugins/univbrisfv/__init__.py index 93653b9f..6c9aef2f 100644 --- a/plugins/univbrisfv/__init__.py +++ b/plugins/univbrisfv/__init__.py @@ -40,7 +40,7 @@ Current implementation makes the following assumptions as we use 'aoColumnDefs' instead. """ - def __init__ (self, query=None, query_all=None, sync_query=None, + def __init__ (self, query=None, query_all=None, checkboxes=False, columns=None, init_key=None, datatables_options={}, **settings): @@ -49,7 +49,6 @@ Current implementation makes the following assumptions # 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: @@ -119,6 +118,6 @@ Current implementation makes the following assumptions # the list of things passed to the js plugin def json_settings_list (self): return ['plugin_uuid', 'domid', - 'query_uuid', 'query_all_uuid', 'sync_query_uuid', + 'query_uuid', 'query_all_uuid', 'checkboxes', 'datatables_options', 'hidden_columns', 'init_key',] diff --git a/plugins/univbrisfv/__init__1.py b/plugins/univbrisfv/__init__1.py deleted file mode 100644 index 853bc1ee..00000000 --- a/plugins/univbrisfv/__init__1.py +++ /dev/null @@ -1,40 +0,0 @@ -from unfold.plugin import Plugin - -class UnivbrisFv (Plugin): -""" -//////////////////////////////////////// -modified querytable for univbris foam -///////////////////////////////////////""" - - def __init__ (self, init_key=None,datatables_options={}, **settings): - Plugin.__init__ (self, **settings) - self.columns = list (['switch dpid','port no<->peer dpid/port no.','selected']) - self.init_key=init_key - self.datatables_options=datatables_options - - def template_file (self): - return "univbrisfv.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/manifold.js", "js/manifold-query.js", - "js/unfold-helper.js", - "js/univbrisfv.js", - ] , - 'css_files': [ "css/dataTables.bootstrap.css", - "css/dataTables.full_numbers.css", - "css/univbrisfv.css" , - ],} - return reqs - - # the list of things passed to the js plugin - def json_settings_list (self): - return ['plugin_uuid', 'domid', 'datatables_options', 'init_key',] diff --git a/plugins/univbrisfv/static/js/univbrisfv.js b/plugins/univbrisfv/static/js/univbrisfv.js index 7cefef60..672a674c 100644 --- a/plugins/univbrisfv/static/js/univbrisfv.js +++ b/plugins/univbrisfv/static/js/univbrisfv.js @@ -201,9 +201,9 @@ fnButsubmit:function(e){ - alert("verifying before submitting"); + console.log("verifying before submitting"); - sync_query_uuid=e.data.options.sync_query_uuid; + query_uuid=e.data.options.query_uuid; try{ var controller= $('#controller_loc').val(); @@ -328,7 +328,7 @@ op : STATE_SET_ADD, value: json_rspec } - manifold.raise_event(sync_query_uuid, FIELD_STATE_CHANGED, data); + manifold.raise_event(query_uuid, FIELD_STATE_CHANGED, data); //alert("sending to manifold backend to build rspec"); @@ -343,7 +343,7 @@ fnAddflowspace:function(e){ - sync_query_uuid=e.data.options.sync_query_uuid; + query_uuid=e.data.options.query_uuid; pk_mode=1; hideFvfError(); var port_table=$("#univbris_foam_ports_selection__table").dataTable(); @@ -366,12 +366,12 @@ $("[id='addflowspaceform']").text('add flowspace'); try{ - manifold.raise_event(e.data.options.sync_query_uuid,CLEAR_FILTERS); + manifold.raise_event(e.data.options.query_uuid,CLEAR_FILTERS); var filter=[]; filter.push("link type"); filter.push("!="); filter.push("optical"); - manifold.raise_event(e.data.options.sync_query_uuid,FILTER_ADDED,filter); + manifold.raise_event(e.data.options.query_uuid,FILTER_ADDED,filter); } catch(err){ alert("raise error:"+err); @@ -397,7 +397,7 @@ fnAddcflowspace:function(e){ pk_mode=0; - sync_query_uuid=e.data.options.sync_query_uuid; + query_uuid=e.data.options.query_uuid; hideFvfError(); var port_table=$("#univbris_foam_ports_selection__table").dataTable(); var nodes = $('input',port_table.fnGetNodes()); @@ -416,22 +416,22 @@ $("[id='addflowspaceform']").text('add flowspace'); try{ - manifold.raise_event(e.data.options.sync_query_uuid,CLEAR_FILTERS); + manifold.raise_event(e.data.options.query_uuid,CLEAR_FILTERS); var filter=[]; filter.push("link type"); filter.push("!="); filter.push("packet"); - manifold.raise_event(e.data.options.sync_query_uuid,FILTER_ADDED,filter); + manifold.raise_event(e.data.options.query_uuid,FILTER_ADDED,filter); filter=[]; filter.push("link type"); filter.push("!="); filter.push("compute"); - manifold.raise_event(e.data.options.sync_query_uuid,FILTER_ADDED,filter); + manifold.raise_event(e.data.options.query_uuid,FILTER_ADDED,filter); filter=[]; filter.push("link type"); filter.push("!="); filter.push("federation"); - manifold.raise_event(e.data.options.sync_query_uuid,FILTER_ADDED,filter); + manifold.raise_event(e.data.options.query_uuid,FILTER_ADDED,filter); } catch(err){ alert("raise error:"+err); diff --git a/plugins/univbrisfv/static/js/univbrisfv1.js b/plugins/univbrisfv/static/js/univbrisfv1.js deleted file mode 100644 index 90ca0e8c..00000000 --- a/plugins/univbrisfv/static/js/univbrisfv1.js +++ /dev/null @@ -1,700 +0,0 @@ -/** - * Description: display a query result in a datatables-powered - * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA - * License: GPLv3 - */ - -(function($){ - - var debug=false; - //debug=true - - var UnivbrisFv = Plugin.extend({ - - init: function(options, element) { - //alert("fv init called"); - this.classname="univbrisfv"; - this._super(options, element); - - //alert(this.options.hidden_columns); - /* Member variables */ - // in general we expect 2 queries here - // query_uuid refers to a single object (typically a slice) - // query_all_uuid refers to a list (typically resources or users) - // these can return in any order so we keep track of which has been received yet - //this.received_all_query = True; - //this.received_query = True; - - // We need to remember the active filter for datatables filtering - // this.filters = Array(); - alert("after super"); - // 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 = []; - - /* Events */ - // xx somehow non of these triggers at all for now - //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); - - //var query = manifold.query_store.find_analyzed_query(this.options.query_uuid); - //this.object = query.object; - - //// we need 2 different keys - // * canonical_key is the primary key as derived from metadata (typically: urn) - // and is used to communicate about a given record with the other plugins - // * init_key is a key that both kinds of records - // (i.e. records returned by both queries) must have (typically: hrn or hostname) - // in general query_all will return well populated records, but query - // returns records with only the fields displayed on startup - //var keys = manifold.metadata.get_key(this.object); - //this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined; - //alert("after super"); - 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 ("UnivbrisFv : cannot find init_key"); - if ( ! this.canonical_key ) messages.warning ("UnivbrisFv : cannot find canonical_key"); - if (debug) messages.debug("UnivbrisFv: 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 */ - //alert("fv init called"); - this.initialize_table(); - - }, - - /* PLUGIN EVENTS */ - - on_show: function(e) { - if (debug) messages.debug("univbrisfv.on_show"); - var self = e.data; - self.table.fnAdjustColumnSizing(); - }, - - on_resize: function(e) { - if (debug) messages.debug("univbrisfv.on_resize"); - var self = e.data; - self.table.fnAdjustColumnSizing(); - }, - - /* GUI EVENTS */ - - /* GUI MANIPULATION */ - - initialize_table: function() - { - alert("init table fnc"); - /* Transforms the table into DataTable, and keep a pointer to it */ - var self = this; - 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-9'r>t<'next'>", - // 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._univbrisfv_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']; - }*/ - //this.redraw_table(); - //this.show(); - alert("before 1"); - $.extend(actual_options, this.options.datatables_options ); - this.table = $('#univbris_flowspace_selection__table').dataTable(actual_options); - alert("after 1"); - alert(this.table); - - /* Setup the SelectAll button in the dataTable header */ - /* xxx not sure this is still working */ - var oSelectAll = $('#datatableSelectAll-'+ this.options.plugin_uuid); - oSelectAll.html("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); - }); - - //alert(this.options.hidden_columns); - - /* 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); - }); - - $('').appendTo('div.next'); - - $('next link').appendTo('div.next'); - alert("before record"); - //this.redraw_table(); - this.new_record("test"); - this._querytable_draw_callback(); - //this.show(e); - alert("after record"); - //this.show_column() - - - }, // initialize_table - - - fnButnext:function(e){ - e.stopPropagation(); - //var sData = this.table.$('input').serialize(); - //var sData = $(this).closest('checkboxes__table').find('input').serialize(); - //var sData = $("form").find('input').serialize(); - //var element=this.table.$("id="'NEC A/80<->NEC B/1080'""); - //var element=this.table.$("[id='"+"NEC A/80<->NEC B/1080"+"']"); - //var x = element.checked; - //var uuid=this.id.split("-"); - //var oTable=$('checkboxes__table').dataTable(); - //var oTable=$.fn.dataTable(); - //this.elts("table").unbind('click').click(this, this.fnButnext); - //var sData = $('input', oTable.fnGetNodes()).serialize(); - //$.fn.dataTable() - //sData="test"; - ///var self = e.data; - //self=self.options.query_uuid; - //var oTable=$("#querytable-"+self).dataTable(); - //var sData = $('input', oTable.fnGetNodes()).serialize(); - //e.stopPropagation(); - //var oTable=$('#myTable').dataTable(); - //var sData = $('input', $("#uob_form")).serialize(); - var sData=$("#uob_form").find("input").serialize(); - //alert("clicked: "+sData); - - //var url = "http://localhost:8000/login/"; - //$(location).attr('href',url); - //window.location.href = "http://localhost:8000/login/" - //window.location.replace("http://localhost:8000/login/"); - //UnivbrisFv(options,elements); - - //$("#next_link").click(); - - }, - - - - /** - * @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 - - // create a checkbox tag - // computes 'id' attribute from canonical_key - // computes 'init_id' from init_key for initialization phase - // no need to used convoluted ids with plugin-uuid or others, since - // we search using table.$ which looks only in this table - checkbox_html : function (record) { - var result=""; - // Prefix id with plugin_uuid - result += " '+record['hrn']); - } else { - if (record[colnames[j]]) - line.push(record[colnames[j]]); - else - line.push(''); - }*/ - } - - // catch up with the last column if checkboxes were requested - if (this.options.checkboxes) { - // Use a key instead of hostname (hard coded...) - line.push(this.checkbox_html(record)); - } - - // adding an array in one call is *much* more efficient - alert("sending to table"); - $('#univbris_flowspace_selection__table').dataTable().fnAddData(['test']); - //$('#univbris_flowspace_selection__table').dataTable().fnDraw(); - this._querytable_draw_callback(); - alert("sent to table"); - //this.buffered_lines.push(line); - }, - - 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("univbrisfv.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("univbrisfv.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('UnivbrisFv::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('UnivbrisFv::clear_fields() not implemented'); - }, - - - /*************************** RECORD HANDLER ***************************/ - - on_new_record: function(record) - { - if (this.received_all_query) { - // if the 'all' query has been dealt with already we may turn on the checkbox - this.set_checkbox_from_record(record, true); - } 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; - // 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); - this.elts("next").unbind('click').click(this, this.fnButnext); - - - 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('UnivbrisFv', UnivbrisFv); - - /* 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); - diff --git a/plugins/univbrisvtam/__init__.py b/plugins/univbrisvtam/__init__.py new file mode 100644 index 00000000..bc2bf9e6 --- /dev/null +++ b/plugins/univbrisvtam/__init__.py @@ -0,0 +1,80 @@ +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
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',] diff --git a/plugins/univbrisvtam/static/css/univbrisvtam.css b/plugins/univbrisvtam/static/css/univbrisvtam.css new file mode 100644 index 00000000..04424afd --- /dev/null +++ b/plugins/univbrisvtam/static/css/univbrisvtam.css @@ -0,0 +1,84 @@ + +/* 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; +} + + diff --git a/plugins/univbrisvtam/static/img/README b/plugins/univbrisvtam/static/img/README new file mode 100644 index 00000000..5df2d69b --- /dev/null +++ b/plugins/univbrisvtam/static/img/README @@ -0,0 +1,2 @@ +these styling elements come from plekit with a simple transition to png +they're currently not all used in myslice diff --git a/plugins/univbrisvtam/static/img/tablesort-bullet1.png b/plugins/univbrisvtam/static/img/tablesort-bullet1.png new file mode 100644 index 00000000..4304f360 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-bullet1.png differ diff --git a/plugins/univbrisvtam/static/img/tablesort-bullet2.png b/plugins/univbrisvtam/static/img/tablesort-bullet2.png new file mode 100644 index 00000000..4f181e19 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-bullet2.png differ diff --git a/plugins/univbrisvtam/static/img/tablesort-col-alt.png b/plugins/univbrisvtam/static/img/tablesort-col-alt.png new file mode 100644 index 00000000..8179f830 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-col-alt.png differ diff --git a/plugins/univbrisvtam/static/img/tablesort-gradient.png b/plugins/univbrisvtam/static/img/tablesort-gradient.png new file mode 100644 index 00000000..26558a49 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-gradient.png differ diff --git a/plugins/univbrisvtam/static/img/tablesort-header-down.png b/plugins/univbrisvtam/static/img/tablesort-header-down.png new file mode 100644 index 00000000..c8ed6576 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-header-down.png differ diff --git a/plugins/univbrisvtam/static/img/tablesort-header-sortable.png b/plugins/univbrisvtam/static/img/tablesort-header-sortable.png new file mode 100644 index 00000000..0c169040 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-header-sortable.png differ diff --git a/plugins/univbrisvtam/static/img/tablesort-header-up.png b/plugins/univbrisvtam/static/img/tablesort-header-up.png new file mode 100644 index 00000000..d12fe2a5 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-header-up.png differ diff --git a/plugins/univbrisvtam/static/img/tablesort-header.png b/plugins/univbrisvtam/static/img/tablesort-header.png new file mode 100644 index 00000000..cff526f9 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-header.png differ diff --git a/plugins/univbrisvtam/static/img/tablesort-td-alt.png b/plugins/univbrisvtam/static/img/tablesort-td-alt.png new file mode 100644 index 00000000..ef5ab358 Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-td-alt.png differ diff --git a/plugins/univbrisvtam/static/img/toggle-hidden.png b/plugins/univbrisvtam/static/img/toggle-hidden.png new file mode 100755 index 00000000..023f22a8 Binary files /dev/null and b/plugins/univbrisvtam/static/img/toggle-hidden.png differ diff --git a/plugins/univbrisvtam/static/img/toggle-visible.png b/plugins/univbrisvtam/static/img/toggle-visible.png new file mode 100755 index 00000000..baf6c286 Binary files /dev/null and b/plugins/univbrisvtam/static/img/toggle-visible.png differ diff --git a/plugins/univbrisfv/static/js/univbrisfv2.js b/plugins/univbrisvtam/static/js/univbrisvtam.js similarity index 65% rename from plugins/univbrisfv/static/js/univbrisfv2.js rename to plugins/univbrisvtam/static/js/univbrisvtam.js index 3048b1e0..86341ff8 100644 --- a/plugins/univbrisfv/static/js/univbrisfv2.js +++ b/plugins/univbrisvtam/static/js/univbrisvtam.js @@ -2,28 +2,30 @@ * Description: display a query result in a datatables-powered * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA * License: GPLv3 - */ + */ (function($){ var debug=false; debug=true - var UnivbrisFv = Plugin.extend({ + 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) { - //alert("foam init called"); - this.classname="univbrisfv"; + this.classname="univbrisvtam"; this._super(options, element); - //alert(this.options.hidden_columns); - /* Member variables */ - // in general we expect 2 queries here - // query_uuid refers to a single object (typically a slice) - // query_all_uuid refers to a list (typically resources or users) - // these can return in any order so we keep track of which has been received yet - //this.received_all_query = false; - //this.received_query = false; + 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(); @@ -33,36 +35,15 @@ // an internal buffer for keeping lines and display them in one call to fnAddData this.buffered_lines = []; - /* Events */ - // xx somehow non of these triggers at all for now - //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); - - //var query = manifold.query_store.find_analyzed_query(this.options.query_uuid); - //this.object = query.object; - - //// we need 2 different keys - // * canonical_key is the primary key as derived from metadata (typically: urn) - // and is used to communicate about a given record with the other plugins - // * init_key is a key that both kinds of records - // (i.e. records returned by both queries) must have (typically: hrn or hostname) - // in general query_all will return well populated records, but query - // returns records with only the fields displayed on startup 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 ("UnivbrisFv : cannot find init_key"); - if ( ! this.canonical_key ) messages.warning ("UnivbrisFv : cannot find canonical_key"); - if (debug) messages.debug("UnivbrisFv: 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'); + 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(); @@ -72,13 +53,13 @@ /* PLUGIN EVENTS */ on_show: function(e) { - if (debug) messages.debug("univbrisfv.on_show"); + if (debug) messages.debug("UnivbrisVtam.on_show"); var self = e.data; self.table.fnAdjustColumnSizing(); }, on_resize: function(e) { - if (debug) messages.debug("univbrisfv.on_resize"); + if (debug) messages.debug("UnivbrisVtam.on_resize"); var self = e.data; self.table.fnAdjustColumnSizing(); }, @@ -89,13 +70,16 @@ 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-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>><'buttons'>", + 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 ? @@ -108,7 +92,7 @@ // sScrollX: '100%', /* Horizontal scrolling */ bProcessing: true, /* Loading */ fnDrawCallback: function() { self._querytable_draw_callback.call(self);} - //fnFooterCallback: function() {self._univbrisfv_footer_callback.call(self,nFoot, aData, iStart, iEnd, aiDisplay)};} + //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 @@ -122,9 +106,12 @@ delete this.options.datatables_options['aoColumnDefs']; } $.extend(actual_options, this.options.datatables_options ); - this.table = $("#univbris_flowspace_selection__table").dataTable(actual_options); - + + this.table = $("#univbris_vtam__table").dataTable(actual_options); + + + //alert(this.table.$("name")); /* Setup the SelectAll button in the dataTable header */ @@ -149,8 +136,6 @@ return self._querytable_filter.call(self, oSettings, aData, iDataIndex); }); - //alert(this.options.hidden_columns); - /* Processing hidden_columns */ $.each(this.options.hidden_columns, function(i, field) { //manifold.raise_event(self.options.query_all_uuid, FIELD_REMOVED, field); @@ -159,49 +144,100 @@ //self.hide_column(field); }); - //document.getElementById('buttons').text-align='center'; - /**$('
').appendTo('div.buttons'); + this._querytable_draw_callback(); + + }, // initialize_table - $('
').appendTo('div.buttons'); - $('
').appendTo('div.buttons'); + fnCreateVms:function(e){ + console.log("building json to send to backend"); + + var vms=[]; + + try{ + var rows = $("#univbris_vtam__table").dataTable().fnGetNodes(); + if (rows.length<=0){ + throw("no vm specified"); + } + else{ + for(var i=0;i0){ + // add the current vm to vms + $.each( vms, function( i, s_vm ) { + // if the server is already listed in vms, add a new vm to the server + s = Object.keys(s_vm); + vm = s_vm[s[0]]; + + if(s[0] == current_server[0]){ + vm_exists = false; + // XXX We should also loop on the vm names + $.each( vm, function( i, vm_name ) { + if(vm_name == current_vm[0]){ + vm_exists = true; + return; + } + }); + if (vm_exists == false){ + vm.push(current_vm[0]); + } + // else add the server with the current vm + }else{ + vms.push(t_server_vm); + } + }); + }else{ + vms.push(t_server_vm); + } - $('
').appendTo('div.buttons');**/ - - - jQuery( "#univbris_flowspace_selection" ).hide(); + } - //$('next link').appendTo('div.submit'); + var rspecs = JSON.stringify(vms); + console.log(rspecs); + // manifold.raise_event(self.options.query_uuid, ...); + } - //this.new_record("t"); - //this.new_record("t"); - //this.new_record("t"); - //this.new_record("t"); - //this.new_record("t"); - this._querytable_draw_callback(); - - + } + catch(err){ + alert(err) + } + }, - }, // initialize_table - fnButsubmit:function(e){ - alert("submitting flowspaces to AM (TO BE IMPLEMENTED)"); - - + 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(); }, - fnAddflowspace:function(e){ - this.table = $("#univbris_flowspace_selection__table").dataTable(); - //alert("table length" + this.table.fnGetNodes().length); - $("#flowspace_name").val("flowspace"+(this.table.fnGetNodes().length+1)); - jQuery( "#univbris_flowspace_selection" ).hide(); - jQuery("#uob_fv_table_form").show(); - }, + + + + + fnDelete:function(e){ + e.preventDefault(); + var nRow = $(this).parents('tr')[0]; + this.table = $("#univbris_vtam__table").dataTable(); + this.table.fnDeleteRow( nRow ); + }, + + + + /** @@ -214,119 +250,12 @@ return (tabIndex.length > 0) ? tabIndex[0] : -1; }, // getColIndex - // create a checkbox tag - // computes 'id' attribute from canonical_key - // computes 'init_id' from init_key for initialization phase - // no need to used convoluted ids with plugin-uuid or others, since - // we search using table.$ which looks only in this table - checkbox_html : function (record) { - var result=""; - // Prefix id with plugin_uuid - result += " '+record['hrn']); - } else { - if (record[colnames[j]]) - line.push(record[colnames[j]]); - else - line.push(''); - }*/ - } - - // catch up with the last column if checkboxes were requested - if (this.options.checkboxes) { - // Use a key instead of hostname (hard coded...) - line.push(this.checkbox_html(record)); - } - - // adding an array in one call is *much* more efficient - // this.table.fnAddData(line); - this.buffered_lines.push(line); - this.table.fnAddData(this.buffered_lines); - //this.table.redraw(); - //this._querytable_draw_callback(); }, clear_table: function() @@ -365,7 +294,7 @@ set_checkbox_from_record: function (record, checked) { if (checked === undefined) checked = true; var init_id = record[this.init_key]; - if (debug) messages.debug("univbrisfv.set_checkbox_from_record, init_id="+init_id); + 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); @@ -374,7 +303,7 @@ // id relates to canonical_key set_checkbox_from_data: function (id, checked) { if (checked === undefined) checked = true; - if (debug) messages.debug("univbrisfv.set_checkbox_from_data, id="+id); + 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); @@ -415,7 +344,7 @@ on_field_clear: function() { - alert('UnivbrisFv::clear_fields() not implemented'); + 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 ! */ @@ -451,7 +380,7 @@ on_all_field_clear: function() { - alert('UnivbrisFv::clear_fields() not implemented'); + alert('UnivbrisVtam::clear_fields() not implemented'); }, @@ -459,12 +388,6 @@ on_new_record: function(record) { - if (this.received_all_query) { - // if the 'all' query has been dealt with already we may turn on the checkbox - this.set_checkbox_from_record(record, true); - } else { - this.buffered_records_to_check.push(record); - } }, on_clear_records: function() @@ -538,7 +461,9 @@ 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.table.fnAddData (this.buffered_lines); this.buffered_lines=[]; var self = this; @@ -614,9 +539,14 @@ * the table is redrawn */ this.elts('querytable-checkbox').unbind('click').click(this, this._check_click); - $("#submit_flowspace").unbind('click').click(this, this.fnButsubmit); - $("#add_flowspace").unbind('click').click(this, this.fnAddflowspace); - + $("#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; @@ -638,6 +568,9 @@ $('.querytable_length', wrapper).css('visibility', 'visible'); } + + + }, @@ -678,7 +611,9 @@ }); - $.plugin('UnivbrisFv', UnivbrisFv); + + + $.plugin('UnivbrisVtam', UnivbrisVtam); /* define the 'dom-checkbox' type for sorting in datatables http://datatables.net/examples/plug-ins/dom_sort.html @@ -691,5 +626,9 @@ } ); } + + })(jQuery); + + diff --git a/plugins/univbrisvtam/templates/univbrisvtamplugin.html b/plugins/univbrisvtam/templates/univbrisvtamplugin.html new file mode 100644 index 00000000..bcd7787a --- /dev/null +++ b/plugins/univbrisvtam/templates/univbrisvtamplugin.html @@ -0,0 +1,29 @@ +
+
+ + + + {% for column in columns %} {% endfor %} + {% for column in hidden_columns %} {% endfor %} + + + + + + + {% for column in columns %} {% endfor %} + {% for column in hidden_columns %} {% endfor %} + + +
{{ column }}{{ column }}
{{ column }}{{ column }}
+ + + + + + + + +
+
+
diff --git a/plugins/univbrisvtamform/__init__.py b/plugins/univbrisvtamform/__init__.py new file mode 100644 index 00000000..5f6c0d22 --- /dev/null +++ b/plugins/univbrisvtamform/__init__.py @@ -0,0 +1,43 @@ +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',] diff --git a/plugins/univbrisvtamform/static/css/univbrisvtamform.css b/plugins/univbrisvtamform/static/css/univbrisvtamform.css new file mode 100644 index 00000000..cd227cf4 --- /dev/null +++ b/plugins/univbrisvtamform/static/css/univbrisvtamform.css @@ -0,0 +1,65 @@ + +/* 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; +} diff --git a/plugins/univbrisvtamform/static/img/README b/plugins/univbrisvtamform/static/img/README new file mode 100644 index 00000000..5df2d69b --- /dev/null +++ b/plugins/univbrisvtamform/static/img/README @@ -0,0 +1,2 @@ +these styling elements come from plekit with a simple transition to png +they're currently not all used in myslice diff --git a/plugins/univbrisvtamform/static/img/tablesort-bullet1.png b/plugins/univbrisvtamform/static/img/tablesort-bullet1.png new file mode 100644 index 00000000..4304f360 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-bullet1.png differ diff --git a/plugins/univbrisvtamform/static/img/tablesort-bullet2.png b/plugins/univbrisvtamform/static/img/tablesort-bullet2.png new file mode 100644 index 00000000..4f181e19 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-bullet2.png differ diff --git a/plugins/univbrisvtamform/static/img/tablesort-col-alt.png b/plugins/univbrisvtamform/static/img/tablesort-col-alt.png new file mode 100644 index 00000000..8179f830 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-col-alt.png differ diff --git a/plugins/univbrisvtamform/static/img/tablesort-gradient.png b/plugins/univbrisvtamform/static/img/tablesort-gradient.png new file mode 100644 index 00000000..26558a49 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-gradient.png differ diff --git a/plugins/univbrisvtamform/static/img/tablesort-header-down.png b/plugins/univbrisvtamform/static/img/tablesort-header-down.png new file mode 100644 index 00000000..c8ed6576 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-header-down.png differ diff --git a/plugins/univbrisvtamform/static/img/tablesort-header-sortable.png b/plugins/univbrisvtamform/static/img/tablesort-header-sortable.png new file mode 100644 index 00000000..0c169040 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-header-sortable.png differ diff --git a/plugins/univbrisvtamform/static/img/tablesort-header-up.png b/plugins/univbrisvtamform/static/img/tablesort-header-up.png new file mode 100644 index 00000000..d12fe2a5 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-header-up.png differ diff --git a/plugins/univbrisvtamform/static/img/tablesort-header.png b/plugins/univbrisvtamform/static/img/tablesort-header.png new file mode 100644 index 00000000..cff526f9 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-header.png differ diff --git a/plugins/univbrisvtamform/static/img/tablesort-td-alt.png b/plugins/univbrisvtamform/static/img/tablesort-td-alt.png new file mode 100644 index 00000000..ef5ab358 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-td-alt.png differ diff --git a/plugins/univbrisvtamform/static/img/toggle-hidden.png b/plugins/univbrisvtamform/static/img/toggle-hidden.png new file mode 100755 index 00000000..023f22a8 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/toggle-hidden.png differ diff --git a/plugins/univbrisvtamform/static/img/toggle-visible.png b/plugins/univbrisvtamform/static/img/toggle-visible.png new file mode 100755 index 00000000..baf6c286 Binary files /dev/null and b/plugins/univbrisvtamform/static/img/toggle-visible.png differ diff --git a/plugins/univbrisvtamform/static/js/univbrisvtamform.js b/plugins/univbrisvtamform/static/js/univbrisvtamform.js new file mode 100644 index 00000000..ac0df1a9 --- /dev/null +++ b/plugins/univbrisvtamform/static/js/univbrisvtamform.js @@ -0,0 +1,326 @@ +/** + * Description: display a query result in a datatables-powered + * 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 */ + + + $('').appendTo('#vtam_form_buttons'); + $("#cancelvtamform").unbind('click').click(this, this.fnCancelVtamForm); + + $('').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") + .attr("value",vt_servers_list[i].urn) + .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 + //{"urn:publicid:IDN+vtam.univbris+node+uclalien":[{"name":"toto"}]} + var vtam='{"'+$('#uob_virtualization_server option:selected').val()+'":'; + vtam+='[{"name":"'+$('#uob_vm_name').val()+'"}]}'; + //var vtam="testbed="+$('#uob_testbed_name option:selected').text(); + // Use the URN instead of the hostname of the server + //vtam +=",vt_server="+$('#uob_virtualization_server option:selected').val(); + //vtam +=",vm_name="+$("#uob_vm_name").val(); + var vm_name="

"+$("#uob_vm_name").val()+"

"; + var vtamtable = $("#univbris_vtam__table").dataTable(); + vtamtable.fnAddData([$('#uob_testbed_name option:selected').text(),$('#uob_virtualization_server option:selected').text(), vm_name,'Delete']); + 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]; + vt_server['urn']=urn; + 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") + .attr("value",key) + .text(value.testbed)); + });*/ + + $('#uob_testbed_name') + .find('option') + .remove() + .end() + + for(var t=0;t") + .attr("value",testbeds_list[t]) + .text(testbeds_list[t])); + } + + $('#uob_virtualization_server') + .find('option') + .remove() + .end() + + for(var i=0;i") + .attr("value",vt_servers_list[i].urn) + .text(vt_servers_list[i].name)); + } + } + + this.unspin(); + }, + + on_field_state_changed: function(data) + { + + }, + + }); //close plugin extend + + $.plugin('UnivbrisVtamForm', UnivbrisVtamForm); + +})(jQuery); + + + + diff --git a/plugins/univbrisvtamform/templates/univbrisvtamform.html b/plugins/univbrisvtamform/templates/univbrisvtamform.html new file mode 100644 index 00000000..b9f7c509 --- /dev/null +++ b/plugins/univbrisvtamform/templates/univbrisvtamform.html @@ -0,0 +1,62 @@ + + +
+
+ + + + + + + + + + + + + + + + + + + +
Testbed + +
Virtualization Server + + + +
VM Name + + + + +

name of VM should be alphanumeric

+
+ +
+ diff --git a/portal/actions.py b/portal/actions.py index eb46bee9..79538bd6 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -61,7 +61,6 @@ def clear_user_creds(request, user_email): try: user_query = Query().get('local:user').filter_by('email', '==', user_email).select('user_id','email','password','config') user_details = execute_admin_query(request, user_query) - # getting the user_id from the session for user_detail in user_details: user_id = user_detail['user_id'] @@ -593,21 +592,31 @@ def create_slice(wsgi_request, request): Exception """ hrn = "%s.%s" % (request['authority_hrn'], request['slice_name']) + # XXX tmp sfa dependency from sfa.util.xrn import Xrn urn = Xrn(hrn, request['type']).get_urn() # Add User to Slice if we have the user_hrn in pendingslice table user_hrn = request.get('user_hrn', None) + user_obj = User.objects.get(username = user_hrn.split(".")[1]) + list_users = [] user_hrns = list([user_hrn]) if user_hrn else list() + for user in user_hrns: + list_users +=[User.objects.get(username = user.split(".")[1])] + + #user_query = Query.get('local:user').select('email').filter_by('email','==',user.username) + #user_details_sfa = execute_admin_query(wsgi_request, user_query) + + pendinguser = PendingUser.objects.filter(login__iexact = user_obj.username) + if pendinguser : + raise Exception, "User %s doesn't exist, validate user before validating slice" % user_obj.username + #if not user_details_sfa: + # raise Exception, "User %s doesn't exist, validate user before validating slice" % user_hrn + #for user in list_users: + + user_email = user_obj.email - user_query = Query().get('user').select('user_hrn','user_email').filter_by('user_hrn','==',user_hrn) - user_details_sfa = execute_admin_query(wsgi_request, user_query) - if not user_details_sfa: - raise Exception, "User %s doesn't exist, validate user before validating slice" % user_hrn - for user in user_details_sfa: - user_email = user['user_email'] - # XXX LOIC Quick fix because this is totally inconsistent if not 'number_of_nodes' in request: request['number_of_nodes']="" @@ -624,13 +633,14 @@ def create_slice(wsgi_request, request): # ignored in request: id, timestamp, number_of_nodes, type_of_nodes, purpose query = Query.create('slice').set(slice_params).select('slice_hrn') - results = execute_query(wsgi_request, query) + results = execute_admin_query(wsgi_request, query) if not results: raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn'] - else: - clear_user_creds(wsgi_request,user_email) + else: + clear_user_creds(wsgi_request,user_obj.username) # log user activity - activity.slice.validate(self.request, "Slice validation", { "slice" : hrn }) + activity.slice.validate(request,{ "slice" : hrn }) #"Slice validation", { "slice" : hrn }) + try: theme.template_name = 'slice_request_validated.txt' text_content = render_to_string(theme.template, request) @@ -889,7 +899,7 @@ def iotlab_create_user (wsgi_request, request, namespace = None, as_admin=False) "structure" : request['authority_hrn'], "city" : "N/A", "country" : "N/A", - "sshPublicKey" : [request['public_key']], + "sshPublicKey" : request['public_key'], "motivations" : "SFA federation", } diff --git a/portal/homeview.py b/portal/homeview.py index 6c5ee9a7..718ba601 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -336,15 +336,16 @@ class HomeView (FreeAccessView, ThemeView): # XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page platform_details = execute_query(self.request, platform_query) account_details = execute_query(self.request, account_query) - for platform_detail in platform_details: - for account_detail in account_details: - if 'platform_id' in platform_detail: - if platform_detail['platform_id'] == account_detail['platform_id']: - if 'config' in account_detail and account_detail['config'] is not '': - account_config = json.loads(account_detail['config']) - if 'myslice' in platform_detail['platform']: - acc_auth_cred = account_config.get('delegated_authority_credentials','N/A') - acc_user_cred = account_config.get('delegated_user_credential','N/A') + if platform_details is not None and platform_details != {}: + for platform_detail in platform_details: + for account_detail in account_details: + if 'platform_id' in platform_detail: + if platform_detail['platform_id'] == account_detail['platform_id']: + if 'config' in account_detail and account_detail['config'] is not '': + account_config = json.loads(account_detail['config']) + if 'myslice' in platform_detail['platform']: + acc_auth_cred = account_config.get('delegated_authority_credentials','N/A') + acc_user_cred = account_config.get('delegated_user_credential','N/A') # assigning values if acc_auth_cred=={} or acc_auth_cred=='N/A': pi = "is_not_pi" diff --git a/portal/slicerequestview.py b/portal/slicerequestview.py index 97a11dd0..b51273f5 100644 --- a/portal/slicerequestview.py +++ b/portal/slicerequestview.py @@ -117,7 +117,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView): 'authority_hrn' : authority_hrn, 'organization' : wsgi_request.POST.get('org_name', ''), 'slice_name' : wsgi_request.POST.get('slice_name', ''), - 'url' : wsgi_request.POST.get('url', ''), + 'url' : wsgi_request.POST.get('exp_url', ''), 'purpose' : wsgi_request.POST.get('purpose', ''), 'current_site' : current_site } diff --git a/portal/sliceresourceview.py b/portal/sliceresourceview.py index c7e02a23..94c0fb41 100644 --- a/portal/sliceresourceview.py +++ b/portal/sliceresourceview.py @@ -30,6 +30,8 @@ from plugins.univbrisfv import UnivbrisFv 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 @@ -51,11 +53,6 @@ class SliceResourceView (LoginRequiredView, ThemeView): metadata = page.get_metadata() page.expose_js_metadata() - # Bristol - univbrisfoam_query=Query().get('ofelia-bristol-of:resource').select('urn') - page.enqueue_query(univbrisfoam_query) - - resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] @@ -82,6 +79,10 @@ class SliceResourceView (LoginRequiredView, ThemeView): 'lease.resource', 'lease.start_time', 'lease.end_time', + # FLOWSPACE + 'flowspace', + # VMS + 'vms', # - The lease_id is important for NITOS identify already existing # leases 'lease.lease_id', @@ -96,6 +97,8 @@ class SliceResourceView (LoginRequiredView, ThemeView): page.enqueue_query(main_query, analyzed_query=aq) sq_resource = aq.subquery('resource') sq_lease = aq.subquery('lease') + sq_flowspace = aq.subquery('flowspace') + sq_vms = aq.subquery('vms') query_resource_all = Query.get('resource').select(resource_fields) page.enqueue_query(query_resource_all) @@ -260,50 +263,6 @@ class SliceResourceView (LoginRequiredView, ThemeView): query = main_query, username = request.user, ) - - # Bristol plugin - univbrisfoamlist = UnivbrisFoam( - page = page, - title = 'univbris_foam_ports_selection', - domid = 'univbris_foam_ports_selection', - query = univbrisfoam_query, - query_all = univbrisfoam_query, - checkboxes = False, - datatables_options = { - 'iDisplayLength': 10, - 'bLengthChange' : True, - 'bAutoWidth' : True, - }, - ) - - #plugin which manages the different flowspaces that the user creates, and also sends flowspaces to manifold - univbrisfvlist = UnivbrisFv( - page = page, - title = 'univbris_flowspace_selection', - domid = 'univbris_flowspace_selection', - query = None, - query_all = None, - datatables_options = { - 'iDisplayLength': 5, - 'bLengthChange' : True, - 'bAutoWidth' : True, - }, - ) - - #plugin which allows the definition of a single flowspace - univbrisfvform = UnivbrisFvf( - page = page, - title = 'univbris_flowspace_form', - domid = 'univbris_flowspace_form', - query = None, - query_all = None, - datatables_options = { - 'iDisplayLength': 3, - 'bLengthChange' : True, - 'bAutoWidth' : True, - }, - ) - # -------------------------------------------------------------------------- # Ofelia OpenFlow Plugin @@ -337,9 +296,8 @@ class SliceResourceView (LoginRequiredView, ThemeView): page = page, title = 'univbris_flowspace_selection', domid = 'univbris_flowspace_selection', - query = None, - query_all = None, - sync_query = query_resource_all, + query = sq_flowspace, + query_all = query_resource_all, datatables_options = { 'iDisplayLength': 5, 'bLengthChange' : True, @@ -361,9 +319,8 @@ class SliceResourceView (LoginRequiredView, ThemeView): }, ) - #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', @@ -382,9 +339,37 @@ class SliceResourceView (LoginRequiredView, ThemeView): 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 + # responsible to send the data to Manifold + univbrisvtamplugin = UnivbrisVtamPlugin( + page = page, + title = 'univbris_vtam', + domid = 'univbris_vtam', + query = sq_vms, + #query = sq_resource, + ) + + #plugin which display a form where an experimenter will specify + # in which testbed and which physical server to setup the VM + 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 @@ -441,12 +426,13 @@ class SliceResourceView (LoginRequiredView, ThemeView): 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 - template_env["username"] = self.request.user - template_env["person"] = self.request.user + template_env["username"] = request.user template_env["pi"] = pi template_env["slice"] = slicename template_env["section"] = "resources" diff --git a/portal/templates/fibre/fibre_account-view.html b/portal/templates/fibre/fibre_account-view.html index 9941e97c..9749c5b4 100644 --- a/portal/templates/fibre/fibre_account-view.html +++ b/portal/templates/fibre/fibre_account-view.html @@ -37,6 +37,12 @@

Platform: Myslice

+ + Username + + {{ person }} + + Email diff --git a/portal/templates/fibre/fibre_home-view.html b/portal/templates/fibre/fibre_home-view.html index b04b911d..347be8c0 100644 --- a/portal/templates/fibre/fibre_home-view.html +++ b/portal/templates/fibre/fibre_home-view.html @@ -145,7 +145,8 @@
{% include 'fibre__widget-login-fed-manager.html' %} - CAFe authentication + + CAFe Expresso authentication
diff --git a/portal/templates/fibre/fibre_institution.html b/portal/templates/fibre/fibre_institution.html index b58f3c41..3e3d415b 100644 --- a/portal/templates/fibre/fibre_institution.html +++ b/portal/templates/fibre/fibre_institution.html @@ -95,13 +95,10 @@ $(document).ready(function() { {% if user_details.parent_authority %} $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) { - var username = "{{person.username}}"; var list_slices = []; var table_slices = []; /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */ $.each( data, function( key, val ) { - if(String(val.users[0]).indexOf("@") != -1){ - if(String(val.users[0]).split("@")[1] == username.split("@")[1]){ list_slices.push( "
  • " + val.slice_hrn + "
  • " ); if(val.nodes=="undefined" || val.nodes==null){ nodes_length=0; @@ -130,8 +127,6 @@ $(document).ready(function() { slice_row += ""+val.slice_expires+""; slice_row += ""; table_slices.push(slice_row); - } - } }); /* $("div#slice-list").html($( "