From 9fa64ef86316036a40f742b92bbe6a3ca1d490fb Mon Sep 17 00:00:00 2001 From: spisarski Date: Mon, 23 Oct 2017 08:48:10 -0600 Subject: Added ext_net_name into template substitution variable. Without the change, the template would always leverage the external network name of 'external'. Also am now creating a security group for the VM with the floating IP so the test will always be able to access. Fixed another test that used the same heat template that was changed to add in security groups. JIRA: SNAPS-206 Change-Id: I19b09e91a844f88bd473ea25b2bba71ae19b0aa1 Signed-off-by: spisarski --- snaps/openstack/tests/create_stack_tests.py | 5 ++++- .../tests/heat/floating_ip_heat_template.yaml | 19 +++++++++++++++++++ snaps/openstack/utils/tests/heat_utils_tests.py | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) (limited to 'snaps') diff --git a/snaps/openstack/tests/create_stack_tests.py b/snaps/openstack/tests/create_stack_tests.py index f4eb1eb..d96462a 100644 --- a/snaps/openstack/tests/create_stack_tests.py +++ b/snaps/openstack/tests/create_stack_tests.py @@ -424,6 +424,7 @@ class CreateComplexStackTests(OSIntegrationTestCase): self.subnet_name = self.guid + '-subnet' self.flavor1_name = self.guid + '-flavor1' self.flavor2_name = self.guid + '-flavor2' + self.sec_grp_name = self.guid + '-sec_grp' self.vm_inst1_name = self.guid + '-inst1' self.vm_inst2_name = self.guid + '-inst2' self.keypair_name = self.guid + '-kp' @@ -437,7 +438,9 @@ class CreateComplexStackTests(OSIntegrationTestCase): 'subnet_name': self.subnet_name, 'inst1_name': self.vm_inst1_name, 'inst2_name': self.vm_inst2_name, - 'keypair_name': self.keypair_name} + 'keypair_name': self.keypair_name, + 'external_net_name': self.ext_net_name, + 'security_group_name': self.sec_grp_name} self.heat_tmplt_path = pkg_resources.resource_filename( 'snaps.openstack.tests.heat', 'floating_ip_heat_template.yaml') diff --git a/snaps/openstack/tests/heat/floating_ip_heat_template.yaml b/snaps/openstack/tests/heat/floating_ip_heat_template.yaml index e09515e..a191acc 100644 --- a/snaps/openstack/tests/heat/floating_ip_heat_template.yaml +++ b/snaps/openstack/tests/heat/floating_ip_heat_template.yaml @@ -61,6 +61,11 @@ parameters: label: Keypair name description: The name of the stack's keypair default: keypair_name + security_group_name: + type: string + label: Security Group name + description: The name of the stack's security group + default: security_group_name inst1_name: type: string label: First VM name @@ -116,6 +121,19 @@ resources: router: { get_resource: management_router } subnet: { get_resource: subnet } + server_security_group: + type: OS::Neutron::SecurityGroup + properties: + description: Add security group rules for server + name: { get_param: security_group_name } + rules: + - remote_ip_prefix: 0.0.0.0/0 + protocol: tcp + port_range_min: 22 + port_range_max: 22 + - remote_ip_prefix: 0.0.0.0/0 + protocol: icmp + floating_ip: type: OS::Neutron::FloatingIP properties: @@ -141,6 +159,7 @@ resources: image: { get_param: image1_name } flavor: { get_resource: flavor1 } key_name: {get_resource: keypair} + security_groups: [{ get_resource: server_security_group }] networks: - network: { get_resource: network } diff --git a/snaps/openstack/utils/tests/heat_utils_tests.py b/snaps/openstack/utils/tests/heat_utils_tests.py index 44235ff..6f75f89 100644 --- a/snaps/openstack/utils/tests/heat_utils_tests.py +++ b/snaps/openstack/utils/tests/heat_utils_tests.py @@ -399,7 +399,7 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase): """ resources = heat_utils.get_resources(self.heat_client, self.stack) self.assertIsNotNone(resources) - self.assertEqual(11, len(resources)) + self.assertEqual(12, len(resources)) options = heat_utils.get_outputs(self.heat_client, self.stack) self.assertIsNotNone(options) -- cgit 1.2.3-korg