Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre fibre
authorRezende & Pedro & Carlos & Raphael <rezende@land.ufrj.br>
Tue, 14 Jul 2015 18:26:50 +0000 (15:26 -0300)
committerRezende & Pedro & Carlos & Raphael <rezende@land.ufrj.br>
Tue, 14 Jul 2015 18:26:50 +0000 (15:26 -0300)
Conflicts:
portal/homeview.py

53 files changed:
activity/__init__.py
manifoldapi/manifoldproxy.py
manifoldapi/static/js/manifold.js
plugins/univbrisfv/__init__.py
plugins/univbrisfv/__init__1.py [deleted file]
plugins/univbrisfv/static/js/univbrisfv.js
plugins/univbrisfv/static/js/univbrisfv1.js [deleted file]
plugins/univbrisvtam/__init__.py [new file with mode: 0644]
plugins/univbrisvtam/static/css/univbrisvtam.css [new file with mode: 0644]
plugins/univbrisvtam/static/img/README [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-bullet1.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-bullet2.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-col-alt.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-gradient.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-header-down.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-header-sortable.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-header-up.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-header.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-td-alt.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/toggle-hidden.png [new file with mode: 0755]
plugins/univbrisvtam/static/img/toggle-visible.png [new file with mode: 0755]
plugins/univbrisvtam/static/js/univbrisvtam.js [moved from plugins/univbrisfv/static/js/univbrisfv2.js with 65% similarity]
plugins/univbrisvtam/templates/univbrisvtamplugin.html [new file with mode: 0644]
plugins/univbrisvtamform/__init__.py [new file with mode: 0644]
plugins/univbrisvtamform/static/css/univbrisvtamform.css [new file with mode: 0644]
plugins/univbrisvtamform/static/img/README [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-bullet1.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-bullet2.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-col-alt.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-gradient.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-header-down.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-header-sortable.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-header-up.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-header.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-td-alt.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/toggle-hidden.png [new file with mode: 0755]
plugins/univbrisvtamform/static/img/toggle-visible.png [new file with mode: 0755]
plugins/univbrisvtamform/static/js/univbrisvtamform.js [new file with mode: 0644]
plugins/univbrisvtamform/templates/univbrisvtamform.html [new file with mode: 0644]
portal/actions.py
portal/homeview.py
portal/slicerequestview.py
portal/sliceresourceview.py
portal/templates/fibre/fibre_account-view.html
portal/templates/fibre/fibre_home-view.html
portal/templates/fibre/fibre_institution.html
portal/templates/fibre/fibre_slice-resource-view.html
portal/templates/fibre/fibre_slice_request_email.html
portal/templates/slice-resource-view.html
portal/templates/slice-tab-experiment.html
portal/templates/univbrisvtam.html [new file with mode: 0644]
portal/univbrisvtam.py [new file with mode: 0644]
portal/urls.py

index 6157bae..d2a9e94 100644 (file)
@@ -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
index 433a854..9897b50 100644 (file)
@@ -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")
index 31d4b00..01b48f5 100644 (file)
@@ -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);
 
index 93653b9..6c9aef2 100644 (file)
@@ -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 (file)
index 853bc1e..0000000
+++ /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',]
index 7cefef6..672a674 100644 (file)
 
 
        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();
                 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");
 
 
 
        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();
                $("[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);
 
        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());
                $("[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 (file)
index 90ca0e8..0000000
+++ /dev/null
@@ -1,700 +0,0 @@
-/**
- * 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
-
-    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("<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);
-            });
-
-          //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);
-            });
-
-           $('<button id="next" type="submit" style="height: 50px; width: 300px" onclick="fnButnext()">select flowspace</button>').appendTo('div.next');
-
-             $('<a href="http://localhost:8000/login/" id="next_link">next link</a>').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 <input> 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 += "<input";
-            result += " class='univbrisfv-checkbox'";
-        // compute id from canonical_key
-           var id = record[this.canonical_key]
-        // compute init_id form init_key
-           var init_id=record[this.init_key];
-        // set id - for retrieving from an id, or for posting events upon user's clicks
-           result += " id='"+record[this.canonical_key]+"'";
-        // set init_id
-           result += "init_id='" + init_id + "'";
-        // wrap up
-            result += " type='checkbox'";
-            result += " autocomplete='off'";
-            result += "></input>";
-            return result;
-        }, 
-
-        fake_checkbox_html : function (record) {
-           //alert("fake fun called");
-            var result="";
-            // Prefix id with plugin_uuid
-            result += "<input";
-            //result += " class='univbrisfv-checkbox'";
-        // set id - for retrieving from an id, or for posting events upon user's clicks
-           result += " id='"+ record +"'";
-           result += " name='"+ record +"'";
-        // set init_id
-           result += " init_id='" + record + "'";
-        // wrap up
-            result += " type='checkbox'";
-            result += " autocomplete='off'";
-            result += "></input>";
-           ///alert(result);
-            return result;
-        }, 
-
-
-        new_record: function(record)
-        {
-           
-        // this models a line in dataTables, each element in the line describes a cell
-          // alert("nb_col: ");
-            line = new Array();
-     
-            // go through table headers to get column names we want
-            // in order (we have temporarily hack some adjustments in names)
-          
-            var cols = this.table.fnSettings().aoColumns;
-           alert("col "+cols);
-            var colnames = cols.map(function(x) {return x.sTitle})
-            var nb_col = cols.length;
-                       alert("nb_col: "+ nb_col);
-            /* if we've requested checkboxes, then forget about the checkbox column for now */
-            if (this.options.checkboxes) nb_col -= 1;
-                       alert("nb_col: "+ nb_col);
-           //alert(colnames);
-           /*replace production*/
-            /* fill in stuff depending on the column name */
-            for (var j = 0; j < nb_col; j++) {
-                if (typeof colnames[j] == 'undefined') {
-                    line.push('...');
-                } else if (colnames[j] == 'Flowspace Selector') {
-                   alert("added");
-                    line.push("first form");
-               }
-       
-               
-
-               /*if (typeof colnames[j] == 'undefined') {
-                    line.push('...');
-                } else if (colnames[j] == 'hostname') {
-                    if (record['type'] == 'resource,link')
-                        //TODO: we need to add source/destination for links
-                        line.push('');
-                    else
-                        line.push(record['hostname']);
-
-                } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
-                    line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+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 (file)
index 0000000..bc2bf9e
--- /dev/null
@@ -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 <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',]
diff --git a/plugins/univbrisvtam/static/css/univbrisvtam.css b/plugins/univbrisvtam/static/css/univbrisvtam.css
new file mode 100644 (file)
index 0000000..04424af
--- /dev/null
@@ -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 (file)
index 0000000..5df2d69
--- /dev/null
@@ -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 (file)
index 0000000..4304f36
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 (file)
index 0000000..4f181e1
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 (file)
index 0000000..8179f83
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 (file)
index 0000000..26558a4
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 (file)
index 0000000..c8ed657
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 (file)
index 0000000..0c16904
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 (file)
index 0000000..d12fe2a
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 (file)
index 0000000..cff526f
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 (file)
index 0000000..ef5ab35
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 (executable)
index 0000000..023f22a
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 (executable)
index 0000000..baf6c28
Binary files /dev/null and b/plugins/univbrisvtam/static/img/toggle-visible.png differ
similarity index 65%
rename from plugins/univbrisfv/static/js/univbrisfv2.js
rename to plugins/univbrisvtam/static/js/univbrisvtam.js
index 3048b1e..86341ff 100644 (file)
@@ -2,28 +2,30 @@
  * 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
 
-    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(); 
            // 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();
         /* 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();
        },        
 
         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 ?
                 // 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
                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 */
                 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);
                //self.hide_column(field);
             });
 
