Run router dashboard unit tests by default

Currently the "router" dashboard does not have its unit tests
run by default. This was beacuse the dashboard needed to be
turned on for these tests to be run and turning on this dashboard
was not mandatory.

However, now that the dashboards are pluggable, turning on the
router dashboard tests, and more specifically the Cisco N1K profile
tests is doable and necessary. This fix aims to remove the checks
put in place to run the tests only when the dashboard is available
and instead now run all the tests mandatorily

Closes-bug: #1229819

Change-Id: I3c77a71db08ac611e5bdf9274af5a558bfda3327
This commit is contained in:
Abishek Subramanian 2014-07-15 11:50:07 -04:00
parent 939e81b760
commit 2f2312dfcc
11 changed files with 472 additions and 366 deletions

View File

@ -868,12 +868,10 @@ def is_agent_extension_supported(request):
# Using this mechanism till a better plugin/sub-plugin detection
# mechanism is available.
# Using local_settings to detect if the "router" dashboard
# should be turned on or not. When using specific plugins the
# profile_support can be turned on if needed.
# 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. This is mainly used in the run_tests
# environment to detect when to use profile_support neutron APIs.
# @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():

View File

@ -33,7 +33,12 @@ class CreateNetwork(forms.SelfHandlingForm):
required=False)
tenant_id = forms.ChoiceField(label=_("Project"))
if api.neutron.is_port_profiles_supported():
net_profile_id = forms.ChoiceField(label=_("Network Profile"))
widget = None
else:
widget = forms.HiddenInput()
net_profile_id = forms.ChoiceField(label=_("Network Profile"),
required=False,
widget=widget)
admin_state = forms.BooleanField(label=_("Admin State"),
initial=True, required=False)
shared = forms.BooleanField(label=_("Shared"),

View File

@ -14,6 +14,7 @@
from django.core.urlresolvers import reverse
from django import http
from django.test.utils import override_settings
from horizon.workflows import views
@ -149,14 +150,12 @@ class NetworkTests(test.BaseAdminViewTests):
@test.create_stubs({api.neutron: ('profile_list',),
api.keystone: ('tenant_list',)})
def test_network_create_get(self):
def test_network_create_get(self,
test_with_profile=False):
tenants = self.tenants.list()
api.keystone.tenant_list(IsA(
http.HttpRequest)).AndReturn([tenants, False])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
net_profiles = self.net_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
@ -167,10 +166,15 @@ class NetworkTests(test.BaseAdminViewTests):
self.assertTemplateUsed(res, 'admin/networks/create.html')
@override_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',),
api.keystone: ('tenant_list',)})
def test_network_create_post(self):
def test_network_create_post(self,
test_with_profile=False):
tenants = self.tenants.list()
tenant_id = self.tenants.first().id
network = self.networks.first()
@ -181,10 +185,7 @@ class NetworkTests(test.BaseAdminViewTests):
'admin_state_up': network.admin_state_up,
'router:external': True,
'shared': True}
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -199,7 +200,7 @@ class NetworkTests(test.BaseAdminViewTests):
'admin_state': network.admin_state_up,
'external': True,
'shared': True}
if api.neutron.is_port_profiles_supported():
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)
@ -207,10 +208,15 @@ class NetworkTests(test.BaseAdminViewTests):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@override_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',),
api.keystone: ('tenant_list',)})
def test_network_create_post_network_exception(self):
def test_network_create_post_network_exception(self,
test_with_profile=False):
tenants = self.tenants.list()
tenant_id = self.tenants.first().id
network = self.networks.first()
@ -221,10 +227,7 @@ class NetworkTests(test.BaseAdminViewTests):
'admin_state_up': network.admin_state_up,
'router:external': True,
'shared': False}
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -239,7 +242,7 @@ class NetworkTests(test.BaseAdminViewTests):
'admin_state': network.admin_state_up,
'external': True,
'shared': False}
if api.neutron.is_port_profiles_supported():
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)
@ -247,6 +250,11 @@ class NetworkTests(test.BaseAdminViewTests):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@override_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: ('network_get',)})
def test_network_update_get(self):
network = self.networks.first()

