remove legacy servicechain code

Change-Id: I1078e4519f52c160d0acdbfc99e019c1b0e7d73f
This commit is contained in:
Pulkit vajpayee 2022-07-04 23:07:31 +05:30 committed by pulkit vajpayee
parent 2fa82d0219
commit a0a4d7efbf
17 changed files with 1 additions and 1630 deletions

View File

@ -1,16 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
PANEL = 'network_services_panel'
PANEL_DASHBOARD = 'project'
PANEL_GROUP = 'GroupPolicyPanels'
ADD_PANEL = 'gbpui.panels.network_services.panel.NetworkServices'

View File

@ -147,33 +147,6 @@ class NetworkServicePolicy(neutron.NeutronAPIDictWrapper):
return policy_dict
class ServiceChainSpec(neutron.NeutronAPIDictWrapper):
"""Wrapper for neutron service chain spec."""
def get_dict(self):
sc_spec_dict = self._apidict
return sc_spec_dict
class ServiceChainNode(neutron.NeutronAPIDictWrapper):
"""Wrapper for neutron service chain spec."""
def get_dict(self):
sc_node_dict = self._apidict
return sc_node_dict
class ServiceChainInstance(neutron.NeutronAPIDictWrapper):
"""Wrapper for neutron service chain spec."""
def get_dict(self):
sc_instance_dict = self._apidict
return sc_instance_dict
class ServiceProfile(neutron.NeutronAPIDictWrapper):
"""Wrapper for neutron service profile."""
@ -544,121 +517,3 @@ def l2policy_update(request, pc_id, **kwargs):
def l2policy_delete(request, policy_id):
gbpclient(request).delete_l2_policy(policy_id)
def servicechainnode_list(request, tenant_id, **kwargs):
sc_nodes = gbpclient(request).list_servicechain_nodes(tenant_id=tenant_id,
shared=False, **kwargs).get('servicechain_nodes')
sc_nodes.extend(gbpclient(request).list_servicechain_nodes(shared=True,
**kwargs).get('servicechain_nodes'))
return [ServiceChainNode(item) for item in sc_nodes]
def servicechainspec_list(request, tenant_id, **kwargs):
sc_specs = gbpclient(request).list_servicechain_specs(tenant_id=tenant_id,
shared=False, **kwargs).get('servicechain_specs')
sc_specs.extend(gbpclient(request).list_servicechain_specs(shared=True,
**kwargs).get('servicechain_specs'))
return [ServiceChainSpec(item) for item in sc_specs]
def servicechaininstance_list(request, tenant_id, **kwargs):
sc_instances = gbpclient(request).list_servicechain_instances(
tenant_id=tenant_id, shared=False, **kwargs).get(
'servicechain_instances')
return [ServiceChainInstance(item) for item in sc_instances]
def get_servicechain_node(request, scnode_id):
scnode = gbpclient(request).show_servicechain_node(
scnode_id).get('servicechain_node')
return ServiceChainNode(scnode)
def create_servicechain_node(request, **kwargs):
body = {'servicechain_node': kwargs}
sc_node = gbpclient(request).create_servicechain_node(
body).get('servicechain_node')
return ServiceChainNode(sc_node)
def update_servicechain_node(request, scnode_id, **kwargs):
body = {'servicechain_node': kwargs}
sc_node = gbpclient(request).update_servicechain_node(
scnode_id, body).get('servicechain_node')
return ServiceChainNode(sc_node)
def delete_servicechain_node(request, scnode_id):
gbpclient(request).delete_servicechain_node(scnode_id)
def get_servicechain_spec(request, scspec_id):
sc_spec = gbpclient(request).show_servicechain_spec(
scspec_id).get('servicechain_spec')
return ServiceChainSpec(sc_spec)
def create_servicechain_spec(request, **kwargs):
body = {'servicechain_spec': kwargs}
sc_spec = gbpclient(request).create_servicechain_spec(
body).get('servicechain_spec')
return ServiceChainSpec(sc_spec)
def update_servicechain_spec(request, scspec_id, **kwargs):
body = {'servicechain_spec': kwargs}
sc_spec = gbpclient(request).update_servicechain_spec(
scspec_id, body).get('servicechain_spec')
return ServiceChainSpec(sc_spec)
def delete_servicechain_spec(request, scspec_id):
gbpclient(request).delete_servicechain_spec(scspec_id)
def get_servicechain_instance(request, scinstance_id):
sc_instance = gbpclient(request).show_servicechain_instance(
scinstance_id).get('servicechain_instance')
return ServiceChainInstance(sc_instance)
def create_servicechain_instance(request, **kwargs):
body = {'servicechain_instance': kwargs}
sc_instance = gbpclient(request).create_servicechain_instance(
body).get('servicechain_instance')
return ServiceChainInstance(sc_instance)
def update_servicechain_instance(request, scinstance_id, **kwargs):
body = {'servicechain_instance': kwargs}
sc_instance = gbpclient(request).update_servicechain_instance(
scinstance_id, body).get('servicechain_instance')
return ServiceChainInstance(sc_instance)
def delete_servicechain_instance(request, scinstance_id):
gbpclient(request).delete_servicechain_instance(scinstance_id)
def serviceprofile_list(request, **kwargs):
sc_profile = gbpclient(request).list_service_profiles(True,
**kwargs).get('service_profiles')
return [ServiceProfile(item) for item in sc_profile]
def get_service_profile(request, service_profile_id):
service_profile = gbpclient(request).show_service_profile(
service_profile_id).get('service_profile')
return ServiceProfile(service_profile)
def create_service_profile(request, **kwargs):
body = {'service_profile': kwargs}
service_profile = gbpclient(request).create_service_profile(
body).get('service_profile')
return ServiceProfile(service_profile)
def delete_service_profile(request, service_profile_id):
gbpclient(request).delete_service_profile(service_profile_id)