-           //document.getElementById('buttons').text-align='center';
 
-           /**$('<table><tr><td><button id="add_flowspace" type="button" style="height: 25px; width: 400px; text-align: center" onclick="fnAddflowspace()">Define another packet  flowspace</button></td>').appendTo('div.buttons');
+           this._querytable_draw_callback();   
+
+        }, // initialize_table
 
-           $('<table><tr><td><button id="add_flowspace" type="button" style="height: 25px; width: 400px" onclick="fnAddflowspace()">Define another optical  flowspace</button></td>').appendTo('div.buttons');
 
-           $('<td><button id="submit_flowspace" type="button" style="height: 25px; width: 400px" onclick="fnButsubmit()">Submit flowspaces</button></td></tr></table>').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;i<rows.length;i++){
+                    // get the id of the html element in the table
+                    var cell=rows[i].cells[2];
+                    element = cell.getElementsByTagName('p');
+                    server_vm = element.item(0).id;
+                    t_server_vm = JSON.parse(server_vm);
+                    current_server = Object.keys(t_server_vm);
+                    current_vm = t_server_vm[current_server[0]];
+                    if(vms.length>0){
+                        // 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);
+                    }
 
-           $('<td><button id="submit_flowspace" type="button" style="height: 25px; width: 400px" onclick="fnButsubmit()">Define controller location</button></td></tr></table>').appendTo('div.buttons');**/
-       
-          
-           jQuery( "#univbris_flowspace_selection" ).hide();
+                               }
 