View File

@ -1175,7 +1175,8 @@ class InstanceTests(test.TestCase):
block_device_mapping_v2=True,
custom_flavor_sort=None,
only_one_network=False,
disk_config=True):
disk_config=True,
test_with_profile=False):
image = self.images.first()
api.nova.extension_supported('BlockDeviceMappingV2Boot',
@ -1204,10 +1205,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
@ -1350,6 +1348,11 @@ class InstanceTests(test.TestCase):
def test_launch_instance_get_with_only_one_network(self):
self.test_launch_instance_get(only_one_network=True)
@test_utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_instance_get_with_profile(self):
self.test_launch_instance_get(test_with_profile=True)
@test.create_stubs({api.nova: ('extension_supported',
'flavor_list',
'keypair_list',
@ -1364,7 +1367,8 @@ class InstanceTests(test.TestCase):
def test_launch_instance_get_bootable_volumes(self,
block_device_mapping_v2=True,
only_one_network=False,
disk_config=True):
disk_config=True,
test_with_profile=False):
api.nova.extension_supported('BlockDeviceMappingV2Boot',
IsA(http.HttpRequest)) \
.AndReturn(block_device_mapping_v2)
@ -1392,7 +1396,7 @@ class InstanceTests(test.TestCase):
shared=True) \
.AndReturn(self.networks.list()[1:])
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
@ -1433,6 +1437,11 @@ class InstanceTests(test.TestCase):
for volume in bootable_volumes:
self.assertTrue(volume in volume_sources_ids)
@test_utils.override_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)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',
@ -1447,7 +1456,8 @@ class InstanceTests(test.TestCase):
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
def test_launch_instance_post(self,
disk_config=True):
disk_config=True,
test_with_profile=False):
flavor = self.flavors.first()
image = self.images.first()
keypair = self.keypairs.first()
@ -1484,10 +1494,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
policy_profile_id = self.policy_profiles.first().id
port = self.ports.first()
@ -1496,8 +1503,9 @@ class InstanceTests(test.TestCase):
'policy').AndReturn(policy_profiles)
api.neutron.port_create(
IsA(http.HttpRequest),
network_id=self.networks.first().id,
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(disk_config)
@ -1544,6 +1552,8 @@ class InstanceTests(test.TestCase):
'count': 1}
if disk_config:
form_data['disk_config'] = 'AUTO'
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)
@ -1553,9 +1563,15 @@ class InstanceTests(test.TestCase):
def test_launch_instance_post_no_disk_config_supported(self):
self.test_launch_instance_post(disk_config=False)
@test_utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_instance_post_with_profile(self):
self.test_launch_instance_post(test_with_profile=True)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
'profile_list',
'port_create',),
api.nova: ('extension_supported',
'flavor_list',
'keypair_list',
@ -1565,7 +1581,8 @@ class InstanceTests(test.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
def test_launch_instance_post_boot_from_volume(self):
def test_launch_instance_post_boot_from_volume(self,
test_with_profile=False):
flavor = self.flavors.first()
keypair = self.keypairs.first()
server = self.servers.first()
@ -1605,10 +1622,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
policy_profile_id = self.policy_profiles.first().id
port = self.ports.first()
@ -1617,7 +1631,7 @@ class InstanceTests(test.TestCase):
'policy').AndReturn(policy_profiles)
api.neutron.port_create(
IsA(http.HttpRequest),
network_id=self.networks.first().id,
self.networks.first().id,
policy_profile_id=policy_profile_id).AndReturn(port)
nics = [{"port-id": port.id}]
api.nova.extension_supported('DiskConfig',
@ -1661,12 +1675,19 @@ class InstanceTests(test.TestCase):
'network': self.networks.first().id,
'count': 1,
'disk_config': 'AUTO'}
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.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test_utils.override_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)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',
@ -1681,7 +1702,9 @@ class InstanceTests(test.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
def test_launch_instance_post_no_images_available_boot_from_volume(self):
def test_launch_instance_post_no_images_available_boot_from_volume(
self,
test_with_profile=False):
flavor = self.flavors.first()
keypair = self.keypairs.first()
server = self.servers.first()
@ -1722,10 +1745,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
policy_profile_id = self.policy_profiles.first().id
port = self.ports.first()
@ -1734,7 +1754,7 @@ class InstanceTests(test.TestCase):
'policy').AndReturn(policy_profiles)
api.neutron.port_create(
IsA(http.HttpRequest),
network_id=self.networks.first().id,
self.networks.first().id,
policy_profile_id=policy_profile_id).AndReturn(port)
nics = [{"port-id": port.id}]
api.nova.extension_supported('DiskConfig',
@ -1779,12 +1799,20 @@ class InstanceTests(test.TestCase):
'device_name': device_name,
'count': 1,
'disk_config': 'MANUAL'}
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.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@test_utils.override_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)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
@ -1797,7 +1825,8 @@ class InstanceTests(test.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
def test_launch_instance_post_no_images_available(self):
def test_launch_instance_post_no_images_available(self,
test_with_profile=False):
flavor = self.flavors.first()
keypair = self.keypairs.first()
server = self.servers.first()
@ -1828,10 +1857,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
@ -1872,6 +1898,12 @@ class InstanceTests(test.TestCase):
self.assertFormErrors(res, 1, "You must select an image.")
self.assertTemplateUsed(res, views.WorkflowView.template_name)
@test_utils.override_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)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
@ -1883,7 +1915,8 @@ class InstanceTests(test.TestCase):
'keypair_list',
'tenant_absolute_limits',
'availability_zone_list',)})
def test_launch_flavorlist_error(self):
def test_launch_flavorlist_error(self,
test_with_profile=False):
api.nova.extension_supported('BlockDeviceMappingV2Boot',
IsA(http.HttpRequest)) \
.AndReturn(True)
@ -1906,10 +1939,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
@ -1936,6 +1966,11 @@ class InstanceTests(test.TestCase):
self.assertTemplateUsed(res, views.WorkflowView.template_name)
@test_utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_flavorlist_error_with_profile(self):
self.test_launch_flavorlist_error(test_with_profile=True)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',
@ -1949,7 +1984,8 @@ class InstanceTests(test.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
def test_launch_form_keystone_exception(self):
def test_launch_form_keystone_exception(self,
test_with_profile=False):
flavor = self.flavors.first()
image = self.images.first()
keypair = self.keypairs.first()
@ -1986,10 +2022,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
policy_profile_id = self.policy_profiles.first().id
port = self.ports.first()
@ -1998,7 +2031,7 @@ class InstanceTests(test.TestCase):
'policy').AndReturn(policy_profiles)
api.neutron.port_create(
IsA(http.HttpRequest),
network_id=self.networks.first().id,
self.networks.first().id,
policy_profile_id=policy_profile_id).AndReturn(port)
nics = [{"port-id": port.id}]
api.nova.extension_supported('DiskConfig',
@ -2045,11 +2078,18 @@ class InstanceTests(test.TestCase):
'admin_pass': 'password',
'confirm_admin_pass': 'password',
'disk_config': 'AUTO'}
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)
@test_utils.override_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)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
@ -2062,7 +2102,8 @@ class InstanceTests(test.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
def test_launch_form_instance_count_error(self):
def test_launch_form_instance_count_error(self,
test_with_profile=False):
flavor = self.flavors.first()
image = self.images.first()
keypair = self.keypairs.first()
@ -2101,10 +2142,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
@ -2145,6 +2183,11 @@ class InstanceTests(test.TestCase):
self.assertContains(res, "greater than or equal to 1")
@test_utils.override_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)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
@ -2157,7 +2200,8 @@ class InstanceTests(test.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
def _test_launch_form_instance_requirement_error(self, image, flavor):
def _test_launch_form_instance_requirement_error(self, image, flavor,
test_with_profile=False):
keypair = self.keypairs.first()
server = self.servers.first()
volume = self.volumes.first()
@ -2194,10 +2238,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
@ -2239,19 +2280,37 @@ class InstanceTests(test.TestCase):
msg = "The flavor '%s' is too small" % flavor.name
self.assertContains(res, msg)
def test_launch_form_instance_requirement_error_disk(self):
def test_launch_form_instance_requirement_error_disk(
self,
test_with_profile=False):
flavor = self.flavors.first()
image = self.images.first()
image.min_ram = flavor.ram
image.min_disk = flavor.disk + 1
self._test_launch_form_instance_requirement_error(image, flavor)
self._test_launch_form_instance_requirement_error(image, flavor,
test_with_profile)
def test_launch_form_instance_requirement_error_ram(self):
def test_launch_form_instance_requirement_error_ram(
self,
test_with_profile=False):
flavor = self.flavors.first()
image = self.images.first()
image.min_ram = flavor.ram + 1
image.min_disk = flavor.disk
self._test_launch_form_instance_requirement_error(image, flavor)
self._test_launch_form_instance_requirement_error(image, flavor,
test_with_profile)
@test_utils.override_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)
@test_utils.override_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)
@test.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
@ -2265,7 +2324,8 @@ class InstanceTests(test.TestCase):
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
def _test_launch_form_instance_volume_size(self, image, volume_size, msg):
def _test_launch_form_instance_volume_size(self, image, volume_size, msg,
test_with_profile=False):
flavor = self.flavors.get(name='m1.massive')
keypair = self.keypairs.first()
server = self.servers.first()
@ -2301,10 +2361,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
@ -2346,17 +2403,33 @@ class InstanceTests(test.TestCase):
res = self.client.post(url, form_data)
self.assertContains(res, msg)
def test_launch_form_instance_volume_size_error(self):
def test_launch_form_instance_volume_size_error(self,
test_with_profile=False):
image = self.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)
self._test_launch_form_instance_volume_size(image, volume_size, msg,
test_with_profile)
def test_launch_form_instance_non_int_volume_size(self):
def test_launch_form_instance_non_int_volume_size(self,
test_with_profile=False):
image = self.images.get(name='protected_images')
msg = "Enter a whole number."
self._test_launch_form_instance_volume_size(image, 1.5, msg)
self._test_launch_form_instance_volume_size(image, 1.5, msg,
test_with_profile)
@test_utils.override_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)
@test_utils.override_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)
@test.create_stubs({api.nova: ('flavor_list', 'server_list',
'tenant_absolute_limits',
@ -2451,7 +2524,8 @@ class InstanceTests(test.TestCase):
api.neutron: ('network_list',
'profile_list'),
api.glance: ('image_list_detailed',)})
def test_select_default_keypair_if_only_one(self):
def test_select_default_keypair_if_only_one(self,
test_with_profile=False):
keypair = self.keypairs.first()
cinder.volume_list(IsA(http.HttpRequest)) \
@ -2473,10 +2547,7 @@ class InstanceTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
shared=True) \
.AndReturn(self.networks.list()[1:])
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
if test_with_profile:
policy_profiles = self.policy_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
@ -2509,6 +2580,11 @@ class InstanceTests(test.TestCase):
html=True,
msg_prefix="The default key pair was not selected.")
@test_utils.override_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)
@test.create_stubs({api.network: ('floating_ip_target_get_by_instance',
'tenant_floating_ip_allocate',
'floating_ip_associate',

View File

@ -562,16 +562,23 @@ class SetNetworkAction(workflows.Action):
help_text=_("Launch instance with"
" these networks"))
if api.neutron.is_port_profiles_supported():
profile = forms.ChoiceField(label=_("Policy Profiles"),
required=False,
help_text=_("Launch instance with "
"this policy profile"))
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:
name = _("Networking")
@ -591,14 +598,20 @@ class SetNetworkAction(workflows.Action):
_('Unable to retrieve networks.'))
return network_list
def populate_profile_choices(self, request, context):
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, 'policy')
profile_list = [(profile.id, profile.name) for profile in profiles]
profiles = api.neutron.profile_list(request, type_p)
except Exception:
profile_list = []
exceptions.handle(request, _("Unable to retrieve profiles."))
return profile_list
msg = _('Network Profiles could not be retrieved.')
exceptions.handle(request, msg)
return profiles
class SetNetwork(workflows.Step):

