Remove Router Dashboard

This patch removes the router dashboard from Horizon

Change-Id: I43b4ba264647a456366baf4dc45484a72dade5d5
Partially-Implements: blueprint horizon-vendor-split
Depends-On: I461c33719b822e3b77b04e2036c4b608418a19a5
This commit is contained in:
Rob Cresswell 2015-07-02 14:23:28 +01:00
parent 0ecb80363f
commit c8b1a400aa
20 changed files with 0 additions and 997 deletions

View File

@ -1,26 +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 Router(horizon.Dashboard):
name = _("Router")
slug = "router"
panels = ('nexus1000v',)
default_panel = 'nexus1000v'
permissions = ('openstack.roles.admin',)
horizon.register(Router)

View File

@ -1,3 +0,0 @@
"""
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
"""

View File

@ -1,211 +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 logging
from horizon import exceptions
from horizon import forms
from horizon import messages
from openstack_dashboard import api
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
LOG = logging.getLogger(__name__)
def get_tenant_choices(request):
tenant_choices = [('', _("Select a project"))]
tenants = []
try:
tenants, has_more = api.keystone.tenant_list(request)
except Exception:
msg = _('Projects could not be retrieved.')
exceptions.handle(request, msg)
for tenant in tenants:
if tenant.enabled:
tenant_choices.append((tenant.id, tenant.name))
return tenant_choices
class CreateNetworkProfile(forms.SelfHandlingForm):
"""Create Network Profile form."""
name = forms.CharField(max_length=255,
label=_("Name"))
segment_type = forms.ChoiceField(label=_('Segment Type'),
choices=[('vlan', _('VLAN')),
('overlay', _('Overlay')),
('trunk', _('Trunk'))],
widget=forms.Select
(attrs={'class': 'switchable',
'data-slug': 'segtype'}))
# Sub type options available for Overlay segment type
sub_type = forms.ChoiceField(label=_('Sub Type'),
choices=[('native_vxlan', _('Native VXLAN')),
('enhanced', _('Enhanced VXLAN')),
('other', _('Other'))],
required=False,
widget=forms.Select
(attrs={'class': 'switchable switched',
'data-slug': 'subtype',
'data-switch-on': 'segtype',
'data-segtype-overlay':
_("Sub Type")}))
# Sub type options available for Trunk segment type
sub_type_trunk = forms.ChoiceField(label=_('Sub Type'),
choices=[('vlan', _('VLAN'))],
required=False,
widget=forms.Select
(attrs={'class': 'switched',
'data-switch-on': 'segtype',
'data-segtype-trunk':
_("Sub Type")}))
segment_range = forms.CharField(max_length=255,
label=_("Segment Range"),
required=False,
widget=forms.TextInput
(attrs={'class': 'switched',
'data-switch-on': 'segtype',
'data-segtype-vlan':
_("Segment Range"),
'data-segtype-overlay':
_("Segment Range")}),
help_text=_("1-4093 for VLAN; "
"5000 and above for Overlay"))
multicast_ip_range = forms.CharField(max_length=30,
label=_("Multicast IP Range"),
required=False,
widget=forms.TextInput
(attrs={'class': 'switched',
'data-switch-on':
'subtype',
'data-subtype-native_vxlan':
_("Multicast IP Range")}),
help_text=_("Multicast IPv4 range"
"(e.g. 224.0.1.0-"
"224.0.1.100)"))
other_subtype = forms.CharField(max_length=255,
label=_("Sub Type Value (Manual Input)"),
required=False,
widget=forms.TextInput
(attrs={'class': 'switched',
'data-switch-on':
'subtype',
'data-subtype-other':
_("Sub Type Value "
"(Manual Input)")}),
help_text=_("Enter parameter (e.g. GRE)"))
physical_network = forms.CharField(max_length=255,
label=_("Physical Network"),
required=False,
widget=forms.TextInput
(attrs={'class': 'switched',
'data-switch-on': 'segtype',
'data-segtype-vlan':
_("Physical Network")}))
project = forms.ChoiceField(label=_("Project"),
required=False)
def __init__(self, request, *args, **kwargs):
super(CreateNetworkProfile, self).__init__(request, *args, **kwargs)
self.fields['project'].choices = get_tenant_choices(request)
def clean(self):
# If sub_type is 'other' or 'trunk' then
# assign this new value for sub_type
cleaned_data = super(CreateNetworkProfile, self).clean()
segment_type = cleaned_data.get('segment_type')
if segment_type == 'overlay':
sub_type = cleaned_data.get('sub_type')
if sub_type == 'other':
other_subtype = cleaned_data.get('other_subtype')
cleaned_data['sub_type'] = other_subtype
LOG.debug('subtype is now %(params)s',
{'params': other_subtype})
elif segment_type == 'trunk':
sub_type_trunk = cleaned_data.get('sub_type_trunk')
cleaned_data['sub_type'] = sub_type_trunk
LOG.debug('subtype is now %(params)s',
{'params': sub_type_trunk})
return cleaned_data
def handle(self, request, data):
try:
LOG.debug('request = %(req)s, params = %(params)s',
{'req': request, 'params': data})
params = {'name': data['name'],
'segment_type': data['segment_type'],
'sub_type': data['sub_type'],
'segment_range': data['segment_range'],
'physical_network': data['physical_network'],
'multicast_ip_range': data['multicast_ip_range'],
'tenant_id': data['project']}
profile = api.neutron.profile_create(request,
**params)
msg = _('Network Profile %s '
'was successfully created.') % data['name']
LOG.debug(msg)
messages.success(request, msg)
return profile
except Exception:
redirect = reverse('horizon:router:nexus1000v:index')
msg = _('Failed to create network profile %s') % data['name']
exceptions.handle(request, msg, redirect=redirect)
class UpdateNetworkProfile(CreateNetworkProfile):
"""Update Network Profile form."""
profile_id = forms.CharField(label=_("ID"),
widget=forms.HiddenInput())
project = forms.CharField(label=_("Project"), required=False)
def __init__(self, request, *args, **kwargs):
super(UpdateNetworkProfile, self).__init__(request, *args, **kwargs)
self.fields['segment_type'].widget.attrs['readonly'] = 'readonly'
self.fields['sub_type'].widget.attrs['readonly'] = 'readonly'
self.fields['sub_type_trunk'].widget.attrs['readonly'] = 'readonly'
self.fields['other_subtype'].widget.attrs['readonly'] = 'readonly'
self.fields['physical_network'].widget.attrs['readonly'] = 'readonly'
self.fields['project'].widget.attrs['readonly'] = 'readonly'
def handle(self, request, data):
try:
LOG.debug('request = %(req)s, params = %(params)s',
{'req': request, 'params': data})
params = {'name': data['name'],
'segment_range': data['segment_range'],
'multicast_ip_range': data['multicast_ip_range']}
profile = api.neutron.profile_update(
request,
data['profile_id'],
**params
)
msg = _('Network Profile %s '
'was successfully updated.') % data['name']
LOG.debug(msg)
messages.success(request, msg)
return profile
except Exception:
msg = _('Failed to update '
'network profile (%s).') % data['name']
redirect = reverse('horizon:router:nexus1000v:index')
exceptions.handle(request, msg, redirect=redirect)
return False

