def update_sc_spec_attributes(request, scspec): img_path = "/static/dashboard/img/" provider = "default" nodes = scspec.nodes nodes = [client.get_servicechain_node(request, item) for item in nodes] 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/img/" if os.path.exists(ds_path): local_img_path = ds_path else: local_img_path = "/usr/share/openstack-dashboard/openstack_dashboard/" \ + "static/dashboard/img/" 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>") 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
def get_context_data(self, request): scspec_id = self.tab_group.kwargs['scspec_id'] try: scspec = client.get_servicechain_spec(request, scspec_id) nodes = [] gn = lambda x, y: client.get_servicechain_node(x, y) for node in scspec.nodes: n = gn(self.request, node) config = n.config config = config.strip() if config.startswith('{'): config = yaml.load(config) if 'heat_template_version' in config: config = yaml.dump( config, default_flow_style=False, indent=4) else: config = json.dumps(config, sort_keys=False, indent=4) else: config = yaml.load(config) config = yaml.dump( config, default_flow_style=False, indent=4) setattr(n, 'config', config) nodes.append(n) setattr(scspec, 'nodes', nodes) except Exception: exceptions.handle(request, _( 'Unable to retrieve service chain spec details.'), redirect=self.failure_url) return {'scspec': scspec}
def get_context_data(self, request): scnode_id = self.tab_group.kwargs['scnode_id'] try: scnode = client.get_servicechain_node(request, scnode_id) except Exception: exceptions.handle(request, _('Unable to retrieve service node details.'), redirect=self.failure_url) return {'scnode': scnode}
def get_context_data(self, request): scnode_id = self.tab_group.kwargs['scnode_id'] try: scnode = client.get_servicechain_node(request, scnode_id) except Exception: exceptions.handle(request, _( 'Unable to retrieve service node details.'), redirect=self.failure_url) return {'scnode': scnode}
def __init__(self, request, *args, **kwargs): super(UpdateServiceChainNodeForm, self).__init__( request, *args, **kwargs) try: scnode_id = self.initial['scnode_id'] scnode = client.get_servicechain_node(request, scnode_id) for item in ['name', 'description', 'shared']: self.fields[item].initial = getattr(scnode, item) except Exception: msg = _("Failed to retrive Service Chain Node details.") LOG.error(msg)
def __init__(self, request, *args, **kwargs): super(UpdateServiceChainNodeForm, self).__init__( request, *args, **kwargs) try: scnode_id = self.initial['scnode_id'] scnode = client.get_servicechain_node(request, scnode_id) for item in ['name', 'description']: self.fields[item].initial = getattr(scnode, item) except Exception: msg = _("Failed to retrive Service Chain Node details.") LOG.error(msg)
def update_sc_spec_attributes(request, scspec): nodes = scspec.nodes nodes = [client.get_servicechain_node(request, item) for item in nodes] t = "<table class='table table-condensed'><tr><td>" val = [t + "<span class='glyphicon glyphicon-remove-circle'></span></td>"] for n in nodes: val.append( "<td><span class='glyphicon glyphicon-arrow-right'></span></td>") val.append("<td>" + n.name + "(" + n.service_type + ")</td>") val.append("</tr></table>") setattr(scspec, 'nodes', mark_safe("".join(val))) return scspec
def get_context_data(self, request): scspec_id = self.tab_group.kwargs['scspec_id'] try: scspec = client.get_servicechain_spec(request, scspec_id) nodes = [] gn = lambda x, y: client.get_servicechain_node(x, y) for node in scspec.nodes: n = gn(self.request, node) setattr(n, 'config', json.loads(n.config)) nodes.append(n) setattr(scspec, 'nodes', nodes) except Exception: exceptions.handle(request, _( 'Unable to retrieve service chain spec details.'), redirect=self.failure_url) return {'scspec': scspec}
def get_context_data(self, request): scspec_id = self.tab_group.kwargs['scspec_id'] try: scspec = client.get_servicechain_spec(request, scspec_id) nodes = [] gn = lambda x, y: client.get_servicechain_node(x, y) for node in scspec.nodes: n = gn(self.request, node) setattr(n, 'config', json.loads(n.config)) nodes.append(n) setattr(scspec, 'nodes', nodes) except Exception: exceptions.handle( request, _('Unable to retrieve service chain spec details.'), redirect=self.failure_url) return {'scspec': scspec}
def update_sc_spec_attributes(request, scspec): static_url = getattr(settings, 'STATIC_URL', "/static/") img_path = static_url + "dashboard/img/" provider = "default" nodes = scspec.nodes nodes = [client.get_servicechain_node(request, item) for item in nodes] 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/img/" if os.path.exists(ds_path): local_img_path = ds_path else: local_img_path = "/usr/share/openstack-dashboard/" \ + "openstack_dashboard/static/dashboard/img/" 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}) service_profile_id = n.service_profile_id try: service_profile = client.get_service_profile( request, service_profile_id) service_type = service_profile.service_type except Exception: pass val.append( "<td><span class='glyphicon glyphicon-arrow-right'></span></td>") scnode = "<td><a href='" + url + "' style='font-size: 9px;' >" \ + "<img src='" + img_src + service_type + ".png'>" \ + "<br>" + n.name + " (" + service_type + ")</a></td>" val.append(scnode) val.append("</tr></table>") setattr(scspec, 'nodes', mark_safe("".join(val))) return scspec
def update_scn_instance_attributes(request, scspec): static_url = getattr(settings, 'STATIC_URL', "/static/") img_path = static_url + "dashboard/img/" provider = "default" nodes = scspec.nodes nodes = [client.get_servicechain_node(request, item) for item in nodes] sc = ["<div>"] ds_path = "/opt/stack/horizon/static/dashboard/img/" if os.path.exists(ds_path): local_img_path = ds_path else: local_img_path = "/usr/share/openstack-dashboard/" \ + "openstack_dashboard/static/dashboard/img/" 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 + "/" for n in nodes: service_profile_id = n.service_profile_id try: service_profile = client.get_service_profile( request, service_profile_id) service_type = service_profile.service_type except Exception: pass sc.append("<span class='glyphicon glyphicon-arrow-right' " "style='margin: auto 10px'></span>") scnode = "<img src='" + img_src + service_type + ".png'>" sc.append(scnode) sc.append("</div>") setattr(scspec, 'chain', mark_safe("".join(sc))) return scspec
def get_context_data(self, request): 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 = yaml.load(config) if 'heat_template_version' in config: scnode.config = yaml.dump( config, default_flow_style=False, indent=4) else: 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) scnode.tree = self.prepare_config_as_tree(config) except Exception: exceptions.handle(request, _( 'Unable to retrieve service node details.'), redirect=self.failure_url) return {'scnode': scnode}