View File

@ -14,6 +14,7 @@
from django.core.urlresolvers import reverse
from django import http
from django.test.utils import override_settings
from django.utils.html import escape
from horizon.workflows import views
@ -218,11 +219,9 @@ class NetworkTests(test.TestCase):
self.assertEqual(len(ports), 0)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_get(self):
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
def test_network_create_get(self,
test_with_profile=False):
if test_with_profile:
net_profiles = self.net_profiles.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
@ -239,16 +238,18 @@ class NetworkTests(test.TestCase):
'<CreateSubnetDetail: createsubnetdetailaction>']
self.assertQuerysetEqual(workflow.steps, expected_objs)
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_get_with_profile(self):
self.test_network_create_get(test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'profile_list',)})
def test_network_create_post(self):
def test_network_create_post(self,
test_with_profile=False):
network = self.networks.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -262,7 +263,7 @@ class NetworkTests(test.TestCase):
'admin_state': network.admin_state_up,
# subnet
'with_subnet': False}
if api.neutron.is_port_profiles_supported():
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')
@ -271,18 +272,20 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@override_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',)})
def test_network_create_post_with_subnet(self):
def test_network_create_post_with_subnet(self,
test_with_profile=False):
network = self.networks.first()
subnet = self.subnets.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -303,7 +306,7 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if api.neutron.is_port_profiles_supported():
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')
@ -312,16 +315,18 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@override_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.create_stubs({api.neutron: ('network_create',
'profile_list',)})
def test_network_create_post_network_exception(self):
def test_network_create_post_network_exception(self,
test_with_profile=False):
network = self.networks.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -335,7 +340,7 @@ class NetworkTests(test.TestCase):
'admin_state': network.admin_state_up,
# subnet
'with_subnet': False}
if api.neutron.is_port_profiles_supported():
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')
@ -344,17 +349,21 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_nw_exception_w_profile(self):
self.test_network_create_post_network_exception(
test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'profile_list')})
def test_network_create_post_with_subnet_network_exception(self):
def test_network_create_post_with_subnet_network_exception(
self,
test_with_profile=False):
network = self.networks.first()
subnet = self.subnets.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -367,7 +376,7 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if api.neutron.is_port_profiles_supported():
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')
@ -376,19 +385,23 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_nw_exception_w_profile(self):
self.test_network_create_post_with_subnet_network_exception(
test_with_profile=True)
@test.create_stubs({api.neutron: ('network_create',
'network_delete',
'subnet_create',
'profile_list')})
def test_network_create_post_with_subnet_subnet_exception(self):
def test_network_create_post_with_subnet_subnet_exception(
self,
test_with_profile=False):
network = self.networks.first()
subnet = self.subnets.first()
params = {'name': network.name,
'admin_state_up': network.admin_state_up}
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -411,7 +424,7 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if api.neutron.is_port_profiles_supported():
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')
@ -420,14 +433,17 @@ class NetworkTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_subnet_exception_w_profile(self):
self.test_network_create_post_with_subnet_subnet_exception(
test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_nocidr(self):
def test_network_create_post_with_subnet_nocidr(self,
test_with_profile=False):
network = self.networks.first()
subnet = self.subnets.first()
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -437,7 +453,7 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if api.neutron.is_port_profiles_supported():
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, cidr='',
allocation_pools=[]))
@ -447,14 +463,17 @@ class NetworkTests(test.TestCase):
self.assertContains(res, escape('Specify "Network Address" or '
'clear "Create Subnet" checkbox.'))
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_no_cidr_w_profile(self):
self.test_network_create_post_with_subnet_nocidr(test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_cidr_without_mask(self):
def test_network_create_post_with_subnet_cidr_without_mask(
self,
test_with_profile=False):
network = self.networks.first()
subnet = self.subnets.first()
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -464,7 +483,7 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if api.neutron.is_port_profiles_supported():
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, cidr='10.0.0.0',
allocation_pools=[]))
@ -474,14 +493,18 @@ class NetworkTests(test.TestCase):
expected_msg = "The subnet in the Network Address is too small (/32)."
self.assertContains(res, expected_msg)
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_cidr_without_mask_w_profile(self):
self.test_network_create_post_with_subnet_cidr_without_mask(
test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_cidr_inconsistent(self):
def test_network_create_post_with_subnet_cidr_inconsistent(
self,
test_with_profile=False):
network = self.networks.first()
subnet = self.subnets.first()
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -493,7 +516,7 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if api.neutron.is_port_profiles_supported():
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, cidr=cidr,
allocation_pools=[]))
@ -503,14 +526,18 @@ class NetworkTests(test.TestCase):
expected_msg = 'Network Address and IP version are inconsistent.'
self.assertContains(res, expected_msg)
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_subnet_cidr_inconsistent_w_profile(self):
self.test_network_create_post_with_subnet_cidr_inconsistent(
test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_gw_inconsistent(self):
def test_network_create_post_with_subnet_gw_inconsistent(
self,
test_with_profile=False):
network = self.networks.first()
subnet = self.subnets.first()
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
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),
@ -522,7 +549,7 @@ class NetworkTests(test.TestCase):
form_data = {'net_name': network.name,
'admin_state': network.admin_state_up,
'with_subnet': True}
if api.neutron.is_port_profiles_supported():
if test_with_profile:
form_data['net_profile_id'] = net_profile_id
form_data.update(form_data_subnet(subnet, gateway_ip=gateway_ip,
allocation_pools=[]))
@ -531,6 +558,11 @@ class NetworkTests(test.TestCase):
self.assertContains(res, 'Gateway IP and IP version are inconsistent.')
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_with_subnet_gw_inconsistent_w_profile(self):
self.test_network_create_post_with_subnet_gw_inconsistent(
test_with_profile=True)
@test.create_stubs({api.neutron: ('network_get',)})
def test_network_update_get(self):
network = self.networks.first()

