Merge branch 'master' of ssh://git.onelab.eu/git/myslice
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Fri, 25 Oct 2013 17:22:40 +0000 (19:22 +0200)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Fri, 25 Oct 2013 17:22:40 +0000 (19:22 +0200)
Conflicts:
portal/sliceview.py

1  2 
plugins/slicestat/__init__.py
plugins/slicestat/static/js/slicestat.js
portal/sliceview.py

@@@ -1,6 -1,6 +1,6 @@@
  from unfold.plugin import Plugin
  
- class Slicestat(Plugin):
+ class SliceStat(Plugin):
      
      def __init__ (self, query, **settings):
          Plugin.__init__ (self, **settings)
@@@ -23,7 -23,7 +23,7 @@@
          return reqs
  
      def json_settings_list (self):
 -        return ['plugin_uuid', 'domid', 'query_uuid']
 +        return ['plugin_uuid', 'domid', 'query_uuid', 'slicename', 'o']
  
      def export_json_settings (self):
          return True
@@@ -13,7 -13,7 +13,7 @@@
  
  (function($){
  
-     var Slicestat = Plugin.extend({
+     var SliceStat = Plugin.extend({
  
          /** XXX to check
           * @brief Plugin constructor
@@@ -26,7 -26,7 +26,7 @@@
              // Call the parent constructor, see FAQ when forgotten
              this._super(options, element);                     
                        
 -
 +                      
              /* Member variables */
  
              /* Plugin events */
              // What happens when we don't define some events ?
              // Some can be less efficient
              this.listen_query(options.query_uuid);
 -
 +                      
              /* GUI setup and event binding */
              // call function
 -
 +                      if (typeof options.slicename != 'undefined') {
 +                      options.slicename = options.slicename.replace("ple.","").replace(".","_");
 +              }
 +              if (typeof options.o == 'undefined') {
 +                      //options.o = 'cpu';
 +              }
 +              
 +              this.elmt().on('show', options, this.on_show);
          },
  
          /* PLUGIN EVENTS */
              // this.id, this.el, this.cl, this.elts
              // same output as a jquery selector with some guarantees
          },
 -
 +              
 +              on_show: function(ev) 
 +              {
 +                      $('iframe#' + ev.target.id + '-iframe').attr('src','http://plestats.planet-lab.eu/nodes.php?slice='+ev.data.slicename+'&order='+ev.data.o);
 +              },
          /* TEMPLATES */
  
          // see in the html template
          /* RECORD HANDLERS */
          on_new_record: function(record)
          {
 -            console.log(record);
 -            
 -            $('iframe#slicestat_resource').attr('src','http://plestats.planet-lab.eu/node.php?node='+record.hostname);
 -            
 +              $('iframe#' + this.elmt().attr('id') + '-iframe').attr('src','http://plestats.planet-lab.eu/node.php?node='+record.hostname);            
          },
  
          /* INTERNAL FUNCTIONS */
      });
  
      /* Plugin registration */
-     $.plugin('Slicestat', Slicestat);
+     $.plugin('SliceStat', SliceStat);
  
      // TODO Here use cases for instanciating plugins in different ways like in the pastie.
  
diff --combined portal/sliceview.py
@@@ -20,14 -20,14 +20,15 @@@ from plugins.query_editor            im
  from plugins.active_filters          import ActiveFilters
  from plugins.quickfilter             import QuickFilter
  from plugins.messages                import Messages
 +from plugins.slicestat               import Slicestat
  
  from myslice.config                  import Config
  
  tmp_default_slice='ple.upmc.myslicedemo'
  
  # temporary : turn off the users part to speed things up
- do_query_users=True
+ #do_query_users=True
+ do_query_users=False
  
  class SliceView (LoginRequiredAutoLogoutView):
  
                  },
              )
  
 +        resources_stats_cpu = Slicestat(
 +            title = "CPU Usage",
 +            domid = 'resources-stats-cpu',
 +            page  = page,
 +            stats = 'slice',
 +            key   = 'hrn',
 +            query = 'none',
 +            slicename = slicename,
 +            o = 'cpu'
 +        )
 +        
 +        resources_stats_mem = Slicestat(
 +            title = "Memory Usage",
 +            domid = 'resources-stats-mem',
 +            page  = page,
 +            stats = 'slice',
 +            key   = 'hrn',
 +            query = 'none',
 +            slicename = slicename,
 +            o = 'mem'
 +        )
 +        
 +        resources_stats_asb = Slicestat(
 +            title = "Traffic Sent",
 +            domid = 'resources-stats-asb',
 +            page  = page,
 +            stats = 'slice',
 +            key   = 'hrn',
 +            query = 'none',
 +            slicename = slicename,
 +            o = 'asb'
 +        )
 +        
 +        resources_stats_arb = Slicestat(
 +            title = "Traffic Received",
 +            domid = 'resources-stats-arb',
 +            page  = page,
 +            stats = 'slice',
 +            key   = 'hrn',
 +            query = 'none',
 +            slicename = slicename,
 +            o = 'arb'
 +        )
 +        
          # with the new 'Filter' stuff on top, no need for anything but the hazelnut
          resources_as_list_area = resources_as_list 
  
                                  togglable=True,
                                  title="Resources",
                                  outline_complete=True,
 -                                sons=[ resources_as_map, resources_as_list_area, ],
 +                                sons=[ resources_as_map, resources_as_list_area, resources_stats_cpu, resources_stats_mem, resources_stats_asb, resources_stats_arb ],
                                  active_domid = 'resources-map',
                                  )
          main_stack.insert (resources_area)
  
 -
          # --------------------------------------------------------------------------
          # USERS
      
 -#        if do_query_users:
 -#            tab_users = Tabs(
 -#                page                = page,
 -#                domid               = 'users',
 -#                outline_complete    = True,
 -#                togglable           = True,
 -#                title               = 'Users',
 -#                active_domid        = 'users-list',
 -#                )
 -#            main_stack.insert(tab_users)
 -#    
 -#            tab_users.insert(Hazelnut( 
 -#                page        = page,
 -#                title       = 'Users List',
 -#                domid       = 'users-list',
 -#                # tab's sons preferably turn this off
 -#                togglable   = False,
 -#                # this is the query at the core of the slice list
 -#                query       = sq_user,
 -#                query_all  = query_user_all,
 -#                checkboxes  = True,
 -#                datatables_options = { 
 -#                    'iDisplayLength' : 25,
 -#                    'bLengthChange'  : True,
 -#                    'bAutoWidth'     : True,
 -#                },
 -#            ))