View File

@ -10,9 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
from django.conf import settings
from django.urls import reverse
from django.utils.safestring import mark_safe
@ -115,12 +112,7 @@ def update_policyrule_attributes(request, prule):
for a in actions:
action = client.policyaction_get(request, a)
u = reverse(action_url, kwargs={'policyaction_id': a})
if action.action_type == 'redirect':
spec = client.get_servicechain_spec(request, action.action_value)
spec_details = "%s:%s" % (spec.name, str(spec.id))
li = "<li><a href='%s'>%s</a></li>" % (u, spec_details)
else:
li = "<li><a href='%s'>%s</a></li>" % (u, action.name)
li = "<li><a href='%s'>%s</a></li>" % (u, action.name)
ul.append(li)
ul.append("</ul>")
ultag = "".join(ul)
@ -129,150 +121,9 @@ def update_policyrule_attributes(request, prule):
def update_policyaction_attributes(request, paction):
if paction.action_type == 'redirect':
spec = client.get_servicechain_spec(request,
paction.action_value)
url = "horizon:project:network_services:sc_spec_details"
url = reverse(url, kwargs={'scspec_id': spec.id})
tag_content = (url, spec.name + ":" + spec.id)
tag = "<a href='%s'>%s</a>" % tag_content
setattr(paction, 'action_value', mark_safe(tag))
return paction
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_sc_node_attributes(request, scnode):
t = "<p style='margin-bottom:0px'>"
val = [t]
sp_url = "horizon:project:network_services:service_profile_details"
url = reverse(sp_url, kwargs={'sp_id': scnode.service_profile_id})
try:
service_profile = client.get_service_profile(request,
scnode.service_profile_id)
sp = "<a href='" + url + "'>" + service_profile.name + ' : ' + \
service_profile.service_type + '</a></p>'
val.append(sp)
except Exception:
return scnode
setattr(scnode, 'service_profile', mark_safe("".join(val)))
return scnode
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 update_sc_instance_attributes(request, scinstance):
ptg_url = "horizon:project:policytargets:policy_targetdetails"
clsurl = "horizon:project:application_policy:policyclassifierdetails"
scspec_url = "horizon:project:network_services:sc_spec_details"
consumer_ptg = scinstance.consumer_ptg_id
provider_ptg = scinstance.provider_ptg_id
scspec = scinstance.servicechain_specs
classifier = scinstance.classifier_id
if consumer_ptg is not None and consumer_ptg != "N/A":
ptg = client.policy_target_get(request, consumer_ptg)
u = reverse(ptg_url, kwargs={'policy_target_id': ptg.id})
atag = "<a href='%s'>%s</a>" % (u, ptg.name)
setattr(scinstance, 'consumer_ptg', mark_safe(atag))
if provider_ptg is not None:
ptg = client.policy_target_get(request, provider_ptg)
u = reverse(ptg_url, kwargs={'policy_target_id': ptg.id})
atag = "<a href='%s'>%s</a>" % (u, ptg.name)
setattr(scinstance, 'provider_ptg', mark_safe(atag))
if classifier is not None:
cls = client.policyclassifier_get(request, classifier)
u = reverse(clsurl, kwargs={'policyclassifier_id': cls.id})
atag = "<a href='%s'>%s</a>" % (u, cls.name)
setattr(scinstance, 'classifier', mark_safe(atag))
if scspec is not None:
scs = client.get_servicechain_spec(request, scspec[0])
url = reverse(scspec_url, kwargs={'scspec_id': scs.id})
atag = "<a href='%s'>%s</a>" % (url, scs.name)
setattr(scinstance, 'servicechain_spec', mark_safe(atag))
scni = update_scn_instance_attributes(request, scs)
setattr(scinstance, 'servicechain', scni.chain)
return scinstance
def update_classifier_attributes(classifiers):
port_protocol_map = {'21': 'ftp', '25': 'smtp', '53': 'dns',
'80': 'http', '443': 'https'}

View File