View File

@ -35,31 +35,36 @@ class CreateNetworkInfoAction(workflows.Action):
label=_("Network Name"),
required=False)
if api.neutron.is_port_profiles_supported():
net_profile_id = forms.ChoiceField(label=_("Network Profile"))
widget = None
else:
widget = forms.HiddenInput()
net_profile_id = forms.ChoiceField(label=_("Network Profile"),
required=False,
widget=widget)
admin_state = forms.BooleanField(label=_("Admin State"),
initial=True, required=False)
if api.neutron.is_port_profiles_supported():
def __init__(self, request, *args, **kwargs):
super(CreateNetworkInfoAction, self).__init__(request,
*args, **kwargs)
def __init__(self, request, *args, **kwargs):
super(CreateNetworkInfoAction, self).__init__(request,
*args, **kwargs)
if api.neutron.is_port_profiles_supported():
self.fields['net_profile_id'].choices = (
self.get_network_profile_choices(request))
def get_network_profile_choices(self, request):
profile_choices = [('', _("Select a profile"))]
for profile in self._get_profiles(request, 'network'):
profile_choices.append((profile.id, profile.name))
return profile_choices
def get_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):
try:
profiles = api.neutron.profile_list(request, type_p)
except Exception:
profiles = []
msg = _('Network Profiles could not be retrieved.')
exceptions.handle(request, msg)
return profiles
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.
@ -72,10 +77,7 @@ class CreateNetworkInfoAction(workflows.Action):
class CreateNetworkInfo(workflows.Step):
action_class = CreateNetworkInfoAction
if api.neutron.is_port_profiles_supported():
contributes = ("net_name", "admin_state", "net_profile_id")
else:
contributes = ("net_name", "admin_state")
contributes = ("net_name", "admin_state", "net_profile_id")
class CreateSubnetInfoAction(workflows.Action):

