summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/utils/tests/neutron_utils_tests.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-08-09 14:17:26 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-08-09 14:37:41 -0600
commit2b9b2d64c5be98405aaaf98db58f06b35b8af983 (patch)
tree7eac6cb5a5182371b5602e53bb613234c5eff11c /snaps/openstack/utils/tests/neutron_utils_tests.py
parent430905e7f76e4a074167a49ca2bfbf727eebcefd (diff)
SNAPS Stack creators can now return SNAPS network creators.
As Heat Stacks are responsible for spawning objects in OpenStack, the class OpenStackHeatStack which is responsible for applying and managing the state of a stack now can retrieve OpenStackNetwork objects for the networks created in the stack for clients who would like to query the networks and subnets or update them outside of Heat. JIRA: SNAPS-171 Change-Id: I9bf0b81d4f7bfeb1b6392f345022c7d9a57d0415 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/tests/neutron_utils_tests.py')
-rw-r--r--snaps/openstack/utils/tests/neutron_utils_tests.py60
1 files changed, 51 insertions, 9 deletions
diff --git a/snaps/openstack/utils/tests/neutron_utils_tests.py b/snaps/openstack/utils/tests/neutron_utils_tests.py
index f6fc2bb..5493f5b 100644
--- a/snaps/openstack/utils/tests/neutron_utils_tests.py
+++ b/snaps/openstack/utils/tests/neutron_utils_tests.py
@@ -152,9 +152,15 @@ class NeutronUtilsSubnetTests(OSComponentTestCase):
Cleans the remote OpenStack objects
"""
if self.subnet:
- neutron_utils.delete_subnet(self.neutron, self.subnet)
+ try:
+ neutron_utils.delete_subnet(self.neutron, self.subnet)
+ except:
+ pass
if self.network:
- neutron_utils.delete_network(self.neutron, self.network)
+ try:
+ neutron_utils.delete_network(self.neutron, self.network)
+ except:
+ pass
def test_create_subnet(self):
"""
@@ -173,6 +179,16 @@ class NeutronUtilsSubnetTests(OSComponentTestCase):
self.assertTrue(validate_subnet(
self.neutron, subnet_setting.name, subnet_setting.cidr, True))
+ subnet_query1 = neutron_utils.get_subnet(
+ self.neutron, subnet_name=subnet_setting.name)
+ self.assertEqual(self.subnet, subnet_query1)
+
+ subnet_query2 = neutron_utils.get_subnets_by_network(self.neutron,
+ self.network)
+ self.assertIsNotNone(subnet_query2)
+ self.assertEqual(1, len(subnet_query2))
+ self.assertEqual(self.subnet, subnet_query2[0])
+
def test_create_subnet_null_name(self):
"""
Tests the neutron_utils.create_neutron_subnet() function for an
@@ -201,13 +217,23 @@ class NeutronUtilsSubnetTests(OSComponentTestCase):
self.neutron, self.net_config.network_settings.name, True))
subnet_setting = self.net_config.network_settings.subnet_settings[0]
- neutron_utils.create_subnet(
+ self.subnet = neutron_utils.create_subnet(
self.neutron, subnet_setting, self.os_creds, network=self.network)
self.assertTrue(validate_subnet(
self.neutron, subnet_setting.name, subnet_setting.cidr, True))
self.assertFalse(validate_subnet(
self.neutron, '', subnet_setting.cidr, True))
+ subnet_query1 = neutron_utils.get_subnet(
+ self.neutron, subnet_name=subnet_setting.name)
+ self.assertEqual(self.subnet, subnet_query1)
+
+ subnet_query2 = neutron_utils.get_subnets_by_network(self.neutron,
+ self.network)
+ self.assertIsNotNone(subnet_query2)
+ self.assertEqual(1, len(subnet_query2))
+ self.assertEqual(self.subnet, subnet_query2[0])
+
def test_create_subnet_null_cidr(self):
"""
Tests the neutron_utils.create_neutron_subnet() function for an
@@ -272,17 +298,29 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
self.subnet)
if self.router:
- neutron_utils.delete_router(self.neutron, self.router)
- validate_router(self.neutron, self.router.name, False)
+ try:
+ neutron_utils.delete_router(self.neutron, self.router)
+ validate_router(self.neutron, self.router.name, False)
+ except:
+ pass
if self.port:
- neutron_utils.delete_port(self.neutron, self.port)
+ try:
+ neutron_utils.delete_port(self.neutron, self.port)
+ except:
+ pass
if self.subnet:
- neutron_utils.delete_subnet(self.neutron, self.subnet)
+ try:
+ neutron_utils.delete_subnet(self.neutron, self.subnet)
+ except:
+ pass
if self.network:
- neutron_utils.delete_network(self.neutron, self.network)
+ try:
+ neutron_utils.delete_network(self.neutron, self.network)
+ except:
+ pass
def test_create_router_simple(self):
"""
@@ -757,7 +795,11 @@ class NeutronUtilsFloatingIpTests(OSComponentTestCase):
Cleans the image and downloaded image file
"""
if self.floating_ip:
- neutron_utils.delete_floating_ip(self.neutron, self.floating_ip)
+ try:
+ neutron_utils.delete_floating_ip(
+ self.neutron, self.floating_ip)
+ except:
+ pass
def test_floating_ips(self):
"""