From c8b1a400aa55cb671339d095b9a632e1a82fb0fe Mon Sep 17 00:00:00 2001 From: Rob Cresswell Date: Thu, 2 Jul 2015 14:23:28 +0100 Subject: [PATCH] Remove Router Dashboard This patch removes the router dashboard from Horizon Change-Id: I43b4ba264647a456366baf4dc45484a72dade5d5 Partially-Implements: blueprint horizon-vendor-split Depends-On: I461c33719b822e3b77b04e2036c4b608418a19a5 --- .../dashboards/router/__init__.py | 0 .../dashboards/router/dashboard.py | 26 -- .../dashboards/router/models.py | 3 - .../dashboards/router/nexus1000v/__init__.py | 0 .../dashboards/router/nexus1000v/forms.py | 211 ------------ .../dashboards/router/nexus1000v/panel.py | 24 -- .../dashboards/router/nexus1000v/tables.py | 99 ------ .../dashboards/router/nexus1000v/tabs.py | 36 -- .../nexus1000v/_create_network_profile.html | 10 - .../nexus1000v/_update_network_profile.html | 7 - .../nexus1000v/create_network_profile.html | 7 - .../templates/nexus1000v/index.html | 19 -- .../nexus1000v/network_profile/index.html | 9 - .../nexus1000v/policy_profile/index.html | 9 - .../nexus1000v/update_network_profile.html | 7 - .../dashboards/router/nexus1000v/tests.py | 318 ------------------ .../dashboards/router/nexus1000v/urls.py | 28 -- .../dashboards/router/nexus1000v/views.py | 171 ---------- openstack_dashboard/enabled/_40_router.py | 10 - openstack_dashboard/test/settings.py | 3 - 20 files changed, 997 deletions(-) delete mode 100644 openstack_dashboard/dashboards/router/__init__.py delete mode 100644 openstack_dashboard/dashboards/router/dashboard.py delete mode 100644 openstack_dashboard/dashboards/router/models.py delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/__init__.py delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/forms.py delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/panel.py delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/tables.py delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/tabs.py delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/_create_network_profile.html delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/_update_network_profile.html delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/create_network_profile.html delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/index.html delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/network_profile/index.html delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/policy_profile/index.html delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/update_network_profile.html delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/tests.py delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/urls.py delete mode 100644 openstack_dashboard/dashboards/router/nexus1000v/views.py delete mode 100644 openstack_dashboard/enabled/_40_router.py diff --git a/openstack_dashboard/dashboards/router/__init__.py b/openstack_dashboard/dashboards/router/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/openstack_dashboard/dashboards/router/dashboard.py b/openstack_dashboard/dashboards/router/dashboard.py deleted file mode 100644 index 9a4fd6a71a..0000000000 --- a/openstack_dashboard/dashboards/router/dashboard.py +++ /dev/null @@ -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) diff --git a/openstack_dashboard/dashboards/router/models.py b/openstack_dashboard/dashboards/router/models.py deleted file mode 100644 index 1b3d5f9efc..0000000000 --- a/openstack_dashboard/dashboards/router/models.py +++ /dev/null @@ -1,3 +0,0 @@ -""" -Stub file to work around django bug: https://code.djangoproject.com/ticket/7198 -""" diff --git a/openstack_dashboard/dashboards/router/nexus1000v/__init__.py b/openstack_dashboard/dashboards/router/nexus1000v/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/openstack_dashboard/dashboards/router/nexus1000v/forms.py b/openstack_dashboard/dashboards/router/nexus1000v/forms.py deleted file mode 100644 index 2f8a3ddb7d..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/forms.py +++ /dev/null @@ -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 diff --git a/openstack_dashboard/dashboards/router/nexus1000v/panel.py b/openstack_dashboard/dashboards/router/nexus1000v/panel.py deleted file mode 100644 index 5e4501d133..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/panel.py +++ /dev/null @@ -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) diff --git a/openstack_dashboard/dashboards/router/nexus1000v/tables.py b/openstack_dashboard/dashboards/router/nexus1000v/tables.py deleted file mode 100644 index f6c5323019..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/tables.py +++ /dev/null @@ -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") diff --git a/openstack_dashboard/dashboards/router/nexus1000v/tabs.py b/openstack_dashboard/dashboards/router/nexus1000v/tabs.py deleted file mode 100644 index 322dc4566f..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/tabs.py +++ /dev/null @@ -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) diff --git a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/_create_network_profile.html b/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/_create_network_profile.html deleted file mode 100644 index 1883ac4848..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/_create_network_profile.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} - -{% block modal-body-right %} -