-             //$('<a href="http://localhost:8000/login/" id="next_link">next link</a>').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 );
+       },
+
+
+
+
        
 
         /**
             return (tabIndex.length > 0) ? tabIndex[0] : -1;
         }, // getColIndex
 
-       // create a checkbox <input> 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 += "<input";
-            result += " class='univbrisfv-checkbox'";
-        // compute id from canonical_key
-           var id = record[this.canonical_key]
-        // compute init_id form init_key
-           var init_id=record[this.init_key];
-        // set id - for retrieving from an id, or for posting events upon user's clicks
-           result += " id='"+record[this.canonical_key]+"'";
-        // set init_id
-           result += "init_id='" + init_id + "'";
-        // wrap up
-            result += " type='checkbox'";
-            result += " autocomplete='off'";
-            result += "></input>";
-            return result;
-        }, 
-
-        fake_checkbox_html : function (record) {
-           //alert("fake fun called");
-            var result="";
-            // Prefix id with plugin_uuid
-            result += "<input";
-            //result += " class='univbrisfv-checkbox'";
-        // set id - for retrieving from an id, or for posting events upon user's clicks
-           result += " id='"+ record +"'";
-           result += " name='"+ record +"'";
-        // set init_id
-           result += " init_id='" + record + "'";
-        // wrap up
-            result += " type='checkbox'";
-            result += " autocomplete='off'";
-            result += "></input>";
-           ///alert(result);
-            return result;
-        }, 
 
+       
 
         new_record: function(record)
         {
            
-        // this models a line in dataTables, each element in the line describes a cell
-            line = new Array();
-     
-            // go through table headers to get column names we want
-            // in order (we have temporarily hack some adjustments in names)
-            var cols = this.table.fnSettings().aoColumns;
-            var colnames = cols.map(function(x) {return x.sTitle})
-            var nb_col = cols.length;
-            /* if we've requested checkboxes, then forget about the checkbox column for now */
-            if (this.options.checkboxes) nb_col -= 1;
-           
-           //alert(colnames);
-           /*replace production*/
-            /* fill in stuff depending on the column name */
-             var cols = this.table.fnSettings().aoColumns;
-           //alert("col "+cols);
-            var colnames = cols.map(function(x) {return x.sTitle})
-            var nb_col = cols.length;
-                       //alert("nb_col: "+ nb_col);
-            /* if we've requested checkboxes, then forget about the checkbox column for now */
-            if (this.options.checkboxes) nb_col -= 1;
-                       //alert("nb_col: "+ nb_col);
-           //alert(colnames);
-           /*replace production*/
-            /* fill in stuff depending on the column name */
-            for (var j = 0; j < nb_col; j++) {
-                if (typeof colnames[j] == 'undefined') {
-                    line.push('...');
-                } else if (colnames[j] == 'Flowspace Selector') {
-                   //alert("added");
-                    line.push("first");
-               }
-               
-
-               /*if (typeof colnames[j] == 'undefined') {
-                    line.push('...');
-                } else if (colnames[j] == 'hostname') {
-                    if (record['type'] == 'resource,link')
-                        //TODO: we need to add source/destination for links
-                        line.push('');
-                    else
-                        line.push(record['hostname']);
-
-                } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
-                    line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+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()
        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);
        // 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);
 
         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 ! */
 
         on_all_field_clear: function()
         {
-            alert('UnivbrisFv::clear_fields() not implemented');
+            alert('UnivbrisVtam::clear_fields() not implemented');
         },
 
 
 
         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()
         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;
              * 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;
 
                 $('.querytable_length', wrapper).css('visibility', 'visible');
             }
 
