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 #print "UNIVBRIS page"
34 metadata = page.get_metadata()
35 page.expose_js_metadata()
37 resource_md = metadata.details_by_object('resource')
38 resource_fields = [column['name'] for column in resource_md['column']]
40 user_md = metadata.details_by_object('user')
41 user_fields = ['user_hrn'] # [column['name'] for column in user_md['column']]
44 #create new query to manifold----query is not called yet
45 #need to modify to get i2cat of resources also
46 univbrisfoam_query=Query().get('ofelia-bristol-of:resource').select('urn')
47 #print univbrisfoam_query #.select('urn')
48 #Query().get('ofelia-bristol-of:resource')
49 ##custom query to communication between univbris plugins
50 #univbris_query=Query()
53 page.enqueue_query(univbrisfoam_query)
54 #page.enqueue_query(univbris_query)
55 page.expose_js_metadata()
58 #plugin which display a "gathering resources" message waiting for all resources to be returned by manifold
59 univbriswelcome = Univbris(
61 title = 'univbris_welcome',
62 domid = 'univbris_welcome',
63 query = univbrisfoam_query,
66 #plugin which collects different openflow ports from maniford
67 univbrisfoamlist = UnivbrisFoam(
69 title = 'univbris_foam_ports_selection',
70 domid = 'univbris_foam_ports_selection',
71 query = univbrisfoam_query,
72 query_all = univbrisfoam_query,
73 sync_query= univbrisfoam_query,
75 datatables_options = {
77 'bLengthChange' : True,
82 #plugin which manages the different flowspaces that the user creates, and also sends flowspaces to manifold
83 univbrisfvlist = UnivbrisFv(
85 title = 'univbris_flowspace_selection',
86 domid = 'univbris_flowspace_selection',
89 sync_query= univbrisfoam_query,
90 datatables_options = {
92 'bLengthChange' : True,
97 #plugin which allows the definition the match criteria on a single PACKET flowspace
98 univbrisfvform = UnivbrisFvf(
100 title = 'univbris_flowspace_form',
101 domid = 'univbris_flowspace_form',
104 datatables_options = {
106 'bLengthChange' : True,
111 #plugin which allows the definition the match criteria on a single OPTICAL flowspace
113 univbrisofvform = UnivbrisFvfo(
115 title = 'univbris_oflowspace_form',
116 domid = 'univbris_oflowspace_form',
119 datatables_options = {
121 'bLengthChange' : True,
127 #plugin which display the gathered topology
128 univbristopology = UnivbrisTopo(
130 title = 'univbris_topology',
131 domid = 'univbris_topology',
132 query = univbrisfoam_query,
135 #render plugins in each context within a single page, but not all plugins are visible at all time.
136 context = super(UnivbrisView, self).get_context_data(**kwargs)
137 context['person'] = self.request.user
138 context['welcome'] = univbriswelcome.render(self.request)
139 context['resources'] = univbrisfoamlist.render(self.request)
140 context['flowspaces']= univbrisfvlist.render(self.request)
141 context['oflowspaces_form']= univbrisofvform.render(self.request)
142 context['flowspaces_form']= univbrisfvform.render(self.request)
143 context['topology']=univbristopology.render(self.request)
145 # XXX This is repeated in all pages
146 # more general variables expected in the template
147 context['title'] = 'Book OpenFlow resources'
148 # the menu items on the top
149 context['topmenu_items'] = topmenu_items_live('univbris', page)
150 # so we can sho who is logged
151 context['username'] = the_user(self.request)
153 context.update(page.prelude_env())
154 page.expose_js_metadata()
157 # the page header and other stuff
158 context.update(page.prelude_env())
160 context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"