@ -1,300 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
import logging
from django.urls import reverse
from django.utils import html
from django.utils.translation import ugettext_lazy as _
from django import http
from django import shortcuts
from horizon import exceptions
from horizon import forms
from horizon import messages
from gbpui import client
LOG = logging.getLogger(__name__)
SERVICE_TYPES = [('LOADBALANCER', 'Load Balancer'),
('FIREWALL', 'Firewall')]
class BaseUpdateForm(forms.SelfHandlingForm):
def clean(self):
cleaned_data = super(BaseUpdateForm, self).clean()
updated_data = {d: cleaned_data[d] for d in cleaned_data
if d in self.changed_data or (d == 'nodes' and
self.fields['nodes'].initial != cleaned_data[d])}
return updated_data
class CreateServiceProfileForm(forms.SelfHandlingForm):
name = forms.CharField(max_length=80, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), required=False)
vendor = forms.CharField(
max_length=80, label=_("Vendor"), required=True)
service_flavor = forms.CharField(
max_length=80, label=_("Service Flavor"), required=False)
service_type = forms.ChoiceField(
label=_("Service Type"), choices=SERVICE_TYPES)
insertion_mode = forms.ChoiceField(
label=_("Insertion Mode"), choices=[('l3', 'L3'), ('l2', 'L2')])
shared = forms.BooleanField(label=_("Shared"),
initial=False, required=False)
def handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
if context.get('name'):
context['name'] = html.escape(context['name'])
if context.get('description'):
context['description'] = html.escape(context['description'])
if context.get('vendor'):
context['vendor'] = html.escape(context['vendor'])
if context.get('service_flavor'):
context['service_flavor'] = html.escape(
context['service_flavor'])
client.create_service_profile(request, **context)
msg = _("Service Profile Created Successfully")
messages.success(request, msg)
return http.HttpResponseRedirect(url)
except Exception as e:
msg = _("Failed to create Service Profile. %s") % (str(e))
LOG.error(msg)
exceptions.handle(request, msg, redirect=shortcuts.redirect)
class CreateServiceChainNodeForm(forms.SelfHandlingForm):
name = forms.CharField(max_length=80, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), required=False)
service_profile_id = forms.ChoiceField(
label=_("Service Profile"))
config_type = forms.ChoiceField(label=_("Config Type"),
choices=[('file', 'Heat Template'),
('string', 'Config String')],
widget=forms.Select(attrs={'class':
'switchable',
'data-slug': 'source'}))
template_file = forms.FileField(label=_('Configuration File'),
help_text=_('A local Heat template file to upload.'),
required=False,
widget=forms.FileInput(attrs={'class': 'switched',
'data-switch-on': 'source',
'data-source-file': _("Configuration File")}))
template_string = forms.CharField(label=_("Configuration String"),
help_text=_('A local Heat template string.'),
widget=forms.Textarea(attrs={'class': 'switched',
'data-switch-on': 'source',
'data-source-string':
_("Configuration String")}),
required=False)
shared = forms.BooleanField(label=_("Shared"),
initial=False, required=False)
def __init__(self, request, *args, **kwargs):
super(CreateServiceChainNodeForm, self).__init__(
request, *args, **kwargs)
try:
service_profile_tuples = []
service_profile_list = client.serviceprofile_list(self.request)
for service_profile in service_profile_list:
sp = (service_profile.id,
service_profile.name + ' : ' + service_profile.service_type)
service_profile_tuples.append(sp)
self.fields['service_profile_id'].choices = service_profile_tuples
except Exception:
msg = _("Failed to retrive Service profile details.")
LOG.error(msg)
def clean(self):
cleaned_data = super(CreateServiceChainNodeForm, self).clean()
files = self.request.FILES
template_str = None
if 'template_file' in files:
temp = files['template_file'].read()
try:
template_str = json.loads(temp)
except Exception:
msg = _('Invalid file format.')
raise forms.ValidationError(msg)
else:
try:
tstr = cleaned_data["template_string"]
if bool(tstr):
template_str = json.loads(tstr)
except Exception:
msg = _("Invalid template string.")
raise forms.ValidationError(msg)
if template_str is not None:
cleaned_data['config'] = template_str
else:
msg = _("Please choose a template file or enter template string.")
raise forms.ValidationError(msg)
return cleaned_data
def handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
try:
del context['template_string']
del context['template_file']
del context['config_type']
except KeyError:
pass
context['config'] = json.dumps(context['config'])
if context.get('name'):
context['name'] = html.escape(context['name'])
if context.get('description'):
context['description'] = html.escape(context['description'])
client.create_servicechain_node(request, **context)
msg = _("Service Chain Node Created Successfully!")
LOG.debug(msg)
return http.HttpResponseRedirect(url)
except Exception as e:
msg = _("Failed to create Service Chain Node. %s") % (str(e))
LOG.error(msg)
exceptions.handle(request, msg, redirect=shortcuts.redirect)
class UpdateServiceChainNodeForm(BaseUpdateForm):
name = forms.CharField(max_length=80, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), required=False)
shared = forms.BooleanField(label=_("Shared"), required=False)
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 handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
scnode_id = self.initial['scnode_id']
if context.get('name'):
context['name'] = html.escape(context['name'])
if context.get('description'):
context['description'] = html.escape(context['description'])
client.update_servicechain_node(
request, scnode_id, **context)
msg = _("Service Chain Node Updated Successfully!")
LOG.debug(msg)
messages.success(request, msg)
return http.HttpResponseRedirect(url)
except Exception as e:
msg = _("Failed to create Service Chain Node. %s") % (str(e))
LOG.error(msg)
exceptions.handle(request, msg, redirect=url)
class CreateServiceChainSpecForm(forms.SelfHandlingForm):
name = forms.CharField(max_length=255, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), required=False)
shared = forms.BooleanField(label=_("Shared"),
initial=False, required=False)
nodes = forms.MultipleChoiceField(label=_("Nodes"),
widget=forms.CheckboxSelectMultiple(),
error_messages={
'required': _(
"At least one node must"
" be specified.")},
help_text=_("Create service chain spec with"
" these nodes"))
def __init__(self, request, *args, **kwargs):
super(CreateServiceChainSpecForm, self).__init__(
request, *args, **kwargs)
try:
node_list = []
nodes = client.servicechainnode_list(request,
tenant_id=request.user.tenant_id)
for n in nodes:
n.set_id_as_name_if_empty()
node_list.append((n.id, n.name))
self.fields['nodes'].choices = sorted(
node_list, key=lambda obj: obj[1])
except Exception:
msg = _("Failed to retrieve service chain spec")
LOG.error(msg)
exceptions.handle(request, msg, redirect=shortcuts.redirect)
def handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
if context.get('name'):
context['name'] = html.escape(context['name'])
if context.get('description'):
context['description'] = html.escape(context['description'])
client.create_servicechain_spec(request, **context)
msg = _("Service Chain Spec Created Successfully!")
LOG.debug(msg)
messages.success(request, msg)
return http.HttpResponseRedirect(url)
except Exception as e:
msg = _("Failed to create Service Chain Spec. %s") % (str(e))
LOG.error(msg)
exceptions.handle(request, msg, redirect=url)
class UpdateServiceChainSpecForm(CreateServiceChainSpecForm, BaseUpdateForm):
def __init__(self, request, *args, **kwargs):
super(UpdateServiceChainSpecForm, self).__init__(
request, *args, **kwargs)
try:
scspec_id = self.initial['scspec_id']
scspec = client.get_servicechain_spec(request, scspec_id)
for attr in ['name', 'description', 'nodes', 'shared']:
self.fields[attr].initial = getattr(scspec, attr)
nodes_available = dict(self.fields['nodes'].choices)
nodes_selected = [
(x, nodes_available[x]) for x in self.fields['nodes'].initial]
nodes_unselected = set(self.fields['nodes'].choices) - set(
nodes_selected)
self.fields['nodes'].choices = nodes_selected + list(
nodes_unselected)
except Exception:
msg = _("Failed to retrieve service chain spec")
LOG.error(msg)
def handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
scspec_id = self.initial['scspec_id']
if context.get('name'):
context['name'] = html.escape(context['name'])
if context.get('description'):
context['description'] = html.escape(context['description'])
client.update_servicechain_spec(request, scspec_id, **context)
msg = _("Service Chain Spec Updated Successfully!")
LOG.debug(msg)
messages.success(request, msg)
return http.HttpResponseRedirect(url)
except Exception as e:
msg = _("Failed to update Service Chain Spec. %s") % (str(e))
LOG.error(msg)
exceptions.handle(request, msg, redirect=shortcuts.redirect)