+           
+
+
         },
 
 
 
     });
 
-    $.plugin('UnivbrisFv', UnivbrisFv);
+   
+
+    $.plugin('UnivbrisVtam', UnivbrisVtam);
 
   /* define the 'dom-checkbox' type for sorting in datatables 
      http://datatables.net/examples/plug-ins/dom_sort.html
        } );
     }
 
+   
+
 })(jQuery);
 
+
+
diff --git a/plugins/univbrisvtam/templates/univbrisvtamplugin.html b/plugins/univbrisvtam/templates/univbrisvtamplugin.html
new file mode 100644 (file)
index 0000000..bcd7787
--- /dev/null
@@ -0,0 +1,29 @@
+<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>
diff --git a/plugins/univbrisvtamform/__init__.py b/plugins/univbrisvtamform/__init__.py
new file mode 100644 (file)
index 0000000..5f6c0d2
--- /dev/null
@@ -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 (file)
index 0000000..cd227cf
--- /dev/null
@@ -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 (file)
index 0000000..5df2d69
--- /dev/null
@@ -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 (file)
index 0000000..4304f36
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 (file)
index 0000000..4f181e1
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 (file)
index 0000000..8179f83
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 (file)
index 0000000..26558a4
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 (file)
index 0000000..c8ed657
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 (file)
index 0000000..0c16904
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 (file)
index 0000000..d12fe2a
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 (file)
index 0000000..cff526f
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 (file)
index 0000000..ef5ab35
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 (executable)
index 0000000..023f22a
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 (executable)
index 0000000..baf6c28
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 (file)
index 0000000..ac0df1a
--- /dev/null
@@ -0,0 +1,326 @@
+/**
+ * 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].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="<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];
+                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<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].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 (file)
index 0000000..b9f7c50
--- /dev/null
@@ -0,0 +1,62 @@
+<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>
+
index eb46bee..79538bd 100644 (file)
@@ -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",
     }    
    
index 6c5ee9a..718ba60 100644 (file)
@@ -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"
index 97a11dd..b51273f 100644 (file)
@@ -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
             }
index c7e02a2..94c0fb4 100644 (file)
@@ -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"
index 9941e97..9749c5b 100644 (file)
                                                                <div><h3>Platform: Myslice</h3></div>
                                                </td>
                                        </tr>
+                                       <tr>
+                                                <td class="key">Username</td>
+                                                <td class="value">
+                                                                <span id="userval" class="value" >{{ person }}</span>
+                                                </td>
+                                        </tr>
                                        <tr>
                                                <td class="key">Email</td>
                                                <td class="value">
index b04b911..347be8c 100644 (file)
                <div class="col-sm-5 col-sm-offset-1">
                        <div class="row">
                            {% include 'fibre__widget-login-fed-manager.html' %}
-                               <a href="/cafe" style="margin-left:80px;"><img src="{{ STATIC_URL }}img/fibre/cafe.jpg" alt="CAFe authentication" /></a>
+                               <!--<a href="/cafe" style="margin-left:80px;"><img src="{{ STATIC_URL }}img/fibre/cafe.jpg" alt="CAFe authentication" /></a>-->
+                               <a href="/cafe" style="margin-left:80px;"><img src="{{ STATIC_URL }}img/fibre/expresso.png" alt="CAFe Expresso authentication" /></a>
                        </div>
                </div>
                <div class="col-sm-1"></div>
index b58f3c4..3e3d415 100644 (file)
@@ -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( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
                 if(val.nodes=="undefined" || val.nodes==null){
                     nodes_length=0;
@@ -130,8 +127,6 @@ $(document).ready(function() {
                 slice_row += "<td>"+val.slice_expires+"</td>";
                 slice_row += "</tr>";
                 table_slices.push(slice_row);
-               }
-              }
             });
            
             /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
index 17e1383..bc2a2ed 100644 (file)
@@ -54,6 +54,7 @@ $(document).ready(function() {
                        <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>
@@ -91,8 +92,12 @@ $(document).ready(function() {
                                <div class="tab-pane" id="resourcemap">
                        {{map_resources}}
                                </div>
+                <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>
@@ -101,12 +106,11 @@ $(document).ready(function() {
                     <p>{{resources}}</p>
 
                     <p>{{below_table}}</p>
-
                 </div>
                                <div class="tab-pane" id="resourcescheduler">
                        {{scheduler}}
                                </div>
-       
+
                                <!--
                                <div id="reserved" class="tab-pane" style="height:370px;display:none;">
                        <table width="80%">
index fd140d7..f053a24 100644 (file)
@@ -3,7 +3,7 @@
 <h1>NEW SLICE REQUEST</h1>
 <br>
 <b>Slice name      :</b> {{slice_name}}</br>
-<b>URL                            :</b> {{exp_url}}</br>
+<b>URL                            :</b> {{number_of_nodes}}</br>
 <b>Purpose         :</b> {{purpose}}</br>
 <b>Organization           :</b> {{organization}}</br>
 <b>Email           :</b> {{email}}</br>
index 2346bf2..dcca68c 100644 (file)
@@ -54,7 +54,8 @@ $(document).ready(function() {
                        <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="#resourceflowspace" role="tab" data-toggle="tab">Flowspace</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>
@@ -91,8 +92,14 @@ $(document).ready(function() {
                                <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>
@@ -101,16 +108,11 @@ $(document).ready(function() {
                     <p>{{resources}}</p>
 
                     <p>{{below_table}}</p>
-
                 </div>
+
                                <div class="tab-pane" id="resourcescheduler">
                     {{scheduler}}
                                </div>
-                               <div class="tab-pane" id="resourceflowspace">
-                        {{resources}}
-                        {{flowspaces}}
-                        {{flowspaces_form}}
-                               </div>
        
                                <!--
                                <div id="reserved" class="tab-pane" style="height:370px;display:none;">
index 1430dae..4d58fe5 100644 (file)
@@ -9,14 +9,27 @@
                on the reserved nodes. To access your slice on a resource just type the following command:
        </p>
        <p class="command">
-               $ ssh your_slice_name@planetlab-resource.hostname.com
+               $ ssh converted_slice_name@planetlab-resource.hostname.com
        </p>
+       <p>You need to convert your typical slicename into a specific format in order to do SSH. An example below will demonstrate the conversion:</p>
+       <p class="command">
+               Typical slice_name = onelab.upmc.mytestslice<br>
+               converted_slice_name = onelab8upmc_mytestslice
+       </p>
+       <p>Please note that the first '.' is replaced by number 8 and the rest of the dot/s are replaced by underscore/s.</p>
        <p>
                Be aware that after you reserve a PlanetLab Europe resource your slice will be deployed with a delay of about 15 minutes, 
                after witch you will be able to access the resource.
        </p>
        
        <h3>FIT IoT-Lab</h3>
+       <p>FIT IoT-Lab resources are accessible directly via SSH and <a href="https://devgrenoble.senslab.info/testbed/" target="_blank">web GUI.</a>
+               To acess IoT-Lab resources using web GUI, use the same login and  password of OneLab portal. To acess Iot-Lab resources using SSH type
+               the following command:
+       </p>
+       <p class="command">
+               ssh onelab_username@fit3-dev.inrialpes.fr
+       </p>
        
        <h3>NITOS</h3>
        
diff --git a/portal/templates/univbrisvtam.html b/portal/templates/univbrisvtam.html
new file mode 100644 (file)
index 0000000..82de78b
--- /dev/null
@@ -0,0 +1,15 @@
+{% 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 %}
diff --git a/portal/univbrisvtam.py b/portal/univbrisvtam.py
new file mode 100644 (file)
index 0000000..c557998
--- /dev/null
@@ -0,0 +1,94 @@
+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
+
index 907267c..8859e62 100644 (file)
@@ -44,16 +44,18 @@ from portal.validationview          import ValidatePendingView
 #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),
@@ -122,7 +124,8 @@ urlpatterns = patterns('',
         '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'),
 
 )