View File

@ -14,8 +14,6 @@
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard.api import neutron
import horizon
@ -27,5 +25,4 @@ class Router(horizon.Dashboard):
permissions = ('openstack.roles.admin',)
if neutron.is_port_profiles_supported():
horizon.register(Router)
horizon.register(Router)

View File

@ -16,7 +16,6 @@
from django.utils.translation import ugettext_lazy as _
import horizon
from openstack_dashboard.api import neutron as neutron
from openstack_dashboard.dashboards.router import dashboard
@ -25,5 +24,4 @@ class Nexus1000v(horizon.Panel):
slug = 'nexus1000v'
permissions = ('openstack.services.network',)
if neutron.is_port_profiles_supported():
dashboard.Router.register(Nexus1000v)
dashboard.Router.register(Nexus1000v)

View File

@ -30,174 +30,170 @@ def form_data_overlay():
return {'physical_network': ''}
# TODO(absubram): Remove if clause and create separate
# test stubs for when profile_support is being used and when not.
# Additionally ensure those are always run even in default setting
if api.neutron.is_port_profiles_supported():
class Nexus1000vTest(test.BaseAdminViewTests):
@test.create_stubs({api.neutron: ('profile_list',
'profile_bindings_list'),
api.keystone: ('tenant_list',)})
def test_index(self):
tenants = self.tenants.list()
net_profiles = self.net_profiles.list()
policy_profiles = self.policy_profiles.list()
net_profile_binding = self.network_profile_binding.list()
policy_profile_binding = self.policy_profile_binding.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'network').AndReturn(net_profile_binding)
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'policy').AndReturn(policy_profile_binding)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
class Nexus1000vTest(test.BaseAdminViewTests):
@test.create_stubs({api.neutron: ('profile_list',
'profile_bindings_list'),
api.keystone: ('tenant_list',)})
def test_index(self):
tenants = self.tenants.list()
net_profiles = self.net_profiles.list()
policy_profiles = self.policy_profiles.list()
net_profile_binding = self.network_profile_binding.list()
policy_profile_binding = self.policy_profile_binding.list()
api.neutron.profile_list(IsA(http.HttpRequest),
'network').AndReturn(net_profiles)
api.neutron.profile_list(IsA(http.HttpRequest),
'policy').AndReturn(policy_profiles)
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'network').AndReturn(net_profile_binding)
api.neutron.profile_bindings_list(
IsA(http.HttpRequest),
'policy').AndReturn(policy_profile_binding)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
res = self.client.get(reverse('horizon:router:nexus1000v:index'))
self.assertTemplateUsed(res, 'router/nexus1000v/index.html')
res = self.client.get(reverse('horizon:router:nexus1000v:index'))
self.assertTemplateUsed(res, 'router/nexus1000v/index.html')
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_vlan_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.first()
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'physical_network': net_profile.physical_network,
'tenant_id': net_profile.project,
# vlan profiles have no sub_type or multicast_ip_range
'multicast_ip_range': '',
'sub_type': ''}
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_vlan_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.first()
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'physical_network': net_profile.physical_network,
'tenant_id': net_profile.project,
# vlan profiles have no sub_type or multicast_ip_range
'multicast_ip_range': '',
'sub_type': ''}
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'physical_network': net_profile.physical_network,
'project': net_profile.project}
form_data.update(form_data_no_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'physical_network': net_profile.physical_network,
'project': net_profile.project}
form_data.update(form_data_no_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_overlay_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[1]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'multicast_ip_range': net_profile.multicast_ip_range,
'sub_type': net_profile.sub_type,
'tenant_id': net_profile.project,
# overlay profiles have no physical_network type
'physical_network': ''}
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_overlay_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[1]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'multicast_ip_range': net_profile.multicast_ip_range,
'sub_type': net_profile.sub_type,
'tenant_id': net_profile.project,
# overlay profiles have no physical_network type
'physical_network': ''}
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'multicast_ip_range': net_profile.multicast_ip_range,
'sub_type': net_profile.sub_type,
'project': net_profile.project}
form_data.update(form_data_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'multicast_ip_range': net_profile.multicast_ip_range,
'sub_type': net_profile.sub_type,
'project': net_profile.project}
form_data.update(form_data_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_overlay_other_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[2]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'sub_type': net_profile.other_subtype,
'tenant_id': net_profile.project,
# overlay 'other' profiles have no multicast_ip_range
# or physical_network type
'multicast_ip_range': '',
'physical_network': ''}
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_overlay_other_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[2]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'sub_type': net_profile.other_subtype,
'tenant_id': net_profile.project,
# overlay 'other' profiles have no multicast_ip_range
# or physical_network type
'multicast_ip_range': '',
'physical_network': ''}
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'sub_type': net_profile.sub_type,
'other_subtype': net_profile.other_subtype,
'project': net_profile.project}
form_data.update(form_data_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'segment_range': net_profile.segment_range,
'sub_type': net_profile.sub_type,
'other_subtype': net_profile.other_subtype,
'project': net_profile.project}
form_data.update(form_data_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_trunk_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[3]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'sub_type': net_profile.sub_type_trunk,
'tenant_id': net_profile.project,
# trunk profiles have no multicast_ip_range,
# no segment_range or no physical_network type
'multicast_ip_range': '',
'segment_range': '',
'physical_network': ''}
@test.create_stubs({api.neutron: ('profile_create',),
api.keystone: ('tenant_list',)})
def test_create_trunk_net_profile(self):
tenants = self.tenants.list()
net_profile = self.net_profiles.list()[3]
params = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'sub_type': net_profile.sub_type_trunk,
'tenant_id': net_profile.project,
# trunk profiles have no multicast_ip_range,
# no segment_range or no physical_network type
'multicast_ip_range': '',
'segment_range': '',
'physical_network': ''}
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
api.neutron.profile_create(IsA(http.HttpRequest),
**params).AndReturn(net_profile)
api.keystone.tenant_list(
IsA(http.HttpRequest)).AndReturn([tenants, False])
self.mox.ReplayAll()
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'sub_type_trunk': net_profile.sub_type_trunk,
'project': net_profile.project}
form_data.update(form_data_no_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
form_data = {'name': net_profile.name,
'segment_type': net_profile.segment_type,
'sub_type_trunk': net_profile.sub_type_trunk,
'project': net_profile.project}
form_data.update(form_data_no_overlay())
url = reverse('horizon:router:nexus1000v:create_network_profile')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse
('horizon:router:nexus1000v:index'))