View File

@ -1,20 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
class NetworkServices(horizon.Panel):
name = _("Network Services")
slug = "network_services"

View File

@ -1,255 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from gbpui import client
from horizon import tables
class CreateServiceChainSpecLink(tables.LinkAction):
name = "create_scspec_link"
verbose_name = _("Create Service Chain Spec")
url = "horizon:project:network_services:create_sc_spec"
classes = ("ajax-modal", "btn-create_scspec")
class EditServiceChainSpecLink(tables.LinkAction):
name = "edit_sc_spec"
verbose_name = _("Edit")
classes = ("ajax-modal", "btn-update",)
def get_link_url(self, scspec):
base_url = reverse("horizon:project:network_services:update_sc_spec",
kwargs={'scspec_id': scspec.id})
return base_url
class DeleteServiceChainSpecLink(tables.DeleteAction):
name = "deletescspec"
def action(self, request, object_id):
client.delete_servicechain_spec(request, object_id)
@staticmethod
def action_present(count):
return ungettext_lazy(
"Delete Service Chain Spec",
"Delete Service Chain Specs",
count
)
@staticmethod
def action_past(count):
return ungettext_lazy(
"Scheduled deletion of Service Chain Spec",
"Scheduled deletion of Service Chain Specs",
count
)
class ServiceChainSpecTable(tables.DataTable):
name = tables.Column(
"name",
verbose_name=_("Name"),
link="horizon:project:network_services:sc_spec_details"
)
description = tables.Column("description",
verbose_name=_("Description"))
nodes = tables.Column("nodes", verbose_name=_("Nodes"))
class Meta(object):
name = "service_chain_spec_table"
verbose_name = _("Service Chain Specs")
table_actions = (CreateServiceChainSpecLink,
DeleteServiceChainSpecLink,)
row_actions = (EditServiceChainSpecLink,
DeleteServiceChainSpecLink,)
class CreateServiceChainNodeLink(tables.LinkAction):
name = "create_scnode_link"
verbose_name = _("Create Service Chain Node")
url = "horizon:project:network_services:create_sc_node"
classes = ("ajax-modal", "btn-create_scnode")
class EditServiceChainNodeLink(tables.LinkAction):
name = "edit_sc_node"
verbose_name = _("Edit")
classes = ("ajax-modal", "btn-update",)
def get_link_url(self, scnode):
base_url = reverse("horizon:project:network_services:update_sc_node",
kwargs={'scnode_id': scnode.id})
return base_url
class DeleteServiceChainNodeLink(tables.DeleteAction):
name = "deletescnode"
def action(self, request, object_id):
client.delete_servicechain_node(request, object_id)
@staticmethod
def action_present(count):
return ungettext_lazy(
"Delete Service Chain Node",
"Delete Service Chain Nodes",
count
)
@staticmethod
def action_past(count):
return ungettext_lazy(
"Scheduled deletion of Service Chain Node",
"Scheduled deletion of Service Chain Nodes",
count
)
class ServiceChainNodeTable(tables.DataTable):
name = tables.Column(
"name",
verbose_name=_("Name"),
link="horizon:project:network_services:sc_node_details"
)
description = tables.Column("description",
verbose_name=_("Description"))
service_profile = tables.Column("service_profile",
verbose_name=_("Service Profile"))
class Meta(object):
name = "service_chain_node_table"
verbose_name = _("Service Chain Node")
table_actions = (CreateServiceChainNodeLink,
DeleteServiceChainNodeLink,)
row_actions = (EditServiceChainNodeLink,
DeleteServiceChainNodeLink,)
class CreateServiceChainInstanceLink(tables.LinkAction):
name = "create_scinstance_link"
verbose_name = _("Create Service Chain Instance")
url = "horizon:project:network_services:create_sc_instance"
classes = ("ajax-modal", "btn-create_scinstance")
class EditServiceChainInstanceLink(tables.LinkAction):
name = "edit_sc_instance"
verbose_name = _("Edit")
classes = ("ajax-modal", "btn-update",)
def get_link_url(self, scinstance):
urlstring = "horizon:project:network_services:update_sc_instance"
base_url = reverse(urlstring, kwargs={'scinstance_id': scinstance.id})
return base_url
class DeleteServiceChainInstanceLink(tables.DeleteAction):
name = "deletescinstance"
def action(self, request, object_id):
client.delete_servicechain_instance(request, object_id)
@staticmethod
def action_present(count):
return ungettext_lazy(
"Delete Service Chain Instance",
"Delete Service Chain Instances",
count
)
@staticmethod
def action_past(count):
return ungettext_lazy(
"Scheduled deletion of Service Chain Instance",
"Scheduled deletion of Service Chain Instances",
count
)
class ServiceChainInstanceTable(tables.DataTable):
name = tables.Column(
"name",
verbose_name=_("Name"),
link="horizon:project:network_services:sc_instance_details"
)
description = tables.Column("description",
verbose_name=_("Description"))
provider_ptg = tables.Column(
"provider_ptg", verbose_name=_("Provider"))
servicechain = tables.Column(
"servicechain", verbose_name=_("Service Chain"))
# consumer_ptg = tables.Column(
# "consumer_ptg", verbose_name=_("Consumer"))
servicechain_spec = tables.Column(
"servicechain_spec", verbose_name=_("Service Chain Spec"))
classifier = tables.Column("classifier", verbose_name=_("Classifier"))
class Meta(object):
name = "service_chain_instance_table"
verbose_name = _("Service Chain Instance")
class CreateServiceProfileLink(tables.LinkAction):
name = "create_service_profile_link"
verbose_name = _("Create Service Profile")
url = "horizon:project:network_services:create_service_profile"
classes = ("ajax-modal", "btn-create_service_profile")
class DeleteServiceProfileLink(tables.DeleteAction):
name = "deleteserviceprofile"
def action(self, request, object_id):
client.delete_service_profile(request, object_id)
@staticmethod
def action_present(count):
return ungettext_lazy(
"Delete Service Chain Profile",
"Delete Service Chain Profiles",
count
)
@staticmethod
def action_past(count):
return ungettext_lazy(
"Scheduled deletion of Service Chain Profile",
"Scheduled deletion of Service Chain Profiles",
count
)
class ServiceProfileTable(tables.DataTable):
name = tables.Column(
"name",
verbose_name=_("Name"),
link="horizon:project:network_services:service_profile_details"
)
description = tables.Column("description",
verbose_name=_("Description"))
service_type = tables.Column("service_type",
verbose_name=_("Service Type"))
insertion_mode = tables.Column("insertion_mode",
verbose_name=_("Insertion Mode"))
vendor = tables.Column("vendor", verbose_name=_("Vendor"))
class Meta(object):
name = "service_profile_table"
verbose_name = _("Service Profile")
table_actions = (CreateServiceProfileLink,
DeleteServiceProfileLink,)
row_actions = (DeleteServiceProfileLink,)

