GBP UI - added network services UI

Change-Id: I71dd954d7a1fba445067299ef361d9c0e1f7b2e2
This commit is contained in:
uday bhaskar
2014-11-24 19:41:20 +05:30
parent 63c4fb93ac
commit a1f2e4f8bd
21 changed files with 977 additions and 0 deletions

View File

@@ -0,0 +1,259 @@
# Copyright 2010-2011 OpenStack Foundation
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# 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.core.urlresolvers import reverse
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 gbpui import client
LOG = logging.getLogger(__name__)
SERVICE_TYPES = [('LOADBALANCER', 'Load Balancer'),
('FIREWALL', 'Firewall')]
class CreateServiceChainNodeForm(forms.SelfHandlingForm):
name = forms.CharField(max_length=80, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), required=False)
service_type = forms.ChoiceField(
label=_("Service Type"), choices=SERVICE_TYPES)
template_file = forms.FileField(label=_('Template File'),
help_text=_(
'A local template file to upload.'),
required=False)
template_string = forms.CharField(label=_("Template String"),
widget=forms.Textarea, required=False)
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']
except KeyError:
pass
context['config'] = json.dumps(context['config'])
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(forms.SelfHandlingForm):
name = forms.CharField(max_length=80, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), 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']:
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']
client.update_servicechain_node(
request, scnode_id, **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 CreateServiceChainSpecForm(forms.SelfHandlingForm):
name = forms.CharField(max_length=80, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), required=False)
nodes = forms.MultipleChoiceField(label=_("Nodes"))
def __init__(self, request, *args, **kwargs):
super(CreateServiceChainSpecForm, self).__init__(
request, *args, **kwargs)
try:
nodes = client.servicechainnode_list(request)
nodes = [(item.id, item.name + ":" + str(item.id))
for item in nodes]
self.fields['nodes'].choices = nodes
except Exception:
msg = _("Failed to retrive service chain nodes.")
LOG.error(msg)
exceptions.handle(request, msg, redirect=shortcuts.redirect)
def handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
client.create_servicechain_spec(request, **context)
msg = _("Service Chain Spec Created Successfully!")
LOG.debug(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=shortcuts.redirect)
class UpdateServiceChainSpecForm(CreateServiceChainSpecForm):
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']:
self.fields[attr].initial = getattr(scspec, attr)
except Exception:
pass
def handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
scspec_id = self.initial['scspec_id']
client.update_servicechain_spec(request, scspec_id, **context)
msg = _("Service Chain Spec Created Successfully!")
LOG.debug(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=shortcuts.redirect)
class CreateServiceChainInstanceForm(forms.SelfHandlingForm):
name = forms.CharField(max_length=80, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), required=False)
servicechain_spec = forms.ChoiceField(label=_("ServiceChain Spec"))
provider_ptg = forms.ChoiceField(label=_("Provider PTG"))
consumer_ptg = forms.ChoiceField(label=_("Consumer PTG"))
classifier = forms.ChoiceField(label=_("Classifier"))
def __init__(self, request, *args, **kwargs):
super(CreateServiceChainInstanceForm, self).__init__(
request, *args, **kwargs)
try:
sc_specs = client.servicechainspec_list(request)
ptgs = client.policy_target_list(request)
ptgs = [(item.id, item.name) for item in ptgs]
classifiers = client.policyclassifier_list(request)
self.fields['servicechain_spec'].choices = [
(item.id, item.name) for item in sc_specs]
self.fields['provider_ptg'].choices = ptgs
self.fields['consumer_ptg'].choices = ptgs
self.fields['classifier'].choices = [
(item.id, item.name) for item in classifiers]
except Exception:
msg = _("Failed to retrive policy targets")
LOG.error(msg)
def handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
client.create_servicechain_instance(request, **context)
msg = _("Service Chain Instance Created Successfully!")
LOG.debug(msg)
return http.HttpResponseRedirect(url)
except Exception as e:
msg = _("Failed to create Service Chain Instance. %s") % (str(e))
LOG.error(msg)
exceptions.handle(request, msg, redirect=shortcuts.redirect)
class UpdateServiceChainInstanceForm(forms.SelfHandlingForm):
name = forms.CharField(max_length=80, label=_("Name"))
description = forms.CharField(
max_length=80, label=_("Description"), required=False)
servicechain_spec = forms.ChoiceField(label=_("ServiceChain Spec"))
def __init__(self, request, *args, **kwargs):
super(UpdateServiceChainInstanceForm, self).__init__(
request, *args, **kwargs)
try:
scinstance_id = self.initial['scinstance_id']
sc_specs = client.servicechainspec_list(request)
self.fields['servicechain_spec'].choices = [
(item.id, item.name) for item in sc_specs]
scinstance = client.get_servicechain_instance(
request, scinstance_id)
for attr in ['name', 'description', 'servicechain_spec']:
self.fields[attr].initial = getattr(scinstance, attr)
except Exception:
pass
def handle(self, request, context):
url = reverse("horizon:project:network_services:index")
try:
scinstance_id = self.initial['scinstance_id']
client.update_servicechain_instance(
request, scinstance_id, **context)
msg = _("Service Chain Instance Created Successfully!")
LOG.debug(msg)
return http.HttpResponseRedirect(url)
except Exception as e:
msg = _("Failed to create Service Chain Instance. %s") % (str(e))
LOG.error(msg)
exceptions.handle(request, msg, redirect=shortcuts.redirect)