View File

@ -1,24 +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
from openstack_dashboard.dashboards.router import dashboard
class Nexus1000v(horizon.Panel):
name = _("Cisco Nexus 1000v")
slug = 'nexus1000v'
permissions = ('openstack.services.network',)
dashboard.Router.register(Nexus1000v)

View File

@ -1,99 +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 logging
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from horizon import exceptions
from horizon import tables
from openstack_dashboard import api
LOG = logging.getLogger(__name__)
class CreateNetworkProfile(tables.LinkAction):
name = "create"
verbose_name = _("Create Network Profile")
url = "horizon:router:nexus1000v:create_network_profile"
classes = ("ajax-modal",)
icon = "plus"
class DeleteNetworkProfile(tables.DeleteAction):
@staticmethod
def action_present(count):
return ungettext_lazy(
u"Delete Network Profile",
u"Delete Network Profiles",
count
)
@staticmethod
def action_past(count):
return ungettext_lazy(
u"Deleted Network Profile",
u"Deleted Network Profiles",
count
)
def delete(self, request, obj_id):
try:
api.neutron.profile_delete(request, obj_id)
except Exception:
msg = _('Failed to delete network profile (%s).') % obj_id
LOG.info(msg)
redirect = reverse('horizon:router:nexus1000v:index')
exceptions.handle(request, msg, redirect=redirect)
class EditNetworkProfile(tables.LinkAction):
name = "update"
verbose_name = _("Edit Network Profile")
url = "horizon:router:nexus1000v:update_network_profile"
classes = ("ajax-modal",)
icon = "pencil"
class NetworkProfile(tables.DataTable):
id = tables.Column("id", hidden=True)
name = tables.Column("name", verbose_name=_("Network Profile"), )
project = tables.Column("project_name", verbose_name=_("Project"))
segment_type = tables.Column("segment_type",
verbose_name=_("Segment Type"))
sub_type = tables.Column("sub_type",
verbose_name=_("Sub Type"))
segment_range = tables.Column("segment_range",
verbose_name=_("Segment Range"))
multicast_ip_range = tables.Column("multicast_ip_range",
verbose_name=_("Multicast IP Range"))
physical_network = tables.Column("physical_network",
verbose_name=_("Physical Network Name"))
class Meta(object):
name = "network_profile"
verbose_name = _("Network Profile")
table_actions = (CreateNetworkProfile, DeleteNetworkProfile,)
row_actions = (EditNetworkProfile, DeleteNetworkProfile,)
class PolicyProfile(tables.DataTable):
id = tables.Column("id", hidden=True)
name = tables.Column("name", verbose_name=_("Policy Profile"), )
project = tables.Column("project_name", verbose_name=_("Project"))
class Meta(object):
name = "policy_profile"
verbose_name = _("Policy Profile")

