Browse Source

Show Service Chain instances list and details

Change-Id: I04724770c3eb1dc67abfa1449ff15bf3d1b9d3b4
Closes-Bug: #1566006
ank 3 years ago
parent
commit
f0bedbde6b

+ 0
- 2
gbpui/client.py View File

@@ -566,8 +566,6 @@ def servicechaininstance_list(request, tenant_id, **kwargs):
566 566
     sc_instances = gbpclient(request).list_servicechain_instances(
567 567
         tenant_id=tenant_id, shared=False, **kwargs).get(
568 568
         'servicechain_instances')
569
-    sc_instances.extend(gbpclient(request).list_servicechain_instances(
570
-        shared=True, **kwargs).get('servicechain_instances'))
571 569
     return [ServiceChainInstance(item) for item in sc_instances]
572 570
 
573 571
 

+ 50
- 9
gbpui/column_filters.py View File

@@ -204,21 +204,60 @@ def update_sc_node_attributes(request, scnode):
204 204
     return scnode
205 205
 
206 206
 
207
+def update_scn_instance_attributes(request, scspec):
208
+    static_url = getattr(settings, 'STATIC_URL', "/static/")
209
+    img_path = static_url + "dashboard/img/"
210
+    provider = "default"
211
+    nodes = scspec.nodes
212
+    nodes = [client.get_servicechain_node(request, item) for item in nodes]
213
+    sc = ["<div>"]
214
+    ds_path = "/opt/stack/horizon/static/dashboard/img/"
215
+    if os.path.exists(ds_path):
216
+        local_img_path = ds_path
217
+    else:
218
+        local_img_path = "/usr/share/openstack-dashboard/" \
219
+            + "openstack_dashboard/static/dashboard/img/"
220
+    if os.path.exists(local_img_path):
221
+        providers = os.listdir(local_img_path)
222
+        for p in providers:
223
+            if p in scspec.description:
224
+                provider = p
225
+                break
226
+
227
+    img_src = img_path + provider + "/"
228
+    for n in nodes:
229
+        service_profile_id = n.service_profile_id
230
+        try:
231
+            service_profile = client.get_service_profile(request,
232
+                service_profile_id)
233
+            service_type = service_profile.service_type
234
+        except Exception:
235
+            pass
236
+        sc.append(
237
+            "<span class='glyphicon glyphicon-arrow-right' "
238
+            "style='margin: auto 10px'></span>")
239
+        scnode = "<img src='" + img_src + service_type + ".png'>"
240
+        sc.append(scnode)
241
+    sc.append("</div>")
242
+    setattr(scspec, 'chain', mark_safe("".join(sc)))
243
+    return scspec
244
+
245
+
207 246
 def update_sc_instance_attributes(request, scinstance):
208 247
     ptg_url = "horizon:project:policytargets:policy_targetdetails"
209 248
     clsurl = "horizon:project:application_policy:policyclassifierdetails"
210 249
     scspec_url = "horizon:project:network_services:sc_spec_details"
211
-    consumer_ptg = scinstance.consumer_ptg
212
-    provider_ptg = scinstance.provider_ptg
213
-    scspec = scinstance.servicechain_spec
214
-    classifier = scinstance.classifier
215
-    if consumer_ptg is not None:
250
+    consumer_ptg = scinstance.consumer_ptg_id
251
+    provider_ptg = scinstance.provider_ptg_id
252
+    scspec = scinstance.servicechain_specs
253
+    classifier = scinstance.classifier_id
254
+    if consumer_ptg is not None and consumer_ptg != "N/A":
216 255
         ptg = client.policy_target_get(request, consumer_ptg)
217 256
         u = reverse(ptg_url, kwargs={'policy_target_id': ptg.id})
218 257
         atag = "<a href='%s'>%s</a>" % (u, ptg.name)
219 258
         setattr(scinstance, 'consumer_ptg', mark_safe(atag))
220 259
     if provider_ptg is not None:
221
-        ptg = client.policy_target_get(request, consumer_ptg)
260
+        ptg = client.policy_target_get(request, provider_ptg)
222 261
         u = reverse(ptg_url, kwargs={'policy_target_id': ptg.id})
223 262
         atag = "<a href='%s'>%s</a>" % (u, ptg.name)
224 263
         setattr(scinstance, 'provider_ptg', mark_safe(atag))
@@ -228,10 +267,12 @@ def update_sc_instance_attributes(request, scinstance):
228 267
         atag = "<a href='%s'>%s</a>" % (u, cls.name)
229 268
         setattr(scinstance, 'classifier', mark_safe(atag))
230 269
     if scspec is not None:
231
-        sc = client.get_servicechain_spec(request, scspec)
232
-        u = reverse(scspec_url, kwargs={'scspec_id': sc.id})
233
-        atag = "<a href='%s'>%s</a>" % (u, sc.name)
270
+        scs = client.get_servicechain_spec(request, scspec[0])
271
+        url = reverse(scspec_url, kwargs={'scspec_id': scs.id})
272
+        atag = "<a href='%s'>%s</a>" % (url, scs.name)
234 273
         setattr(scinstance, 'servicechain_spec', mark_safe(atag))