View File

@ -1,284 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
from gbpui.panels.network_services import tables as ns_tables
import yaml
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from gbpui import client
from gbpui import column_filters as gfilters
class ServiceChainSpecTab(tabs.TableTab):
name = _("Service Chain Specs")
table_classes = (ns_tables.ServiceChainSpecTable,)
slug = "service_chain_specs"
template_name = "horizon/common/_detail_table.html"
def get_service_chain_spec_table_data(self):
specs = []
try:
specs = client.servicechainspec_list(self.request,
tenant_id=self.request.user.tenant_id)
specs = [gfilters.update_sc_spec_attributes(
self.request, item) for item in specs]
except Exception:
pass
return specs
class ServiceChainNodeTab(tabs.TableTab):
name = _("Service Chain Nodes")
table_classes = (ns_tables.ServiceChainNodeTable,)
slug = "service_chain_node"
template_name = "horizon/common/_detail_table.html"
def get_service_chain_node_table_data(self):
nodes = []
try:
nodes = client.servicechainnode_list(self.request,
tenant_id=self.request.user.tenant_id)
nodes = [gfilters.update_sc_node_attributes(
self.request, item) for item in nodes]
except Exception:
pass
return nodes
class ServiceChainInstanceTab(tabs.TableTab):
name = _("Service Chain Instances")
table_classes = (ns_tables.ServiceChainInstanceTable,)
slug = "service_chain_instance"
template_name = "horizon/common/_detail_table.html"
def get_service_chain_instance_table_data(self):
instances = []
try:
instances = client.servicechaininstance_list(self.request,
tenant_id=self.request.user.tenant_id)
instances = [gfilters.update_sc_instance_attributes(
self.request, item) for item in instances]
except Exception:
pass
return instances
class ServiceProfileTab(tabs.TableTab):
name = _("Service Profiles")
table_classes = (ns_tables.ServiceProfileTable,)
slug = "service_profile"
template_name = "horizon/common/_detail_table.html"
def get_service_profile_table_data(self):
service_profiles = []
try:
service_profiles = client.serviceprofile_list(self.request)
except Exception:
pass
return service_profiles
class ServiceChainTabs(tabs.TabGroup):
slug = "service_chain_spec_tabs"
tabs = (ServiceChainSpecTab, ServiceChainNodeTab, ServiceProfileTab,
ServiceChainInstanceTab)
sticky = True
class ServiceProfileDetailsTab(tabs.Tab):
name = _("Service Profile Details")
slug = "serviceprofile_details"
template_name = "project/network_services/_serviceprofile_details.html"
failure_url = reverse_lazy('horizon:project:network_services:index')
def get_context_data(self, request):
service_profile_id = self.tab_group.kwargs['sp_id']
try:
service_profile = client.get_service_profile(
request, service_profile_id)
except Exception:
exceptions.handle(request, _(
'Unable to retrieve service profile details.'),
redirect=self.failure_url)
return {'service_profile': service_profile}
class ServiceProfileDetailsTabGroup(tabs.TabGroup):
slug = 'scnode_details'
tabs = (ServiceProfileDetailsTab,)
class ServiceChainNodeDetailsTab(tabs.Tab):
name = _("Service Chain Node Details")
slug = "scnode_details"
template_name = "project/network_services/_scnode_details.html"
failure_url = reverse_lazy('horizon:project:network_services:index')
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}
def prepare_config_as_tree(self, config):
tree = []
for key, value in config.items():
node = {}
if isinstance(value, dict):
node = self.prepare_root_node(value)
node["text"] = key
else:
node["text"] = key + " : " + str(value)
node["icon"] = static("dashboard/img/text.png")
tree.append(node)
return json.dumps(tree)
def prepare_root_node(self, obj):
node = {}
if obj:
children = self.prepare_children(obj)
node["children"] = children
state = {}
state["opened"] = True
node["state"] = state
return node
def prepare_children(self, obj):
children = []
for key, value in obj.items():
node = {}
child = self.json2array(value)
node["text"] = key
node["children"] = child
children.append(node)
return children
def json2array(self, obj):
arr = []
for key, value in obj.items():
node = {}
if isinstance(value, dict):
children = self.json2array(value)
node["text"] = key
node["children"] = children
elif isinstance(value, list):
items = []
for item in value:
items.append(json.dumps(item))
node["children"] = items
node["text"] = key
else:
node["text"] = key + " : " + str(value)
node["icon"] = static("dashboard/img/text.png")
arr.append(node)
return arr
class SCNodeDetailsTabGroup(tabs.TabGroup):
slug = 'scnode_details'
tabs = (ServiceChainNodeDetailsTab,)
class ServiceChainSpecDetailsTab(tabs.Tab):
name = _("Service Chain Spec Details")
slug = "scspec_details"
template_name = "project/network_services/_scspec_details.html"
failure_url = reverse_lazy('horizon:project:network_services:index')
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}
class SCSpecDetailsTabGroup(tabs.TabGroup):
slug = 'scspec_details'
tabs = (ServiceChainSpecDetailsTab,)
class ServiceChainInstanceDetailsTab(tabs.Tab):
name = _("Service Chain Instance Details")
slug = "scinstance_details"
template_name = "project/network_services/_scinstance_details.html"
failure_url = reverse_lazy('horizon:project:network_services:index')
def get_context_data(self, request):
scinstance_id = self.tab_group.kwargs['scinstance_id']
try:
scinstance = client.get_servicechain_instance(
request, scinstance_id)
except Exception:
exceptions.handle(request, _(
'Unable to retrieve service instance details.'),
redirect=self.failure_url)
return {'scinstance': scinstance}
class SCInstanceDetailsTabGroup(tabs.TabGroup):
slug = 'scinstance_details'
tabs = (ServiceChainInstanceDetailsTab,)