View File

@ -1,36 +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 _
from horizon import tabs
class NetworkProfileTab(tabs.Tab):
name = _("Network Profile")
slug = "network_profile"
template_name = 'router/nexus1000v/network_profile/index.html'
def get_context_data(self, request):
return None
class PolicyProfileTab(tabs.Tab):
name = _("Policy Profile")
slug = "policy_profile"
template_name = 'router/nexus1000v/policy_profile/index.html'
preload = False
class IndexTabs(tabs.TabGroup):
slug = "indextabs"
tabs = (NetworkProfileTab, PolicyProfileTab)

View File

@ -1,10 +0,0 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p><strong>{% trans "Name:" %}</strong> {% blocktrans %} Select a name for your network profile.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Type:" %}</strong> {% blocktrans %} Segment types available are VLAN, Overlay and Trunk.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Sub Type:" %}</strong> {% blocktrans %} Sub types available are for the Overlay and Trunk segments. Available sub-types for Overlay are: Native-VXLAN, Enhanced-VXLAN or 'Other' (eg. GRE) which can be manually inputed as a text parameter for subtype. Available sub-type for Trunk is: VLAN.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Range:" %}</strong> {% blocktrans %} Segment Ranges are 1-4093 for VLAN and above 5000 for Enhanced-VXLAN Overlay.{% endblocktrans %}</p>
{% endblock %}

View File

@ -1,7 +0,0 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Edit the network profile to update name, segment range or multicast IP range." %}</p>
{% endblock %}

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Create Network Profile" %}{% endblock %}
{% block main %}
{% include "router/nexus1000v/_create_network_profile.html" %}
{% endblock %}

View File

@ -1,19 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Cisco Nexus 1000V Networking" %}{% endblock %}
{% block main %}
<div id="network_profile">
{{ network_profile_table.render }}
</div>
<div id="policy_profile">
{{ policy_profile_table.render }}
</div>
{% comment %}
<div class="row">
<div class="col-sm-12">
{{ tab_group.render }}
</div>
</div>
{% endcomment %}
{% endblock %}

