Removing Network Profile support in stable/kilo

Network profile is not supported in stable/kilo by the Cisco N1KV
ML2 driver. As the patch for enabling/disabling network profile
support based on a configurable parameter was rejected, this patch
pulls out the network profile code completly from stable/kilo.

This patch is necessary for horizon to be functional with Cisco
N1KV ML2 driver.

Change-Id: I1ef2f489c9bb2adfbe3174c3667539c59562966f
Closes-bug: #1475190
This commit is contained in:
shivrao 2015-07-15 15:26:37 -07:00 committed by Shiva Prasad Rao
parent f7f8d7d1a3
commit d29a68c4f3
7 changed files with 19 additions and 609 deletions

View File

@ -648,8 +648,6 @@ def network_create(request, **kwargs):
"""
LOG.debug("network_create(): kwargs = %s" % kwargs)
# In the case network profiles are being used, profile id is needed.
if 'net_profile_id' in kwargs:
kwargs['n1kv:profile_id'] = kwargs.pop('net_profile_id')
if 'tenant_id' not in kwargs:
kwargs['tenant_id'] = request.user.project_id
body = {'network': kwargs}

View File

@ -38,13 +38,6 @@ class CreateNetwork(forms.SelfHandlingForm):
label=_("Name"),
required=False)
tenant_id = forms.ChoiceField(label=_("Project"))
if api.neutron.is_port_profiles_supported():
widget = None
else:
widget = forms.HiddenInput()
net_profile_id = forms.ChoiceField(label=_("Network Profile"),
required=False,
widget=widget)
network_type = forms.ChoiceField(
label=_("Provider Network Type"),
help_text=_("The physical mechanism by which the virtual "
@ -95,10 +88,6 @@ class CreateNetwork(forms.SelfHandlingForm):
tenant_choices.append((tenant.id, tenant.name))
self.fields['tenant_id'].choices = tenant_choices
if api.neutron.is_port_profiles_supported():
self.fields['net_profile_id'].choices = (
self.get_network_profile_choices(request))
if api.neutron.is_extension_supported(request, 'provider'):
neutron_settings = getattr(settings,
'OPENSTACK_NEUTRON_NETWORK', {})
@ -141,21 +130,6 @@ class CreateNetwork(forms.SelfHandlingForm):
else:
self._hide_provider_network_type()
def get_network_profile_choices(self, request):
profile_choices = [('', _("Select a profile"))]
for profile in self._get_profiles(request, 'network'):
profile_choices.append((profile.id, profile.name))
return profile_choices
def _get_profiles(self, request, type_p):
profiles = []
try:
profiles = api.neutron.profile_list(request, type_p)
except Exception:
msg = _('Network Profiles could not be retrieved.')
exceptions.handle(request, msg)
return profiles
def _hide_provider_network_type(self):
self.fields['network_type'].widget = forms.HiddenInput()
self.fields['physical_network'].widget = forms.HiddenInput()
@ -171,8 +145,6 @@ class CreateNetwork(forms.SelfHandlingForm):
'admin_state_up': (data['admin_state'] == 'True'),
'shared': data['shared'],
'router:external': data['external']}
if api.neutron.is_port_profiles_supported():
params['net_profile_id'] = data['net_profile_id']
if api.neutron.is_extension_supported(request, 'provider'):
network_type = data['network_type']
params['provider:network_type'] = network_type

View File

@ -257,19 +257,13 @@ class NetworkTests(test.BaseAdminViewTests):
self.assertItemsEqual(subnets, [self.subnets.first()])
self.assertEqual(len(ports), 0)
@test.create_stubs({api.neutron: ('profile_list',
'list_extensions',),
@test.create_stubs({api.neutron: ('list_extensions',),
api.keystone: ('tenant_list',)})
def test_network_create_get(self,
test_with_profile=False):
def test_network_create_get(self):
tenants = self.tenants.list()
extensions = self.api_extensions.list()
api.keystone.tenant_list(IsA(
http.HttpRequest)).AndReturn([tenants, False])
if test_with_profile:
net_profiles = self.net_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
api.neutron.list_extensions(
IsA(http.HttpRequest)).AndReturn(extensions)
self.mox.ReplayAll()
@ -279,17 +273,10 @@ class NetworkTests(test.BaseAdminViewTests):
self.assertTemplateUsed(res, 'admin/networks/create.html')
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_get_with_profile(self):
self.test_network_create_get(test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'profile_list',
'list_extensions',),
api.keystone: ('tenant_list',)})
def test_network_create_post(self,
test_with_profile=False):
def test_network_create_post(self):
tenants = self.tenants.list()
tenant_id = self.tenants.first().id
network = self.networks.first()
@ -302,12 +289,6 @@ class NetworkTests(test.BaseAdminViewTests):
'router:external': True,
'shared': True,
'provider:network_type': 'local'}
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
params['net_profile_id'] = net_profile_id
api.neutron.list_extensions(
IsA(http.HttpRequest)).AndReturn(extensions)
api.neutron.network_create(IsA(http.HttpRequest), **params)\
@ -320,25 +301,16 @@ class NetworkTests(test.BaseAdminViewTests):
'external': True,
'shared': True,
'network_type': 'local'}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
url = reverse('horizon:admin:networks:create')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_profile(self):
self.test_network_create_post(test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'profile_list',
'list_extensions',),
api.keystone: ('tenant_list',)})
def test_network_create_post_network_exception(self,
test_with_profile=False):
def test_network_create_post_network_exception(self):
tenants = self.tenants.list()
tenant_id = self.tenants.first().id
network = self.networks.first()
@ -351,12 +323,6 @@ class NetworkTests(test.BaseAdminViewTests):
'router:external': True,
'shared': False,
'provider:network_type': 'local'}
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
params['net_profile_id'] = net_profile_id
api.neutron.list_extensions(
IsA(http.HttpRequest)).AndReturn(extensions)
api.neutron.network_create(IsA(http.HttpRequest),
@ -369,20 +335,12 @@ class NetworkTests(test.BaseAdminViewTests):
'external': True,
'shared': False,
'network_type': 'local'}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
url = reverse('horizon:admin:networks:create')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_network_exception_with_profile(self):
self.test_network_create_post_network_exception(
test_with_profile=True)
@test.create_stubs({api.neutron: ('list_extensions',),
api.keystone: ('tenant_list',)})
def test_network_create_vlan_segmentation_id_invalid(self):

View File

@ -308,13 +308,7 @@ class NetworkTests(test.TestCase):
self.assertItemsEqual(subnets, [self.subnets.first()])
self.assertEqual(len(ports), 0)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_get(self,
test_with_profile=False):
if test_with_profile:
net_profiles = self.net_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
def test_network_create_get(self):
self.mox.ReplayAll()
url = reverse('horizon:project:networks:create')
@ -328,24 +322,11 @@ class NetworkTests(test.TestCase):
'<CreateSubnetDetail: createsubnetdetailaction>']
self.assertQuerysetEqual(workflow.steps, expected_objs)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_get_with_profile(self):
self.test_network_create_get(test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'profile_list',)})
def test_network_create_post(self,
test_with_profile=False):
@test.create_stubs({api.neutron: ('network_create',)})
def test_network_create_post(self):
network = self.networks.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
params['net_profile_id'] = net_profile_id
api.neutron.network_create(IsA(http.HttpRequest),
**params).AndReturn(network)
self.mox.ReplayAll()
@ -354,8 +335,6 @@ class NetworkTests(test.TestCase):
'admin_state': network.admin_state_up,
# subnet
'with_subnet': False}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_no_subnet())
url = reverse('horizon:project:networks:create')
res = self.client.post(url, form_data)
@ -363,16 +342,9 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_profile(self):
self.test_network_create_post(test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'subnet_create',
'profile_list',)})
'subnet_create')})
def test_network_create_post_with_subnet(self,
test_with_profile=False,
test_with_ipv6=True):
network = self.networks.first()
subnet = self.subnets.first()
@ -384,12 +356,6 @@ class NetworkTests(test.TestCase):
'ip_version': subnet.ip_version,
'gateway_ip': subnet.gateway_ip,
'enable_dhcp': subnet.enable_dhcp}
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
params['net_profile_id'] = net_profile_id
if not test_with_ipv6:
subnet.ip_version = 4
subnet_params['ip_version'] = subnet.ip_version
@ -402,8 +368,6 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, allocation_pools=[]))
url = reverse('horizon:project:networks:create')
res = self.client.post(url, form_data)
@ -411,28 +375,15 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_subnet_w_profile(self):
self.test_network_create_post_with_subnet(test_with_profile=True)
@test.update_settings(OPENSTACK_NEUTRON_NETWORK={'enable_ipv6': False})
def test_create_network_with_ipv6_disabled(self):
self.test_network_create_post_with_subnet(test_with_ipv6=False)
@test.create_stubs({api.neutron: ('network_create',
'profile_list',)})
def test_network_create_post_network_exception(self,
test_with_profile=False):
@test.create_stubs({api.neutron: ('network_create',)})
def test_network_create_post_network_exception(self):
network = self.networks.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
params['net_profile_id'] = net_profile_id
api.neutron.network_create(IsA(http.HttpRequest),
**params).AndRaise(self.exceptions.neutron)
self.mox.ReplayAll()
@ -441,8 +392,6 @@ class NetworkTests(test.TestCase):
'admin_state': network.admin_state_up,
# subnet
'with_subnet': False}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_no_subnet())
url = reverse('horizon:project:networks:create')
res = self.client.post(url, form_data)
@ -450,28 +399,12 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_nw_exception_w_profile(self):
self.test_network_create_post_network_exception(
test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'profile_list')})
def test_network_create_post_with_subnet_network_exception(
self,
test_with_profile=False,
):
@test.create_stubs({api.neutron: ('network_create',)})
def test_network_create_post_with_subnet_network_exception(self):
network = self.networks.first()
subnet = self.subnets.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
params['net_profile_id'] = net_profile_id
api.neutron.network_create(IsA(http.HttpRequest),
**params).AndRaise(self.exceptions.neutron)
self.mox.ReplayAll()
@ -479,8 +412,6 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, allocation_pools=[]))
url = reverse('horizon:project:networks:create')
res = self.client.post(url, form_data)
@ -488,30 +419,14 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_nw_exception_w_profile(self):
self.test_network_create_post_with_subnet_network_exception(
test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'network_delete',
'subnet_create',
'profile_list')})
def test_network_create_post_with_subnet_subnet_exception(
self,
test_with_profile=False,
):
'subnet_create')})
def test_network_create_post_with_subnet_subnet_exception(self):
network = self.networks.first()
subnet = self.subnets.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
params['net_profile_id'] = net_profile_id
api.neutron.network_create(IsA(http.HttpRequest),
**params).AndReturn(network)
api.neutron.subnet_create(IsA(http.HttpRequest),
@ -529,8 +444,6 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, allocation_pools=[]))
url = reverse('horizon:project:networks:create')
res = self.client.post(url, form_data)
@ -538,29 +451,14 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_subnet_exception_w_profile(self):
self.test_network_create_post_with_subnet_subnet_exception(
test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_nocidr(self,
test_with_profile=False):
def test_network_create_post_with_subnet_nocidr(self):
network = self.networks.first()
subnet = self.subnets.first()
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
self.mox.ReplayAll()
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, cidr='',
allocation_pools=[]))
url = reverse('horizon:project:networks:create')
@ -569,31 +467,13 @@ class NetworkTests(test.TestCase):
self.assertContains(res, escape('Specify "Network Address" or '
'clear "Create Subnet" checkbox.'))
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_no_cidr_w_profile(self):
self.test_network_create_post_with_subnet_nocidr(
test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_cidr_without_mask(
self,
test_with_profile=False,
):
def test_network_create_post_with_subnet_cidr_without_mask(self):
network = self.networks.first()
subnet = self.subnets.first()
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
self.mox.ReplayAll()
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, cidr='10.0.0.0',
allocation_pools=[]))
url = reverse('horizon:project:networks:create')
@ -602,24 +482,9 @@ class NetworkTests(test.TestCase):
expected_msg = "The subnet in the Network Address is too small (/32)."
self.assertContains(res, expected_msg)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_cidr_without_mask_w_profile(self):
self.test_network_create_post_with_subnet_cidr_without_mask(
test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_cidr_inconsistent(
self,
test_with_profile=False,
):
def test_network_create_post_with_subnet_cidr_inconsistent(self):
network = self.networks.first()
subnet = self.subnets.first()
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
self.mox.ReplayAll()
# dummy IPv6 address
@ -627,8 +492,6 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, cidr=cidr,
allocation_pools=[]))
url = reverse('horizon:project:networks:create')
@ -637,24 +500,9 @@ class NetworkTests(test.TestCase):
expected_msg = 'Network Address and IP version are inconsistent.'
self.assertContains(res, expected_msg)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_subnet_cidr_inconsistent_w_profile(self):
self.test_network_create_post_with_subnet_cidr_inconsistent(
test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_gw_inconsistent(
self,
test_with_profile=False,
):
def test_network_create_post_with_subnet_gw_inconsistent(self):
network = self.networks.first()
subnet = self.subnets.first()
if test_with_profile:
net_profiles = self.net_profiles.list()
net_profile_id = self.net_profiles.first().id
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
self.mox.ReplayAll()
# dummy IPv6 address
@ -662,8 +510,6 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, gateway_ip=gateway_ip,
allocation_pools=[]))
url = reverse('horizon:project:networks:create')
@ -671,12 +517,6 @@ class NetworkTests(test.TestCase):
self.assertContains(res, 'Gateway IP and IP version are inconsistent.')
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_subnet_gw_inconsistent_w_profile(self):
self.test_network_create_post_with_subnet_gw_inconsistent(
test_with_profile=True)
@test.create_stubs({api.neutron: ('network_get',)})
def test_network_update_get(self):
network = self.networks.first()

View File

@ -36,13 +36,6 @@ class CreateNetworkInfoAction(workflows.Action):
net_name = forms.CharField(max_length=255,
label=_("Network Name"),
required=False)
if api.neutron.is_port_profiles_supported():
widget = None
else:
widget = forms.HiddenInput()
net_profile_id = forms.ChoiceField(label=_("Network Profile"),
required=False,
widget=widget)
admin_state = forms.ChoiceField(choices=[(True, _('UP')),
(False, _('DOWN'))],
@ -53,26 +46,6 @@ class CreateNetworkInfoAction(workflows.Action):
def __init__(self, request, *args, **kwargs):
super(CreateNetworkInfoAction, self).__init__(request,
*args, **kwargs)
if api.neutron.is_port_profiles_supported():
self.fields['net_profile_id'].choices = (
self.get_network_profile_choices(request))
def get_network_profile_choices(self, request):
profile_choices = [('', _("Select a profile"))]
for profile in self._get_profiles(request, 'network'):
profile_choices.append((profile.id, profile.name))
return profile_choices
def _get_profiles(self, request, type_p):
profiles = []
try:
profiles = api.neutron.profile_list(request, type_p)
except Exception:
msg = _('Network Profiles could not be retrieved.')
exceptions.handle(request, msg)
return profiles
# TODO(absubram): Add ability to view network profile information
# in the network detail if a profile is used.
class Meta(object):
name = _("Network")
@ -361,8 +334,6 @@ class CreateNetwork(workflows.Workflow):
try:
params = {'name': data['net_name'],
'admin_state_up': (data['admin_state'] == 'True')}
if api.neutron.is_port_profiles_supported():
params['net_profile_id'] = data['net_profile_id']
network = api.neutron.network_create(request, **params)
self.context['net_id'] = network.id
msg = (_('Network "%s" was successfully created.') %

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 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

@ -52,16 +52,6 @@ def _get_profiles(request, type_p):
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
@ -89,8 +79,7 @@ class IndexTabGroup(tabs.TabGroup):
class IndexView(tables.MultiTableView):
table_classes = (profiletables.NetworkProfile,
profiletables.PolicyProfile,)
table_classes = (profiletables.PolicyProfile,)
template_name = 'router/nexus1000v/index.html'
page_title = _("Cisco Nexus 1000V")