View File

@ -1,64 +0,0 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% block form_id %}create_service_chain_spec{% endblock %}
{% block form_action %}{% url 'horizon:project:network_services:create_sc_spec' %}{% endblock %}
{% block modal-header %}{% trans "Create Service Chain Spec" %}{% endblock %}
{% block modal-body %}
<link href="{{ STATIC_URL }}dashboard/css/scspec.css" rel='stylesheet' type='text/css'>
<div class="left">
<fieldset>
<table class="table-fixed" id="nodeListIdContainer">
<tbody>
<tr>
<td class="actions">
<div id="nodeListId">
{% include "horizon/common/_form_fields.html" %}
</div>
</td>
</tr>
</tbody>
</table>
<table class="table-fixed" id="nodeListSortContainer">
<tbody>
<tr>
<td class="actions">
<label id="selected_node_label">{% trans "Selected nodes" %}</label>
<ul id="selected_node" class="nodelist">
</ul>
<label>{% trans "Available nodes" %}</label>
<ul id="available_node" class="nodelist">
</ul>
</td>
</tr>
</tbody>
</table>
</fieldset>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:network_services:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}
{% block modal-js %}
<script src='{{ STATIC_URL }}dashboard/js/horizon.scspec.js' type='text/javascript'></script>
<script>
if (typeof $ !== 'undefined') {
horizon.Node.sc_init($(".workflow"));
} else {
addHorizonLoadEvent(function() {
horizon.Node.sc_init($(".workflow"));
});
}
</script>
{% endblock %}

View File

@ -1,37 +0,0 @@
{% load i18n sizeformat parse_date %}
<div class="info detail">
<hr class="header_rule">
<dl class="dl-horizontal">
<dt>{% trans "Name" %}</dt>
<dd>{{ scinstance.name|default:_("-") }}</dd>
<dt>{% trans "Description" %}</dt>
<dd>{{ scinstance.description|default:_("-") }}</dd>
<dt>{% trans "ID" %}</dt>
<dd>{{ scinstance.id }} </dd>
<dt>{% trans "Provider PTG" %}</dt>
<dd>{{ scinstance.provider_ptg_id }} </dd>
<!--<dt>{% trans "Consumer PTG" %}</dt>
<dd>{{ scinstance.consumer_ptg_id }} </dd>-->
<dt>{% trans "Management PTG" %}</dt>
<dd>{{ scinstance.management_ptg_id }} </dd>
<dt>{% trans "Service Chain Spec" %}</dt>
<dd>{{ scinstance.servicechain_specs}} </dd>
<dt>{% trans "Classifier" %}</dt>
<dd>{{ scinstance.classifier_id}} </dd>
<dt>{% trans "Config parameter values" %}</dt>
<dd>{{ scinstance.config_param_values}} </dd>
<dt>{% trans "Project ID" %}</dt>
<dd>{{ scinstance.tenant_id}} </dd>
</dl>
</div>