274
+        scni = update_scn_instance_attributes(request, scs)
275
+        setattr(scinstance, 'servicechain', scni.chain)
235 276
     return scinstance
236 277
 
237 278
 

+ 5
- 6
gbpui/panels/network_services/tables.py View File

@@ -136,9 +136,11 @@ class ServiceChainInstanceTable(tables.DataTable):
136 136
     description = tables.Column("description",
137 137
                                 verbose_name=_("Description"))
138 138
     provider_ptg = tables.Column(
139
-        "provider_ptg", verbose_name=_("Provider PTG"))
140
-    consumer_ptg = tables.Column(
141
-        "consumer_ptg", verbose_name=_("Consumer PTG"))
139
+        "provider_ptg", verbose_name=_("Provider"))
140
+    servicechain = tables.Column(
141
+        "servicechain", verbose_name=_("Service Chain"))
142
+    # consumer_ptg = tables.Column(
143
+    #    "consumer_ptg", verbose_name=_("Consumer"))
142 144
     servicechain_spec = tables.Column(
143 145
         "servicechain_spec", verbose_name=_("Service Chain Spec"))
144 146
     classifier = tables.Column("classifier", verbose_name=_("Classifier"))
@@ -146,9 +148,6 @@ class ServiceChainInstanceTable(tables.DataTable):
146 148
     class Meta(object):
147 149
         name = "service_chain_instance_table"
148 150
         verbose_name = _("Service Chain Instance")
149
-        table_actions = (CreateServiceChainInstanceLink,)
150
-        row_actions = (
151
-            EditServiceChainInstanceLink, DeleteServiceChainInstanceLink,)
152 151
 
153 152
 
154 153
 class CreateServiceProfileLink(tables.LinkAction):

+ 2
- 1
gbpui/panels/network_services/tabs.py View File

@@ -98,7 +98,8 @@ class ServiceProfileTab(tabs.TableTab):
98 98
 
99 99
 class ServiceChainTabs(tabs.TabGroup):
100 100
     slug = "service_chain_spec_tabs"
101
-    tabs = (ServiceChainSpecTab, ServiceChainNodeTab, ServiceProfileTab,)
101
+    tabs = (ServiceChainSpecTab, ServiceChainNodeTab, ServiceProfileTab,
102
+            ServiceChainInstanceTab)
102 103
     sticky = True
103 104
 
104 105
 

+ 16
- 8
gbpui/panels/network_services/templates/network_services/_scinstance_details.html View File

@@ -1,9 +1,9 @@
1 1
 {% load i18n sizeformat parse_date %}
2 2
 {% load url from future %}
3 3
 
4
-<div class="info row detail">
4
+<div class="info detail">
5 5
 	<hr class="header_rule">
6
-	<dl>
6
+	<dl class="dl-horizontal">
7 7
 		<dt>{% trans "Name" %}</dt>
8 8
 		<dd>{{ scinstance.name|default:_("-") }}</dd>
9 9
 
@@ -14,17 +14,25 @@
14 14
 		<dd>{{ scinstance.id }} </dd>
15 15
 		
16 16
 		<dt>{% trans "Provider PTG" %}</dt>
17
-		<dd>{{ scinstance.provider_ptg }} </dd>
17
+		<dd>{{ scinstance.provider_ptg_id }} </dd>
18 18
 
19
-		<dt>{% trans "Consumer PTG" %}</dt>
20
-		<dd>{{ scinstance.consumer_ptg }} </dd>
19
+		<!--<dt>{% trans "Consumer PTG" %}</dt>
20
+		<dd>{{ scinstance.consumer_ptg_id }} </dd>-->
21
+
22
+		<dt>{% trans "Management PTG" %}</dt>
23
+		<dd>{{ scinstance.management_ptg_id }} </dd>
21 24
 
22 25
 		<dt>{% trans "Service Chain Spec" %}</dt>
23
-		<dd>{{ scinstance.servicechain_spec}} </dd>
26
+		<dd>{{ scinstance.servicechain_specs}} </dd>
24 27
 
25 28
 		<dt>{% trans "Classifier" %}</dt>
26
-		<dd>{{ scinstance.classifier}} </dd>
27
-	
29
+		<dd>{{ scinstance.classifier_id}} </dd>
30
+
31
+		<dt>{% trans "Config parameter values" %}</dt>
32
+		<dd>{{ scinstance.config_param_values}} </dd>		
33
+
34
+		<dt>{% trans "Project ID" %}</dt>
35
+		<dd>{{ scinstance.tenant_id}} </dd>	
28 36
 	</dl>
29 37
 </div>
30 38
      

Loading…
Cancel
Save