2 from manifold.core.query import Query
3 from manifoldapi.manifoldapi import execute_query
5 from unfold.page import Page
7 from plugins.lists.testbedlist import TestbedList
8 from plugins.lists.slicelist import SliceList
10 from unfold.loginrequired import FreeAccessView
11 from unfold.loginrequired import LoginRequiredAutoLogoutView
13 from ui.topmenu import topmenu_items_live, the_user
14 from plugins.lists.staticlist import StaticList
15 from plugins.lists.slicelist import SliceList
16 from plugins.messages import Messages
17 from plugins.querytable import QueryTable
18 from plugins.univbrisfoam import UnivbrisFoam
19 from plugins.univbrisfv import UnivbrisFv
20 from plugins.univbrisvtam import UnivbrisVtam as UnivbrisVtamPlugin
21 from plugins.univbrisvtamform import UnivbrisVtamForm
23 #This view requires login
24 class UnivbrisVtam (LoginRequiredAutoLogoutView):
25 template_name = "univbrisvtam.html"
27 def get_context_data(self, **kwargs):
29 page = Page(self.request)
30 #print "UNIVBRIS page"
32 #create new query to manifold----query is not called yet
33 #need to modify to get i2cat of resources also
34 univbrisvtamform_query=Query().get('ofelia-i2cat-vt:resource').select('hostname')
35 #print univbrisfoam_query #.select('urn')
38 page.enqueue_query(univbrisvtamform_query)
39 page.expose_js_metadata()
42 #plugin which display a table where an experimenter will add VMs to according to his needs
43 univbrisvtamplugin = UnivbrisVtamPlugin(
45 title = 'univbris_vtam',
46 domid = 'univbris_vtam',
50 #plugin which display a form where an experimenter will specify where a
51 univbrisvtamform = UnivbrisVtamForm(
53 title = 'univbris_vtam_form',
54 domid = 'univbris_vtam_form',
55 query = univbrisvtamform_query,
57 datatables_options = {
59 'bLengthChange' : True,
64 #render plugins in each context within a single page, but not all plugins are visible at all time.
65 context = super(UnivbrisVtam, self).get_context_data(**kwargs)
66 context['person'] = self.request.user
67 #context['welcome'] = univbriswelcome.render(self.request)
68 #context['resources'] = univbrisfoamlist.render(self.request)
69 context['vms_list']= univbrisvtamplugin.render(self.request)
70 context['vm_form']= univbrisvtamform.render(self.request)
71 #context['oflowspaces_form']= univbrisofvform.render(self.request)
72 #context['flowspaces_form']= univbrisfvform.render(self.request)
73 #context['topology']=univbristopology.render(self.request)
76 # XXX This is repeated in all pages
77 # more general variables expected in the template
78 context['title'] = 'Create New Virtual Machines'
79 # the menu items on the top
80 context['topmenu_items'] = topmenu_items_live('univbris', page)
81 # so we can sho who is logged
82 context['username'] = the_user(self.request)
84 context.update(page.prelude_env())
85 page.expose_js_metadata()
88 # the page header and other stuff
89 context.update(page.prelude_env())
91 context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"