View File

@ -1,60 +0,0 @@
{% load i18n sizeformat parse_date %}
{% load staticfiles %}
{% block css %}
<link href="{% static "dashboard/css/jstree.css" %}" rel='stylesheet' type='text/css'>
{% endblock %}
<div class="info row detail">
<hr class="header_rule">
<dl style="font-size:14px">
<dt>{% trans "Name" %}</dt>
<dd>{{ scnode.name|default:_("-") }}</dd>
<dt>{% trans "Description" %}</dt>
<dd>{{ scnode.description|default:_("-") }}</dd>
<dt>{% trans "ID" %}</dt>
<dd>{{ scnode.id }} </dd>
<dt>{% trans "Service Profile" %}</dt>
<dd><a href="{% url 'horizon:project:network_services:service_profile_details' sp_id=scnode.service_profile_id %}">{{ scnode.service_profile_id }}</a></dd>
<dt>{% trans "Shared" %}</dt>
<dd>{{ scnode.shared }}</dd>
<dt>
<img src="{% static "dashboard/img/config_as_text.png" %}"
data-swap="{% static "dashboard/img/config_as_tree.png" %}"
id="display_format" alt="" > {% trans "Config" %}</dt>
<dd >
<div style="white-space:pre;display:none" id="config_text" >{{ scnode.config }} </div>
<div id="config_tree"></div>
</dd>
</dl>
</div>
{% block custom_js %}
<script src='{% static "dashboard/js/jstree.min.js" %}' type='text/javascript'></script>
<script type="text/javascript">
function display_config_as_tree(){
var data = JSON.stringify({{scnode.tree|safe}});
$('#config_tree').jstree({ 'core' : {
'data' : $.parseJSON(data),
} });
}
function swap_image(_this){
var current = _this.attr("src");
var swap = _this.attr("data-swap");
_this.attr('src', swap).attr("data-swap",current);
}
$(function(){
display_config_as_tree();
$("#display_format").click(function(){
$("#config_text").toggle();
$("#config_tree").toggle();
swap_image($(this));
});
});
</script>
{% endblock %}

View File

@ -1,49 +0,0 @@
{% load i18n sizeformat parse_date %}
<div class="info row detail">
<hr class="header_rule">
<dl>
<dt>{% trans "Name" %}</dt>
<dd>{{ scspec.name|default:_("-") }}</dd>
<dt>{% trans "Description" %}</dt>
<dd>{{ scspec.description|default:_("-") }}</dd>
<dt>{% trans "ID" %}</dt>
<dd>{{ scspec.id }} </dd>
<dt>{% trans "Shared" %}</dt>
<dd>{{ scspec.shared }}</dd>
</dl>
{% if scspec.nodes %}
<div class="panel panel-default">
<div class="panel-heading">Nodes</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Service Profile</th>
<th>Config</th>
</tr>
</thead>
{% for node in scspec.nodes %}
<tr>
<td>
<a href="{% url 'horizon:project:network_services:sc_node_details' scnode_id=node.id %}">
{{node.name}}</a>
</td>
<td>
<a href="{% url 'horizon:project:network_services:service_profile_details' sp_id=node.service_profile_id %}">
{{ node.service_profile_id }}</a>
</td>
<td>
<div style ="white-space:pre;overflow-y: scroll;height:300px;background-color:#EEEEEE">{{node.config}}</div>
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endif %}
</div>

View File

@ -1,31 +0,0 @@
{% load i18n sizeformat parse_date %}
<div class="info row detail">
<hr class="header_rule">
<dl style="font-size:14px">
<dt>{% trans "Name" %}</dt>
<dd>{{ service_profile.name|default:_("-") }}</dd>
<dt>{% trans "Description" %}</dt>
<dd>{{ service_profile.description|default:_("-") }}</dd>
<dt>{% trans "ID" %}</dt>
<dd>{{ service_profile.id }} </dd>
<dt>{% trans "Service Type" %}</dt>
<dd>{{ service_profile.service_type }} </dd>
<dt>{% trans "Insertion Mode" %}</dt>
<dd>{{ service_profile.insertion_mode }}</dd>
<dt>{% trans "Vendor" %}</dt>
<dd>{{ service_profile.vendor }}</dd>
<dt>{% trans "Service Flavor" %}</dt>
<dd>{{ service_profile.service_flavor|default:_("-") }}</dd>
<dt>{% trans "Shared" %}</dt>
<dd>{{ service_profile.shared }}</dd>
</dl>
</div>

View File

