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.querytable import QueryTable
15 from plugins.univbrisfoam import UnivbrisFoam
16 from plugins.univbrisfv import UnivbrisFv
17 from plugins.lists.staticlist import StaticList
18 from plugins.lists.slicelist import SliceList
19 from plugins.messages import Messages
20 from plugins.univbrisfvf import UnivbrisFvf
21 from plugins.univbrisfvfo import UnivbrisFvfo
22 from plugins.univbris import Univbris
23 from plugins.univbristopo import UnivbrisTopo
25 #This view requires login
26 class UnivbrisView (LoginRequiredAutoLogoutView):
27 #class UnivbrisView (FreeAccessView):
28 template_name = "univbris.html"
30 def get_context_data(self, **kwargs):
32 page = Page(self.request)
33 metadata = page.get_metadata()
34 page.expose_js_metadata()
36 resource_md = metadata.details_by_object('resource')
37 resource_fields = [column['name'] for column in resource_md['column']]
39 user_md = metadata.details_by_object('user')
40 user_fields = ['user_hrn'] # [column['name'] for column in user_md['column']]
43 #create new query to manifold----query is not called yet
44 #need to modify to get i2cat of resources also
45 univbrisfoam_query=Query().get('ofelia-bristol-of:resource').select('urn')
46 #print univbrisfoam_query #.select('urn')
47 #Query().get('ofelia-bristol-of:resource')
48 ##custom query to communication between univbris plugins
49 #univbris_query=Query()
52 page.enqueue_query(univbrisfoam_query)
53 #page.enqueue_query(univbris_query)
54 page.expose_js_metadata()
57 #plugin which display a "gathering resources" message waiting for all resources to be returned by manifold
58 univbriswelcome = Univbris(
60 title = 'univbris_welcome',
61 domid = 'univbris_welcome',
62 query = univbrisfoam_query,
65 #plugin which collects different openflow ports from maniford
66 univbrisfoamlist = UnivbrisFoam(
68 title = 'univbris_foam_ports_selection',
69 domid = 'univbris_foam_ports_selection',
70 query = univbrisfoam_query,
71 query_all = univbrisfoam_query,
72 sync_query= univbrisfoam_query,
74 datatables_options = {
76 'bLengthChange' : True,
81 #plugin which manages the different flowspaces that the user creates, and also sends flowspaces to manifold
82 univbrisfvlist = UnivbrisFv(
84 title = 'univbris_flowspace_selection',
85 domid = 'univbris_flowspace_selection',
88 sync_query= univbrisfoam_query,
89 datatables_options = {
91 'bLengthChange' : True,
96 #plugin which allows the definition the match criteria on a single PACKET flowspace
97 univbrisfvform = UnivbrisFvf(
99 title = 'univbris_flowspace_form',
100 domid = 'univbris_flowspace_form',
103 datatables_options = {
105 'bLengthChange' : True,
110 #plugin which allows the definition the match criteria on a single OPTICAL flowspace
112 univbrisofvform = UnivbrisFvfo(
114 title = 'univbris_oflowspace_form',
115 domid = 'univbris_oflowspace_form',
118 datatables_options = {
120 'bLengthChange' : True,
126 #plugin which display the gathered topology
127 univbristopology = UnivbrisTopo(
129 title = 'univbris_topology',
130 domid = 'univbris_topology',
131 query = univbrisfoam_query,
134 #render plugins in each context within a single page, but not all plugins are visible at all time.
135 context = super(UnivbrisView, self).get_context_data(**kwargs)
136 context['person'] = self.request.user
137 context['welcome'] = univbriswelcome.render(self.request)
138 context['resources'] = univbrisfoamlist.render(self.request)
139 context['flowspaces']= univbrisfvlist.render(self.request)
140 context['oflowspaces_form']= univbrisofvform.render(self.request)
141 context['flowspaces_form']= univbrisfvform.render(self.request)
142 context['topology']=univbristopology.render(self.request)
144 # XXX This is repeated in all pages
145 # more general variables expected in the template
146 context['title'] = 'Book OpenFlow resources'
147 # the menu items on the top
148 context['topmenu_items'] = topmenu_items_live('univbris', page)
149 # so we can sho who is logged
150 context['username'] = the_user(self.request)
152 context.update(page.prelude_env())
153 page.expose_js_metadata()
156 # the page header and other stuff
157 context.update(page.prelude_env())
159 context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"