++<<<<<<< HEAD
 +        if do_query_users:
 +            tab_users = Tabs(
 +                page                = page,
 +                domid               = 'users',
 +                outline_complete    = True,
 +                togglable           = True,
 +                title               = 'Users',
 +                active_domid        = 'users-list',
 +                )
 +            main_stack.insert(tab_users)
 +    
 +            tab_users.insert(Hazelnut( 
 +                page        = page,
 +                title       = 'Users List',
 +                domid       = 'users-list',
 +                # tab's sons preferably turn this off
 +                togglable   = False,
 +                # this is the query at the core of the slice list
 +                query       = sq_user,
 +                query_all  = query_user_all,
 +                checkboxes  = True,
 +                datatables_options = { 
 +                    'iDisplayLength' : 25,
 +                    'bLengthChange'  : True,
 +                    'bAutoWidth'     : True,
 +                },
 +            ))
 +            
 +        
++=======
++        if do_query_users:
++            tab_users = Tabs(
++                page                = page,
++                domid               = 'users',
++                outline_complete    = True,
++                togglable           = True,
++                title               = 'Users',
++                active_domid        = 'users-list',
++                )
++            main_stack.insert(tab_users)
++    
++            tab_users.insert(Hazelnut( 
++                page        = page,
++                title       = 'Users List',
++                domid       = 'users-list',
++                # tab's sons preferably turn this off
++                togglable   = False,
++                # this is the query at the core of the slice list
++                query       = sq_user,
++                query_all  = query_user_all,
++                checkboxes  = True,
++                datatables_options = { 
++                    'iDisplayLength' : 25,
++                    'bLengthChange'  : True,
++                    'bAutoWidth'     : True,
++                },
++            ))
++>>>>>>> 0c8a634162f3271018102e75a3934c5db5e48f59
  # DEMO    
          # --------------------------------------------------------------------------
          # MEASUREMENTS