@ -1,61 +0,0 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% block form_id %}update_service_chain_spec{% endblock %}
{% block form_action %}{% url 'horizon:project:network_services:update_sc_spec' scspec_id %}{% endblock %}
{% block modal-header %}{% trans "Update Service Chain Spec" %}{% endblock %}
{% block modal-body %}
<link href="{{ STATIC_URL }}dashboard/css/scspec.css" rel='stylesheet' type='text/css'>
<div class="left">
<table class="table-fixed" id="nodeListIdContainer">
<tbody>
<tr>
<td class="actions">
<div id="nodeListId">
{% include "horizon/common/_form_fields.html" %}
</div>
</td>
</tr>
</tbody>
</table>
<table class="table-fixed" id="nodeListSortContainer">
<tbody>
<tr>
<td class="actions">
<label id="selected_node_label">{% trans "Selected nodes" %}</label>
<ul id="selected_node" class="nodelist">
</ul>
<label>{% trans "Available nodes" %}</label>
<ul id="available_node" class="nodelist">
</ul>
</td>
</tr>
</tbody>
</table>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:project:network_services:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}
{% block modal-js %}
<script src='{{ STATIC_URL }}dashboard/js/horizon.scspec.js' type='text/javascript'></script>
<script>
if (typeof $ !== 'undefined') {
horizon.Node.sc_init($(".workflow"));
} else {
addHorizonLoadEvent(function() {
horizon.Node.sc_init($(".workflow"));
});
}
</script>
{% endblock %}

View File

@ -1,46 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.conf.urls import url # noqa
from gbpui.panels.network_services import views
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^create_service_profile$',
views.CreateServiceProfileView.as_view(),
name='create_service_profile'),
url(r'^serviceprofile/(?P<sp_id>[^/]+)/$',
views.ServiceProfileDetailsView.as_view(),
name='service_profile_details'),
url(r'^create_sc_node$',
views.CreateServiceChainNodeView.as_view(),
name='create_sc_node'),
url(r'^update_sc_node/(?P<scnode_id>[^/]+)/$',
views.UpdateServiceChainNodeView.as_view(),
name='update_sc_node'),
url(r'^sc_node/(?P<scnode_id>[^/]+)/$',
views.ServiceChainNodeDetailsView.as_view(),
name='sc_node_details'),
url(r'^create_sc_spec$',
views.CreateServiceChainSpecView.as_view(),
name='create_sc_spec'),
url(r'^update_sc_spec/(?P<scspec_id>[^/]+)/$',
views.UpdateServiceChainSpecView.as_view(),
name='update_sc_spec'),
url(r'^sc_spec/(?P<scspec_id>[^/]+)/$',
views.ServiceChainSpecDetailsView.as_view(),
name='sc_spec_details'),
url(r'^sc_instance/(?P<scinstance_id>[^/]+)/$',
views.ServiceChainInstanceDetailsView.as_view(),
name='sc_instance_details'),
]

View File

@ -1,112 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from horizon import forms
from horizon import tabs
from gbpui.panels.network_services import forms as ns_forms
from gbpui.panels.network_services import tabs as ns_tabs
from django.utils.translation import ugettext_lazy as _
from gbpui.common import forms as gbforms
class IndexView(tabs.TabbedTableView):
tab_group_class = (ns_tabs.ServiceChainTabs)
template_name = 'gbpui/details_tabs.html'
page_title = _("Network Services")
class ServiceProfileDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.ServiceProfileDetailsTabGroup)
template_name = 'gbpui/details_tabs.html'
page_title = _("Service Profile Details")
class CreateServiceProfileView(gbforms.HelpTextModalMixin,
gbforms.ReversingModalFormView):
form_class = ns_forms.CreateServiceProfileForm
template_name = "gbpui/form_with_description.html"
submit_url = "horizon:project:network_services:create_service_profile"
modal_header = _("Create Service Profile")
submit_label = _("Create")
page_title = _("Create Service Profile")
help_text = _("Create Service Profile.")
class CreateServiceChainNodeView(gbforms.HelpTextModalMixin,
gbforms.ReversingModalFormView):
form_class = ns_forms.CreateServiceChainNodeForm
template_name = "gbpui/form_with_description.html"
submit_url = "horizon:project:network_services:create_sc_node"
modal_header = _("Create Service Chain Node")
submit_label = _("Create")
page_title = _("Create Service Chain Node")
help_text = _("Create Service Chain Node.")
class UpdateServiceChainNodeView(gbforms.HelpTextModalMixin,
gbforms.ReversingModalFormView):
form_class = ns_forms.UpdateServiceChainNodeForm
template_name = "gbpui/form_with_description.html"
submit_url = "horizon:project:network_services:update_sc_node"
modal_header = _("Update Service Chain Node")
submit_label = _("Save Changes")
page_title = _("Update Service Chain Node")
help_text = _("Update Service Chain Node.")
def get_submit_url_params(self, **kwargs):
return {"scnode_id": self.kwargs['scnode_id']}
def get_initial(self):
return self.kwargs
class ServiceChainNodeDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.SCNodeDetailsTabGroup)
template_name = 'gbpui/details_tabs.html'
page_title = _("Service Chain Node Details")
class CreateServiceChainSpecView(forms.ModalFormView):
form_class = ns_forms.CreateServiceChainSpecForm
template_name = "project/network_services/create_service_chain_spec.html"
def get_context_data(self, **kwargs):
context = super(
CreateServiceChainSpecView, self).get_context_data(**kwargs)
return context
class UpdateServiceChainSpecView(forms.ModalFormView):
form_class = ns_forms.UpdateServiceChainSpecForm
template_name = "project/network_services/update_service_chain_spec.html"
def get_context_data(self, **kwargs):
context = super(
UpdateServiceChainSpecView, self).get_context_data(**kwargs)
context['scspec_id'] = self.kwargs['scspec_id']
return context
def get_initial(self):
return self.kwargs
class ServiceChainSpecDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.SCSpecDetailsTabGroup)
template_name = 'gbpui/details_tabs.html'
page_title = _("Service Chain Spec Details")
class ServiceChainInstanceDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.SCInstanceDetailsTabGroup)
template_name = 'gbpui/details_tabs.html'
page_title = _("Service Chain Instance Details")