Merge "Add functional test for neutron port"
diff --git a/common/config.py b/common/config.py
index 5ced77b..4f6ea3d 100644
--- a/common/config.py
+++ b/common/config.py
@@ -62,10 +62,10 @@
                default=1200,
                help="Timeout in seconds to wait for a stack to build."),
     cfg.StrOpt('network_for_ssh',
-               default='private',
+               default='heat-net',
                help="Network used for SSH connections."),
     cfg.StrOpt('fixed_network_name',
-               default='private',
+               default='heat-net',
                help="Visible fixed network name "),
     cfg.StrOpt('floating_network_name',
                default='public',
@@ -77,7 +77,7 @@
                     "resource type Heat::InstallConfigAgent. Needs to "
                     "be appropriate for the image_ref."),
     cfg.StrOpt('fixed_subnet_name',
-               default='private-subnet',
+               default='heat-subnet',
                help="Visible fixed sub-network name "),
     cfg.IntOpt('ssh_timeout',
                default=300,
diff --git a/common/test.py b/common/test.py
index 4168fb4..acfe1ad 100644
--- a/common/test.py
+++ b/common/test.py
@@ -174,17 +174,6 @@
             if net['name'] == net_name:
                 return net
 
-    def _get_subnet_by_version(self, network, ip_version=4):
-        for subnet_id in self.net['subnets']:
-            subnet_info = self.network_client.show_subnet(subnet_id)
-            if subnet_info['subnet']['ip_version'] == ip_version:
-                return subnet_id
-
-    def _get_server_ip_by_version(self, addresses, ip_version=4):
-        for address in addresses:
-            if address['version'] == ip_version:
-                return address['addr']
-
     @staticmethod
     def _stack_output(stack, output_key):
         """Return a stack output value for a given key."""
diff --git a/functional/test_create_update.py b/functional/test_create_update.py
index 37b1790..6053303 100644
--- a/functional/test_create_update.py
+++ b/functional/test_create_update.py
@@ -116,6 +116,8 @@
     type: string
   image:
     type: string
+  network:
+    type: string
 
 resources:
   server:
@@ -123,6 +125,7 @@
     properties:
       image: {get_param: image}
       flavor: {get_param: flavor}
+      networks: [{network: {get_param: network} }]
       user_data_format: SOFTWARE_CONFIG
       user_data: {get_param: user_data}
 '''
@@ -369,6 +372,7 @@
 
         parms = {'flavor': self.conf.minimal_instance_type,
                  'image': self.conf.minimal_image_ref,
+                 'network': self.conf.fixed_network_name,
                  'user_data': ''}
         name = self._stack_rand_name()
 
diff --git a/scenario/scenario_base.py b/scenario/scenario_base.py
index dbd825b..dd25b89 100644
--- a/scenario/scenario_base.py
+++ b/scenario/scenario_base.py
@@ -25,7 +25,6 @@
         if not self.conf.fixed_network_name:
             raise self.skipException("No default network configured to test")
         self.net = self._get_network()
-        self.subnet_v4 = self._get_subnet_by_version(self.net)
 
         if not self.conf.image_ref:
             raise self.skipException("No image configured to test")
diff --git a/scenario/templates/test_neutron_autoscaling.yaml b/scenario/templates/test_neutron_autoscaling.yaml
index 59aad2c..a34ec43 100644
--- a/scenario/templates/test_neutron_autoscaling.yaml
+++ b/scenario/templates/test_neutron_autoscaling.yaml
@@ -11,7 +11,7 @@
     type: string
     label: Capacity
     description: Auto-scaling group desired capacity
-  fixed_subnet_name:
+  fixed_subnet:
     type: string
     label: fixed subnetwork ID
     description: subnetwork ID used for autoscaling
@@ -28,7 +28,7 @@
       lb_method: ROUND_ROBIN
       name: test_pool
       protocol: HTTP
-      subnet: { get_param: fixed_subnet_name }
+      subnet: { get_param: fixed_subnet }
       vip: {
         "description": "Test VIP",
         "protocol_port": 80,
@@ -49,6 +49,7 @@
     properties:
       AvailabilityZones : ["nova"]
       LaunchConfigurationName : { get_resource : launch_config }
+      VPCZoneIdentifier: [{ get_param: fixed_subnet }]
       MinSize : 1
       MaxSize : 5
       DesiredCapacity: { get_param: capacity }
diff --git a/scenario/templates/test_neutron_loadbalancer.yaml b/scenario/templates/test_neutron_loadbalancer.yaml
index b0c48c2..dd659d0 100644
--- a/scenario/templates/test_neutron_loadbalancer.yaml
+++ b/scenario/templates/test_neutron_loadbalancer.yaml
@@ -10,6 +10,8 @@
     type: string
   image:
     type: string
+  network:
+    type: string
   private_subnet_id:
     type: string
   external_network_id:
@@ -66,6 +68,7 @@
       image: { get_param: image }
       flavor: { get_param: flavor }
       key_name: { get_param: key_name }
+      networks: [{network: {get_param: network} }]
       security_groups: [{ get_resource: sec_group }]
       user_data_format: SOFTWARE_CONFIG
       user_data: { get_resource: config }
@@ -77,6 +80,7 @@
       image: { get_param: image }
       flavor: { get_param: flavor }
       key_name: { get_param: key_name }
+      networks: [{network: {get_param: network} }]
       security_groups: [{ get_resource: sec_group }]
       user_data_format: SOFTWARE_CONFIG
       user_data: { get_resource: config }
@@ -119,10 +123,10 @@
       - { get_resource: server1 }
 
 outputs:
-  serv1_addresses:
-    value: {get_attr: [server1, addresses, private]}
-  serv2_addresses:
-    value: {get_attr: [server2, addresses, private]}
+  serv1_ip:
+    value: {get_attr: [server1, networks, { get_param: network }, 0]}
+  serv2_ip:
+    value: {get_attr: [server2, networks, { get_param: network }, 0]}
   vip:
     value: {get_attr: [test_pool, vip, address]}
   fip:
diff --git a/scenario/test_neutron_autoscaling.py b/scenario/test_neutron_autoscaling.py
index 9a1e634..e7aae19 100644
--- a/scenario/test_neutron_autoscaling.py
+++ b/scenario/test_neutron_autoscaling.py
@@ -40,7 +40,7 @@
             "image_id": self.conf.minimal_image_ref,
             "capacity": "1",
             "instance_type": self.conf.minimal_instance_type,
-            "fixed_subnet_name": self.conf.fixed_subnet_name,
+            "fixed_subnet": self.net['subnets'][0],
         }
 
         # Launch stack
diff --git a/scenario/test_neutron_loadbalancer.py b/scenario/test_neutron_loadbalancer.py
index 61642d1..d8e0197 100644
--- a/scenario/test_neutron_loadbalancer.py
+++ b/scenario/test_neutron_loadbalancer.py
@@ -55,7 +55,8 @@
             'key_name': self.keypair_name,
             'flavor': self.conf.minimal_instance_type,
             'image': self.conf.image_ref,
-            'private_subnet_id': self.subnet_v4,
+            'network': self.net['name'],
+            'private_subnet_id': self.net['subnets'][0],
             'external_network_id': self.public_net['id'],
             'timeout': self.conf.build_timeout
         }
@@ -69,10 +70,8 @@
         stack = self.client.stacks.get(sid)
         floating_ip = self._stack_output(stack, 'fip')
         vip = self._stack_output(stack, 'vip')
-        server1_ip = self._get_server_ip_by_version(
-            self._stack_output(stack, 'serv1_addresses'))
-        server2_ip = self._get_server_ip_by_version(
-            self._stack_output(stack, 'serv2_addresses'))
+        server1_ip = self._stack_output(stack, 'serv1_ip')
+        server2_ip = self._stack_output(stack, 'serv2_ip')
         # Check connection and info about received responses
         self.check_connectivity(server1_ip)
         self.collect_responses(server1_ip, {'server1\n'})
diff --git a/scenario/test_server_cfn_init.py b/scenario/test_server_cfn_init.py
index b2650bb..b5b1e67 100644
--- a/scenario/test_server_cfn_init.py
+++ b/scenario/test_server_cfn_init.py
@@ -95,7 +95,7 @@
             'flavor': self.conf.instance_type,
             'image': self.conf.image_ref,
             'timeout': self.conf.build_timeout,
-            'subnet': self.subnet_v4,
+            'subnet': self.net['subnets'][0],
         }
 
         # Launch stack