{% trans "Description:" %}

-

{% trans "Name:" %} {% blocktrans %} Select a name for your network profile.{% endblocktrans %}

-

{% trans "Segment Type:" %} {% blocktrans %} Segment types available are VLAN, Overlay and Trunk.{% endblocktrans %}

-

{% trans "Segment Sub Type:" %} {% 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 %}

-

{% trans "Segment Range:" %} {% blocktrans %} Segment Ranges are 1-4093 for VLAN and above 5000 for Enhanced-VXLAN Overlay.{% endblocktrans %}

-{% endblock %} diff --git a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/_update_network_profile.html b/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/_update_network_profile.html deleted file mode 100644 index dc56b9f843..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/_update_network_profile.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} - -{% block modal-body-right %} -

{% trans "Description:" %}

-

{% trans "Edit the network profile to update name, segment range or multicast IP range." %}

-{% endblock %} diff --git a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/create_network_profile.html b/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/create_network_profile.html deleted file mode 100644 index e5f7129cda..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/create_network_profile.html +++ /dev/null @@ -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 %} diff --git a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/index.html b/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/index.html deleted file mode 100644 index 7d07d0dd15..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/index.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} -{% block title %}{% trans "Cisco Nexus 1000V Networking" %}{% endblock %} - -{% block main %} -
- {{ network_profile_table.render }} -
-
- {{ policy_profile_table.render }} -
- {% comment %} -
-
- {{ tab_group.render }} -
-
- {% endcomment %} -{% endblock %} diff --git a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/network_profile/index.html b/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/network_profile/index.html deleted file mode 100644 index fe1a96f10e..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/network_profile/index.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} -{% block title %}{% trans "Cisco Nexus 1000V Networking" %}{% endblock %} - -{% block main %} -
- {{ table.render }} -
-{% endblock %} diff --git a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/policy_profile/index.html b/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/policy_profile/index.html deleted file mode 100644 index 6434db0aec..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/policy_profile/index.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} -{% block title %}{% trans "Cisco Nexus 1000V Networking" %}{% endblock %} - -{% block main %} -
- {{ table.render }} -
-{% endblock %} diff --git a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/update_network_profile.html b/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/update_network_profile.html deleted file mode 100644 index 7f5ec27a8a..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/templates/nexus1000v/update_network_profile.html +++ /dev/null @@ -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 %} diff --git a/openstack_dashboard/dashboards/router/nexus1000v/tests.py b/openstack_dashboard/dashboards/router/nexus1000v/tests.py deleted file mode 100644 index aaa5bbe6e8..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/tests.py +++ /dev/null @@ -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')) diff --git a/openstack_dashboard/dashboards/router/nexus1000v/urls.py b/openstack_dashboard/dashboards/router/nexus1000v/urls.py deleted file mode 100644 index 5a631938c9..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/urls.py +++ /dev/null @@ -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[^/]+)/update$', - views.UpdateNetworkProfileView.as_view(), - name='update_network_profile'), -) diff --git a/openstack_dashboard/dashboards/router/nexus1000v/views.py b/openstack_dashboard/dashboards/router/nexus1000v/views.py deleted file mode 100644 index d890b51cb8..0000000000 --- a/openstack_dashboard/dashboards/router/nexus1000v/views.py +++ /dev/null @@ -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} diff --git a/openstack_dashboard/enabled/_40_router.py b/openstack_dashboard/enabled/_40_router.py deleted file mode 100644 index e1124fc8a0..0000000000 --- a/openstack_dashboard/enabled/_40_router.py +++ /dev/null @@ -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 diff --git a/openstack_dashboard/test/settings.py b/openstack_dashboard/test/settings.py index 2dd59de352..b1a0c05221 100644 --- a/openstack_dashboard/test/settings.py +++ b/openstack_dashboard/test/settings.py @@ -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',)