View File

@ -1,9 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Cisco Nexus 1000V Networking" %}{% endblock %}
{% block main %}
<div id="network_profile">
{{ table.render }}
</div>
{% endblock %}

View File

@ -1,9 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Cisco Nexus 1000V Networking" %}{% endblock %}
{% block main %}
<div id="policy_profile">
{{ table.render }}
</div>
{% endblock %}

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Update Network Profile" %}{% endblock %}
{% block main %}
{% include 'router/nexus1000v/_update_network_profile.html' %}
{% endblock %}

View File

@ -1,318 +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.core.urlresolvers import reverse
from django import http
from mox3.mox import IsA # noqa
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
def form_data_no_overlay():
return {'multicast_ip_range': '',
'sub_type': ''}
def form_data_overlay():
return {'physical_network': ''}
class Nexus1000vTest(test.BaseAdminViewTests):
@test.create_stubs({api.neutron: ('profile_list',
'profile_bindings_list'),
api.keystone: ('tenant_list',)})
def test_index(self):
tenants = self.tenants.list()
net_profiles = self.net_profiles.list()
policy_profiles = self.policy_profiles.list()
net_profile_binding = self.network_profile_binding.list()
policy_profile_binding = self.policy_profile_binding.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'network').AndReturn(net_profile_binding)
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'policy').AndReturn(policy_profile_binding)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
res = self.client.get(reverse('horizon:router:nexus1000v:index'))
self.assertTemplateUsed(res, 'router/nexus1000v/index.html')
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_vlan_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.first()
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'physical_network': net_profile.physical_network,
'tenant_id': net_profile.project,
# vlan profiles have no sub_type or multicast_ip_range
'multicast_ip_range': '',
'sub_type': ''}
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'physical_network': net_profile.physical_network,
'project': net_profile.project}
form_data.update(form_data_no_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_overlay_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[1]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'multicast_ip_range': net_profile.multicast_ip_range,
'sub_type': net_profile.sub_type,
'tenant_id': net_profile.project,
# overlay profiles have no physical_network type
'physical_network': ''}
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'multicast_ip_range': net_profile.multicast_ip_range,
'sub_type': net_profile.sub_type,
'project': net_profile.project}
form_data.update(form_data_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_overlay_other_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[2]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'sub_type': net_profile.other_subtype,
'tenant_id': net_profile.project,
# overlay 'other' profiles have no multicast_ip_range
# or physical_network type
'multicast_ip_range': '',
'physical_network': ''}
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'sub_type': net_profile.sub_type,
'other_subtype': net_profile.other_subtype,
'project': net_profile.project}
form_data.update(form_data_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_trunk_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[3]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'sub_type': net_profile.sub_type_trunk,
'tenant_id': net_profile.project,
# trunk profiles have no multicast_ip_range,
# no segment_range or no physical_network type
'multicast_ip_range': '',
'segment_range': '',
'physical_network': ''}
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'sub_type_trunk': net_profile.sub_type_trunk,
'project': net_profile.project}
form_data.update(form_data_no_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
@test.create_stubs({api.neutron: ('profile_get',
'profile_bindings_list'),
api.keystone: ('tenant_list',)})
def test_network_profile_update_get(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.first()
net_profile_binding = self.network_profile_binding.list()
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'network').AndReturn(net_profile_binding)
api.neutron.profile_get(
IsA(http.HttpRequest),
net_profile.id).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
url = reverse('horizon:router:nexus1000v:update_network_profile',
args=[net_profile.id])
res = self.client.get(url)
self.assertTemplateUsed(
res,
'router/nexus1000v/_update_network_profile.html')
@test.create_stubs({api.neutron: ('profile_update',
'profile_get',
'profile_bindings_list'),
api.keystone: ('tenant_list',)})
def test_vlan_net_profile_update_post(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.first()
net_profile_binding = self.network_profile_binding.list()
# vlan profiles can only update name and segment_range
params = {'name': net_profile.name,
'segment_range': net_profile.segment_range,
# vlan profiles have no multicast_ip_range
'multicast_ip_range': ''}
api.neutron.profile_update(
IsA(http.HttpRequest),
net_profile.id,
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'network').AndReturn(net_profile_binding)
api.neutron.profile_get(
IsA(http.HttpRequest),
net_profile.id).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'profile_id': net_profile.id,
'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'physical_network': net_profile.physical_network,
'project': net_profile.project}
form_data.update(form_data_no_overlay())
url = reverse('horizon:router:nexus1000v:update_network_profile',
args=[net_profile.id])
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
@test.create_stubs({api.neutron: ('profile_update',
'profile_get',
'profile_bindings_list'),
api.keystone: ('tenant_list',)})
def test_overlay_net_profile_update_post(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.get(name="net_profile_test2")
net_profile_binding = self.network_profile_binding.list()
# overlay profiles can only update
# name, segment_range and multicast_ip_range
params = {'name': net_profile.name,
'segment_range': net_profile.segment_range,
'multicast_ip_range': net_profile.multicast_ip_range}
api.neutron.profile_update(
IsA(http.HttpRequest),
net_profile.id,
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'network').AndReturn(net_profile_binding)
api.neutron.profile_get(
IsA(http.HttpRequest),
net_profile.id).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'profile_id': net_profile.id,
'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'multicast_ip_range': net_profile.multicast_ip_range,
'sub_type': net_profile.sub_type,
'project': net_profile.project}
form_data.update(form_data_overlay())
url = reverse('horizon:router:nexus1000v:update_network_profile',
args=[net_profile.id])
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))

