Remove all remaining vendor specific code

There's some vendor specific code still lingering from several cycles
ago. This patch removes all usage of it, all related tests, and all
default settings.

Implements: blueprint horizon-vendor-split
Change-Id: Ic0bb84f547b07b130480e587bd365f6e7805dfb5
This commit is contained in:
Rob Cresswell 2017-03-13 17:00:23 +00:00 committed by Akihiro Motoki
parent f084006845
commit a8f17150bf
19 changed files with 66 additions and 1400 deletions

View File

@ -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``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -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")

View File

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

View File

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

View File

@ -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):

View File

@ -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())

View File

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

View File

@ -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 = []

View File

@ -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):
'<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',
'is_extension_supported',
'subnetpool_list')})
def test_network_create_post(self,
test_with_profile=False):
def test_network_create_post(self):
network = self.networks.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up,
'shared': 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),
'subnet_allocation').\
AndReturn(True)
@ -403,8 +384,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'shared': False,
# 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)
@ -413,20 +392,13 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_stubs({api.neutron: ('network_create',
'profile_list',
'is_extension_supported',
'subnetpool_list')})
def test_network_create_post_with_shared(self, test_with_profile=False):
def test_network_create_post_with_shared(self):
network = self.networks.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up,
'shared': True}
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),
'subnet_allocation').\
AndReturn(True)
@ -441,8 +413,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'shared': True,
# 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,18 +420,11 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
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',
'is_extension_supported',
'subnetpool_list')})
def test_network_create_post_with_subnet(self,
test_with_profile=False,
test_with_ipv6=True):
network = self.networks.first()
subnet = self.subnets.first()
@ -474,12 +437,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'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
@ -498,8 +455,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'admin_state': network.admin_state_up,
'shared': False,
'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)
@ -507,31 +462,18 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
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',
'is_extension_supported',
'subnetpool_list')})
def test_network_create_post_network_exception(self,
test_with_profile=False):
def test_network_create_post_network_exception(self):
network = self.networks.first()
params = {'name': network.name,
'shared': False,
'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.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
AndReturn(True)
@ -546,8 +488,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
# subnet
'shared': False,
'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)
@ -555,19 +495,11 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
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',
'is_extension_supported',
'subnetpool_list')})
def test_network_create_post_with_subnet_network_exception(
self,
test_with_profile=False,
test_with_subnetpool=False,
):
network = self.networks.first()
@ -575,12 +507,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
params = {'name': network.name,
'shared': False,
'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.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
AndReturn(True)
@ -594,8 +520,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'admin_state': network.admin_state_up,
'shared': False,
'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)
@ -603,33 +527,17 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
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',
'is_extension_supported',
'subnetpool_list',)})
def test_network_create_post_with_subnet_subnet_exception(
self,
test_with_profile=False,
):
def test_network_create_post_with_subnet_subnet_exception(self):
network = self.networks.first()
subnet = self.subnets.first()
params = {'name': network.name,
'shared': False,
'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.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
AndReturn(True)
@ -653,8 +561,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'admin_state': network.admin_state_up,
'shared': False,
'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)
@ -662,25 +568,12 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
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',
'is_extension_supported',
@test.create_stubs({api.neutron: ('is_extension_supported',
'subnetpool_list',)})
def test_network_create_post_with_subnet_nocidr(self,
test_with_profile=False,
test_with_snpool=False):
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)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
AndReturn(True)
@ -692,8 +585,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'admin_state': network.admin_state_up,
'shared': False,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
if test_with_snpool:
form_data['subnetpool_id'] = ''
form_data['prefixlen'] = ''
@ -706,31 +597,18 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'clear "Create Subnet" checkbox'
' in previous step.'))
@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)
def test_network_create_post_with_subnet_nocidr_nosubnetpool(self):
self.test_network_create_post_with_subnet_nocidr(
test_with_snpool=True)
@test.create_stubs({api.neutron: ('profile_list',
'is_extension_supported',
@test.create_stubs({api.neutron: ('is_extension_supported',
'subnetpool_list',)})
def test_network_create_post_with_subnet_cidr_without_mask(
self,
test_with_profile=False,
test_with_subnetpool=False,
):
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)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
AndReturn(True)
@ -742,8 +620,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'shared': False,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
if test_with_subnetpool:
subnetpool = self.subnetpools.first()
form_data['subnetpool'] = subnetpool.id
@ -756,12 +632,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
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)
def test_network_create_post_with_subnet_cidr_without_mask_w_snpool(self):
self.test_network_create_post_with_subnet_cidr_without_mask(
test_with_subnetpool=True)
@ -769,20 +639,13 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
@test.update_settings(
ALLOWED_PRIVATE_SUBNET_CIDR={'ipv4': ['192.168.0.0/16']})
@test.create_stubs({api.neutron: ('is_extension_supported',
'profile_list',
'subnetpool_list')})
def test_network_create_post_with_subnet_cidr_invalid_v4_range(
self,
test_with_profile=False,
test_with_subnetpool=False
):
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)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
@ -795,8 +658,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'shared': False,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
if test_with_subnetpool:
subnetpool = self.subnetpools.first()
form_data['subnetpool'] = subnetpool.id
@ -811,15 +672,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
"are 192.168.0.0/16.")
self.assertContains(res, expected_msg)
@test.update_settings(
ALLOWED_PRIVATE_SUBNET_CIDR={'ipv4': ['192.168.0.0/16']})
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_subnet_cidr_invalid_v4_range_w_profile(
self):
self.test_network_create_post_with_subnet_cidr_invalid_v4_range(
test_with_profile=True)
@test.update_settings(
ALLOWED_PRIVATE_SUBNET_CIDR={'ipv4': ['192.168.0.0/16']})
def test_network_create_post_with_subnet_cidr_invalid_v4_range_w_snpool(
@ -829,22 +681,14 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
@test.update_settings(ALLOWED_PRIVATE_SUBNET_CIDR={'ipv6': ['fc00::/9']})
@test.create_stubs({api.neutron: ('is_extension_supported',
'profile_list',
'subnetpool_list')})
def test_network_create_post_with_subnet_cidr_invalid_v6_range(
self,
test_with_profile=False,
test_with_subnetpool=False
):
network = self.networks.first()
subnet_v6 = self.subnets.list()[3]
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)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
AndReturn(True)
@ -856,8 +700,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'shared': False,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
if test_with_subnetpool:
subnetpool = self.subnetpools.first()
form_data['subnetpool'] = subnetpool.id
@ -872,14 +714,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
"are fc00::/9.")
self.assertContains(res, expected_msg)
@test.update_settings(ALLOWED_PRIVATE_SUBNET_CIDR={'ipv6': ['fc00::/9']})
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_subnet_cidr_invalid_v6_range_w_profile(
self):
self.test_network_create_post_with_subnet_cidr_invalid_v6_range(
test_with_profile=True)
@test.update_settings(ALLOWED_PRIVATE_SUBNET_CIDR={'ipv6': ['fc00::/9']})
def test_network_create_post_with_subnet_cidr_invalid_v6_range_w_snpool(
self):
@ -888,13 +722,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
@test.create_stubs({api.neutron: ('network_create',
'subnet_create',
'profile_list',
'is_extension_supported',
'subnetpool_list')})
def test_network_create_post_with_subnet_cidr_not_restrict(
self,
test_with_profile=False
):
def test_network_create_post_with_subnet_cidr_not_restrict(self):
network = self.networks.first()
subnet = self.subnets.first()
cidr = '30.30.30.0/24'
@ -909,12 +739,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'gateway_ip': 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
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
AndReturn(True)
@ -931,9 +755,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'shared': False,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, cidr=cidr,
gateway_ip=gateway_ip,
allocation_pools=[]))
@ -943,27 +764,14 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_subnet_cidr_not_restrict_w_profile(self):
self.test_network_create_post_with_subnet_cidr_not_restrict(
test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',
'is_extension_supported',
@test.create_stubs({api.neutron: ('is_extension_supported',
'subnetpool_list',)})
def test_network_create_post_with_subnet_cidr_inconsistent(
self,
test_with_profile=False,
test_with_subnetpool=False
):
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)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
@ -978,8 +786,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'shared': False,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
if test_with_subnetpool:
subnetpool = self.subnetpools.first()
form_data['subnetpool'] = subnetpool.id
@ -992,31 +798,18 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
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)
def test_network_create_post_with_subnet_cidr_inconsistent_w_snpool(self):
self.test_network_create_post_with_subnet_cidr_inconsistent(
test_with_subnetpool=True)
@test.create_stubs({api.neutron: ('profile_list',
'is_extension_supported',
@test.create_stubs({api.neutron: ('is_extension_supported',
'subnetpool_list',)})
def test_network_create_post_with_subnet_gw_inconsistent(
self,
test_with_profile=False,
test_with_subnetpool=False,
):
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)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation').\
@ -1031,8 +824,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
'shared': False,
'admin_state': network.admin_state_up,
'with_subnet': True}
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
if test_with_subnetpool:
subnetpool = self.subnetpools.first()
form_data['subnetpool'] = subnetpool.id
@ -1044,12 +835,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
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)
def test_network_create_post_with_subnet_gw_inconsistent_w_snpool(self):
self.test_network_create_post_with_subnet_gw_inconsistent(
test_with_subnetpool=True)

