diff --git a/tobiko/openstack/stacks/_neutron.py b/tobiko/openstack/stacks/_neutron.py index 1dd168b66..de69d59ce 100644 --- a/tobiko/openstack/stacks/_neutron.py +++ b/tobiko/openstack/stacks/_neutron.py @@ -60,10 +60,13 @@ class NetworkStackFixture(heat.HeatStackFixture): class FloatingIpServerStackFixture(heat.HeatStackFixture): #: Heat template file - template = _hot.heat_template_file('neutron/server.yaml') + template = _hot.heat_template_file('neutron/floating_ip_server.yaml') + #: stack with the key pair for the server instance key_pair_stack = tobiko.required_setup_fixture( _nova.KeyPairStackFixture) + + #: stack with the internal where the server port is created network_stack = tobiko.required_setup_fixture(NetworkStackFixture) #: Glance image used to create a Nova server instance diff --git a/tobiko/openstack/stacks/neutron/server.yaml b/tobiko/openstack/stacks/neutron/floating_ip_server.yaml similarity index 100% rename from tobiko/openstack/stacks/neutron/server.yaml rename to tobiko/openstack/stacks/neutron/floating_ip_server.yaml diff --git a/tobiko/tests/scenario/neutron/templates/floating_ip.yaml b/tobiko/tests/scenario/neutron/templates/floating_ip.yaml deleted file mode 100644 index 4121b7528..000000000 --- a/tobiko/tests/scenario/neutron/templates/floating_ip.yaml +++ /dev/null @@ -1,81 +0,0 @@ -heat_template_version: newton - -description: | - Stack of resources used to test floating IP - - -parameters: - key_name: - type: string - - flavor: - type: string - - image: - type: string - - floating_network: - type: string - - internal_network: - type: string - - port_security_enabled: - type: boolean - default: false - - security_groups: - type: comma_delimited_list - default: [] - - -resources: - - port: - type: OS::Neutron::Port - properties: - network: {get_param: internal_network} - port_security_enabled: {get_param: port_security_enabled} - security_groups: {get_param: security_groups} - - server_name: - type: OS::Heat::RandomString - properties: - character_classes: [{'class': 'lowercase', 'min': 1}] - length: 8 - - server: - type: OS::Nova::Server - properties: - name: {get_attr: [server_name, value]} - key_name: {get_param: key_name} - image: {get_param: image} - flavor: {get_param: flavor} - networks: - - port: {get_resource: port} - - floating_ip: - type: OS::Neutron::FloatingIP - properties: - floating_network: {get_param: floating_network} - - floating_ip_association: - type: OS::Neutron::FloatingIPAssociation - properties: - floatingip_id: {get_resource: floating_ip} - port_id: {get_resource: port} - - -outputs: - - floating_ip_address: - value: {get_attr: [floating_ip, floating_ip_address]} - - port_security_enabled: - value: {get_attr: [port, port_security_enabled]} - - security_groups: - value: {get_attr: [port, security_groups]} - - server_name: - value: {get_attr: [server, name]} diff --git a/tobiko/tests/scenario/neutron/test_floating_ip.py b/tobiko/tests/scenario/neutron/test_floating_ip.py index 405114dd6..cc8b8eb64 100644 --- a/tobiko/tests/scenario/neutron/test_floating_ip.py +++ b/tobiko/tests/scenario/neutron/test_floating_ip.py @@ -17,9 +17,7 @@ from __future__ import absolute_import import tobiko from tobiko import config from tobiko.shell import ping -from tobiko.shell import ssh from tobiko.shell import sh -from tobiko.openstack import heat from tobiko.openstack import neutron from tobiko.openstack import stacks from tobiko.tests import base @@ -29,43 +27,15 @@ from tobiko.tests.scenario.neutron import _stacks CONF = config.CONF -class FloatingIPFixture(heat.HeatStackFixture): +class FloatingIPFixture(stacks.FloatingIpServerStackFixture): """Heat stack for testing a floating IP instance """ - #: Heat template file - template = _stacks.heat_template_file('floating_ip.yaml') - - #: Floating IP network where the Neutron floating IP is created - floating_network = CONF.tobiko.neutron.floating_network - - #: Glance image used to create a Nova server instance - image = CONF.tobiko.nova.image - - #: Nova flavor used to create a Nova server instance - flavor = CONF.tobiko.nova.flavor - - #: Username used to login to Nova server instance - username = CONF.tobiko.nova.username - - @property - def internal_network(self): - """Internal network where the Nova server instance is connected - - """ - return self.internal_network_stack.outputs.network_id - - # --- required fixtures --- - - #: Heat stack for creating internal network with a router to floating - #: network - internal_network_stack = tobiko.required_setup_fixture( + #: stack with the internal where the server port is created + network_stack = tobiko.required_setup_fixture( _stacks.InternalNetworkFixture) - # --- class parameters --- #: Whenever port security on internal network is enable - key_pair_stack = tobiko.required_setup_fixture( - stacks.KeyPairStackFixture) port_security_enabled = False #: Security groups to be associated to network ports @@ -88,10 +58,6 @@ class FloatingIPFixture(heat.HeatStackFixture): port_security_enabled=self.port_security_enabled, security_groups=self.security_groups or []) - @property - def key_name(self): - return self.key_pair_stack.outputs.key_name - @property def server_name(self): return self.outputs.server_name @@ -100,16 +66,6 @@ class FloatingIPFixture(heat.HeatStackFixture): def floating_ip_address(self): return self.outputs.floating_ip_address - @property - def ssh_client(self): - return ssh.ssh_client(host=self.floating_ip_address, - username=self.username) - - @property - def ssh_command(self): - return ssh.ssh_command(host=self.floating_ip_address, - username=self.username) - class FloatingIPTest(base.TobikoTest): """Tests connectivity to Nova instances via floating IPs""" @@ -212,12 +168,12 @@ class FloatingIPTest(base.TobikoTest): @property def expected_net_mtu(self): """Expected MTU value for internal network""" - return self.floating_ip_stack.internal_network_stack.mtu + return self.floating_ip_stack.network_stack.mtu @property def observed_net_mtu(self): """Actual MTU value for internal network""" - return self.floating_ip_stack.internal_network_stack.outputs.mtu + return self.floating_ip_stack.network_stack.outputs.mtu @neutron.skip_if_missing_networking_extensions('port-security') @@ -311,7 +267,7 @@ class FloatingIPWithNetMtuWritableFixture(FloatingIPFixture): """ #: Heat stack for creating internal network with custom MTU value - internal_network_stack = tobiko.required_setup_fixture( + network_stack = tobiko.required_setup_fixture( _stacks.InternalNetworkWithNetMtuWritableFixture)