View File

@ -1,28 +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 patterns
from django.conf.urls import url
from openstack_dashboard.dashboards.router.nexus1000v import views
urlpatterns = patterns(
'',
url(r'^$', views.IndexView.as_view(), name='index'),
# Network Profile
url(r'^network_profile/create$', views.CreateNetworkProfileView.as_view(),
name='create_network_profile'),
url(r'^network_profile/(?P<profile_id>[^/]+)/update$',
views.UpdateNetworkProfileView.as_view(),
name='update_network_profile'),
)

View File

@ -1,171 +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 logging
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy
from django.utils import datastructures
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from horizon import tables
from horizon import tabs
from horizon.utils import memoized
from openstack_dashboard import api
from openstack_dashboard.dashboards.router.nexus1000v \
import forms as profileforms
from openstack_dashboard.dashboards.router.nexus1000v \
import tables as profiletables
LOG = logging.getLogger(__name__)
def _get_tenant_list(request):
tenants = []
try:
tenants, has_more = api.keystone.tenant_list(request)
except Exception:
msg = _('Unable to retrieve project information.')
exceptions.handle(request, msg)
return datastructures.SortedDict([(t.id, t) for t in tenants])
def _get_profiles(request, type_p):
try:
profiles = api.neutron.profile_list(request, type_p)
except Exception:
profiles = []
msg = _('Network Profiles could not be retrieved.')
exceptions.handle(request, msg)
if profiles:
# Set project name
tenant_dict = _get_tenant_list(request)
bindings = api.neutron.profile_bindings_list(request, type_p)
bindings_dict = datastructures.SortedDict(
[(b.profile_id, b.tenant_id) for b in bindings])
for p in profiles:
project_id = bindings_dict.get(p.id)
project = tenant_dict.get(project_id)
p.project_name = getattr(project, 'name', None)
return profiles
class NetworkProfileIndexView(tables.DataTableView):
table_class = profiletables.NetworkProfile
template_name = 'router/nexus1000v/network_profile/index.html'
page_title = _("Cisco Nexus 1000V")
def get_data(self):
return _get_profiles(self.request, 'network')
class PolicyProfileIndexView(tables.DataTableView):
table_class = profiletables.PolicyProfile
template_name = 'router/nexus1000v/policy_profile/index.html'
page_title = _("Cisco Nexus 1000V")
def get_data(self):
return _get_profiles(self.request, 'policy')
class IndexTabGroup(tabs.TabGroup):
slug = "group"
tabs = (NetworkProfileIndexView, PolicyProfileIndexView,)
class IndexView(tables.MultiTableView):
table_classes = (profiletables.NetworkProfile,
profiletables.PolicyProfile,)
template_name = 'router/nexus1000v/index.html'
page_title = _("Cisco Nexus 1000V")
def get_network_profile_data(self):
return _get_profiles(self.request, 'network')
def get_policy_profile_data(self):
return _get_profiles(self.request, 'policy')
class CreateNetworkProfileView(forms.ModalFormView):
form_class = profileforms.CreateNetworkProfile
form_id = "create_network_profile_form"
modal_header = _("Create Network Profile")
template_name = 'router/nexus1000v/create_network_profile.html'
submit_label = _("Create Network Profile")
submit_url = reverse_lazy(
"horizon:router:nexus1000v:create_network_profile")
success_url = reverse_lazy('horizon:router:nexus1000v:index')
page_title = _("Create Network Profile")
class UpdateNetworkProfileView(forms.ModalFormView):
form_class = profileforms.UpdateNetworkProfile
form_id = "update_network_profile_form"
modal_header = _("Edit Network Profile")
template_name = 'router/nexus1000v/update_network_profile.html'
context_object_name = 'network_profile'
submit_label = _("Save Changes")
submit_url = "horizon:router:nexus1000v:update_network_profile"
success_url = reverse_lazy('horizon:router:nexus1000v:index')
page_title = _("Update Network Profile")
def get_context_data(self, **kwargs):
context = super(UpdateNetworkProfileView,
self).get_context_data(**kwargs)
context["profile_id"] = self.kwargs['profile_id']
args = (self.kwargs['profile_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context
@memoized.memoized_method
def _get_object(self, *args, **kwargs):
profile_id = self.kwargs['profile_id']
try:
profile = api.neutron.profile_get(self.request,
profile_id)
LOG.debug("Network Profile object=%s", profile)
return profile
except Exception:
redirect = self.success_url
msg = _('Unable to retrieve network profile details.')
exceptions.handle(self.request, msg, redirect=redirect)
def get_initial(self):
profile = self._get_object()
# Set project name
tenant_dict = _get_tenant_list(self.request)
try:
bindings = api.neutron.profile_bindings_list(
self.request, 'network')
except Exception:
msg = _('Failed to obtain network profile binding')
redirect = self.success_url
exceptions.handle(self.request, msg, redirect=redirect)
bindings_dict = datastructures.SortedDict(
[(b.profile_id, b.tenant_id) for b in bindings])
project_id = bindings_dict.get(profile.id)
project = tenant_dict.get(project_id)
project_name = getattr(project, 'name', project_id)
return {'profile_id': profile['id'],
'name': profile['name'],
'segment_range': profile['segment_range'],
'segment_type': profile['segment_type'],
'physical_network': profile['physical_network'],
'sub_type': profile['sub_type'],
'multicast_ip_range': profile['multicast_ip_range'],
'project': project_name}

View File

@ -1,10 +0,0 @@
# The slug of the dashboard to be added to HORIZON['dashboards']. Required.
DASHBOARD = 'router'
# A list of applications to be added to INSTALLED_APPS.
ADD_INSTALLED_APPS = [
'openstack_dashboard.dashboards.router',
]
# If set to True, this dashboard will not be added to the settings.
DISABLED = True

View File

@ -48,9 +48,6 @@ INSTALLED_APPS = (
'compressor',
'horizon',
'openstack_dashboard',
# TODO(david-lyle) remove this in later patch, issue with enabled vs
# non-enabled panels/dashs for testing.
'openstack_dashboard.dashboards.router',
)
AUTHENTICATION_BACKENDS = ('openstack_auth.backend.KeystoneBackend',)