View File

@ -37,14 +37,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.ThemableChoiceField(label=_("Network Profile"),
required=False,
widget=widget)
admin_state = forms.ThemableChoiceField(
choices=[(True, _('UP')),
(False, _('DOWN'))],
@ -72,30 +64,9 @@ 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))
if not policy.check((("network", "create_network:shared"),), request):
self.fields['shared'].widget = forms.HiddenInput()
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")
help_text = _('Create a new network. '
@ -105,8 +76,7 @@ class CreateNetworkInfoAction(workflows.Action):
class CreateNetworkInfo(workflows.Step):
action_class = CreateNetworkInfoAction
contributes = ("net_name", "admin_state", "net_profile_id", "with_subnet",
"shared")
contributes = ("net_name", "admin_state", "with_subnet", "shared")
class CreateSubnetInfoAction(workflows.Action):
@ -495,8 +465,6 @@ class CreateNetwork(workflows.Workflow):
params = {'name': data['net_name'],
'admin_state_up': (data['admin_state'] == 'True'),
'shared': data['shared']}
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

@ -137,7 +137,6 @@
allowedBootSources: [],
images: [],
allowCreateVolumeFromImage: false,
arePortProfilesSupported: false,
imageSnapshots: [],
keypairs: [],
metadataDefs: {
@ -151,7 +150,6 @@
ports: [],
neutronEnabled: false,
novaLimits: {},
profiles: [],
securityGroups: [],
serverGroups: [],
volumeBootable: false,
@ -187,7 +185,6 @@
name: null,
networks: [],
ports: [],
profile: {},
scheduler_hints: {},
// REQUIRED Server Key. May be empty.
security_groups: [],

View File

@ -345,7 +345,7 @@
it('has empty arrays for all data', function() {
var datasets = ['availabilityZones', 'flavors', 'allowedBootSources',
'images', 'imageSnapshots', 'keypairs', 'networks',
'profiles', 'securityGroups', 'serverGroups', 'volumes',
'securityGroups', 'serverGroups', 'volumes',
'volumeSnapshots'];
datasets.forEach(function(name) {
@ -366,10 +366,6 @@
expect(model.allowCreateVolumeFromImage).toBe(false);
});
it('defaults "are port profiles supported" to false', function() {
expect(model.arePortProfilesSupported).toBe(false);
});
it('defaults "volume bootable" to false', function() {
expect(model.volumeBootable).toBe(false);
});
@ -746,7 +742,7 @@
// This is here to ensure that as people add/change items, they
// don't forget to implement tests for them.
it('has the right number of properties', function() {
expect(Object.keys(model.newInstanceSpec).length).toBe(21);
expect(Object.keys(model.newInstanceSpec).length).toBe(20);
});
it('sets availability zone to null', function() {
@ -793,10 +789,6 @@
expect(model.newInstanceSpec.ports).toEqual([]);
});
it('sets profile to an empty object', function() {
expect(model.newInstanceSpec.profile).toEqual({});
});
it('sets security groups to an empty array', function() {
expect(model.newInstanceSpec.security_groups).toEqual([]);
});

View File

@ -3,13 +3,6 @@
Networks provide the communication channels for instances in the cloud.
</p>
<div class="form-group" ng-if="model.arePortProfilesSupported">
<label class="control-label" for="profile" translate>Profile</label>
<select class="form-control" id="profile" ng-model="model.newInstanceSpec.profile" ng-options="profile.name for profile in model.profiles">
<option value="" translate>(None)</option>
</select>
</div>
<transfer-table tr-model="ctrl.tableDataMulti" help-text="ctrl.tableHelpText" limits="ctrl.tableLimits">
<allocated validate-number-min="{$ ctrl.tableDataMulti.minItems $}" ng-model="ctrl.tableDataMulti.allocated.length">
<table st-table="ctrl.tableDataMulti.displayedAllocated" st-safe-src="ctrl.tableDataMulti.allocated" hz-table

View File

@ -297,12 +297,6 @@ OPENSTACK_NEUTRON_NETWORK = {
# real deployments
# 'default_dns_nameservers': ["8.8.8.8", "8.8.4.4", "208.67.222.222"],
# The profile_support option is used to detect if an external router can be
# configured via the dashboard. When using specific plugins the
# profile_support can be turned on if needed.
'profile_support': None,
#'profile_support': 'cisco',
# Set which provider network types are supported. Only the network types
# in this list will be available to choose from when creating a network.
# Network types include local, flat, vlan, gre, vxlan and geneve.

View File

@ -94,7 +94,6 @@
* {
* "name": "myNewNetwork",
* "admin_state_up": true,
* "net_profile_id" : "asdsarafssdaser",
* "shared": true,
* "tenant_id": "4fd44f30292945e481c7b8a0c8908869
* }
@ -108,9 +107,6 @@
* The administrative state of the network, which is up (true) or
* down (false). Optional.
*
* @property {string} newNetwork.net_profile_id
* The network profile id. Optional.
*
* @property {boolean} newNetwork.shared
* Indicates whether this network is shared across all tenants.
* By default, only adminstative users can change this value. Optional.

View File

@ -171,41 +171,16 @@ class NeutronApiTests(test.APITestCase):
ret_val = api.neutron.network_get(self.request, network_id)
self.assertIsInstance(ret_val, api.neutron.Network)
def _test_network_create(self, with_n1kv=False):
def test_network_create(self):
network = {'network': self.api_networks.first()}
form_data = {'network': {'name': 'net1',
'tenant_id': self.request.user.project_id}}
neutronclient = self.stub_neutronclient()
if with_n1kv:
n1kv_profile = 'n1kv:profile'
test_net_profile = 'test_net_profile'
network['network'][n1kv_profile] = test_net_profile
form_data['network'][n1kv_profile] = test_net_profile
neutronclient.create_network(body=form_data).AndReturn(network)
self.mox.ReplayAll()
ret_val = api.neutron.network_create(
self.request,
name='net1',
net_profile_id=test_net_profile)
# assert that when 'net_profile_id' is passed as a param to
# network_create function, 'n1kv:profile' is appended as a key to
# the returned network dictionary with value TEST_NET_PROFILE
self.assertEqual(test_net_profile, ret_val[n1kv_profile])
# also assert that 'net_profile_id' isn't there in the returned
# network dictionary
self.assertNotIn('net_profile_id', [k for k, _ in ret_val.items()])
else:
neutronclient.create_network(body=form_data).AndReturn(network)
self.mox.ReplayAll()
ret_val = api.neutron.network_create(self.request, name='net1')
neutronclient.create_network(body=form_data).AndReturn(network)
self.mox.ReplayAll()
ret_val = api.neutron.network_create(self.request, name='net1')
self.assertIsInstance(ret_val, api.neutron.Network)
def test_network_create(self):
self._test_network_create()
def test_network_create_with_net_profile(self):
self._test_network_create(with_n1kv=True)
def test_network_update(self):
network = {'network': self.api_networks.first()}
network_id = self.api_networks.first()['id']
@ -402,7 +377,7 @@ class NeutronApiTests(test.APITestCase):
ret_val = api.neutron.port_get(self.request, port_id)
self.assertIsInstance(ret_val, api.neutron.Port)
def _test_port_create(self, with_n1kv=False):
def test_port_create(self):
port = {'port': self.api_ports.first()}
params = {'network_id': port['port']['network_id'],
'tenant_id': port['port']['tenant_id'],
@ -410,39 +385,12 @@ class NeutronApiTests(test.APITestCase):
'device_id': port['port']['device_id']}
neutronclient = self.stub_neutronclient()
if with_n1kv:
n1kv_profile = 'n1kv:profile'
test_policy_profile = 'test_policy_profile'
port['port'][n1kv_profile] = test_policy_profile
body = {k: v for (k, v) in params.items()}
body[n1kv_profile] = port['port'][n1kv_profile]
neutronclient.create_port(body={'port': body}).AndReturn(port)
self.mox.ReplayAll()
ret_val = api.neutron.port_create(
self.request,
policy_profile_id=test_policy_profile,
**params)
# assert that when 'policy_profile_id' is passed as a param to
# port_create function, 'n1kv:profile' is appended as a key to the
# returned port dictionary with value TEST_POLICY_PROFILE
self.assertEqual(test_policy_profile, ret_val[n1kv_profile])
# also assert that 'policy_profile_id' isn't there in the returned
# port dictionary
self.assertNotIn('policy_profile_id',
[k for k, _ in ret_val.items()])
else:
neutronclient.create_port(body={'port': params}).AndReturn(port)
self.mox.ReplayAll()
ret_val = api.neutron.port_create(self.request, **params)
neutronclient.create_port(body={'port': params}).AndReturn(port)
self.mox.ReplayAll()
ret_val = api.neutron.port_create(self.request, **params)
self.assertIsInstance(ret_val, api.neutron.Port)
self.assertEqual(api.neutron.Port(port['port']).id, ret_val.id)
def test_port_create(self):
self._test_port_create()
def test_port_create_with_policy_profile(self):
self._test_port_create(with_n1kv=True)
def test_port_update(self):
port_data = self.api_ports.first()
port_id = port_data['id']

View File

@ -172,9 +172,7 @@ OPENSTACK_NEUTRON_NETWORK = {
# to avoid stubbing neutron extension check calls.
'enable_firewall': False,
'enable_vpn': False,
'profile_support': None,
'enable_distributed_router': False,
# 'profile_support': 'cisco'
}
OPENSTACK_HYPERVISOR_FEATURES = {

View File

@ -44,10 +44,6 @@ def data(TEST):
TEST.monitors = utils.TestDataContainer()
TEST.neutron_quotas = utils.TestDataContainer()
TEST.neutron_quota_usages = utils.TestDataContainer()
TEST.net_profiles = utils.TestDataContainer()
TEST.policy_profiles = utils.TestDataContainer()
TEST.network_profile_binding = utils.TestDataContainer()
TEST.policy_profile_binding = utils.TestDataContainer()
TEST.vpnservices = utils.TestDataContainer()
TEST.ikepolicies = utils.TestDataContainer()
TEST.ipsecpolicies = utils.TestDataContainer()
@ -73,10 +69,6 @@ def data(TEST):
TEST.api_members = utils.TestDataContainer()
TEST.api_monitors = utils.TestDataContainer()
TEST.api_extensions = utils.TestDataContainer()
TEST.api_net_profiles = utils.TestDataContainer()
TEST.api_policy_profiles = utils.TestDataContainer()
TEST.api_network_profile_binding = utils.TestDataContainer()
TEST.api_policy_profile_binding = utils.TestDataContainer()
TEST.api_vpnservices = utils.TestDataContainer()
TEST.api_ikepolicies = utils.TestDataContainer()
TEST.api_ipsecpolicies = utils.TestDataContainer()
@ -117,47 +109,6 @@ def data(TEST):
TEST.networks.add(neutron.Network(network))
TEST.subnets.add(subnet)
# Network profile for network when using the cisco n1k plugin.
net_profile_dict = {'name': 'net_profile_test1',
'segment_type': 'vlan',
'physical_network': 'phys1',
'segment_range': '3000-3100',
'id':
'00000000-1111-1111-1111-000000000000',
'project': TEST.networks.get(name="net1")['tenant_id'],
# vlan profiles have no sub_type or multicast_ip_range
'multicast_ip_range': None,
'sub_type': None}
TEST.api_net_profiles.add(net_profile_dict)
TEST.net_profiles.add(neutron.Profile(net_profile_dict))
# Policy profile for port when using the cisco n1k plugin.
policy_profile_dict = {'name': 'policy_profile_test1',
'id':
'00000000-9999-9999-9999-000000000000'}
TEST.api_policy_profiles.add(policy_profile_dict)
TEST.policy_profiles.add(neutron.Profile(policy_profile_dict))
# Network profile binding.
network_profile_binding_dict = {'profile_id':
'00000000-1111-1111-1111-000000000000',
'tenant_id': network_dict['tenant_id']}
TEST.api_network_profile_binding.add(network_profile_binding_dict)
TEST.network_profile_binding.add(neutron.Profile(
network_profile_binding_dict))
# Policy profile binding.
policy_profile_binding_dict = {'profile_id':
'00000000-9999-9999-9999-000000000000',
'tenant_id': network_dict['tenant_id']}
TEST.api_policy_profile_binding.add(policy_profile_binding_dict)
TEST.policy_profile_binding.add(neutron.Profile(
policy_profile_binding_dict))
# Ports on 1st network.
port_dict = {'admin_state_up': True,
'device_id': 'af75c8e5-a1cc-4567-8d04-44fcd6922890',
@ -951,167 +902,19 @@ def data(TEST):
fw2._apidict['policy'] = policy1
TEST.firewalls.add(fw2)
# Additional Cisco N1K profiles.
# 2nd network profile for network when using the cisco n1k plugin.
# Profile applied on 1st network.
net_profile_dict = {'name': 'net_profile_test2',
'segment_type': 'overlay',
'sub_type': 'native_vxlan',
'segment_range': '10000-10100',
'multicast_ip_range': '144.0.0.0-144.0.0.100',
'id':
'00000000-2222-2222-2222-000000000000',
'project': '1',
# overlay profiles have no physical_network
'physical_network': None}
TEST.api_net_profiles.add(net_profile_dict)
TEST.net_profiles.add(neutron.Profile(net_profile_dict))
# 2nd network profile binding.
network_profile_binding_dict = {'profile_id':
'00000000-2222-2222-2222-000000000000',
'tenant_id': '1'}
TEST.api_network_profile_binding.add(network_profile_binding_dict)
TEST.network_profile_binding.add(neutron.Profile(
network_profile_binding_dict))
# 3rd network profile for network when using the cisco n1k plugin
# Profile applied on 1st network
net_profile_dict = {'name': 'net_profile_test3',
'segment_type': 'overlay',
'sub_type': 'other',
'other_subtype': 'GRE',
'segment_range': '11000-11100',
'id':
'00000000-3333-3333-3333-000000000000',
'project': '1'}
TEST.api_net_profiles.add(net_profile_dict)
TEST.net_profiles.add(neutron.Profile(net_profile_dict))
# 3rd network profile binding
network_profile_binding_dict = {'profile_id':
'00000000-3333-3333-3333-000000000000',
'tenant_id': '1'}
TEST.api_network_profile_binding.add(network_profile_binding_dict)
TEST.network_profile_binding.add(neutron.Profile(
network_profile_binding_dict))
# 4th network profile for network when using the cisco n1k plugin
# Profile applied on 1st network
net_profile_dict = {'name': 'net_profile_test4',
'segment_type': 'trunk',
'sub_type_trunk': 'vlan',
'id':
'00000000-4444-4444-4444-000000000000',
'project': '1'}
TEST.api_net_profiles.add(net_profile_dict)
TEST.net_profiles.add(neutron.Profile(net_profile_dict))
# 4th network profile binding
network_profile_binding_dict = {'profile_id':
'00000000-4444-4444-4444-000000000000',
'tenant_id': '1'}
TEST.api_network_profile_binding.add(network_profile_binding_dict)
TEST.network_profile_binding.add(neutron.Profile(
network_profile_binding_dict))
# Adding a new network and new network and policy profile
# similar to the first to test launching an instance with multiple
# nics and multiple profiles.
# 4th network to use for testing instances with multiple-nics & profiles
network_dict = {'admin_state_up': True,
'id': '7aa23d91-ffff-abab-dcdc-3411ae767e8a',
'name': 'net4',
'status': 'ACTIVE',
'subnets': ['31be4a21-aadd-73da-6422-821ff249a4bb'],
'tenant_id': '1',
'router:external': False,
'shared': False}
subnet_dict = {'allocation_pools': [{'end': '11.10.0.254',
'start': '11.10.0.2'}],
'dns_nameservers': [],
'host_routes': [],
'cidr': '11.10.0.0/24',
'enable_dhcp': True,
'gateway_ip': '11.10.0.1',
'id': network_dict['subnets'][0],
'ip_version': 4,
'name': 'mysubnet4',
'network_id': network_dict['id'],
'tenant_id': network_dict['tenant_id']}
TEST.api_networks.add(network_dict)
TEST.api_subnets.add(subnet_dict)
network = copy.deepcopy(network_dict)
subnet = neutron.Subnet(subnet_dict)
network['subnets'] = [subnet]
TEST.networks.add(neutron.Network(network))
TEST.subnets.add(subnet)
# 5th network profile for network when using the cisco n1k plugin
# Network Profile applied on 4th network
net_profile_dict = {'name': 'net_profile_test5',
'segment_type': 'vlan',
'physical_network': 'phys5',
'segment_range': '400-450',
'id':
'00000000-5555-5555-5555-000000000000',
'project': TEST.networks.get(name="net4")['tenant_id']}
TEST.api_net_profiles.add(net_profile_dict)
TEST.net_profiles.add(neutron.Profile(net_profile_dict))
# 2nd policy profile for port when using the cisco n1k plugin
policy_profile_dict = {'name': 'policy_profile_test2',
'id':
'11111111-9999-9999-9999-111111111111'}
TEST.api_policy_profiles.add(policy_profile_dict)
TEST.policy_profiles.add(neutron.Profile(policy_profile_dict))
# network profile binding
network_profile_binding_dict = {'profile_id':
'00000000-5555-5555-5555-000000000000',
'tenant_id':
TEST.networks.get(name="net4")['tenant_id']
}
TEST.api_network_profile_binding.add(network_profile_binding_dict)
TEST.network_profile_binding.add(neutron.Profile(
network_profile_binding_dict))
# policy profile binding
policy_profile_binding_dict = {'profile_id':
'11111111-9999-9999-9999-111111111111',
'tenant_id':
TEST.networks.get(name="net4")['tenant_id']}
TEST.api_policy_profile_binding.add(policy_profile_binding_dict)
TEST.policy_profile_binding.add(neutron.Profile(
policy_profile_binding_dict))
# ports on 4th network
port_dict = {'admin_state_up': True,
'device_id': '9872faaa-b2b2-eeee-9911-21332eedaa77',
'device_owner': 'network:dhcp',
'fixed_ips': [{'ip_address': '11.10.0.3',
'subnet_id':
TEST.subnets.get(name="mysubnet4")['id']}],
TEST.subnets.first().id}],
'id': 'a21dcd22-6733-cccc-aa32-22adafaf16a2',
'mac_address': '78:22:ff:1a:ba:23',
'name': 'port5',
'network_id': TEST.networks.get(name="net4")['id'],
'network_id': TEST.networks.first().id,
'status': 'ACTIVE',
'tenant_id': TEST.networks.get(name="net4")['tenant_id'],
'tenant_id': TEST.networks.first().tenant_id,
'binding:vnic_type': 'normal',
'binding:host_id': 'host'}
TEST.api_ports.add(port_dict)

View File

@ -0,0 +1,6 @@
---
upgrade:
- The ``profile_support`` setting has been removed from the
``OPENSTACK_NEUTRON_NETWORK`` dict, and any usages have been removed from
the Horizon code base. If you were relying on this being set by default,
you will now need to manually set the value in your plugin/customisation.