View File

@ -47,13 +47,7 @@ INSTALLED_APPS = (
'openstack_dashboard.dashboards.project',
'openstack_dashboard.dashboards.admin',
'openstack_dashboard.dashboards.settings',
# If the profile_support config is turned on in local_settings
# the "router" dashboard will be enabled which can be used to
# create and use profiles with networks and instances. In which case
# using run_tests will require the registration of the "router" dashboard.
# TODO (absubram): Need to make this permanent when a better solution
# for run_tests is implemented to use with and without the n1k sub-plugin.
#'openstack_dashboard.dashboards.router',
'openstack_dashboard.dashboards.router',
)
AUTHENTICATION_BACKENDS = ('openstack_auth.backend.KeystoneBackend',)
@ -61,14 +55,7 @@ AUTHENTICATION_BACKENDS = ('openstack_auth.backend.KeystoneBackend',)
SITE_BRANDING = 'OpenStack'
HORIZON_CONFIG = {
'dashboards': ('project', 'admin', 'settings',),
# If the profile_support config is turned on in local_settings
# the "router" dashboard will be enabled which can be used to
# create and use profiles with networks and instances. In which case
# using run_tests will require the registration of the "router" dashboard.
# TODO (absubram): Need to make this permanent when a better solution
# for run_tests is implemented to use with and without the n1k sub-plugin.
#'dashboards': ('project', 'admin', 'settings', 'router',),
'dashboards': ('project', 'admin', 'settings', 'router',),
'default_dashboard': 'project',
"password_validator": {
"regex": '^.{8,18}$',
@ -121,12 +108,6 @@ OPENSTACK_NEUTRON_NETWORK = {
'enable_firewall': True,
'enable_quotas': False, # Enabled in specific tests only
'enable_vpn': True,
# If the profile_support config is turned on in local_settings
# the "router" dashboard will be enabled which can be used to
# create and use profiles with networks and instances. In which case
# using run_tests will require the registration of the "router" dashboard.
# TODO (absubram): Need to make this permanent when a better solution
# for run_tests is implemented to use with and without the n1k sub-plugin.
'profile_support': None,
#'profile_support': 'cisco'
}