View File

View File

@@ -0,0 +1,22 @@
# 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.
#
# @author: Ronak Shah
from django.utils.translation import ugettext_lazy as _
import horizon
class NetworkServices(horizon.Panel):
name = _("Network Services")
slug = "network_services"

View File

@@ -0,0 +1,149 @@
# 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.
#
# @author: Ronak Shah
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
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 = "delete_servicechain_spec"
action_present = _("Delete")
action_past = _("Scheduled deletion of %(data_type)s")
data_type_singular = _("ServiceChainSpec")
data_type_plural = _("ServiceChainSpecs")
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:
name = "service_chain_spec_table"
verbose_name = _("Service Chain Specs")
table_actions = (CreateServiceChainSpecLink,)
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 = "delete_servicechain_node"
action_present = _("Delete")
action_past = _("Scheduled deletion of %(data_type)s")
data_type_singular = _("ServiceChainNode")
data_type_plural = _("ServiceChainNodes")
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_type = tables.Column("service_type",
verbose_name=_("Service Type"))
class Meta:
name = "service_chain_node_table"
verbose_name = _("Service Chain Node")
table_actions = (CreateServiceChainNodeLink,)
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 = "delete_servicechain_instance"
action_present = _("Delete")
action_past = _("Scheduled deletion of %(data_type)s")
data_type_singular = _("ServiceChainInstance")
data_type_plural = _("ServiceChainInstances")
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 PTG"))
consumer_ptg = tables.Column(
"consumer_ptg", verbose_name=_("Consumer PTG"))
servicechain_spec = tables.Column(
"servicechain_spec", verbose_name=_("Service Chain Spec"))
classifier = tables.Column("classifier", verbose_name=_("Classifier"))
class Meta:
name = "service_chain_instance_table"
verbose_name = _("Service Chain Instance")
table_actions = (CreateServiceChainInstanceLink,)
row_actions = (
EditServiceChainInstanceLink, DeleteServiceChainInstanceLink,)

View File

@@ -0,0 +1,149 @@
# 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.
#
# @author: Ronak Shah
from django.core.urlresolvers 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
import tables as ns_tables
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)
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)
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)
instances = [gfilters.update_sc_instance_attributes(
self.request, item) for item in instances]
except Exception:
pass
return instances
class ServiceChainTabs(tabs.TabGroup):
slug = "service_chain_spec_tabs"
tabs = (ServiceChainSpecTab,
ServiceChainNodeTab,
ServiceChainInstanceTab,)
sticky = True
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)
except Exception:
exceptions.handle(request, _(
'Unable to retrieve service node details.'),
redirect=self.failure_url)
return {'scnode': scnode}
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)
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

@@ -0,0 +1,25 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}create_service_chain_instance{% endblock %}
{% block form_action %}{% url 'horizon:project:network_services:create_sc_instance' %}{% endblock %}
{% block modal-header %}{% trans "Create Service Chain Instance" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Create Service Chain Instance." %}</p>
</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:create_sc_instance' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}create_service_chain_node{% endblock %}
{% block form_action %}{% url 'horizon:project:network_services:create_sc_node' %}{% endblock %}
{% block form_attrs %}enctype="multipart/form-data"{% endblock %}
{% block modal-header %}{% trans "Create Service Chain Node" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Create Service Chain Node." %}</p>
</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:create_sc_node' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@@ -0,0 +1,25 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% 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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Create Service Chain Spec." %}</p>
</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:create_sc_spec' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@@ -0,0 +1,30 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<div class="info row detail">
<hr class="header_rule">
<dl>
<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 }} </dd>
<dt>{% trans "Consumer PTG" %}</dt>
<dd>{{ scinstance.consumer_ptg }} </dd>
<dt>{% trans "Service Chain Spec" %}</dt>
<dd>{{ scinstance.servicechain_spec}} </dd>
<dt>{% trans "Classifier" %}</dt>
<dd>{{ scinstance.classifier}} </dd>
</dl>
</div>

