def get_context_data(self, **kwargs): page = Page(self.request) # This will simulate fake records in order to test the plugin fake_query = Query.get('ping').select('hrn', 'src_hostname', 'dst_hostname', 'delay') fake_query_all = Query.get('ping').select('hrn', 'src_hostname', 'dst_hostname', 'delay') generators = { 'hrn': 'random_string', 'src_hostname': 'random_string', 'dst_hostname': 'random_string', 'delay': 'random_int' } page.generate_records(fake_query, generators, 5) page.generate_records(fake_query_all, generators, 20) plugin = MadDash(query=fake_query, query_all=fake_query_all, page=page) context = super(MadDashView, self).get_context_data(**kwargs) context['unfold_main'] = plugin.render(self.request) context['title'] = 'Sandbox for MadDash plugin' context['topmenu_items'] = topmenu_items_live('maddash', page) context['username'] = the_user(self.request) prelude_env = page.prelude_env() context.update(prelude_env) return context
def get_context_data(self, **kwargs): page = Page(self.request) # pres_view = PresView(page = page) pres_view = Raw(page=page, html="<h1>PresView needs to be integrated</h1>") context = super(PresViewView, self).get_context_data(**kwargs) #context['ALL_STATIC'] = "all_static" context['unfold_main'] = pres_view.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Test view that combines various plugins' # the menu items on the top context['topmenu_items'] = topmenu_items_live('PresView', page) # so we can sho who is logged context['username'] = the_user(self.request) prelude_env = page.prelude_env() context.update(prelude_env) return context
def get(self, request, username='******'): if username == 'logged': username = '******' page = Page(request) # variables that will get passed to the view-unfold1.html template template_env = {} # write something of our own instead template_env['unfold_main'] = '<h1>Some title </h1>' # more general variables expected in the template template_env[ 'title'] = 'simple topmenuvalidation %(username)s' % locals() # the menu items on the top template_env['topmenu_items'] = topmenu_items_live('Slice', page) # so we can see who is logged template_env['username'] = the_user(request) # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} prelude_env = page.prelude_env() # logger.info(prelude_env.keys()) # for k in [ 'js_files' ] : # logger.info('prelude_env {} {} {}'.format(prelude_env,k,prelude_env[k])) template_env.update(prelude_env) result = render_to_response('view-unfold1.html', template_env, context_instance=RequestContext(request)) return result
def get_context_data(self, **kwargs): page = Page(self.request) # This will simulate fake records in order to test the plugin fake_query = Query.get('ping').select('hrn', 'src_hostname', 'dst_hostname', 'delay') fake_query_all = Query.get('ping').select('hrn', 'src_hostname', 'dst_hostname', 'delay') generators = { 'hrn': 'random_string', 'src_hostname': 'random_string', 'dst_hostname': 'random_string', 'delay': 'random_int' } page.generate_records(fake_query, generators, 5) page.generate_records(fake_query_all, generators, 20) plugin = MadDash(query = fake_query, query_all = fake_query_all, page = page) context = super(MadDashView, self).get_context_data(**kwargs) context['unfold_main'] = plugin.render(self.request) context['title'] = 'Sandbox for MadDash plugin' context['topmenu_items'] = topmenu_items_live ('maddash', page) context['username'] = the_user(self.request) prelude_env = page.prelude_env() context.update(prelude_env) return context
def get (self, request, username='******'): if username=='logged': username='******' page=Page(request) # variables that will get passed to the view-unfold1.html template template_env = {} # write something of our own instead template_env ['unfold_main'] = '<h1>Some title </h1>' # more general variables expected in the template template_env [ 'title' ] = 'simple topmenuvalidation %(username)s'%locals() # the menu items on the top template_env [ 'topmenu_items' ] = topmenu_items_live('Slice', page) # so we can see who is logged template_env [ 'username' ] = the_user (request) # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} prelude_env = page.prelude_env() # print prelude_env.keys() # for k in [ 'js_files' ] : # print 'prelude_env',prelude_env,k,prelude_env[k] template_env.update(prelude_env) result=render_to_response ('view-unfold1.html',template_env, context_instance=RequestContext(request)) return result
def get(self, request, state=None): env = self.default_env() if request.user.is_authenticated(): env['person'] = self.request.user # user_query = Query().get('user').select('user_hrn','parent_authority').filter_by('user_hrn','==','$user_hrn') # user_details = execute_query(self.request, user_query) # try: # env['user_details'] = user_details[0] # except Exception,e: # env['error'] = "Please check your Credentials" # try: # user_local_query = Query().get('local:user').select('config').filter_by('email','==',str(env['person'])) # user_local_details = execute_query(self.request, user_local_query) # user_local = user_local_details[0] # user_local_config = user_local['config'] # user_local_config = json.loads(user_local_config) # user_local_authority = user_local_config.get('authority') # if 'user_details' not in env or 'parent_authority' not in env['user_details'] or env['user_details']['parent_authority'] is None: # env['user_details'] = {'parent_authority': user_local_authority} # except Exception,e: # env['error'] = "Please check your Manifold user config" # ## check user is pi or not # platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled') # account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config') # 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_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') # # assigning values # if acc_auth_cred == {}: # pi = "is_not_pi" # else: # pi = "is_pi" else: env['person'] = None env['theme'] = self.theme env['section'] = "Institution" # env['pi'] = pi env['username'] = the_user(request) env['topmenu_items'] = topmenu_items(None, request) env['servdirurl'] = self.server_url if state: env['state'] = state elif not env['username']: env['state'] = None # use one or two columns for the layout - not logged in users will see the login prompt env['layout_1_or_2'] = "layout-unfold2.html" if not env[ 'username'] else "layout-unfold1.html" return render_to_response(self.template, env, context_instance=RequestContext(request))
def scroll_view(request): return render_to_response('view-scroll.html', { 'title': 'Toy page for scrolling', 'topmenu_items': topmenu_items('scroll', request), 'username': the_user(request), 'lorem': lorem, }, context_instance=RequestContext(request))
def scroll_view (request): return render_to_response ('view-scroll.html', {'title':'Toy page for scrolling', 'topmenu_items': topmenu_items('scroll',request), 'username':the_user (request), 'lorem':lorem, }, context_instance=RequestContext(request))
def get(self, request, state=None): env = self.default_env() email_list = [] status_list = [] authority_list = [] config = {} user_query = Query().get('local:user').select('email', 'status', 'config') user_details = execute_admin_query(self.request, user_query) for user in user_details: # get email email_list.append(user['email']) # get status if user['status'] == 0: user_status = 'Disabled' elif user['status'] == 1: user_status = 'Validation Pending' elif user['status'] == 2: user_status = 'Enabled' else: user_status = 'N/A' status_list.append(user_status) #get authority if user['config'] is not None: user_config = json.loads(user['config']) user_authority = user_config.get('authority', 'N/A') authority_list.append(user_authority) user_list = [{ 'email': t[0], 'status': t[1], 'authority': t[2] } for t in zip(email_list, status_list, authority_list)] if request.user.is_authenticated(): env['person'] = self.request.user else: env['person'] = None env['theme'] = self.theme env['user_list'] = user_list env['username'] = the_user(request) env['topmenu_items'] = topmenu_items(None, request) if state: env['state'] = state elif not env['username']: env['state'] = None # use one or two columns for the layout - not logged in users will see the login prompt env['layout_1_or_2'] = "layout-unfold2.html" if not env[ 'username'] else "layout-unfold1.html" return render_to_response(self.template, env, context_instance=RequestContext(request))
def get (self, request, state=None): env = self.default_env() env['username']=the_user(request) env['topmenu_items'] = topmenu_items(None, request) if state: env['state'] = state elif not env['username']: env['state'] = None # use one or two columns for the layout - not logged in users will see the login prompt env['layout_1_or_2']="layout-unfold2.html" if not env['username'] else "layout-unfold1.html" return render_to_response('home-view.html',env, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): page = Page(self.request) prelude_env = page.prelude_env() context = super(GraphicBuilderView, self).get_context_data(**kwargs) context['title'] = 'Graphic Builder Tools' # the menu items on the top context['topmenu_items'] = topmenu_items('Graphic Builder', page.request) # @qursaan change from _live # so we can sho who is logged context['username'] = the_user(self.request) context.update(prelude_env) return context
def tab_view (request): print "request", request.__class__ print request prelude=Prelude( js_files='js/bootstrap.js', css_files='css/bootstrap.css') tab_env = {'title':'Page for playing with Tabs', 'topmenu_items': topmenu_items('tab',request), 'username':the_user (request), 'lorem': lorem, } tab_env.update (prelude.prelude_env()) return render_to_response ('view-tab.html', tab_env, context_instance=RequestContext(request))
def tab_view (request): logger.info("request {}".format(request.__class__)) logger.info("{}".format(request)) prelude=Prelude( js_files='js/bootstrap.js', css_files='css/bootstrap.css') tab_env = {'title':'Page for playing with Tabs', 'topmenu_items': topmenu_items('tab',request), 'username':the_user (request), 'lorem': lorem, } tab_env.update (prelude.prelude_env()) return render_to_response ('view-tab.html', tab_env, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): # We might have slices on different registries with different user accounts # We note that this portal could be specific to a given registry, to which we register users, but i'm not sure that simplifies things # Different registries mean different identities, unless we identify via SFA HRN or have associated the user email to a single hrn context = super(WebSockets2View, self).get_context_data(**kwargs) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'SAMPLE WEBSOCKET PAGE', # the menu items on the top context['topmenu_items'] = topmenu_items('Dashboard', self.request) # so we can sho who is logged context['username'] = the_user(self.request) return context
def get_context_data(self, **kwargs): page = Page(self.request) page.add_js_files(["js/common.functions.js"]) platform_query = Query().get('local:platform').filter_by( 'disabled', '==', '0').select('platform', 'platform_longname', 'gateway_type') #platform_query = Query().get('local:platform').select('platform','platform_longname','gateway_type') page.enqueue_query(platform_query) page.expose_js_metadata() platformlist = QueryTable( page=page, title='List', domid='checkboxes', # this is the query at the core of the slice list query=platform_query, query_all=platform_query, checkboxes=False, init_key='platform', datatables_options={ 'iDisplayLength': 10, 'bLengthChange': True, 'bAutoWidth': True, }, ) context = super(PlatformsView, self).get_context_data(**kwargs) context['person'] = self.request.user context['platforms'] = platformlist.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Platforms connected to MySlice' # the menu items on the top context['topmenu_items'] = topmenu_items_live('Platforms', page) # so we can sho who is logged context['username'] = the_user(self.request) context['theme'] = self.theme context.update(page.prelude_env()) context['layout_1_or_2'] = "layout-unfold2.html" if not context[ 'username'] else "layout-unfold1.html" return context
def get_context_data(self, **kwargs): page = Page(self.request) plugin = MyPlugin(page = page) context = super(MyPluginView, self).get_context_data(**kwargs) context['unfold_main'] = plugin.render(self.request) # more general variables expected in the template context['title'] = 'Sandbox for MyPlugin plugin' # the menu items on the top context['topmenu_items'] = topmenu_items_live('myplugin', page) # so we can sho who is logged context['username'] = the_user(self.request) prelude_env = page.prelude_env() context.update(prelude_env) return context
def get_context_data(self, **kwargs): page = Page(self.request) plugin = MyPlugin(page=page) context = super(MyPluginView, self).get_context_data(**kwargs) context['unfold_main'] = plugin.render(self.request) # more general variables expected in the template context['title'] = 'Sandbox for MyPlugin plugin' # the menu items on the top context['topmenu_items'] = topmenu_items_live('myplugin', page) # so we can sho who is logged context['username'] = the_user(self.request) prelude_env = page.prelude_env() context.update(prelude_env) return context
def get_context_data(self, **kwargs): page = Page(self.request) page.add_js_files ( [ "js/common.functions.js" ] ) platform_query = Query().get('local:platform').filter_by('disabled', '==', '0').select('platform','platform_longname','gateway_type') #platform_query = Query().get('local:platform').select('platform','platform_longname','gateway_type') page.enqueue_query(platform_query) page.expose_js_metadata() platformlist = QueryTable( page = page, title = 'List', domid = 'checkboxes', # this is the query at the core of the slice list query = platform_query, query_all = platform_query, checkboxes = False, init_key = 'platform', datatables_options = { 'iDisplayLength': 10, 'bLengthChange' : True, 'bAutoWidth' : True, }, ) context = super(PlatformsView, self).get_context_data(**kwargs) context['person'] = self.request.user context['platforms'] = platformlist.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Platforms connected to MySlice' # the menu items on the top context['topmenu_items'] = topmenu_items_live('Platforms', page) # so we can sho who is logged context['username'] = the_user(self.request) context.update(page.prelude_env()) context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html" return context
def get(self, request, state=None): env = self.default_env() if request.user.is_authenticated(): env['person'] = self.request.user else: env['person'] = None env['theme'] = self.theme env['section'] = "About" env['username'] = the_user(request) env['topmenu_items'] = topmenu_items(None, request) if state: env['state'] = state elif not env['username']: env['state'] = None # use one or two columns for the layout - not logged in users will see the login prompt env['layout_1_or_2'] = "layout-unfold2.html" if not env[ 'username'] else "layout-unfold1.html" return render_to_response(self.template, env, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): page = Page(self.request) debug_platform = DebugPlatform(page = page) context = super(PlatformView, self).get_context_data(**kwargs) context['ALL_STATIC'] = "all_static" context['unfold_main'] = debug_platform.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Test view that combines various plugins' # the menu items on the top context['topmenu_items'] = topmenu_items('Dashboard', self.request) # so we can sho who is logged context['username'] = the_user(self.request) prelude_env = page.prelude_env() context.update(prelude_env) return context
def get_context_data(self, **kwargs): page = Page(self.request) debug_platform = DebugPlatform(page=page) context = super(PlatformView, self).get_context_data(**kwargs) context['ALL_STATIC'] = "all_static" context['unfold_main'] = debug_platform.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Test view that combines various plugins' # the menu items on the top context['topmenu_items'] = topmenu_items('Dashboard', self.request) # so we can sho who is logged context['username'] = the_user(self.request) prelude_env = page.prelude_env() context.update(prelude_env) return context
def render(self): template_env = {} # define 'unfold_main' to the template engine - the main contents template_env [ 'unfold_main' ] = "\n".join(self._content) # more general variables expected in the template template_env [ 'title' ] = 'Test view that combines various plugins' # the menu items on the top template_env [ 'topmenu_items' ] = topmenu_items('slice', self.request) # so we can sho who is logged template_env [ 'username' ] = the_user (self.request) # don't forget to run the requests # Jordan: it seems we need this to init plugins js # Issue a "manifold is not defined" error #self.expose_queries () # Thierry: this is deprecated anyway, and will happen as part of prelude_env # "manifold not defined" would be due to a missing dependency to manifold.js or something... template_env.update(self.prelude_env()) result=render_to_response ('view-unfold1.html',template_env, context_instance=RequestContext(self.request)) return result
def get_context_data(self, **kwargs): page = Page(self.request) # pres_view = PresView(page = page) pres_view = Raw(page = page,html="<h1>PresView needs to be integrated</h1>") context = super(PresViewView, self).get_context_data(**kwargs) #context['ALL_STATIC'] = "all_static" context['unfold_main'] = pres_view.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Test view that combines various plugins' # the menu items on the top context['topmenu_items'] = topmenu_items_live('PresView', page) # so we can sho who is logged context['username'] = the_user(self.request) prelude_env = page.prelude_env() context.update(prelude_env) return context
def dashboard_view(request): page = Page(request) slices_query = Query.get('slice').select('slice_hrn') #old# # xxx filter : should filter on the slices the logged user can see #old# # we don't have the user's hrn yet #old# # in addition this currently returns all slices anyways #old# # filter = ... #old# sort='slice_hrn',) page.enqueue_query(slices_query) main_plugin = Stack( page=page, title="Putting stuff together", sons=[ QueryCode( page=page, title="Vizualize your query", query=slices_query, toggled=False, ), QuickFilter( # we play with this one for demo purposes in dashboard.css domid='myquickfilter', page=page, title='play with filters', criterias=quickfilter_criterias, toggled=False, ), SliceList( # setting visible attributes first page=page, title='Asynchroneous SliceList', header='slices list', with_datatables=False, # this is the query at the core of the slice list query=slices_query, ), ]) # variables that will get passed to the view-unfold2.html template template_env = {} # define 'unfold_main' to the template engine template_env['unfold_main'] = main_plugin.render(request) # more general variables expected in the template template_env['title'] = 'Test view for a full request cycle' # the menu items on the top template_env['topmenu_items'] = topmenu_items_live('dashboard', page) # so we can sho who is logged template_env['username'] = the_user(request) # ########## add another plugin with the same request, on the RHS pane # will show up in the right-hand side area named 'related' related_plugin = SliceList( page=page, title='Same request, other layout', domid='sidelist', with_datatables=True, header='paginated slices', # share the query query=slices_query, ) # likewise but on the side view template_env['unfold_margin'] = related_plugin.render(request) # add our own css in the mix #page.add_css_files ( 'css/dashboard.css') # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} prelude_env = page.prelude_env() template_env.update(prelude_env) return render_to_response('view-unfold2.html', template_env, context_instance=RequestContext(request))
def get (self, request, state=None): env = self.default_env() acc_auth_cred={} try: if request.user.is_authenticated(): jfed_identity = get_jfed_identity(request) if jfed_identity is not None: import base64 encoded_jfed_identity = base64.b64encode(jfed_identity) env['jfed_identity'] = encoded_jfed_identity else: env['jfed_identity'] = None ## check user is pi or not platform_details = {} account_details = {} acc_auth_cred = {} acc_user_cred = {} platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled') account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config') # XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page account_detail = get_myslice_account(self.request) if 'config' in account_detail and account_detail['config'] is not '': account_config = json.loads(account_detail['config']) 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" #else: # pi = "is_pi" user_email = str(self.request.user) #pi = authority_check_pis(self.request, user_email) # check if the user has creds or not if acc_user_cred == {} or acc_user_cred == 'N/A': user_cred = 'no_creds' else: exp_date = get_expiration(acc_user_cred, 'timestamp') if exp_date < time.time(): user_cred = 'creds_expired' else: user_cred = 'has_creds' # list the pending slices of this user pending_slices = [] for slices in PendingSlice.objects.filter(type_of_nodes__iexact=self.request.user).all(): pending_slices.append(slices.slice_name) env['pending_slices'] = pending_slices #env['pi'] = pi env['user_cred'] = user_cred env['person'] = self.request.user else: env['person'] = None except Exception as e: print e env['person'] = None env['state'] = "Your session has expired" env['theme'] = self.theme env['section'] = "Dashboard" logger.debug("homeview called") env['next'] = request.GET.get('next',None) env['username']=the_user(request) env['topmenu_items'] = topmenu_items(None, request) env['request'] = request if state: env['state'] = state elif not env['username']: env['state'] = None # use one or two columns for the layout - not logged in users will see the login prompt return render_to_response(self.template, env, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): page = Page(self.request) page.add_js_files(["js/common.functions.js"]) for key, value in kwargs.iteritems(): logger.debug("{} = {}".format(key, value)) if key == "platformname": platformname = value network_query = Query().get('local:platform')\ .filter_by('platform', '==', platformname)\ .select('platform','platform_longname','gateway_type') page.enqueue_query(network_query) # ListResources of the platform metadata = page.get_metadata() resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] resources = platformname + ':resource' query_resource_all = Query.get(resources).select(resource_fields) page.enqueue_query(query_resource_all) query_resource_default_fields = Query.get(resources).select( 'hrn', 'hostname', 'type', 'country') page.enqueue_query(query_resource_default_fields) page.expose_js_metadata() networklist = QueryTable( page=page, title='List', domid='checkboxes', # this is the query at the core of the slice list query=network_query, query_all=network_query, checkboxes=False, datatables_options={ 'iDisplayLength': 25, 'bLengthChange': True, }, ) # networklist = SimpleList( # title = None, # page = page, # key = 'platform', # query = network_query, # ) # # -------------------------------------------------------------------------- # RESOURCES # for internal use in the querytable plugin; # needs to be a unique column present for each returned record main_query_init_key = 'hrn' # the resources part is made of a Tabs (Geographic, List), resources_as_gmap = GoogleMap( page=page, title='Geographic view', domid='resources-map', # tab's sons preferably turn this off togglable=False, query=query_resource_default_fields, query_all=query_resource_all, # this key is the one issued by google googlemap_api_key=ConfigEngine().googlemap_api_key(), # the key to use at init-time init_key=main_query_init_key, checkboxes=False, # center on Paris latitude=49., longitude=9, zoom=4, ) resources_as_3dmap = SensLabMap( page=page, title='3D Map', domid='senslabmap', query=query_resource_default_fields, query_all=query_resource_all, ) resources_as_list = QueryTable( page=page, domid='resources-list', title='List view', # this is the query at the core of the slice list query=query_resource_default_fields, query_all=query_resource_all, init_key=main_query_init_key, checkboxes=False, datatables_options={ 'iDisplayLength': 25, 'bLengthChange': True, 'bAutoWidth': True, }, ) resources_sons = [ resources_as_gmap, resources_as_3dmap, resources_as_list, ] resources_area = Tabs( page=page, domid="resources", togglable=True, title="Resources", outline_complete=True, sons=resources_sons, active_domid='resources-map', persistent_active=True, ) context = super(PlatformView, self).get_context_data(**kwargs) context['person'] = self.request.user context['networks'] = networklist.render(self.request) context['resources'] = resources_area.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Platforms connected to MySlice' # the menu items on the top context['topmenu_items'] = topmenu_items_live('Platforms', page) # so we can sho who is logged context['username'] = the_user(self.request) context['theme'] = self.theme context.update(page.prelude_env()) return context
def get(self, request, slicename='ple.inria.f14'): page = Page(request) page.expose_js_metadata() metadata = page.get_metadata() resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] main_query = Query.get('slice').filter_by('slice_hrn', '=', slicename) main_query.select( 'slice_hrn', #'resource.hrn', 'resource.hostname', 'resource.type', 'resource.network_hrn', 'lease.urn', 'user.user_hrn', #'application.measurement_point.counter' ) # for internal use in the querygrid plugin; # needs to be a unique column present for each returned record main_query_init_key = 'hostname' query_resource_all = Query.get('resource').select(resource_fields) aq = AnalyzedQuery(main_query, metadata=metadata) page.enqueue_query(main_query, analyzed_query=aq) page.enqueue_query(query_resource_all) sq_resource = aq.subquery('resource') resources_as_list = QueryGrid( page=page, domid='resources-list', title='List view', # this is the query at the core of the slice list query=sq_resource, query_all=query_resource_all, # safer to use 'hrn' as the internal unique key for this plugin init_key=main_query_init_key, checkboxes=True, datatables_options={ 'iDisplayLength': 25, 'bLengthChange': True, 'bAutoWidth': True, }, ) # variables that will get passed to the view-unfold1.html template template_env = {} # define 'unfold_main' to the template engine - the main contents template_env['unfold_main'] = resources_as_list.render(request) # more general variables expected in the template template_env['title'] = 'simple %(slicename)s' % locals() # the menu items on the top template_env['topmenu_items'] = topmenu_items_live('Slice', page) # so we can sho who is logged template_env['username'] = the_user(request) # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} prelude_env = page.prelude_env() template_env.update(prelude_env) result = render_to_response('view-unfold1.html', template_env, context_instance=RequestContext(request)) return result
def get_context_data(self, **kwargs): page = Page(self.request) page.add_js_files ( [ "js/common.functions.js" ] ) #platform_query = Query().get('local:platform').filter_by('disabled', '==', '0').select('platform','platform_longname','gateway_type') #platform_query = Query().get('local:platform').select('platform','platform_longname','gateway_type') email_list = [] status_list = [] authority_list = [] config={} user_query = Query().get('local:user').select('email','status','config') user_details = execute_admin_query(self.request, user_query) for user in user_details: # get email email_list.append(user['email']) # get status if user['status'] == 0: user_status = 'Disabled' elif user['status'] == 1: user_status = 'Validation Pending' elif user['status'] == 2: user_status = 'Enabled' else: user_status = 'N/A' status_list.append(user_status) #get authority #if user['config']: user_config = json.loads(user['config']) user_authority = user_config.get('authority','N/A') authority_list.append(user_authority) user_list = [{'email': t[0], 'status': t[1], 'authority':t[2]} for t in zip(email_list, status_list, authority_list)] #page.enqueue_query(user_query) #page.expose_js_metadata() #userlist = QueryTable( # page = page, # title = 'List', # domid = 'checkboxes', # # this is the query at the core of the slice list # query = user_query, # query_all = user_query, # checkboxes = False, # init_key = 'user', # datatables_options = { # 'iDisplayLength': 10, # 'bLengthChange' : True, # 'bAutoWidth' : True, # }, #) context = super(UsersView, self).get_context_data(**kwargs) context['person'] = self.request.user context['user_list'] = user_list # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Users in MySlice' # the menu items on the top context['topmenu_items'] = topmenu_items_live('Users', page) # so we can sho who is logged context['username'] = the_user(self.request) context.update(page.prelude_env()) context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html" return context
def get (self,request, slicename=tmp_default_slice): page = Page(request) page.add_css_files ('css/slice-view.css') page.add_js_files ( [ "js/common.functions.js" ] ) page.add_js_chunks ('$(function() { messages.debug("sliceview: jQuery version " + $.fn.jquery); });') page.add_js_chunks ('$(function() { messages.debug("sliceview: users turned %s"); });'%("on" if do_query_users else "off")) page.add_js_chunks ('$(function() { messages.debug("sliceview: leases turned %s"); });'%("on" if do_query_leases else "off")) page.add_js_chunks ('$(function() { messages.debug("manifold URL %s"); });'%(ConfigEngine().manifold_url())) metadata = page.get_metadata() resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] user_md = metadata.details_by_object('user') user_fields = ['user_hrn'] # [column['name'] for column in user_md['column']] # TODO The query to run is embedded in the URL main_query = Query.get('slice').filter_by('slice_hrn', '=', slicename) main_query.select( 'slice_hrn', #'resource.hrn', 'resource.urn', 'resource.hostname', 'resource.type', 'resource.network_hrn', 'lease.urn', 'user.user_hrn', #'application.measurement_point.counter' ) # for internal use in the querytable plugin; # needs to be a unique column present for each returned record main_query_init_key = 'hostname' query_resource_all = Query.get('resource').select(resource_fields) aq = AnalyzedQuery(main_query, metadata=metadata) page.enqueue_query(main_query, analyzed_query=aq) page.enqueue_query(query_resource_all) if do_query_users: # Required: the user must have an authority in its user.config # XXX Temporary solution user_query = Query().get('local:user').select('config','email') user_details = execute_query(self.request, user_query) # not always found in user_details... config={} # for user_detail in user_details: # #email = user_detail['email'] # if user_detail['config']: # config = json.loads(user_detail['config']) # user_detail['authority'] = config.get('authority',"Unknown Authority") # # if user_detail['authority'] is not None: # sub_authority = user_detail['authority'].split('.') # root_authority = sub_authority[0] # query_user_all = Query.get(root_authority+':user').select(user_fields) # # # XXX TODO this filter doesn't work - to be improved in Manifold # #.filter_by('authority.authority_hrn', '=', user_detail['authority']) # # page.enqueue_query(query_user_all) # else: # print "authority of the user is not in local:user db" query_user_all = Query.get('user').select(user_fields) # query_user_all = None # ... and for the relations # XXX Let's hardcode resources for now sq_resource = aq.subquery('resource') sq_user = aq.subquery('user') sq_lease = aq.subquery('lease') sq_measurement = aq.subquery('measurement') # Prepare the display according to all metadata # (some parts will be pending, others can be triggered by users). # # For example slice measurements will not be requested by default... # Create the base layout (Stack)... main_stack = Stack ( page=page, title="Slice %s"%slicename, sons=[], ) # ... responsible for the slice properties... # a nice header main_stack.insert ( Raw (page=page, togglable=False, toggled=True, html="<h2 class='well well-lg'> Slice %s</h2>"%slicename) ) # -------------------------------------------------------------------------- # QueryUpdater (Pending Operations) main_stack.insert(QueryUpdater( page = page, title = 'Pending operations', query = main_query, togglable = True, # start turned off, it will open up itself when stuff comes in toggled = False, domid = 'pending', outline_complete = True, )) # -------------------------------------------------------------------------- # Filter Resources # turn off for now -- see above filter_query_editor = QueryEditor( page = page, query = sq_resource, query_all = query_resource_all, title = "Select Columns", domid = 'select-columns', ) filter_active_filters = ActiveFilters( page = page, query = sq_resource, title = "Active Filters", ) filters_area = Stack( page = page, title = 'Filter Resources', domid = 'filters', sons = [filter_query_editor, filter_active_filters], togglable = True, toggled = 'persistent', outline_complete = True, ) main_stack.insert (filters_area) # -------------------------------------------------------------------------- # RESOURCES # the resources part is made of a Tabs (Geographic, List), resources_as_gmap = GoogleMap( page = page, title = 'Geographic view', domid = 'resources-map', # tab's sons preferably turn this off togglable = False, query = sq_resource, query_all = query_resource_all, # this key is the one issued by google googlemap_api_key = ConfigEngine().googlemap_api_key(), # the key to use at init-time init_key = main_query_init_key, checkboxes = True, # center on Paris latitude = 49., longitude = 9, zoom = 4, ) resources_as_3dmap = SensLabMap( page = page, title = '3D Map', domid = 'senslabmap', query = sq_resource, query_all = query_resource_all, ) resources_as_list = QueryTable( page = page, domid = 'resources-list', title = 'List view', # this is the query at the core of the slice list query = sq_resource, query_all = query_resource_all, init_key = main_query_init_key, checkboxes = True, datatables_options = { 'iDisplayLength': 25, 'bLengthChange' : True, 'bAutoWidth' : True, }, ) if insert_grid: resources_as_grid = QueryGrid( page = page, domid = 'resources-grid', title = 'Grid view', # this is the query at the core of the slice list query = sq_resource, query_all = query_resource_all, init_key = main_query_init_key, checkboxes = True, ) #if do_query_leases: # resources_as_scheduler = Scheduler( # page = page, # title = 'Scheduler', # domid = 'scheduler', # query = sq_resource, # query_all_resources = query_resource_all, # query_lease = sq_lease, # ) resources_as_scheduler2 = Scheduler2( page = page, domid = 'scheduler', title = 'Scheduler', # this is the query at the core of the slice list query = sq_resource, query_all_resources = query_resource_all, query_lease = sq_lease, ) # with the new 'Filter' stuff on top, no need for anything but the querytable resources_as_list_area = resources_as_list resources_sons = [ resources_as_gmap, resources_as_3dmap, resources_as_scheduler2, resources_as_list_area, ] if do_query_leases else [ resources_as_gmap, resources_as_3dmap, resources_as_list_area, resources_as_scheduler2, ] if insert_grid: resources_sons.append(resources_as_grid) resources_area = Tabs ( page=page, domid="resources", togglable=True, title="Resources", outline_complete=True, sons= resources_sons, active_domid = 'scheduler', persistent_active=True, ) main_stack.insert (resources_area) # -------------------------------------------------------------------------- # USERS if do_query_users and query_user_all is not None: 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(QueryTable( 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, }, )) # DEMO # -------------------------------------------------------------------------- # MEASUREMENTS measurements_stats_cpu = SliceStat( title = "CPU Usage", domid = 'resources-stats-cpu', page = page, stats = 'slice', key = 'hrn', query = 'none', slicename = slicename, o = 'cpu' ) measurements_stats_mem = SliceStat( title = "Memory Usage", domid = 'resources-stats-mem', page = page, stats = 'slice', key = 'hrn', query = 'none', slicename = slicename, o = 'mem' ) measurements_stats_asb = SliceStat( title = "Traffic Sent", domid = 'resources-stats-asb', page = page, stats = 'slice', key = 'hrn', query = 'none', slicename = slicename, o = 'asb' ) measurements_stats_arb = SliceStat( title = "Traffic Received", domid = 'resources-stats-arb', page = page, stats = 'slice', key = 'hrn', query = 'none', slicename = slicename, o = 'arb' ) tab_measurements = Tabs ( page=page, domid = "measurements", togglable = True, toggled = 'persistent', title = "Measurements", outline_complete=True, sons = [ measurements_stats_cpu, measurements_stats_mem, measurements_stats_asb, measurements_stats_arb ], active_domid = 'resources-stats-cpu', persistent_active = True, ) main_stack.insert (tab_measurements) # tab_measurements = Tabs ( # page = page, # active_domid = 'measurements-list', # outline_complete = True, # togglable = True, # title = 'Measurements', # domid = 'measurements', # ) # main_stack.insert(tab_measurements) # # tab_measurements.insert(QueryTable( # page = page, # title = 'Measurements', # domid = 'measurements-list', # # tab's sons preferably turn this off # togglable = False, # # this is the query at the core of the slice list # query = sq_measurement, # # do NOT set checkboxes to False # # this table being otherwise empty, it just does not fly with dataTables # checkboxes = True, # datatables_options = { # 'iDisplayLength' : 25, # 'bLengthChange' : True, # 'bAutoWidth' : True, # }, # )) # # # -------------------------------------------------------------------------- # # MESSAGES (we use transient=False for now) if insert_messages: main_stack.insert(Messages( page = page, title = "Runtime messages for slice %s"%slicename, domid = "msgs-pre", levels = "ALL", # plain messages are probably less nice for production but more reliable for development for now transient = False, # these make sense only in non-transient mode.. togglable = True, toggled = 'persistent', outline_complete = True, )) # variables that will get passed to the view-unfold1.html template template_env = {} # define 'unfold_main' to the template engine - the main contents template_env [ 'unfold_main' ] = main_stack.render(request) # more general variables expected in the template template_env [ 'title' ] = '%(slicename)s'%locals() # the menu items on the top template_env [ 'topmenu_items' ] = topmenu_items_live('Slice', page) # so we can sho who is logged template_env [ 'username' ] = the_user (request) # don't forget to run the requests page.expose_js_metadata() # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} template_env.update(page.prelude_env()) return render_to_response ('view-unfold1.html',template_env, context_instance=RequestContext(request))
'parent_authority': user_local_authority } except Exception, e: env['error'] = "Please check your Credentials" else: env['project'] = True env['user_details'] = {'parent_authority': authority_hrn} logger.debug("BEFORE ####------#### is_pi") logger.debug("is_pi = {}".format(is_pi)) pi = is_pi(self.request, '$user_hrn', env['user_details']['parent_authority']) else: env['person'] = None pi = False env['theme'] = self.theme env['section'] = "Institution" env['pi'] = pi env['username'] = the_user(request) env['topmenu_items'] = topmenu_items(None, request) if state: env['state'] = state elif not env['username']: env['state'] = None # use one or two columns for the layout - not logged in users will see the login prompt env['layout_1_or_2'] = "layout-unfold2.html" if not env[ 'username'] else "layout-unfold1.html" env['request'] = request return render_to_response(self.template, env, context_instance=RequestContext(request))
def test_plugin_view(request): page = Page(request) page.expose_js_metadata() # variables that will get passed to this template template_env = {} slicename = 'ple.inria.heartbeat' main_query = Query.get('resource').filter_by( 'slice_hrn', '=', slicename).select(['network', 'type', 'hrn', 'hostname', 'sliver']) # without an querytable, this would use use : run_it=False as nothing would listen to the results page.enqueue_query( main_query, # run_it=False ) main_plugin = \ Stack ( page=page, title='thestack', togglable=True, domid='stack', sons=[ \ # make sure the 2 things work together Messages ( page=page, title="Transient Runtime messages", domid="messages-transient", levels='ALL', ), QueryTable ( page=page, title="Slice %s - checkboxes"%slicename, query=main_query, domid="querytable", checkboxes=True, togglable=True, ), Messages ( page=page, title="Inline Runtime messages", domid="messages", levels='ALL', togglable=True, transient=False, ), Raw ( page=page, title="issue messages", togglable=True, html=""" <input type="button" id="bouton" value="Click me" /> """, ), ]) page.add_js_chunks(""" function issue_debug() {console.log("issue_debug");messages.debug("issue_debug");}; $(function(){$("#bouton").click(issue_debug);}); """) # define 'unfold_main' to the template engine template_env['unfold_main'] = main_plugin.render(request) # more general variables expected in the template template_env['title'] = 'Single Plugin View' template_env['topmenu_items'] = topmenu_items_live('plugin', page) template_env['username'] = the_user(request) # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} prelude_env = page.prelude_env() template_env.update(prelude_env) return render_to_response('view-unfold1.html', template_env, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): page = Page(self.request) page.add_js_files ( [ "js/common.functions.js" ] ) for key, value in kwargs.iteritems(): print "%s = %s" % (key, value) if key == "urn": resource_urn=value resource_query = Query().get('resource')\ .filter_by('urn', '==', resource_urn)\ .select('hostname','type','hrn','urn', 'latitude', 'longitude', 'country') page.enqueue_query(resource_query) page.expose_js_metadata() resourcelist = QueryTable( page = page, title = 'List', domid = 'checkboxes', # this is the query at the core of the slice list query = resource_query, query_all = resource_query, checkboxes = False, datatables_options = { 'iDisplayLength' : 25, 'bLengthChange' : True, }, ) resource_as_map = GoogleMap( page = page, title = 'Geographic view', domid = 'resources-map', # tab's sons preferably turn this off togglable = True, query = resource_query, query_all = resource_query, googlemap_api_key = ConfigEngine().googlemap_api_key(), checkboxes = False, # center on Paris #latitude = 49., #longitude = 9, #zoom = 4, ) # resourcelist = SimpleList( # title = None, # page = page, # key = 'hrn', # query = resource_query, # ) resource_stats = SliceStat( title = None, page = page, stats = 'node', key = 'hrn', query = resource_query ) context = super(ResourceView, self).get_context_data(**kwargs) context['person'] = self.request.user context['resource'] = resourcelist.render(self.request) context['resource_as_map'] = resource_as_map.render(self.request) context['resource_stats'] = resource_stats.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Information about a resource' # the menu items on the top context['topmenu_items'] = topmenu_items_live(None, page) # so we can sho who is logged context['username'] = the_user(self.request) context.update(page.prelude_env()) return context
def get (self, request, state=None): env = self.default_env() ##### *** Reputation Plugin-specific START *** ############ #The following 'if' is a dirty way for bypassing the JS AJAX cross-domain prevention policy...not pretty if request.GET.has_key(u'slicedata[user_eval][overall]'): dict_to_send = {} dict_to_send['eid'] = str(request.GET[u'slicedata[id]']) dict_to_send['slice_hrn'] = str(request.GET[u'slicedata[slice_hrn]']) dict_to_send['user_hrn'] = str(request.GET[u'slicedata[user_hrn]']) dict_to_send['start_tunix'] = str(request.GET[u'slicedata[start_tunix]']) dict_to_send['end_tunix'] = str(request.GET[u'slicedata[end_tunix]']) dict_to_send['start_t'] = str(request.GET[u'slicedata[start_t]']) dict_to_send['end_t'] = str(request.GET[u'slicedata[end_t]']) dict_to_send['testbeds'] = ast.literal_eval(str(request.GET[u'testbeds'])) dict_to_send['user_eval'] = {} dict_to_send['user_eval']['reuse'] = str(request.GET[u'slicedata[user_eval][reuse]']) dict_to_send['user_eval']['availability'] = str(request.GET[u'slicedata[user_eval][availability]']) dict_to_send['user_eval']['pay'] = str(request.GET[u'slicedata[user_eval][pay]']) dict_to_send['user_eval']['support'] = str(request.GET[u'slicedata[user_eval][support]']) dict_to_send['user_eval']['overall'] = str(request.GET[u'slicedata[user_eval][overall]']) dict_to_send['user_eval']['link_quality'] = str(request.GET[u'slicedata[user_eval][link_quality]']) dict_to_send['user_eval']['problems'] = str(request.GET[u'slicedata[user_eval][problems]']) dict_to_send['user_eval']['quality'] = str(request.GET[u'slicedata[user_eval][quality]']) slicedata_received = json_to_rest('http://survivor.lab.netmode.ntua.gr:4567/reputation/json', dict_to_send ) return HttpResponse(json.dumps(slicedata_received), content_type = response_content_type(self.request)) slices_users = [] #get slices userslice_query = Query().get('slice').select('slice_urn', 'slice_hrn', 'users', 'resource', 'lease', 'slice_last_updated') slice_details = execute_query(self.request, userslice_query) #get local users local_user_query = Query().get('local:user').select('email','status','config') local_user_details = execute_admin_query(self.request, local_user_query) #get users - create dict[email]=hrn user_query = Query().get('user').select('user_hrn','user_urn','user_email') user_details = execute_admin_query(self.request, user_query) users_hrn = {} for item in user_details: users_hrn[item['user_email']] = item['user_hrn'] #get currenct username (email) if request.user.is_authenticated(): cur_username = request.user.username #get a list of all the slices for the logged in user testbeds = [] #env['slices_users'] = json.dumps(slice_details, ensure_ascii=False) for slice in slice_details: if users_hrn[cur_username] in slice['users']: slices_users.append({'slice_hrn':slice['slice_hrn'], 'user':cur_username, 'user_hrn':users_hrn[cur_username] \ , 'resource':slice['resource'], 'lease':slice['lease'], 'slice_last_updated':slice['slice_last_updated'] }) #env['slices_users'] = slices_users ### For logging #####create slicelist for template & JSON experiments,testbeds = slice_to_exp(slices_users) all_exp = [] iddata = [] for exp in experiments: experiment = {} experiment['slice_hrn'] = experiments[exp]['slice_hrn'] experiment['user_hrn'] = users_hrn[cur_username] experiment['start_tunix'] = experiments[exp]['start'] experiment['end_tunix'] = experiments[exp]['end'] experiment['start_t'] = unix_to_timestamp(experiments[exp]['start']) experiment['end_t'] = unix_to_timestamp(experiments[exp]['end']) experiment['testbeds'] = {} for exp_node in experiments[exp]['nodes']: list_testbeds = [ key for key,val in testbeds.items()] for tkey in list_testbeds: if exp_node in testbeds[tkey]: if tkey in experiment['testbeds']: if exp_node not in experiment['testbeds'][tkey]: experiment['testbeds'][tkey].append(exp_node) else: experiment['testbeds'][tkey] = [exp_node] tempid = hashlib.sha1(str(experiment)).hexdigest() experiment['id'] = tempid iddata.append(tempid) all_exp.append(experiment) env['logging_test'] = json.dumps(all_exp, ensure_ascii=False) env['slices_users'] = json.dumps(all_exp, ensure_ascii=False) ###### Check which experiments have not been rated yet. Pop from all_exp any experiment that has already been rated unrated_exp = json_to_rest('http://survivor.lab.netmode.ntua.gr:4567/reputation/qid', iddata) for item in all_exp: if item['id'] in unrated_exp: pass else: all_exp.pop(all_exp.index(item)) ###### Get Reputation values from Reputation DB reps = json_to_rest('http://survivor.lab.netmode.ntua.gr:4567/reputation/showrep', "a") #env['logging_test'] = reps #create a services list and a dict containing the services for each testbed serv_per_tb = {} services = [] for item in reps: serv_per_tb[item['testbed']]=[] for serv in item['services']: if serv.keys()[0] not in services: services.append(serv.keys()[0]) serv_per_tb[item['testbed']].append(serv.keys()[0]) #in json, sevices are in the form: 'services':[{'serv1':x}, {'serv2':y}], so we transform it to 'services':[x,y] based on # the services dict above. If for a specific service there is no applicable value, we put N/A for testbed in reps: d = list(testbed['services']) del testbed['services'] testbed['services'] = [] for s in services: set_v = 0 for i in d: try: testbed['services'].append(i[s]) set_v=1 except: pass if set_v == 0 : testbed['services'].append('N/A') ###### Pass variables to template #env['logging_test'] = json.dumps(all_exp, ensure_ascii=False) env['serv_per_tb'] = json.dumps(serv_per_tb, ensure_ascii=False) env['reputation'] = reps env['rep_serv'] = services env['slicelist'] = all_exp env['json_data'] = json.dumps(all_exp, ensure_ascii=False) ###### *** Reputation Plugin-specific END *** ############ if request.user.is_authenticated(): env['person'] = self.request.user else: env['person'] = None env['theme'] = self.theme #env['user_list']= user_list env['username']=the_user(request) env['topmenu_items'] = topmenu_items(None, request) if state: env['state'] = state elif not env['username']: env['state'] = None # use one or two columns for the layout - not logged in users will see the login prompt env['layout_1_or_2']="layout-unfold2.html" if not env['username'] else "layout-unfold1.html" return render_to_response(self.template, env, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): # We might have slices on different registries with different user accounts # We note that this portal could be specific to a given registry, to which we register users, but i'm not sure that simplifies things # Different registries mean different identities, unless we identify via SFA HRN or have associated the user email to a single hrn #messages.info(self.request, 'You have logged in') page = Page(self.request) logger.info("Dashboard page") # Slow... #slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn') testbed_query = Query().get('network').select('network_hrn', 'platform', 'version') # DEMO GEC18 Query only PLE # user_query = Query().get('local:user').select('config','email') # user_details = execute_query(self.request, user_query) # not always found in user_details... # config={} # for user_detail in user_details: # #email = user_detail['email'] # if user_detail['config']: # config = json.loads(user_detail['config']) # user_detail['authority'] = config.get('authority',"Unknown Authority") # # print user_detail # if user_detail['authority'] is not None: # sub_authority = user_detail['authority'].split('.') # root_authority = sub_authority[0] # slice_query = Query().get(root_authority+':user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn') # else: logger.debug("SLICE QUERY") logger.debug("-" * 80) slice_query = Query().get('myslice:user').filter_by( 'user_hrn', '==', '$user_hrn').select('slices.slice_hrn') page.enqueue_query(slice_query) page.enqueue_query(testbed_query) slicelist = SliceList( page=page, title="slices", warning_msg="<a href='../slice_request'>Request Slice</a>", query=slice_query, ) testbedlist = TestbedList( page=page, title="testbeds", query=testbed_query, ) context = super(DashboardView, self).get_context_data(**kwargs) context['person'] = self.request.user context['testbeds'] = testbedlist.render(self.request) context['slices'] = slicelist.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Dashboard' # the menu items on the top context['topmenu_items'] = topmenu_items_live('Dashboard', page) # so we can sho who is logged context['username'] = the_user(self.request) context['theme'] = self.theme page.expose_js_metadata() # the page header and other stuff context.update(page.prelude_env()) return context
def _display (self, request, form): return render(request, 'contact.html', { 'form': form, 'topmenu_items': topmenu_items('Contact', request), 'username': the_user (request) })
def get(self, request, slicename=tmp_default_slice): page = Page(request) page.add_css_files('css/slice-view.css') page.add_js_files(["js/common.functions.js"]) page.add_js_chunks( '$(function() { messages.debug("sliceview: jQuery version " + $.fn.jquery); });' ) page.add_js_chunks( '$(function() { messages.debug("sliceview: users turned %s"); });' % ("on" if do_query_users else "off")) page.add_js_chunks( '$(function() { messages.debug("sliceview: leases turned %s"); });' % ("on" if do_query_leases else "off")) page.add_js_chunks( '$(function() { messages.debug("manifold URL %s"); });' % (ConfigEngine().manifold_url())) metadata = page.get_metadata() resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] user_md = metadata.details_by_object('user') user_fields = ['user_hrn' ] # [column['name'] for column in user_md['column']] # TODO The query to run is embedded in the URL main_query = Query.get('slice').filter_by('slice_hrn', '=', slicename) main_query.select( 'slice_hrn', #'resource.hrn', 'resource.urn', 'resource.hostname', 'resource.type', 'resource.network_hrn', 'lease.urn', 'user.user_hrn', #'application.measurement_point.counter' ) # for internal use in the querytable plugin; # needs to be a unique column present for each returned record main_query_init_key = 'hostname' query_resource_all = Query.get('resource').select(resource_fields) aq = AnalyzedQuery(main_query, metadata=metadata) page.enqueue_query(main_query, analyzed_query=aq) page.enqueue_query(query_resource_all) if do_query_users: # Required: the user must have an authority in its user.config # XXX Temporary solution user_query = Query().get('local:user').select('config', 'email') user_details = execute_query(self.request, user_query) # not always found in user_details... config = {} # for user_detail in user_details: # #email = user_detail['email'] # if user_detail['config']: # config = json.loads(user_detail['config']) # user_detail['authority'] = config.get('authority',"Unknown Authority") # # if user_detail['authority'] is not None: # sub_authority = user_detail['authority'].split('.') # root_authority = sub_authority[0] # query_user_all = Query.get(root_authority+':user').select(user_fields) # # # XXX TODO this filter doesn't work - to be improved in Manifold # #.filter_by('authority.authority_hrn', '=', user_detail['authority']) # # page.enqueue_query(query_user_all) # else: # print "authority of the user is not in local:user db" query_user_all = Query.get('user').select(user_fields) # query_user_all = None # ... and for the relations # XXX Let's hardcode resources for now sq_resource = aq.subquery('resource') sq_user = aq.subquery('user') sq_lease = aq.subquery('lease') sq_measurement = aq.subquery('measurement') # Prepare the display according to all metadata # (some parts will be pending, others can be triggered by users). # # For example slice measurements will not be requested by default... # Create the base layout (Stack)... main_stack = Stack( page=page, title="Slice %s" % slicename, sons=[], ) # ... responsible for the slice properties... # a nice header main_stack.insert( Raw(page=page, togglable=False, toggled=True, html="<h2 class='well well-lg'> Slice %s</h2>" % slicename)) # -------------------------------------------------------------------------- #DEPRECATED| # QueryUpdater (Pending Operations) #DEPRECATED| #DEPRECATED| main_stack.insert(QueryUpdater( #DEPRECATED| page = page, #DEPRECATED| title = 'Pending operations', #DEPRECATED| query = main_query, #DEPRECATED| togglable = True, #DEPRECATED| # start turned off, it will open up itself when stuff comes in #DEPRECATED| toggled = False, #DEPRECATED| domid = 'pending', #DEPRECATED| outline_complete = True, #DEPRECATED| )) # -------------------------------------------------------------------------- # Filter Resources # turn off for now -- see above filter_query_editor = QueryEditor( page=page, query=sq_resource, query_all=query_resource_all, title="Select Columns", domid='select-columns', ) filter_active_filters = ActiveFilters( page=page, query=sq_resource, title="Active Filters", ) filters_area = Stack( page=page, title='Filter Resources', domid='filters', sons=[filter_query_editor, filter_active_filters], togglable=True, toggled='persistent', outline_complete=True, ) main_stack.insert(filters_area) # -------------------------------------------------------------------------- # RESOURCES # the resources part is made of a Tabs (Geographic, List), resources_as_gmap = GoogleMap( page=page, title='Geographic view', domid='resources-map', # tab's sons preferably turn this off togglable=False, query=sq_resource, query_all=query_resource_all, # this key is the one issued by google googlemap_api_key=ConfigEngine().googlemap_api_key(), # the key to use at init-time init_key=main_query_init_key, checkboxes=True, # center on Paris latitude=49., longitude=9, zoom=4, ) resources_as_3dmap = SensLabMap( page=page, title='3D Map', domid='senslabmap', query=sq_resource, query_all=query_resource_all, ) resources_as_list = QueryTable( page=page, domid='resources-list', title='List view', # this is the query at the core of the slice list query=sq_resource, query_all=query_resource_all, init_key=main_query_init_key, checkboxes=True, datatables_options={ 'iDisplayLength': 25, 'bLengthChange': True, 'bAutoWidth': True, }, ) if insert_grid: resources_as_grid = QueryGrid( page=page, domid='resources-grid', title='Grid view', # this is the query at the core of the slice list query=sq_resource, query_all=query_resource_all, init_key=main_query_init_key, checkboxes=True, ) if do_query_leases: resources_as_scheduler = Scheduler( page=page, title='Scheduler', domid='scheduler', query=sq_resource, query_all_resources=query_resource_all, query_lease=sq_lease, ) # with the new 'Filter' stuff on top, no need for anything but the querytable resources_as_list_area = resources_as_list resources_sons = [ resources_as_gmap, resources_as_3dmap, resources_as_scheduler, resources_as_list_area, ] if do_query_leases else [ resources_as_gmap, resources_as_3dmap, resources_as_list_area, ] if insert_grid: resources_sons.append(resources_as_grid) resources_area = Tabs( page=page, domid="resources", togglable=True, title="Resources", outline_complete=True, sons=resources_sons, active_domid='resources-map', persistent_active=True, ) main_stack.insert(resources_area) # -------------------------------------------------------------------------- # USERS if do_query_users and query_user_all is not None: 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( QueryTable( 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, }, )) # DEMO # -------------------------------------------------------------------------- # MEASUREMENTS measurements_stats_cpu = SliceStat(title="CPU Usage", domid='resources-stats-cpu', page=page, stats='slice', key='hrn', query='none', slicename=slicename, o='cpu') measurements_stats_mem = SliceStat(title="Memory Usage", domid='resources-stats-mem', page=page, stats='slice', key='hrn', query='none', slicename=slicename, o='mem') measurements_stats_asb = SliceStat(title="Traffic Sent", domid='resources-stats-asb', page=page, stats='slice', key='hrn', query='none', slicename=slicename, o='asb') measurements_stats_arb = SliceStat(title="Traffic Received", domid='resources-stats-arb', page=page, stats='slice', key='hrn', query='none', slicename=slicename, o='arb') tab_measurements = Tabs( page=page, domid="measurements", togglable=True, toggled='persistent', title="Measurements", outline_complete=True, sons=[ measurements_stats_cpu, measurements_stats_mem, measurements_stats_asb, measurements_stats_arb ], active_domid='resources-stats-cpu', persistent_active=True, ) main_stack.insert(tab_measurements) # tab_measurements = Tabs ( # page = page, # active_domid = 'measurements-list', # outline_complete = True, # togglable = True, # title = 'Measurements', # domid = 'measurements', # ) # main_stack.insert(tab_measurements) # # tab_measurements.insert(QueryTable( # page = page, # title = 'Measurements', # domid = 'measurements-list', # # tab's sons preferably turn this off # togglable = False, # # this is the query at the core of the slice list # query = sq_measurement, # # do NOT set checkboxes to False # # this table being otherwise empty, it just does not fly with dataTables # checkboxes = True, # datatables_options = { # 'iDisplayLength' : 25, # 'bLengthChange' : True, # 'bAutoWidth' : True, # }, # )) # # # -------------------------------------------------------------------------- # # MESSAGES (we use transient=False for now) if insert_messages: main_stack.insert( Messages( page=page, title="Runtime messages for slice %s" % slicename, domid="msgs-pre", levels="ALL", # plain messages are probably less nice for production but more reliable for development for now transient=False, # these make sense only in non-transient mode.. togglable=True, toggled='persistent', outline_complete=True, )) # variables that will get passed to the view-unfold1.html template template_env = {} # define 'unfold_main' to the template engine - the main contents template_env['unfold_main'] = main_stack.render(request) # more general variables expected in the template template_env['title'] = '%(slicename)s' % locals() # the menu items on the top template_env['topmenu_items'] = topmenu_items_live('Slice', page) # so we can sho who is logged template_env['username'] = the_user(request) template_env['theme'] = self.theme # don't forget to run the requests page.expose_js_metadata() # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} template_env.update(page.prelude_env()) return render_to_response('view-unfold1.html', template_env, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): page = Page(self.request) metadata = page.get_metadata() page.expose_js_metadata() resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] user_md = metadata.details_by_object('user') user_fields = ['user_hrn'] # [column['name'] for column in user_md['column']] #create new query to manifold----query is not called yet #need to modify to get i2cat of resources also univbrisfoam_query=Query().get('ofelia-bristol-of:resource').select('urn') #print univbrisfoam_query #.select('urn') #Query().get('ofelia-bristol-of:resource') ##custom query to communication between univbris plugins #univbris_query=Query() #queue the query page.enqueue_query(univbrisfoam_query) #page.enqueue_query(univbris_query) page.expose_js_metadata() #plugin which display a "gathering resources" message waiting for all resources to be returned by manifold univbriswelcome = Univbris( page = page, title = 'univbris_welcome', domid = 'univbris_welcome', query = univbrisfoam_query, ) #plugin which collects different openflow ports from maniford univbrisfoamlist = UnivbrisFoam( page = page, title = 'univbris_foam_ports_selection', domid = 'univbris_foam_ports_selection', query = univbrisfoam_query, query_all = univbrisfoam_query, sync_query= 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, sync_query= univbrisfoam_query, datatables_options = { 'iDisplayLength': 5, 'bLengthChange' : True, 'bAutoWidth' : True, }, ) #plugin which allows the definition the match criteria on a single PACKET 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, }, ) #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', query = None, query_all = None, datatables_options = { 'iDisplayLength': 3, 'bLengthChange' : True, 'bAutoWidth' : True, }, ) #plugin which display the gathered topology univbristopology = UnivbrisTopo( page = page, title = 'univbris_topology', domid = 'univbris_topology', query = univbrisfoam_query, ) #render plugins in each context within a single page, but not all plugins are visible at all time. context = super(UnivbrisView, self).get_context_data(**kwargs) context['person'] = self.request.user context['welcome'] = univbriswelcome.render(self.request) context['resources'] = univbrisfoamlist.render(self.request) context['flowspaces']= univbrisfvlist.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'] = 'Book OpenFlow resources' # 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
def get_context_data(self, **kwargs): # We might have slices on different registries with different user accounts # We note that this portal could be specific to a given registry, to which we register users, but i'm not sure that simplifies things # Different registries mean different identities, unless we identify via SFA HRN or have associated the user email to a single hrn #messages.info(self.request, 'You have logged in') page = Page(self.request) print "Dashboard page" # Slow... #slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn') testbed_query = Query().get('network').select('network_hrn','platform','version') # DEMO GEC18 Query only PLE # user_query = Query().get('local:user').select('config','email') # user_details = execute_query(self.request, user_query) # not always found in user_details... # config={} # for user_detail in user_details: # #email = user_detail['email'] # if user_detail['config']: # config = json.loads(user_detail['config']) # user_detail['authority'] = config.get('authority',"Unknown Authority") # # print user_detail # if user_detail['authority'] is not None: # sub_authority = user_detail['authority'].split('.') # root_authority = sub_authority[0] # slice_query = Query().get(root_authority+':user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn') # else: slice_query = Query().get('user').filter_by('user_hrn', '==', '$user_hrn').select('slice.slice_hrn') page.enqueue_query(slice_query) page.enqueue_query(testbed_query) slicelist = SliceList( page = page, title = "slices", warning_msg = "<a href='../slice_request'>Request Slice</a>", query = slice_query, ) testbedlist = TestbedList( page = page, title = "testbeds", query = testbed_query, ) context = super(DashboardView, self).get_context_data(**kwargs) context['person'] = self.request.user context['testbeds'] = testbedlist.render(self.request) context['slices'] = slicelist.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Dashboard' # the menu items on the top context['topmenu_items'] = topmenu_items_live('Dashboard', page) # so we can sho who is logged context['username'] = the_user(self.request) page.expose_js_metadata() # the page header and other stuff context.update(page.prelude_env()) return context
def get_context_data(self, **kwargs): page = Page(self.request) page.add_js_files ( [ "js/common.functions.js" ] ) for key, value in kwargs.iteritems(): print "%s = %s" % (key, value) if key == "platformname": platformname=value network_query = Query().get('local:platform')\ .filter_by('platform', '==', platformname)\ .select('platform','platform_longname','gateway_type') page.enqueue_query(network_query) # ListResources of the platform metadata = page.get_metadata() resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] resources = platformname + ':resource' query_resource_all = Query.get(resources).select(resource_fields) page.enqueue_query(query_resource_all) query_resource_default_fields = Query.get(resources).select('hrn','hostname', 'type','country') page.enqueue_query(query_resource_default_fields) page.expose_js_metadata() networklist = QueryTable( page = page, title = 'List', domid = 'checkboxes', # this is the query at the core of the slice list query = network_query, query_all = network_query, checkboxes = False, datatables_options = { 'iDisplayLength' : 25, 'bLengthChange' : True, }, ) # networklist = SimpleList( # title = None, # page = page, # key = 'platform', # query = network_query, # ) # # -------------------------------------------------------------------------- # RESOURCES # for internal use in the querytable plugin; # needs to be a unique column present for each returned record main_query_init_key = 'hrn' # the resources part is made of a Tabs (Geographic, List), resources_as_gmap = GoogleMap( page = page, title = 'Geographic view', domid = 'resources-map', # tab's sons preferably turn this off togglable = False, query = query_resource_default_fields, query_all = query_resource_all, # this key is the one issued by google googlemap_api_key = ConfigEngine().googlemap_api_key(), # the key to use at init-time init_key = main_query_init_key, checkboxes = False, # center on Paris latitude = 49., longitude = 9, zoom = 4, ) resources_as_3dmap = SensLabMap( page = page, title = '3D Map', domid = 'senslabmap', query = query_resource_default_fields, query_all = query_resource_all, ) resources_as_list = QueryTable( page = page, domid = 'resources-list', title = 'List view', # this is the query at the core of the slice list query = query_resource_default_fields, query_all = query_resource_all, init_key = main_query_init_key, checkboxes = False, datatables_options = { 'iDisplayLength': 25, 'bLengthChange' : True, 'bAutoWidth' : True, }, ) resources_sons = [ resources_as_gmap, resources_as_3dmap, resources_as_list, ] resources_area = Tabs ( page=page, domid="resources", togglable=True, title="Resources", outline_complete=True, sons= resources_sons, active_domid = 'resources-map', persistent_active=True, ) context = super(PlatformView, self).get_context_data(**kwargs) context['person'] = self.request.user context['networks'] = networklist.render(self.request) context['resources'] = resources_area.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Platforms connected to MySlice' # the menu items on the top context['topmenu_items'] = topmenu_items_live('Platforms', page) # so we can sho who is logged context['username'] = the_user(self.request) context.update(page.prelude_env()) return context
def get_context_data(self, **kwargs): page = Page(self.request) page.add_js_files([ "js/jquery.validate.js", "js/my_account.register.js", "js/my_account.edit_profile.js", "js/jquery-ui.js" ]) page.add_css_files([ "css/onelab.css", "css/account_view.css", "css/plugin.css", "css/jquery-ui.css" ]) for key, value in kwargs.iteritems(): if key == "email": selected_email = value user_query = Query().get('local:user').filter_by( 'email', '==', selected_email).select('user_id', 'config', 'email', 'status') user_details = execute_admin_query(self.request, user_query) # not always found in user_details... config = {} for user_detail in user_details: user_id = user_detail['user_id'] user_email = user_detail['email'] # different significations of user_status if user_detail['status'] == 0: user_status = 'Disabled' elif user_detail['status'] == 1: user_status = 'Validation Pending' elif user_detail['status'] == 2: user_status = 'Enabled' else: user_status = 'N/A' #email = user_detail['email'] if user_detail['config']: config = json.loads(user_detail['config']) authority_hrn = config.get('authority', 'Unknown Authority') platform_query = Query().get('local:platform').select( 'platform_id', 'platform', 'gateway_type', 'disabled') account_query = Query().get('local:account').filter_by( 'user_id', '==', user_id).select('user_id', 'platform_id', 'auth_type', 'config') platform_details = execute_query(self.request, platform_query) account_details = execute_admin_query(self.request, account_query) # initial assignment needed for users having account.config = {} platform_name = '' account_type = '' account_usr_hrn = '' account_pub_key = '' account_priv_key = '' account_reference = '' my_users = '' my_slices = '' my_auths = '' ref_acc_list = '' principal_acc_list = '' user_status_list = [] platform_name_list = [] platform_name_secondary_list = [] platform_access_list = [] platform_no_access_list = [] total_platform_list = [] account_type_list = [] account_type_secondary_list = [] account_reference_list = [] delegation_type_list = [] user_cred_exp_list = [] slice_list = [] auth_list = [] slice_cred_exp_list = [] auth_cred_exp_list = [] usr_hrn_list = [] pub_key_list = [] for platform_detail in platform_details: if 'sfa' in platform_detail['gateway_type']: total_platform = platform_detail['platform'] total_platform_list.append(total_platform) for account_detail in account_details: if platform_detail['platform_id'] == account_detail[ 'platform_id']: platform_name = platform_detail['platform'] if 'config' in account_detail and account_detail[ 'config'] is not '': account_config = json.loads(account_detail['config']) account_usr_hrn = account_config.get('user_hrn', 'N/A') account_pub_key = account_config.get( 'user_public_key', 'N/A') account_reference = account_config.get( 'reference_platform', 'N/A') # credentials of myslice platform if 'myslice' in platform_detail['platform']: acc_user_cred = account_config.get( 'delegated_user_credential', 'N/A') acc_slice_cred = account_config.get( 'delegated_slice_credentials', 'N/A') acc_auth_cred = account_config.get( 'delegated_authority_credentials', 'N/A') #usr_hrn of myslice platform. used to check pi or no account_usr_hrn_myslice = account_config.get( 'user_hrn', 'N/A') if 'N/A' not in acc_user_cred: exp_date = re.search('<expires>(.*)</expires>', acc_user_cred) if exp_date: user_exp_date = exp_date.group(1) user_cred_exp_list.append(user_exp_date) my_users = [{ 'cred_exp': t[0] } for t in zip(user_cred_exp_list)] if 'N/A' not in acc_slice_cred: for key, value in acc_slice_cred.iteritems(): slice_list.append(key) # get cred_exp date exp_date = re.search('<expires>(.*)</expires>', value) if exp_date: exp_date = exp_date.group(1) slice_cred_exp_list.append(exp_date) my_slices = [{ 'slice_name': t[0], 'cred_exp': t[1] } for t in zip(slice_list, slice_cred_exp_list)] if 'N/A' not in acc_auth_cred: for key, value in acc_auth_cred.iteritems(): auth_list.append(key) #get cred_exp date exp_date = re.search('<expires>(.*)</expires>', value) if exp_date: exp_date = exp_date.group(1) auth_cred_exp_list.append(exp_date) my_auths = [{ 'auth_name': t[0], 'cred_exp': t[1] } for t in zip(auth_list, auth_cred_exp_list)] # for reference accounts if 'reference' in account_detail['auth_type']: account_type = 'Reference' delegation = 'N/A' platform_name_secondary_list.append(platform_name) account_type_secondary_list.append(account_type) account_reference_list.append(account_reference) ref_acc_list = [{ 'platform_name': t[0], 'account_type': t[1], 'account_reference': t[2] } for t in zip(platform_name_secondary_list, account_type_secondary_list, account_reference_list)] elif 'managed' in account_detail['auth_type']: account_type = 'Principal' delegation = 'Automatic' else: account_type = 'Principal' delegation = 'Manual' # for principal (auth_type=user/managed) accounts if 'reference' not in account_detail['auth_type']: platform_name_list.append(platform_name) account_type_list.append(account_type) delegation_type_list.append(delegation) usr_hrn_list.append(account_usr_hrn) pub_key_list.append(account_pub_key) user_status_list.append(user_status) # combining 5 lists into 1 [to render in the template] principal_acc_list = [{ 'platform_name': t[0], 'account_type': t[1], 'delegation_type': t[2], 'usr_hrn': t[3], 'usr_pubkey': t[4], 'user_status': t[5], } for t in zip(platform_name_list, account_type_list, delegation_type_list, usr_hrn_list, pub_key_list, user_status_list)] # to hide private key row if it doesn't exist if 'myslice' in platform_detail['platform']: account_config = json.loads(account_detail['config']) account_priv_key = account_config.get( 'user_private_key', 'N/A') if 'sfa' in platform_detail['gateway_type']: platform_access = platform_detail['platform'] platform_access_list.append(platform_access) # Removing the platform which already has access for platform in platform_access_list: total_platform_list.remove(platform) # we could use zip. this one is used if columns have unequal rows platform_list = [{ 'platform_no_access': t[0] } for t in itertools.izip_longest(total_platform_list)] ## check pi or no pi_status = self.request.session['user']['pi'] context = super(UserView, self).get_context_data(**kwargs) context['principal_acc'] = principal_acc_list context['ref_acc'] = ref_acc_list context['platform_list'] = platform_list context['my_users'] = my_users context['my_slices'] = my_slices context['my_auths'] = my_auths context['user_status'] = user_status context['user_email'] = user_email context['firstname'] = config.get('firstname', "?") context['lastname'] = config.get('lastname', "?") context['fullname'] = context['firstname'] + ' ' + context['lastname'] context['authority'] = config.get('authority', "Unknown Authority") context['user_private_key'] = account_priv_key context['pi'] = pi_status # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Platforms connected to MySlice' # the menu items on the top context['topmenu_items'] = topmenu_items_live('My Account', page) # so we can sho who is logged context['username'] = the_user(self.request) context['theme'] = self.theme # context ['firstname'] = config['firstname'] prelude_env = page.prelude_env() context.update(prelude_env) return context
def get (self, request, slicename='ple.inria.f14'): page=Page(request) page.expose_js_metadata() metadata = page.get_metadata() resource_md = metadata.details_by_object('resource') resource_fields = [column['name'] for column in resource_md['column']] main_query = Query.get('slice').filter_by('slice_hrn', '=', slicename) main_query.select( 'slice_hrn', #'resource.hrn', 'resource.hostname', 'resource.type', 'resource.network_hrn', 'lease.urn', 'user.user_hrn', #'application.measurement_point.counter' ) # for internal use in the querygrid plugin; # needs to be a unique column present for each returned record main_query_init_key = 'hostname' query_resource_all = Query.get('resource').select(resource_fields) aq = AnalyzedQuery(main_query, metadata=metadata) page.enqueue_query(main_query, analyzed_query=aq) page.enqueue_query(query_resource_all) sq_resource = aq.subquery('resource') resources_as_list = QueryGrid( page = page, domid = 'resources-list', title = 'List view', # this is the query at the core of the slice list query = sq_resource, query_all = query_resource_all, # safer to use 'hrn' as the internal unique key for this plugin init_key = main_query_init_key, checkboxes = True, datatables_options = { 'iDisplayLength': 25, 'bLengthChange' : True, 'bAutoWidth' : True, }, ) # variables that will get passed to the view-unfold1.html template template_env = {} # define 'unfold_main' to the template engine - the main contents template_env [ 'unfold_main' ] = resources_as_list.render(request) # more general variables expected in the template template_env [ 'title' ] = 'simple %(slicename)s'%locals() # the menu items on the top template_env [ 'topmenu_items' ] = topmenu_items_live('Slice', page) # so we can sho who is logged template_env [ 'username' ] = the_user (request) # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} prelude_env = page.prelude_env() template_env.update(prelude_env) result=render_to_response ('view-unfold1.html',template_env, context_instance=RequestContext(request)) return result
def get_context_data(self, **kwargs): pi = "" # We might have slices on different registries with different user accounts # We note that this portal could be specific to a given registry, to which we register users, but i'm not sure that simplifies things # Different registries mean different identities, unless we identify via SFA HRN or have associated the user email to a single hrn #messages.info(self.request, 'You have logged in') page = Page(self.request) ctx_my_authorities = {} ctx_delegation_authorities = {} ctx_sub_authorities = {} dest = {} # The user need to be logged in if the_user(self.request): # Who can a PI validate: # His own authorities + those he has credentials for. # In MySlice we need to look at credentials also. # XXX This will have to be asynchroneous. Need to implement barriers, # for now it will be sufficient to have it working statically # get user_id to later on query accounts # XXX Having real query plan on local tables would simplify all this # XXX $user_email is still not available for local tables #user_query = Query().get('local:user').filter_by('email', '==', '$user_email').select('user_id') user_query = Query().get('local:user').filter_by( 'email', '==', the_user(self.request)).select('user_id') user, = execute_query(self.request, user_query) user_id = user['user_id'] # Query manifold to learn about available SFA platforms for more information # In general we will at least have the portal # For now we are considering all registries all_authorities = [] platform_ids = [] sfa_platforms_query = Query().get('local:platform').filter_by( 'gateway_type', '==', 'sfa').select('platform_id', 'platform', 'auth_type') sfa_platforms = execute_query(self.request, sfa_platforms_query) for sfa_platform in sfa_platforms: logger.info("SFA PLATFORM > {}".format( sfa_platform['platform'])) if not 'auth_type' in sfa_platform: continue auth = sfa_platform['auth_type'] if not auth in all_authorities: all_authorities.append(auth) platform_ids.append(sfa_platform['platform_id']) logger.warning("W: Hardcoding platform myslice") # There has been a tweak on how new platforms are referencing a # so-called 'myslice' platform for storing authentication tokens. # XXX This has to be removed in final versions. myslice_platforms_query = Query().get('local:platform').filter_by( 'platform', '==', 'myslice').select('platform_id') myslice_platforms = execute_query(self.request, myslice_platforms_query) if myslice_platforms: myslice_platform, = myslice_platforms platform_ids.append(myslice_platform['platform_id']) # We can check on which the user has authoritity credentials = PI rights credential_authorities = set() credential_authorities_expired = set() # User account on these registries user_accounts_query = Query.get('local:account').filter_by( 'user_id', '==', user_id).filter_by('platform_id', 'included', platform_ids).select('auth_type', 'config') user_accounts = execute_query(self.request, user_accounts_query) #print "=" * 80 #print user_accounts #print "=" * 80 for user_account in user_accounts: logger.debug("USER ACCOUNT {}".format(user_account)) if user_account['auth_type'] == 'reference': continue # we hardcoded the myslice platform... config = json.loads(user_account['config']) creds = [] logger.debug("CONFIG KEYS {}".format(config.keys())) if 'authority_credentials' in config: logger.debug("*** AC {}".format( config['authority_credentials'].keys())) for authority_hrn, credential in config[ 'authority_credentials'].items(): #if credential is not expired: credential_authorities.add(authority_hrn) #else # credential_authorities_expired.add(authority_hrn) if 'delegated_authority_credentials' in config: logger.debug("*** DAC {}".format( config['delegated_authority_credentials'].keys())) for authority_hrn, credential in config[ 'delegated_authority_credentials'].items(): #if credential is not expired: credential_authorities.add(authority_hrn) #else # credential_authorities_expired.add(authority_hrn) logger.debug( 'credential_authorities = {}'.format(credential_authorities)) logger.debug('credential_authorities_expired = {}'.format( credential_authorities_expired)) # # Using cache manifold-tables to get the list of authorities faster # all_authorities_query = Query.get('authority').select('name', 'authority_hrn') # all_authorities = execute_query(self.request, all_authorities_query) # ** Where am I a PI ** # For this we need to ask SFA (of all authorities) = PI function pi_authorities_query = Query.get('myslice:user').filter_by( 'user_hrn', '==', '$user_hrn').select('pi_authorities') pi_authorities_tmp = execute_query(self.request, pi_authorities_query) pi_authorities = set() try: for pa in pi_authorities_tmp: pi_authorities |= set(pa['pi_authorities']) except Exception as e: logger.error('No pi_authorities') # TODO: exception if no parent_authority # try: # for pa in pi_authorities_tmp: # pi_authorities |= set(pa['pi_authorities']) # except: # # include all sub-authorities of the PI # # if PI on ple, include all sub-auths ple.upmc, ple.inria and so on... # pi_subauthorities = set() # for authority in all_authorities: # authority_hrn = authority['authority_hrn'] # for my_authority in pi_authorities: # if authority_hrn.startswith(my_authority) and authority_hrn not in pi_subauthorities: # pi_subauthorities.add(authority_hrn) #print "pi_authorities =", pi_authorities #print "pi_subauthorities =", pi_subauthorities # My authorities + I have a credential pi_credential_authorities = pi_authorities & credential_authorities pi_no_credential_authorities = pi_authorities - credential_authorities - credential_authorities_expired pi_expired_credential_authorities = pi_authorities & credential_authorities_expired # Authorities I've been delegated PI rights pi_delegation_credential_authorities = credential_authorities - pi_authorities pi_delegation_expired_authorities = credential_authorities_expired - pi_authorities #print "pi_credential_authorities =", pi_credential_authorities #print "pi_no_credential_authorities =", pi_no_credential_authorities #print "pi_expired_credential_authorities =", pi_expired_credential_authorities #print "pi_delegation_credential_authorities = ", pi_delegation_credential_authorities #print "pi_delegation_expired_authorities = ", pi_delegation_expired_authorities # Summary intermediary pi_my_authorities = pi_credential_authorities | pi_no_credential_authorities | pi_expired_credential_authorities pi_delegation_authorities = pi_delegation_credential_authorities | pi_delegation_expired_authorities #print "--" #print "pi_my_authorities = ", pi_my_authorities #print "pi_delegation_authorities = ", pi_delegation_authorities #print "pi_subauthorities = ", pi_subauthorities # Summary all queried_pending_authorities = pi_my_authorities | pi_delegation_authorities #| pi_subauthorities #print "----" #print "queried_pending_authorities = ", queried_pending_authorities # iterate on the requests and check if the authority matches a prefix startswith an authority on which the user is PI requests = get_requests() # requests = get_requests(queried_pending_authorities) for request in requests: auth_hrn = request['authority_hrn'] for my_auth in pi_my_authorities: if auth_hrn.startswith(my_auth): dest = ctx_my_authorities request['allowed'] = 'allowed' for my_auth in pi_delegation_authorities: if auth_hrn.startswith(my_auth): dest = ctx_delegation_authorities request['allowed'] = 'allowed' if auth_hrn in pi_expired_credential_authorities: request['allowed'] = 'expired' if 'allowed' not in request: request['allowed'] = 'denied' #print "authority for this request", auth_hrn # if auth_hrn in pi_my_authorities: # dest = ctx_my_authorities # # # define the css class # if auth_hrn in pi_credential_authorities: # request['allowed'] = 'allowed' # elif auth_hrn in pi_expired_credential_authorities: # request['allowed'] = 'expired' # else: # pi_no_credential_authorities # request['allowed'] = 'denied' # # elif auth_hrn in pi_delegation_authorities: # dest = ctx_delegation_authorities # # if auth_hrn in pi_delegation_credential_authorities: # request['allowed'] = 'allowed' # else: # pi_delegation_expired_authorities # request['allowed'] = 'expired' # # elif auth_hrn in pi_subauthorities: # dest = ctx_sub_authorities # # if auth_hrn in pi_subauthorities: # request['allowed'] = 'allowed' # else: # pi_delegation_expired_authorities # request['allowed'] = 'denied' # # else: # continue if not auth_hrn in dest: dest[auth_hrn] = [] dest[auth_hrn].append(request) context = super(ValidatePendingView, self).get_context_data(**kwargs) logger.debug("testing") logger.debug(ctx_my_authorities) context['my_authorities'] = ctx_my_authorities context['sub_authorities'] = ctx_sub_authorities context['delegation_authorities'] = ctx_delegation_authorities # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Test view that combines various plugins' # the menu items on the top context['topmenu_items'] = topmenu_items_live('Validation', page) # so we can sho who is logged context['username'] = the_user(self.request) context['pi'] = "is_pi" context['theme'] = self.theme context['section'] = "Requests" # XXX We need to prepare the page for queries #context.update(page.prelude_env()) return context
def get_context_data(self, **kwargs): page = Page(self.request) #page.add_js_files ( [ "js/jquery.validate.js", "js/my_account.register.js", "js/my_account.edit_profile.js" ] ) #page.add_css_files ( [ "css/onelab.css", "css/account_view.css","css/plugin.css" ] ) if self.request.is_secure(): current_site = 'https://' else: current_site = 'http://' current_site += self.request.META['HTTP_HOST'] for key, value in kwargs.iteritems(): if key == "hash_code": hash_code = value #if PendingUser.objects.filter(email_hash__iexact = hash_code).filter(status__iexact = 'False'): if PendingUser.objects.filter(email_hash__iexact=hash_code): activation = 'success' pending_users = PendingUser.objects.filter( email_hash__iexact=hash_code) pending_user = pending_users[0] # AUTO VALIDATION of PLE enabled users (only for OneLab Portal) if self.theme == "onelab": # Auto-Validation of pending user, which is enabled in a trusted SFA Registry (example: PLE) # We could check in the Registry based on email, but it takes too long # as we currently need to do a Resolve on each user_hrn of the Registry in order to get its email # TODO in SFA XXX We need a Resolve based on email # TODO maybe we can use MyPLC API for PLE # by default user is not in PLE ple_user_enabled = False if pending_user: # Auto Validation if self.is_ple_enabled(pending_user): pending_user_request = make_request_user(pending_user) # Create user in SFA and Update in Manifold create_user(self.request, pending_user_request, namespace='myslice', as_admin=True) # Delete pending user PendingUser.objects.filter( email_hash__iexact=hash_code).delete() # template user auto validated activation = 'validated' PendingUser.objects.filter(email_hash__iexact=hash_code).update( status='True') u = {} u['first_name'] = pending_user.first_name u['last_name'] = pending_user.last_name u['authority_hrn'] = pending_user.authority_hrn u['email'] = pending_user.email u['user_hrn'] = pending_user.user_hrn u['pi'] = pending_user.pi u['public_key'] = pending_user.public_key u['current_site'] = current_site send_email_to_pis(self.request, u, 'user') else: activation = 'failed' context = super(ActivateEmailView, self).get_context_data(**kwargs) context['activation_status'] = activation # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Platforms connected to MySlice' # the menu items on the top context['topmenu_items'] = topmenu_items_live('My Account', page) # so we can sho who is logged context['username'] = the_user(self.request) #context['first_name'] = first_name #context['last_name'] = last_name #context['authority_hrn'] = authority_hrn #context['email'] = email #context['user_hrn'] = user_hrn context['theme'] = self.theme # context ['firstname'] = config['firstname'] prelude_env = page.prelude_env() context.update(prelude_env) return context
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
def dashboard_view(request): page = Page(request) slices_query = Query.get("slice").select("slice_hrn") # old# # xxx filter : should filter on the slices the logged user can see # old# # we don't have the user's hrn yet # old# # in addition this currently returns all slices anyways # old# # filter = ... # old# sort='slice_hrn',) page.enqueue_query(slices_query) main_plugin = Stack( page=page, title="Putting stuff together", sons=[ QueryCode(page=page, title="Vizualize your query", query=slices_query, toggled=False), QuickFilter( # we play with this one for demo purposes in dashboard.css domid="myquickfilter", page=page, title="play with filters", criterias=quickfilter_criterias, toggled=False, ), SliceList( # setting visible attributes first page=page, title="Asynchroneous SliceList", header="slices list", with_datatables=False, # this is the query at the core of the slice list query=slices_query, ), ], ) # variables that will get passed to the view-unfold2.html template template_env = {} # define 'unfold_main' to the template engine template_env["unfold_main"] = main_plugin.render(request) # more general variables expected in the template template_env["title"] = "Test view for a full request cycle" # the menu items on the top template_env["topmenu_items"] = topmenu_items_live("dashboard", page) # so we can sho who is logged template_env["username"] = the_user(request) # ########## add another plugin with the same request, on the RHS pane # will show up in the right-hand side area named 'related' related_plugin = SliceList( page=page, title="Same request, other layout", domid="sidelist", with_datatables=True, header="paginated slices", # share the query query=slices_query, ) # likewise but on the side view template_env["unfold_margin"] = related_plugin.render(request) # add our own css in the mix # page.add_css_files ( 'css/dashboard.css') # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} prelude_env = page.prelude_env() template_env.update(prelude_env) return render_to_response("view-unfold2.html", template_env, context_instance=RequestContext(request))
def get_context_data(self, **kwargs): page = Page(self.request) page.add_js_files ( [ "js/jquery.validate.js", "js/my_account.register.js", "js/my_account.edit_profile.js" ] ) page.add_css_files ( [ "css/onelab.css", "css/account_view.css","css/plugin.css" ] ) user_query = Query().get('local:user').select('config','email','status') user_details = execute_query(self.request, user_query) # not always found in user_details... config={} for user_detail in user_details: # different significations of user_status if user_detail['status'] == 0: user_status = 'Disabled' elif user_detail['status'] == 1: user_status = 'Validation Pending' elif user_detail['status'] == 2: user_status = 'Enabled' else: user_status = 'N/A' #email = user_detail['email'] if user_detail['config']: config = json.loads(user_detail['config']) platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled') account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config') platform_details = execute_query(self.request, platform_query) account_details = execute_query(self.request, account_query) # initial assignment needed for users having account.config = {} platform_name = '' account_type = '' account_usr_hrn = '' account_pub_key = '' account_priv_key = '' account_reference = '' my_users = '' my_slices = '' my_auths = '' ref_acc_list = '' principal_acc_list = '' user_status_list = [] platform_name_list = [] platform_name_secondary_list = [] platform_access_list = [] platform_no_access_list = [] total_platform_list = [] account_type_list = [] account_type_secondary_list = [] account_reference_list = [] delegation_type_list = [] user_cred_exp_list = [] slice_list = [] auth_list = [] slice_cred_exp_list = [] auth_cred_exp_list = [] usr_hrn_list = [] pub_key_list = [] for platform_detail in platform_details: if 'sfa' in platform_detail['gateway_type']: total_platform = platform_detail['platform'] total_platform_list.append(total_platform) for account_detail in account_details: if platform_detail['platform_id'] == account_detail['platform_id']: platform_name = platform_detail['platform'] account_config = json.loads(account_detail['config']) account_usr_hrn = account_config.get('user_hrn','N/A') account_pub_key = account_config.get('user_public_key','N/A') account_reference = account_config.get ('reference_platform','N/A') # credentials of myslice platform if 'myslice' in platform_detail['platform']: acc_user_cred = account_config.get('delegated_user_credential','N/A') acc_slice_cred = account_config.get('delegated_slice_credentials','N/A') acc_auth_cred = account_config.get('delegated_authority_credentials','N/A') if 'N/A' not in acc_user_cred: exp_date = re.search('<expires>(.*)</expires>', acc_user_cred) if exp_date: user_exp_date = exp_date.group(1) user_cred_exp_list.append(user_exp_date) my_users = [{'cred_exp': t[0]} for t in zip(user_cred_exp_list)] if 'N/A' not in acc_slice_cred: for key, value in acc_slice_cred.iteritems(): slice_list.append(key) # get cred_exp date exp_date = re.search('<expires>(.*)</expires>', value) if exp_date: exp_date = exp_date.group(1) slice_cred_exp_list.append(exp_date) my_slices = [{'slice_name': t[0], 'cred_exp': t[1]} for t in zip(slice_list, slice_cred_exp_list)] if 'N/A' not in acc_auth_cred: for key, value in acc_auth_cred.iteritems(): auth_list.append(key) #get cred_exp date exp_date = re.search('<expires>(.*)</expires>', value) if exp_date: exp_date = exp_date.group(1) auth_cred_exp_list.append(exp_date) my_auths = [{'auth_name': t[0], 'cred_exp': t[1]} for t in zip(auth_list, auth_cred_exp_list)] # for reference accounts if 'reference' in account_detail['auth_type']: account_type = 'Reference' delegation = 'N/A' platform_name_secondary_list.append(platform_name) account_type_secondary_list.append(account_type) account_reference_list.append(account_reference) ref_acc_list = [{'platform_name': t[0], 'account_type': t[1], 'account_reference': t[2]} for t in zip(platform_name_secondary_list, account_type_secondary_list, account_reference_list)] elif 'managed' in account_detail['auth_type']: account_type = 'Principal' delegation = 'Automatic' else: account_type = 'Principal' delegation = 'Manual' # for principal (auth_type=user/managed) accounts if 'reference' not in account_detail['auth_type']: platform_name_list.append(platform_name) account_type_list.append(account_type) delegation_type_list.append(delegation) usr_hrn_list.append(account_usr_hrn) pub_key_list.append(account_pub_key) user_status_list.append(user_status) # combining 5 lists into 1 [to render in the template] principal_acc_list = [{'platform_name': t[0], 'account_type': t[1], 'delegation_type': t[2], 'usr_hrn':t[3], 'usr_pubkey':t[4], 'user_status':t[5],} for t in zip(platform_name_list, account_type_list, delegation_type_list, usr_hrn_list, pub_key_list, user_status_list)] # to hide private key row if it doesn't exist if 'myslice' in platform_detail['platform']: account_config = json.loads(account_detail['config']) account_priv_key = account_config.get('user_private_key','N/A') if 'sfa' in platform_detail['gateway_type']: platform_access = platform_detail['platform'] platform_access_list.append(platform_access) # Removing the platform which already has access for platform in platform_access_list: total_platform_list.remove(platform) # we could use zip. this one is used if columns have unequal rows platform_list = [{'platform_no_access': t[0]} for t in itertools.izip_longest(total_platform_list)] context = super(AccountView, self).get_context_data(**kwargs) context['principal_acc'] = principal_acc_list context['ref_acc'] = ref_acc_list context['platform_list'] = platform_list context['my_users'] = my_users context['my_slices'] = my_slices context['my_auths'] = my_auths context['user_status'] = user_status context['person'] = self.request.user context['firstname'] = config.get('firstname',"?") context['lastname'] = config.get('lastname',"?") context['fullname'] = context['firstname'] +' '+ context['lastname'] context['authority'] = config.get('authority',"Unknown Authority") context['user_private_key'] = account_priv_key # XXX This is repeated in all pages # more general variables expected in the template context['title'] = 'Platforms connected to MySlice' # the menu items on the top context['topmenu_items'] = topmenu_items_live('My Account', page) # so we can sho who is logged context['username'] = the_user(self.request) # context ['firstname'] = config['firstname'] prelude_env = page.prelude_env() context.update(prelude_env) return context
def test_plugin_view (request): page = Page(request) page.expose_js_metadata() # variables that will get passed to this template template_env = {} slicename='ple.inria.heartbeat' main_query = Query.get('resource').filter_by('slice_hrn', '=', slicename).select(['network','type','hrn','hostname','sliver']) # without an querytable, this would use use : run_it=False as nothing would listen to the results page.enqueue_query (main_query, # run_it=False ) main_plugin = \ Stack ( page=page, title='thestack', togglable=True, domid='stack', sons=[ \ # make sure the 2 things work together Messages ( page=page, title="Transient Runtime messages", domid="messages-transient", levels='ALL', ), QueryTable ( page=page, title="Slice %s - checkboxes"%slicename, query=main_query, domid="querytable", checkboxes=True, togglable=True, ), Messages ( page=page, title="Inline Runtime messages", domid="messages", levels='ALL', togglable=True, transient=False, ), Raw ( page=page, title="issue messages", togglable=True, html=""" <input type="button" id="bouton" value="Click me" /> """, ), ]) page.add_js_chunks ( """ function issue_debug() {console.log("issue_debug");messages.debug("issue_debug");}; $(function(){$("#bouton").click(issue_debug);}); """) # define 'unfold_main' to the template engine template_env [ 'unfold_main' ] = main_plugin.render(request) # more general variables expected in the template template_env [ 'title' ] = 'Single Plugin View' template_env [ 'topmenu_items' ] = topmenu_items_live('plugin', page) template_env [ 'username' ] = the_user (request) # the prelude object in page contains a summary of the requirements() for all plugins # define {js,css}_{files,chunks} prelude_env = page.prelude_env() template_env.update(prelude_env) return render_to_response ('view-unfold1.html',template_env, context_instance=RequestContext(request))