Enhanced service chain nodes display and node config

Change-Id: Ib5ddc0b2789f436fbf72d305c65daae2154f1e33
Closes-Bug: 1455557
This commit is contained in:
ank 2015-05-15 23:20:12 +05:30
parent 6317b24f46
commit 2839ed28bb
6 changed files with 37 additions and 4 deletions

View File

@ -11,6 +11,7 @@
# under the License.
import logging
import os
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
@ -129,14 +130,36 @@ def update_policyaction_attributes(request, paction):
def update_sc_spec_attributes(request, scspec):
img_path = "/static/dashboard/images/"
provider = "default"
nodes = scspec.nodes
nodes = [client.get_servicechain_node(request, item) for item in nodes]
t = "<table class='table table-condensed'><tr><td>"
t = "<table class='table table-condensed' \
style='margin-bottom:0px'><tr><td>"
val = [t + "<span class='glyphicon glyphicon-remove-circle'></span></td>"]
ds_path = "/opt/stack/horizon/static/dashboard/images/"
if os.path.exists(ds_path):
local_img_path = ds_path
else:
local_img_path = "/usr/share/openstack-dashboard/openstack_dashboard/" \
+ "static/dashboard/images/"
if os.path.exists(local_img_path):
providers = os.listdir(local_img_path)
for p in providers:
if p in scspec.description:
provider = p
break
img_src = img_path + provider + "/"
scn_url = "horizon:project:network_services:sc_node_details"
for n in nodes:
url = reverse(scn_url, kwargs={'scnode_id': n.id})
val.append(
"<td><span class='glyphicon glyphicon-arrow-right'></span></td>")
val.append("<td>" + n.name + "(" + n.service_type + ")</td>")
scnode = "<td><a href='" + url + "' style='font-size: 9px;' >" \
+ "<img src='" + img_src + n.service_type + ".png'>" \
+ "<br>" + n.name + " (" + n.service_type + ")</a></td>"
val.append(scnode)
val.append("</tr></table>")
setattr(scspec, 'nodes', mark_safe("".join(val)))
return scspec

View File

@ -11,6 +11,7 @@
# under the License.
import json
import yaml
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
@ -90,6 +91,15 @@ class ServiceChainNodeDetailsTab(tabs.Tab):
scnode_id = self.tab_group.kwargs['scnode_id']
try:
scnode = client.get_servicechain_node(request, scnode_id)
config = scnode.config
config = config.strip()
if config.startswith('{'):
config = json.loads(config)
scnode.config = json.dumps(config, sort_keys=False, indent=4)
else:
config = yaml.load(config)
scnode.config = yaml.dump(
config, default_flow_style=False, indent=4)
except Exception:
exceptions.handle(request, _(
'Unable to retrieve service node details.'),

View File

@ -18,7 +18,7 @@
<dt>{% trans "Config" %}</dt>
<dd>
{{ scnode.config }}
</dd>
<div style ="white-space:pre">{{ scnode.config }}</div>
</dd>
</dl>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B