View File

@@ -0,0 +1,16 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<div class="info row detail">
<hr class="header_rule">
<dl>
<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>
</dl>
</div>

View File

@@ -0,0 +1,25 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<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 "Nodes" %}</dt>
<dd>
<ul class="list-unstyled">
{% for node in scspec.nodes %}
<li>{{ node}}</li>
{% endfor %}
</ul>
</dd>
</dl>
</div>

View File

@@ -0,0 +1,25 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}update_service_chain_instance{% endblock %}
{% block form_action %}{% url 'horizon:project:network_services:update_sc_instance' scinstance_id %}{% endblock %}
{% block modal-header %}{% trans "Update Service Chain Instance" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Update Service Chain Instance." %}</p>
</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 %}

View File

@@ -0,0 +1,25 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}update_service_chain_node{% endblock %}
{% block form_action %}{% url 'horizon:project:network_services:update_sc_node' scnode_id %}{% endblock %}
{% block modal-header %}{% trans "Update Service Chain Node" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Update Service Chain Node." %}</p>
</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 %}

View File

@@ -0,0 +1,25 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% 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 %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Update Service Chain Spec." %}</p>
</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 %}

View File

@@ -0,0 +1,15 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Network Services" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Network Services") %}
{% endblock page_header %}
{% block main %}
<div class="row">
<div class="col-sm-12">
{{ tab_group.render }}
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,50 @@
# 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.
#
# @author: Ronak Shah
from django.conf.urls import patterns # noqa
from django.conf.urls import url # noqa
import views
urlpatterns = patterns('',
url(r'^$', views.IndexView.as_view(), name='index'),
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'^create_sc_instance$',
views.CreateServiceChainInstanceView.as_view(),
name='create_sc_instance'),
url(r'^update_sc_instance/(?P<scinstance_id>[^/]+)/$',
views.UpdateServiceChainInstanceView.as_view(),
name='update_sc_instance'),
url(r'^sc_instance/(?P<scinstance_id>[^/]+)/$',
views.ServiceChainInstanceDetailsView.as_view(),
name='sc_instance_details'),
)

View File

@@ -0,0 +1,111 @@
# 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
import forms as ns_forms
import tabs as ns_tabs
class IndexView(tabs.TabView):
tab_group_class = (ns_tabs.ServiceChainTabs)
template_name = 'project/network_services/details_tabs.html'
class CreateServiceChainNodeView(forms.ModalFormView):
form_class = ns_forms.CreateServiceChainNodeForm
template_name = "project/network_services/create_service_chain_node.html"
def get_context_data(self, **kwargs):
context = super(
CreateServiceChainNodeView, self).get_context_data(**kwargs)
return context
class UpdateServiceChainNodeView(forms.ModalFormView):
form_class = ns_forms.UpdateServiceChainNodeForm
template_name = "project/network_services/update_service_chain_node.html"
def get_context_data(self, **kwargs):
context = super(
UpdateServiceChainNodeView, self).get_context_data(**kwargs)
context['scnode_id'] = self.kwargs['scnode_id']
return context
def get_initial(self):
return self.kwargs
class ServiceChainNodeDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.SCNodeDetailsTabGroup)
template_name = 'project/network_services/details_tabs.html'
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 = 'project/network_services/details_tabs.html'
class CreateServiceChainInstanceView(forms.ModalFormView):
form_class = ns_forms.CreateServiceChainInstanceForm
template_name = "project / network_services/"\
"ceate_service_chain_instance.html"
def get_context_data(self, **kwargs):
context = super(
CreateServiceChainInstanceView, self).get_context_data(**kwargs)
return context
class UpdateServiceChainInstanceView(forms.ModalFormView):
form_class = ns_forms.UpdateServiceChainInstanceForm
template_name = "project/network_services/"\
"update_service_chain_instance.html"
def get_context_data(self, **kwargs):
context = super(
UpdateServiceChainInstanceView, self).get_context_data(**kwargs)
context['scinstance_id'] = self.kwargs['scinstance_id']
return context
def get_initial(self):
return self.kwargs
class ServiceChainInstanceDetailsView(tabs.TabView):
tab_group_class = (ns_tabs.SCInstanceDetailsTabGroup)
template_name = 'project/network_services/details_tabs.html'