diff --git a/doc/source/topics/settings.rst b/doc/source/topics/settings.rst
index db25a898f2..81d8b96efb 100644
--- a/doc/source/topics/settings.rst
+++ b/doc/source/topics/settings.rst
@@ -1312,15 +1312,6 @@ when VPNaaS feature is available in Neutron and this option is no
longer needed. We suggest not to use this option to disable the
VPN panel from now on.
-``profile_support``
-~~~~~~~~~~~~~~~~~~~
-
-Default: ``None``
-
-This option specifies a type of network port profile support. Currently the
-available value is either ``None`` or ``"cisco"``. ``None`` means to disable
-port profile support. ``cisco`` can be used with Neutron Cisco plugins.
-
``supported_provider_types``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py
index b97d423417..0bd07bf234 100644
--- a/openstack_dashboard/api/neutron.py
+++ b/openstack_dashboard/api/neutron.py
@@ -135,12 +135,6 @@ class PortAllowedAddressPair(NeutronAPIDictWrapper):
self.id = addr_pair['ip_address']
-class Profile(NeutronAPIDictWrapper):
- """Wrapper for neutron profiles."""
- _attrs = ['profile_id', 'name', 'segment_type', 'segment_range',
- 'sub_type', 'multicast_ip_index', 'multicast_ip_range']
-
-
class Router(NeutronAPIDictWrapper):
"""Wrapper for neutron routers."""
@@ -711,9 +705,6 @@ def network_create(request, **kwargs):
:returns: Network object
"""
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'] = kwargs.pop('net_profile_id')
if 'tenant_id' not in kwargs:
kwargs['tenant_id'] = request.user.project_id
body = {'network': kwargs}
@@ -900,9 +891,6 @@ def port_create(request, network_id, **kwargs):
:returns: Port object
"""
LOG.debug("port_create(): netid=%s, kwargs=%s" % (network_id, kwargs))
- # In the case policy profiles are being used, profile id is needed.
- if 'policy_profile_id' in kwargs:
- kwargs['n1kv:profile'] = kwargs.pop('policy_profile_id')
kwargs = unescape_port_kwargs(**kwargs)
body = {'port': {'network_id': network_id}}
if 'tenant_id' not in kwargs:
@@ -927,71 +915,6 @@ def port_update(request, port_id, **kwargs):
return Port(port)
-@profiler.trace
-def profile_list(request, type_p, **params):
- LOG.debug("profile_list(): "
- "profile_type=%(profile_type)s, params=%(params)s",
- {'profile_type': type_p, 'params': params})
- if type_p == 'network':
- profiles = neutronclient(request).list_network_profiles(
- **params).get('network_profiles')
- elif type_p == 'policy':
- profiles = neutronclient(request).list_policy_profiles(
- **params).get('policy_profiles')
- return [Profile(n) for n in profiles]
-
-
-@profiler.trace
-def profile_get(request, profile_id, **params):
- LOG.debug("profile_get(): "
- "profileid=%(profileid)s, params=%(params)s",
- {'profileid': profile_id, 'params': params})
- profile = neutronclient(request).show_network_profile(
- profile_id, **params).get('network_profile')
- return Profile(profile)
-
-
-@profiler.trace
-def profile_create(request, **kwargs):
- LOG.debug("profile_create(): kwargs=%s", kwargs)
- body = {'network_profile': {}}
- body['network_profile'].update(kwargs)
- profile = neutronclient(request).create_network_profile(
- body=body).get('network_profile')
- return Profile(profile)
-
-
-@profiler.trace
-def profile_delete(request, profile_id):
- LOG.debug("profile_delete(): profile_id=%s", profile_id)
- neutronclient(request).delete_network_profile(profile_id)
-
-
-@profiler.trace
-def profile_update(request, profile_id, **kwargs):
- LOG.debug("profile_update(): "
- "profileid=%(profileid)s, kwargs=%(kwargs)s",
- {'profileid': profile_id, 'kwargs': kwargs})
- body = {'network_profile': kwargs}
- profile = neutronclient(request).update_network_profile(
- profile_id, body=body).get('network_profile')
- return Profile(profile)
-
-
-@profiler.trace
-def profile_bindings_list(request, type_p, **params):
- LOG.debug("profile_bindings_list(): "
- "profile_type=%(profile_type)s params=%(params)s",
- {'profile_type': type_p, 'params': params})
- if type_p == 'network':
- bindings = neutronclient(request).list_network_profile_bindings(
- **params).get('network_profile_bindings')
- elif type_p == 'policy':
- bindings = neutronclient(request).list_policy_profile_bindings(
- **params).get('policy_profile_bindings')
- return [Profile(n) for n in bindings]
-
-
@profiler.trace
def router_create(request, **kwargs):
LOG.debug("router_create():, kwargs=%s" % kwargs)
@@ -1303,23 +1226,6 @@ def is_router_enabled(request):
return (is_enabled_by_config('enable_router') and
is_extension_supported(request, 'router'))
-
-# Using this mechanism till a better plugin/sub-plugin detection
-# mechanism is available.
-# When using specific plugins the profile_support can be
-# turned on if needed to configure and/or use profiles.
-# Since this is a temporary mechanism used to detect profile_support
-# @memorize is not being used.
-# TODO(absubram): Change this config variable check with
-# subplugin/plugin detection API when it becomes available.
-def is_port_profiles_supported():
- network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {})
- # Can be used to check for vendor specific plugin
- profile_support = network_config.get('profile_support', None)
- if str(profile_support).lower() == 'cisco':
- return True
-
-
# FEATURE_MAP is used to define:
# - related neutron extension name (key: "extension")
# - corresponding dashboard config (key: "config")
diff --git a/openstack_dashboard/api/rest/neutron.py b/openstack_dashboard/api/rest/neutron.py
index 8098d58c6a..f6bf110531 100644
--- a/openstack_dashboard/api/rest/neutron.py
+++ b/openstack_dashboard/api/rest/neutron.py
@@ -51,7 +51,6 @@ class Networks(generic.View):
network, which is up (true) or down (false).
:param name (optional): The network name. A request body is optional:
If you include it, it can specify this optional attribute.
- :param net_profile_id (optional): network profile id
:param shared (optional): Indicates whether this network is shared
across all tenants. By default, only administrative users can
change this value.
@@ -64,8 +63,6 @@ class Networks(generic.View):
:return: JSON representation of a Network
"""
- if not api.neutron.is_port_profiles_supported():
- request.DATA.pop("net_profile_id", None)
new_network = api.neutron.network_create(request, **request.DATA)
return rest_utils.CreatedResponse(
'/api/neutron/networks/%s' % new_network.id,
diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py
index 592cfe1d6c..c9d9e614f5 100644
--- a/openstack_dashboard/dashboards/admin/networks/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/forms.py
@@ -94,13 +94,6 @@ class CreateNetwork(forms.SelfHandlingForm):
label=_("Name"),
required=False)
tenant_id = forms.ThemableChoiceField(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 "
@@ -161,9 +154,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))
try:
is_extension_supported = \
api.neutron.is_extension_supported(request, 'provider')
@@ -248,21 +238,6 @@ class CreateNetwork(forms.SelfHandlingForm):
else:
self.fields['network_type'].choices = network_type_choices
- 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()
@@ -278,8 +253,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
diff --git a/openstack_dashboard/dashboards/admin/networks/tests.py b/openstack_dashboard/dashboards/admin/networks/tests.py
index a1598bb049..b0ccb42478 100644
--- a/openstack_dashboard/dashboards/admin/networks/tests.py
+++ b/openstack_dashboard/dashboards/admin/networks/tests.py
@@ -364,18 +364,12 @@ class NetworkTests(test.BaseAdminViewTests):
subnets = res.context['subnets_table'].data
self.assertItemsEqual(subnets, [self.subnets.first()])
- @test.create_stubs({api.neutron: ('profile_list',
- 'is_extension_supported',),
+ @test.create_stubs({api.neutron: ('is_extension_supported',),
api.keystone: ('tenant_list',)})
- def test_network_create_get(self,
- test_with_profile=False):
+ def test_network_create_get(self):
tenants = self.tenants.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.is_extension_supported(IsA(http.HttpRequest), 'provider').\
AndReturn(True)
self.mox.ReplayAll()
@@ -385,18 +379,11 @@ class NetworkTests(test.BaseAdminViewTests):
self.assertTemplateUsed(res, 'horizon/common/_workflow_base.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',
'is_extension_supported',
'subnetpool_list'),
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()
@@ -410,12 +397,6 @@ class NetworkTests(test.BaseAdminViewTests):
'shared': True,
'provider:network_type': 'local',
'with_subnet': False}
- 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.is_extension_supported(IsA(http.HttpRequest), 'provider').\
MultipleTimes().AndReturn(True)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
@@ -434,8 +415,6 @@ 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)
@@ -444,12 +423,10 @@ class NetworkTests(test.BaseAdminViewTests):
@test.create_stubs({api.neutron: ('network_create',
'subnet_create',
- 'profile_list',
'is_extension_supported',
'subnetpool_list'),
api.keystone: ('tenant_list',)})
- def test_network_create_post_with_subnet(self,
- test_with_profile=False):
+ def test_network_create_post_with_subnet(self):
tenants = self.tenants.list()
tenant_id = self.tenants.first().id
network = self.networks.first()
@@ -465,12 +442,6 @@ class NetworkTests(test.BaseAdminViewTests):
api.keystone.tenant_list(IsA(http.HttpRequest))\
.AndReturn([tenants, False])
- 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.is_extension_supported(IsA(http.HttpRequest), 'provider').\
MultipleTimes().AndReturn(True)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
@@ -489,8 +460,6 @@ class NetworkTests(test.BaseAdminViewTests):
'shared': True,
'network_type': 'local',
'with_subnet': True}
- if test_with_profile:
- form_data['net_profile_id'] = net_profile_id
form_data.update(tests.form_data_subnet(subnet, allocation_pools=[]))
url = reverse('horizon:admin:networks:create')
res = self.client.post(url, form_data)
@@ -498,18 +467,11 @@ class NetworkTests(test.BaseAdminViewTests):
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',
'is_extension_supported',
'subnetpool_list'),
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()
@@ -523,12 +485,6 @@ class NetworkTests(test.BaseAdminViewTests):
'shared': False,
'provider:network_type': 'local',
'with_subnet': False}
- 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.is_extension_supported(IsA(http.HttpRequest), 'provider').\
MultipleTimes().AndReturn(True)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
@@ -546,20 +502,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: ('is_extension_supported',),
api.keystone: ('tenant_list',)})
def test_network_create_vlan_segmentation_id_invalid(self):
diff --git a/openstack_dashboard/dashboards/admin/networks/workflows.py b/openstack_dashboard/dashboards/admin/networks/workflows.py
index 77a05a3aab..ff98b33d0d 100644
--- a/openstack_dashboard/dashboards/admin/networks/workflows.py
+++ b/openstack_dashboard/dashboards/admin/networks/workflows.py
@@ -44,7 +44,7 @@ class CreateNetworkInfoAction(network_workflows.CreateNetworkInfoAction):
class CreateNetworkInfo(network_workflows.CreateNetworkInfo):
action_class = CreateNetworkInfoAction
- contributes = ("net_name", "admin_state", "net_profile_id", "with_subnet")
+ contributes = ("net_name", "admin_state", "with_subnet")
def __init__(self, workflow):
self.contributes = tuple(workflow.create_network_form.fields.keys())
diff --git a/openstack_dashboard/dashboards/project/instances/tests.py b/openstack_dashboard/dashboards/project/instances/tests.py
index bd3a9a20be..446e68ad1e 100644
--- a/openstack_dashboard/dashboards/project/instances/tests.py
+++ b/openstack_dashboard/dashboards/project/instances/tests.py
@@ -1564,7 +1564,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
cinder: ('volume_snapshot_list',
'volume_list',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.glance: ('image_list_detailed',),
quotas: ('tenant_limit_usages',)})
@@ -1575,8 +1574,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
only_one_network=False,
disk_config=True,
config_drive=True,
- config_drive_default=False,
- test_with_profile=False):
+ config_drive_default=False):
image = self.versioned_images.first()
api.nova.extension_supported('BlockDeviceMappingV2Boot',
@@ -1615,10 +1613,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
network_id=net.id) \
.AndReturn(self.ports.list())
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(disk_config)
@@ -1796,11 +1790,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_launch_instance_get_with_only_one_network(self):
self.test_launch_instance_get(only_one_network=True)
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_instance_get_with_profile(self):
- self.test_launch_instance_get(test_with_profile=True)
-
@helpers.create_stubs({api.nova: ('extension_supported',
'flavor_list',
'keypair_list',
@@ -1810,7 +1799,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
cinder: ('volume_snapshot_list',
'volume_list',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.glance: ('image_list_detailed',),
quotas: ('tenant_limit_usages',)})
@@ -1818,8 +1806,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
block_device_mapping_v2=True,
only_one_network=False,
disk_config=True,
- config_drive=True,
- test_with_profile=False):
+ config_drive=True):
api.nova.extension_supported('BlockDeviceMappingV2Boot',
IsA(http.HttpRequest)) \
.AndReturn(block_device_mapping_v2)
@@ -1856,10 +1843,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.neutron.port_list(IsA(http.HttpRequest),
network_id=net.id) \
.AndReturn(self.ports.list())
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(disk_config)
@@ -1902,14 +1885,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_launch_instance_get_bootable_volumes_glance_v1(self):
self.test_launch_instance_get_bootable_volumes()
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_instance_get_bootable_volumes_with_profile(self):
- self.test_launch_instance_get_bootable_volumes(test_with_profile=True)
-
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_create',
'port_list'),
api.nova: ('extension_supported',
@@ -1924,9 +1901,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
quotas: ('tenant_quota_usages',)})
def test_launch_instance_post(self,
disk_config=True,
- config_drive=True,
- test_with_profile=False,
- test_with_multi_nics=False):
+ config_drive=True):
flavor = self.flavors.first()
image = self.versioned_images.first()
keypair = self.keypairs.first()
@@ -1940,27 +1915,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self._mock_nova_glance_neutron_lists()
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- policy_profile_id = self.policy_profiles.first().id
- port_one = self.ports.first()
- nics = [{"port-id": port_one.id}]
- api.neutron.profile_list(
- IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
- api.neutron.port_create(IsA(http.HttpRequest),
- self.networks.first().id,
- policy_profile_id=policy_profile_id) \
- .AndReturn(port_one)
- if test_with_multi_nics:
- port_two = self.ports.get(name="port5")
- nics = [{"port-id": port_one.id},
- {"port-id": port_two.id}]
- # Add a second port to test multiple nics
- api.neutron.port_create(IsA(http.HttpRequest),
- self.networks.get(name="net4")['id'],
- policy_profile_id=policy_profile_id) \
- .AndReturn(port_two)
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(disk_config)
@@ -2026,11 +1980,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
form_data['disk_config'] = 'AUTO'
if config_drive:
form_data['config_drive'] = True
- if test_with_profile:
- form_data['profile'] = self.policy_profiles.first().id
- if test_with_multi_nics:
- form_data['network'] = [self.networks.first().id,
- self.networks.get(name="net4")['id']]
url = reverse('horizon:project:instances:launch')
res = self.client.post(url, form_data)
@@ -2047,148 +1996,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_launch_instance_post_no_config_drive_supported(self):
self.test_launch_instance_post(config_drive=False)
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_instance_post_with_profile(self):
- self.test_launch_instance_post(test_with_profile=True)
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_instance_post_with_profile_and_multi_nics(self):
- self.test_launch_instance_post(test_with_profile=True,
- test_with_multi_nics=True)
-
- def _test_launch_instance_post_with_profile_and_port_error(
- self,
- test_with_multi_nics=False,
- ):
- flavor = self.flavors.first()
- image = self.versioned_images.first()
- keypair = self.keypairs.first()
- server = self.servers.first()
- sec_group = self.security_groups.first()
- avail_zone = self.availability_zones.first()
- customization_script = 'user data'
- quota_usages = self.quota_usages.first()
-
- self._mock_nova_glance_neutron_lists()
-
- policy_profiles = self.policy_profiles.list()
- policy_profile_id = self.policy_profiles.first().id
- port_one = self.ports.first()
- api.neutron.profile_list(
- IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
- if test_with_multi_nics:
- api.neutron.port_create(IsA(http.HttpRequest),
- self.networks.first().id,
- policy_profile_id=policy_profile_id) \
- .AndReturn(port_one)
- # Add a second port which has the exception to test multiple nics
- api.neutron.port_create(IsA(http.HttpRequest),
- self.networks.get(name="net4")['id'],
- policy_profile_id=policy_profile_id) \
- .AndRaise(self.exceptions.neutron)
- # Delete the first port
- api.neutron.port_delete(IsA(http.HttpRequest),
- port_one.id)
- else:
- api.neutron.port_create(IsA(http.HttpRequest),
- self.networks.first().id,
- policy_profile_id=policy_profile_id) \
- .AndRaise(self.exceptions.neutron)
- api.nova.extension_supported('DiskConfig',
- IsA(http.HttpRequest)) \
- .AndReturn(True)
- api.nova.extension_supported('ConfigDrive',
- IsA(http.HttpRequest)).AndReturn(True)
- api.nova.extension_supported('ServerGroups',
- IsA(http.HttpRequest)).AndReturn(False)
- cinder.volume_list(IsA(http.HttpRequest),
- search_opts=VOLUME_SEARCH_OPTS) \
- .AndReturn([])
- cinder.volume_snapshot_list(IsA(http.HttpRequest),
- search_opts=SNAPSHOT_SEARCH_OPTS) \
- .AndReturn([])
- quotas.tenant_quota_usages(IsA(http.HttpRequest)) \
- .AndReturn(quota_usages)
- api.nova.flavor_list(IsA(http.HttpRequest)) \
- .AndReturn(self.flavors.list())
-
- self.mox.ReplayAll()
-
- form_data = {'flavor': flavor.id,
- 'source_type': 'image_id',
- 'image_id': image.id,
- 'keypair': keypair.name,
- 'name': server.name,
- 'script_source': 'raw',
- 'script_data': customization_script,
- 'project_id': self.tenants.first().id,
- 'user_id': self.user.id,
- 'groups': str(sec_group.id),
- 'availability_zone': avail_zone.zoneName,
- 'volume_type': '',
- 'network': self.networks.first().id,
- 'count': 1,
- 'disk_config': 'AUTO',
- 'config_drive': True,
- 'profile': self.policy_profiles.first().id}
- if test_with_multi_nics:
- form_data['network'] = [self.networks.first().id,
- self.networks.get(name="net4")['id']]
- url = reverse('horizon:project:instances:launch')
- res = self.client.post(url, form_data)
-
- self.assertNoFormErrors(res)
- self.assertRedirectsNoFollow(res, INDEX_URL)
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
- 'port_create',
- 'port_delete',
- 'port_list'),
- api.nova: ('extension_supported',
- 'flavor_list',
- 'keypair_list',
- 'availability_zone_list',),
- api.network: ('security_group_list',),
- cinder: ('volume_list',
- 'volume_snapshot_list',),
- quotas: ('tenant_quota_usages',)})
- def test_launch_instance_post_with_profile_and_port_error(self):
- self._test_launch_instance_post_with_profile_and_port_error()
-
- @override_settings(OPENSTACK_API_VERSIONS={'image': 1})
- def test_launch_instance_post_with_profile_and_port_error_glance_v1(self):
- self.test_launch_instance_post_with_profile_and_port_error()
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- @helpers.create_stubs({api.glance: ('image_list_detailed',),
- api.neutron: ('network_list',
- 'profile_list',
- 'port_create',
- 'port_delete',
- 'port_list'),
- api.nova: ('extension_supported',
- 'flavor_list',
- 'keypair_list',
- 'availability_zone_list',),
- api.network: ('security_group_list',),
- cinder: ('volume_list',
- 'volume_snapshot_list',),
- quotas: ('tenant_quota_usages',)})
- def test_lnch_inst_post_w_profile_and_multi_nics_w_port_error(self):
- self._test_launch_instance_post_with_profile_and_port_error(
- test_with_multi_nics=True)
-
- @helpers.create_stubs({api.glance: ('image_list_detailed',),
- api.neutron: ('network_list',
- 'profile_list',
'port_create',
'port_list'),
api.nova: ('extension_supported',
@@ -2202,7 +2011,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
quotas: ('tenant_quota_usages',)})
def test_launch_instance_post_boot_from_volume(
self,
- test_with_profile=False,
test_with_bdmv2=False
):
flavor = self.flavors.first()
@@ -2238,18 +2046,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova.flavor_list(IsA(http.HttpRequest)) \
.AndReturn(self.flavors.list())
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- policy_profile_id = self.policy_profiles.first().id
- port = self.ports.first()
- api.neutron.profile_list(
- IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
- api.neutron.port_create(
- IsA(http.HttpRequest),
- self.networks.first().id,
- policy_profile_id=policy_profile_id).AndReturn(port)
- nics = [{"port-id": port.id}]
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -2308,8 +2104,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'count': 1,
'disk_config': 'AUTO',
'config_drive': True}
- if test_with_profile:
- form_data['profile'] = self.policy_profiles.first().id
url = reverse('horizon:project:instances:launch')
res = self.client.post(url, form_data)
@@ -2323,14 +2117,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_launch_instance_post_boot_from_volume_with_bdmv2(self):
self.test_launch_instance_post_boot_from_volume(test_with_bdmv2=True)
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_instance_post_boot_from_volume_with_profile(self):
- self.test_launch_instance_post_boot_from_volume(test_with_profile=True)
-
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_create',
'port_list'),
api.nova: ('server_create',
@@ -2343,10 +2131,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
- def test_launch_instance_post_no_images_available_boot_from_volume(
- self,
- test_with_profile=False,
- ):
+ def test_launch_instance_post_no_images_available_boot_from_volume(self):
flavor = self.flavors.first()
keypair = self.keypairs.first()
server = self.servers.first()
@@ -2364,18 +2149,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova.flavor_list(IsA(http.HttpRequest)) \
.AndReturn(self.flavors.list())
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- policy_profile_id = self.policy_profiles.first().id
- port = self.ports.first()
- api.neutron.profile_list(
- IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
- api.neutron.port_create(
- IsA(http.HttpRequest),
- self.networks.first().id,
- policy_profile_id=policy_profile_id).AndReturn(port)
- nics = [{"port-id": port.id}]
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -2435,8 +2208,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'count': 1,
'disk_config': 'MANUAL',
'config_drive': True}
- if test_with_profile:
- form_data['profile'] = self.policy_profiles.first().id
url = reverse('horizon:project:instances:launch')
res = self.client.post(url, form_data)
@@ -2447,15 +2218,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_lnch_inst_post_no_images_avail_boot_from_volume_glance_v1(self):
self.test_launch_instance_post_no_images_available_boot_from_volume()
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_lnch_inst_post_no_images_avail_boot_from_vol_with_profile(self):
- self.test_launch_instance_post_no_images_available_boot_from_volume(
- test_with_profile=True)
-
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.nova: ('extension_supported',
'flavor_list',
@@ -2466,8 +2230,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',
'tenant_limit_usages')})
- def test_launch_instance_post_no_images_available(self,
- test_with_profile=False):
+ def test_launch_instance_post_no_images_available(self):
flavor = self.flavors.first()
keypair = self.keypairs.first()
server = self.servers.first()
@@ -2489,10 +2252,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova.flavor_list(IsA(http.HttpRequest)) \
.AndReturn(self.flavors.list())
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -2533,16 +2292,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self.assertFormErrors(res, 1, "You must select an image.")
self.assertTemplateUsed(res, views.WorkflowView.template_name)
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_instance_post_no_images_available_with_profile(self):
- self.test_launch_instance_post_no_images_available(
- test_with_profile=True)
-
@helpers.create_stubs({
api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_create',
'port_list'),
api.nova: ('extension_supported',
@@ -2557,7 +2309,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
quotas: ('tenant_quota_usages',)})
def test_launch_instance_post_boot_from_snapshot(
self,
- test_with_profile=False,
test_with_bdmv2=False
):
flavor = self.flavors.first()
@@ -2594,18 +2345,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova.flavor_list(IsA(http.HttpRequest)) \
.AndReturn(self.flavors.list())
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- policy_profile_id = self.policy_profiles.first().id
- port = self.ports.first()
- api.neutron.profile_list(
- IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
- api.neutron.port_create(
- IsA(http.HttpRequest),
- self.networks.first().id,
- policy_profile_id=policy_profile_id).AndReturn(port)
- nics = [{"port-id": port.id}]
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -2665,8 +2404,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'count': 1,
'disk_config': 'AUTO',
'config_drive': True}
- if test_with_profile:
- form_data['profile'] = self.policy_profiles.first().id
url = reverse('horizon:project:instances:launch')
res = self.client.post(url, form_data)
@@ -2680,19 +2417,11 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_launch_instance_post_boot_from_snapshot_with_bdmv2(self):
self.test_launch_instance_post_boot_from_snapshot(test_with_bdmv2=True)
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_instance_post_boot_from_snapshot_with_profile(self):
- self.test_launch_instance_post_boot_from_snapshot(
- test_with_profile=True)
-
@helpers.create_stubs({
api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_create',
- 'port_list',
- 'is_port_profiles_supported'),
+ 'port_list'),
api.nova: ('extension_supported',
'flavor_list',
'keypair_list',
@@ -2704,10 +2433,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'volume_snapshot_list',
'tenant_absolute_limits'),
quotas: ('tenant_quota_usages',)})
- def test_launch_instance_post_boot_from_snapshot_error(
- self,
- test_with_profile=False,
- ):
+ def test_launch_instance_post_boot_from_snapshot_error(self):
flavor = self.flavors.first()
keypair = self.keypairs.first()
server = self.servers.first()
@@ -2727,9 +2453,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
quotas.tenant_quota_usages(IsA(http.HttpRequest)) \
.AndReturn(quota_usages)
- api.neutron.is_port_profiles_supported()\
- .MultipleTimes().AndReturn(test_with_profile)
-
self._mock_neutron_network_and_port_list()
api.nova.extension_supported('DiskConfig',
@@ -2757,7 +2480,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'image_id': '',
'device_name': 'vda',
'count': 1,
- 'profile': '',
'customization_script': ''}
url = reverse('horizon:project:instances:launch')
@@ -2767,7 +2489,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
cinder: ('volume_list',
'volume_snapshot_list',),
@@ -2777,8 +2498,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'keypair_list',
'availability_zone_list',),
quotas: ('tenant_limit_usages',)})
- def test_launch_flavorlist_error(self,
- test_with_profile=False):
+ def test_launch_flavorlist_error(self):
api.nova.extension_supported('BlockDeviceMappingV2Boot',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -2792,10 +2512,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self._mock_glance_image_list_detailed(self.versioned_images.list())
self._mock_neutron_network_and_port_list()
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -2827,14 +2543,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_launch_flavorlist_error_glance_v1(self):
self.test_launch_flavorlist_error()
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_flavorlist_error_with_profile(self):
- self.test_launch_flavorlist_error(test_with_profile=True)
-
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_create',
'port_delete',
'port_list'),
@@ -2848,8 +2558,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
- def test_launch_form_keystone_exception(self,
- test_with_profile=False):
+ def test_launch_form_keystone_exception(self):
flavor = self.flavors.first()
image = self.versioned_images.first()
keypair = self.keypairs.first()
@@ -2883,18 +2592,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self._mock_glance_image_list_detailed(self.versioned_images.list())
self._mock_neutron_network_and_port_list()
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- policy_profile_id = self.policy_profiles.first().id
- port = self.ports.first()
- api.neutron.profile_list(
- IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
- api.neutron.port_create(
- IsA(http.HttpRequest),
- self.networks.first().id,
- policy_profile_id=policy_profile_id).AndReturn(port)
- nics = [{"port-id": port.id}]
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -2919,8 +2616,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
config_drive=False,
scheduler_hints={}) \
.AndRaise(self.exceptions.keystone)
- if test_with_profile:
- api.neutron.port_delete(IsA(http.HttpRequest), port.id)
quotas.tenant_quota_usages(IsA(http.HttpRequest)) \
.AndReturn(quota_usages)
api.nova.flavor_list(IsA(http.HttpRequest)) \
@@ -2948,25 +2643,17 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'confirm_admin_pass': 'password',
'disk_config': 'AUTO',
'config_drive': False}
- if test_with_profile:
- form_data['profile'] = self.policy_profiles.first().id
url = reverse('horizon:project:instances:launch')
res = self.client.post(url, form_data)
self.assertRedirectsNoFollow(res, INDEX_URL)
@override_settings(OPENSTACK_API_VERSIONS={'image': 1})
- def test_launch_form_keystone_exception_with_profile_glance_v1(self):
+ def test_launch_form_keystone_exception_with_glance_v1(self):
self.test_launch_form_keystone_exception()
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_form_keystone_exception_with_profile(self):
- self.test_launch_form_keystone_exception(test_with_profile=True)
-
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.nova: ('extension_supported',
'flavor_list',
@@ -2977,8 +2664,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'volume_snapshot_list',),
quotas: ('tenant_limit_usages',
'tenant_quota_usages')})
- def test_launch_form_instance_count_error(self,
- test_with_profile=False):
+ def test_launch_form_instance_count_error(self):
flavor = self.flavors.first()
image = self.versioned_images.first()
keypair = self.keypairs.first()
@@ -2993,10 +2679,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self._mock_nova_glance_neutron_lists()
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -3050,7 +2732,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.nova: ('extension_supported',
'flavor_list',
@@ -3062,8 +2743,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',
'tenant_limit_usages')})
- def _test_launch_form_count_error(self, resource,
- avail, test_with_profile=False):
+ def _test_launch_form_count_error(self, resource, avail):
flavor = self.flavors.first()
image = self.versioned_images.first()
keypair = self.keypairs.first()
@@ -3083,10 +2763,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self._mock_nova_glance_neutron_lists()
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -3147,26 +2823,20 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self.assertContains(res, msg)
def test_launch_form_cores_count_error_glance_v2(self):
- self._test_launch_form_count_error('cores', 1, test_with_profile=False)
+ self._test_launch_form_count_error('cores', 1)
@override_settings(OPENSTACK_API_VERSIONS={'image': 1})
def test_launch_form_cores_count_error_glance_v1(self):
- self._test_launch_form_count_error('cores', 1, test_with_profile=False)
+ self._test_launch_form_count_error('cores', 1)
def test_launch_form_ram_count_error(self):
- self._test_launch_form_count_error('ram', 512, test_with_profile=False)
+ self._test_launch_form_count_error('ram', 512)
def test_launch_form_ram_cores_count_error(self):
- self._test_launch_form_count_error('both', 1, test_with_profile=False)
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_form_instance_count_error_with_profile(self):
- self.test_launch_form_instance_count_error(test_with_profile=True)
+ self._test_launch_form_count_error('both', 1)
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.nova: ('extension_supported',
'flavor_list',
@@ -3178,7 +2848,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
quotas: ('tenant_quota_usages',
'tenant_limit_usages')})
def _test_launch_form_instance_requirement_error(self, image, flavor,
- test_with_profile=False,
keypair_require=False):
keypair = self.keypairs.first()
server = self.servers.first()
@@ -3191,10 +2860,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
quota_usages = self.quota_usages.first()
self._mock_nova_glance_neutron_lists()
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
+
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -3248,47 +2914,26 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
msg = "The flavor '%s' is too small" % flavor.name
self.assertContains(res, msg)
- def test_launch_form_instance_requirement_error_disk(
- self,
- test_with_profile=False,
- ):
+ def test_launch_form_instance_requirement_error_disk(self):
flavor = self.flavors.first()
image = self.versioned_images.first()
image.min_ram = flavor.ram
image.min_disk = flavor.disk + 1
- self._test_launch_form_instance_requirement_error(image, flavor,
- test_with_profile)
+ self._test_launch_form_instance_requirement_error(image, flavor)
@override_settings(OPENSTACK_API_VERSIONS={'image': 1})
def test_launch_form_instance_requirement_error_disk_glance_v1(self):
self.test_launch_form_instance_requirement_error_disk()
- def test_launch_form_instance_requirement_error_ram(
- self,
- test_with_profile=False,
- ):
+ def test_launch_form_instance_requirement_error_ram(self):
flavor = self.flavors.first()
image = self.versioned_images.first()
image.min_ram = flavor.ram + 1
image.min_disk = flavor.disk
- self._test_launch_form_instance_requirement_error(image, flavor,
- test_with_profile)
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_form_instance_requirement_error_disk_with_profile(self):
- self.test_launch_form_instance_requirement_error_disk(
- test_with_profile=True)
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_form_instance_requirement_error_ram_with_profile(self):
- self.test_launch_form_instance_requirement_error_ram(
- test_with_profile=True)
+ self._test_launch_form_instance_requirement_error(image, flavor)
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.nova: ('extension_supported',
'flavor_list',
@@ -3432,7 +3077,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.nova: ('extension_supported',
'flavor_list',
@@ -3445,7 +3089,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
quotas: ('tenant_quota_usages',
'tenant_limit_usages')})
def _test_launch_form_instance_volume_size(self, image, volume_size, msg,
- test_with_profile=False,
volumes=None):
flavor = self.flavors.get(name='m1.massive')
keypair = self.keypairs.first()
@@ -3475,10 +3118,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self._mock_glance_image_list_detailed(self.versioned_images.list())
self._mock_neutron_network_and_port_list()
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
api.nova.extension_supported('DiskConfig',
IsA(http.HttpRequest)) \
.AndReturn(True)
@@ -3529,43 +3168,27 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
res = self.client.post(url, form_data)
self.assertContains(res, msg)
- def test_launch_form_instance_volume_size_error(self,
- test_with_profile=False):
+ def test_launch_form_instance_volume_size_error(self):
image = self.versioned_images.get(name='protected_images')
volume_size = image.min_disk // 2
msg = ("The Volume size is too small for the '%s' image" %
image.name)
- self._test_launch_form_instance_volume_size(image, volume_size, msg,
- test_with_profile)
+ self._test_launch_form_instance_volume_size(image, volume_size, msg)
@override_settings(OPENSTACK_API_VERSIONS={'image': 1})
def test_launch_form_instance_volume_size_error_glance_v1(self):
self.test_launch_form_instance_volume_size_error()
- def test_launch_form_instance_non_int_volume_size(self,
- test_with_profile=False):
+ def test_launch_form_instance_non_int_volume_size(self):
image = self.versioned_images.get(name='protected_images')
msg = "Enter a whole number."
- self._test_launch_form_instance_volume_size(image, 1.5, msg,
- test_with_profile)
+ self._test_launch_form_instance_volume_size(image, 1.5, msg)
def test_launch_form_instance_volume_exceed_quota(self):
image = self.versioned_images.get(name='protected_images')
msg = "Requested volume exceeds quota: Available: 0, Requested: 1"
self._test_launch_form_instance_volume_size(image, image.min_disk,
- msg, False, 0)
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_form_instance_volume_size_error_with_profile(self):
- self.test_launch_form_instance_volume_size_error(
- test_with_profile=True)
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_launch_form_instance_non_int_volume_size_with_profile(self):
- self.test_launch_form_instance_non_int_volume_size(
- test_with_profile=True)
+ msg, 0)
@helpers.create_stubs({
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
@@ -3809,12 +3432,10 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
cinder: ('volume_snapshot_list',
'volume_list',),
api.neutron: ('network_list',
- 'profile_list',
'port_list'),
api.glance: ('image_list_detailed',),
quotas: ('tenant_limit_usages',)})
- def test_select_default_keypair_if_only_one(self,
- test_with_profile=False):
+ def test_select_default_keypair_if_only_one(self):
keypair = self.keypairs.first()
cinder.volume_list(IsA(http.HttpRequest),
@@ -3827,10 +3448,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self._mock_glance_image_list_detailed(self.versioned_images.list())
self._mock_neutron_network_and_port_list()
- if test_with_profile:
- policy_profiles = self.policy_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'policy').AndReturn(policy_profiles)
quotas.tenant_limit_usages(IsA(http.HttpRequest))\
.AndReturn(self.limits['absolute'])
api.nova.extension_supported('BlockDeviceMappingV2Boot',
@@ -3861,11 +3478,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_select_default_keypair_if_only_one_glance_v1(self):
self.test_select_default_keypair_if_only_one()
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- def test_select_default_keypair_if_only_one_with_profile(self):
- self.test_select_default_keypair_if_only_one(test_with_profile=True)
-
@helpers.create_stubs({api.network: ('floating_ip_target_get_by_instance',
'tenant_floating_ip_allocate',
'floating_ip_associate',
@@ -4842,156 +4454,3 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
-
- @helpers.update_settings(
- OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
- @helpers.create_stubs({api.glance: ('image_list_detailed',),
- api.neutron: ('network_list',
- 'profile_list',
- 'port_create',
- 'port_delete',
- 'port_list'),
- api.nova: ('extension_supported',
- 'flavor_list',
- 'keypair_list',
- 'availability_zone_list',
- 'server_group_list',
- 'server_create',),
- api.network: ('security_group_list',),
- cinder: ('volume_list',
- 'volume_snapshot_list',),
- quotas: ('tenant_quota_usages',)})
- def _test_port_cleanup_called_on_failed_vm_launch(self, image, images):
- flavor = self.flavors.first()
- keypair = self.keypairs.first()
- server = self.servers.first()
- sec_group = self.security_groups.first()
- avail_zone = self.availability_zones.first()
- customization_script = 'user data'
- quota_usages = self.quota_usages.first()
-
- api.nova.extension_supported('BlockDeviceMappingV2Boot',
- IsA(http.HttpRequest)) \
- .AndReturn(True)
- volumes = [v for v in self.volumes.list() if (v.status == AVAILABLE
- and v.bootable ==
- 'true')]
- cinder.volume_list(IsA(http.HttpRequest),
- search_opts=VOLUME_SEARCH_OPTS) \
- .AndReturn(volumes)
- volumes = [v for v in self.volumes.list() if (v.status == AVAILABLE)]
- cinder.volume_snapshot_list(IsA(http.HttpRequest),
- search_opts=SNAPSHOT_SEARCH_OPTS) \
- .AndReturn(volumes)
- api.nova.flavor_list(IgnoreArg()).AndReturn(self.flavors.list())
- api.nova.keypair_list(IgnoreArg()).AndReturn(self.keypairs.list())
- api.network.security_group_list(IsA(http.HttpRequest)) \
- .AndReturn(self.security_groups.list())
- api.nova.availability_zone_list(IsA(http.HttpRequest)) \
- .AndReturn(self.availability_zones.list())
- api.glance.image_list_detailed(
- IsA(http.HttpRequest),
- filters={'is_public': True, 'status': 'active'}) \
- .AndReturn([images, False, False])
- api.glance.image_list_detailed(
- IsA(http.HttpRequest),
- filters={'property-owner_id': self.tenant.id,
- 'status': 'active'}) \
- .AndReturn([[], False, False])
- api.neutron.network_list(IsA(http.HttpRequest),
- tenant_id=self.tenant.id,
- shared=False) \
- .AndReturn(self.networks.list()[:1])
- api.neutron.network_list(IsA(http.HttpRequest),
- shared=True) \
- .AndReturn(self.networks.list()[1:])
- api.neutron.network_list(IsA(http.HttpRequest),
- tenant_id=self.tenant.id,
- shared=False) \
- .AndReturn(self.networks.list()[:1])
- api.neutron.network_list(IsA(http.HttpRequest),
- shared=True) \
- .AndReturn(self.networks.list()[1:])
- for net in self.networks.list():
- api.neutron.port_list(IsA(http.HttpRequest),
- network_id=net.id) \
- .AndReturn(self.ports.list())
- policy_profiles = self.policy_profiles.list()
- policy_profile_id = self.policy_profiles.first().id
- port = self.ports.first()
- api.neutron.profile_list(
- IsA(http.HttpRequest), 'policy').AndReturn(policy_profiles)
- api.neutron.port_create(
- IsA(http.HttpRequest),
- self.networks.first().id,
- policy_profile_id=policy_profile_id).AndReturn(port)
- nics = [{"port-id": port.id}]
- api.nova.extension_supported('DiskConfig',
- IsA(http.HttpRequest)) \
- .AndReturn(True)
- api.nova.extension_supported('ConfigDrive',
- IsA(http.HttpRequest)).AndReturn(True)
- api.nova.extension_supported('ServerGroups',
- IsA(http.HttpRequest)).AndReturn(True)
- api.nova.server_group_list(IsA(http.HttpRequest)).AndReturn([])
- api.nova.server_create(IsA(http.HttpRequest),
- server.name,
- image.id,
- flavor.id,
- keypair.name,
- customization_script,
- [str(sec_group.id)],
- block_device_mapping=None,
- block_device_mapping_v2=None,
- nics=nics,
- availability_zone=avail_zone.zoneName,
- instance_count=IsA(int),
- admin_pass='password',
- disk_config='AUTO',
- config_drive=False,
- scheduler_hints={}) \
- .AndRaise(self.exceptions.neutron)
- api.neutron.port_delete(IsA(http.HttpRequest), port.id)
- quotas.tenant_quota_usages(IsA(http.HttpRequest)) \
- .AndReturn(quota_usages)
- api.nova.flavor_list(IsA(http.HttpRequest)) \
- .AndReturn(self.flavors.list())
-
- self.mox.ReplayAll()
-
- form_data = {'flavor': flavor.id,
- 'source_type': 'image_id',
- 'source_id': image.id,
- 'volume_size': '1',
- 'image_id': image.id,
- 'availability_zone': avail_zone.zoneName,
- 'keypair': keypair.name,
- 'name': server.name,
- 'script_source': 'raw',
- 'script_data': customization_script,
- 'project_id': self.tenants.first().id,
- 'user_id': self.user.id,
- 'groups': [str(sec_group.id)],
- 'volume_type': '',
- 'network': self.networks.first().id,
- 'count': 1,
- 'admin_pass': 'password',
- 'confirm_admin_pass': 'password',
- 'disk_config': 'AUTO',
- 'config_drive': False,
- 'profile': self.policy_profiles.first().id}
- url = reverse('horizon:project:instances:launch')
- res = self.client.post(url, form_data)
-
- self.assertRedirectsNoFollow(res, INDEX_URL)
-
- @override_settings(OPENSTACK_API_VERSIONS={'image': 1})
- def test_port_cleanup_called_on_failed_vm_launch_v1(self):
- image = self.images.first()
- images = self.images.list()
- self._test_port_cleanup_called_on_failed_vm_launch(image, images)
-
- def test_port_cleanup_called_on_failed_vm_launch_v2(self):
- image = self.imagesV2.first()
- images = self.imagesV2.list()
- self._test_port_cleanup_called_on_failed_vm_launch(image, images)
diff --git a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
index 1ee4dfcc3c..75670ecef5 100644
--- a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
+++ b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
@@ -713,24 +713,12 @@ class SetNetworkAction(workflows.Action):
" be specified.")},
help_text=_("Launch instance with"
" these networks"))
- if api.neutron.is_port_profiles_supported():
- widget = None
- else:
- widget = forms.HiddenInput()
- profile = forms.ChoiceField(label=_("Policy Profiles"),
- required=False,
- widget=widget,
- help_text=_("Launch instance with "
- "this policy profile"))
def __init__(self, request, *args, **kwargs):
super(SetNetworkAction, self).__init__(request, *args, **kwargs)
network_list = self.fields["network"].choices
if len(network_list) == 1:
self.fields['network'].initial = [network_list[0][0]]
- if api.neutron.is_port_profiles_supported():
- self.fields['profile'].choices = (
- self.get_policy_profile_choices(request))
class Meta(object):
name = _("Networking")
@@ -740,32 +728,11 @@ class SetNetworkAction(workflows.Action):
def populate_network_choices(self, request, context):
return instance_utils.network_field_data(request)
- def get_policy_profile_choices(self, request):
- profile_choices = [('', _("Select a profile"))]
- for profile in self._get_profiles(request, 'policy'):
- 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
-
class SetNetwork(workflows.Step):
action_class = SetNetworkAction
- # Disabling the template drag/drop only in the case port profiles
- # are used till the issue with the drag/drop affecting the
- # profile_id detection is fixed.
- if api.neutron.is_port_profiles_supported():
- contributes = ("network_id", "profile_id",)
- else:
- template_name = "project/instances/_update_networks.html"
- contributes = ("network_id",)
+ template_name = "project/instances/_update_networks.html"
+ contributes = ("network_id",)
def contribute(self, data, context):
if data:
@@ -775,9 +742,6 @@ class SetNetwork(workflows.Step):
networks = [n for n in networks if n != '']
if networks:
context['network_id'] = networks
-
- if api.neutron.is_port_profiles_supported():
- context['profile_id'] = data.get('profile', None)
return context
@@ -977,13 +941,6 @@ class LaunchInstance(workflows.Workflow):
if server_group:
scheduler_hints['group'] = server_group
- port_profiles_supported = api.neutron.is_port_profiles_supported()
-
- if port_profiles_supported:
- nics = self.set_network_port_profiles(request,
- context['network_id'],
- context['profile_id'])
-
ports = context.get('ports')
if ports:
if nics is None:
@@ -1009,54 +966,9 @@ class LaunchInstance(workflows.Workflow):
scheduler_hints=scheduler_hints)
return True
except Exception:
- if port_profiles_supported:
- ports_failing_deletes = _cleanup_ports_on_failed_vm_launch(
- request, nics)
- if ports_failing_deletes:
- ports_str = ', '.join(ports_failing_deletes)
- msg = (_('Port cleanup failed for these port-ids (%s).')
- % ports_str)
- exceptions.handle(request, msg)
exceptions.handle(request)
return False
- def set_network_port_profiles(self, request, net_ids, profile_id):
- # Create port with Network ID and Port Profile
- # for the use with the plugin supporting port profiles.
- nics = []
- for net_id in net_ids:
- try:
- port = api.neutron.port_create(
- request,
- net_id,
- policy_profile_id=profile_id,
- )
- except Exception as e:
- msg = (_('Unable to create port for profile '
- '"%(profile_id)s": %(reason)s'),
- {'profile_id': profile_id,
- 'reason': e})
- for nic in nics:
- try:
- port_id = nic['port-id']
- api.neutron.port_delete(request, port_id)
- except Exception:
- msg = (msg +
- _(' Also failed to delete port %s') % port_id)
- redirect = self.success_url
- exceptions.handle(request, msg, redirect=redirect)
-
- if port:
- nics.append({"port-id": port.id})
- LOG.debug("Created Port %(portid)s with "
- "network %(netid)s "
- "policy profile %(profile_id)s",
- {'portid': port.id,
- 'netid': net_id,
- 'profile_id': profile_id})
-
- return nics
-
def _cleanup_ports_on_failed_vm_launch(request, nics):
ports_failing_deletes = []
diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py
index 659dc5d2b7..6adc470c8e 100644
--- a/openstack_dashboard/dashboards/project/networks/tests.py
+++ b/openstack_dashboard/dashboards/project/networks/tests.py
@@ -341,20 +341,14 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
subnets = res.context['subnets_table'].data
self.assertItemsEqual(subnets, [self.subnets.first()])
- @test.create_stubs({api.neutron: ('profile_list',
- 'is_extension_supported',
+ @test.create_stubs({api.neutron: ('is_extension_supported',
'subnetpool_list')})
- def test_network_create_get(self,
- test_with_profile=False):
+ def test_network_create_get(self):
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
AndReturn(True)
api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
AndReturn(self.subnetpools.list())
- if test_with_profile:
- net_profiles = self.net_profiles.list()
- api.neutron.profile_list(IsA(http.HttpRequest),
- 'network').AndReturn(net_profiles)
self.mox.ReplayAll()
url = reverse('horizon:project:networks:create')
@@ -368,27 +362,14 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'