Use ipv4 subnet in Heat scenario tests

Previously we used first subnet from network and it was correct, because
there was only one subnet in network by default. According to the last changes
in devstack new ipv6 subnet was added to the all default networks.
This patch adds function to the base class, which allows to choose
subnet based on ip version. All scenario tests were updated to use only ipv4
subnet.

Also was added property for FIP, which specify ip of vip.

Change-Id: I199075909b97fe98e1a3c1d175b0b4cf7100403d
Closes-Bug: #1449896
diff --git a/common/test.py b/common/test.py
index ed1e254..0f8442b 100644
--- a/common/test.py
+++ b/common/test.py
@@ -172,6 +172,12 @@
             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
+
     @staticmethod
     def _stack_output(stack, output_key):
         """Return a stack output value for a given key."""
diff --git a/scenario/scenario_base.py b/scenario/scenario_base.py
index dd25b89..dbd825b 100644
--- a/scenario/scenario_base.py
+++ b/scenario/scenario_base.py
@@ -25,6 +25,7 @@
         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_loadbalancer.yaml b/scenario/templates/test_neutron_loadbalancer.yaml
index a8c4769..3014356 100644
--- a/scenario/templates/test_neutron_loadbalancer.yaml
+++ b/scenario/templates/test_neutron_loadbalancer.yaml
@@ -106,6 +106,8 @@
        floating_network: { get_param: external_network_id }
        port_id:
          { get_attr: [test_pool, vip, 'port_id'] }
+       fixed_ip_address:
+         { get_attr: [test_pool, vip, 'address'] }
 
   LBaaS:
     type: OS::Neutron::LoadBalancer
diff --git a/scenario/test_neutron_loadbalancer.py b/scenario/test_neutron_loadbalancer.py
index 1cb1c6f..2d852b3 100644
--- a/scenario/test_neutron_loadbalancer.py
+++ b/scenario/test_neutron_loadbalancer.py
@@ -55,7 +55,7 @@
             'key_name': self.keypair_name,
             'flavor': self.conf.minimal_instance_type,
             'image': self.conf.image_ref,
-            'private_subnet_id': self.net['subnets'][0],
+            'private_subnet_id': self.subnet_v4,
             'external_network_id': self.public_net['id'],
             'timeout': self.conf.build_timeout
         }
diff --git a/scenario/test_server_cfn_init.py b/scenario/test_server_cfn_init.py
index 8134713..b2650bb 100644
--- a/scenario/test_server_cfn_init.py
+++ b/scenario/test_server_cfn_init.py
@@ -91,11 +91,11 @@
                via generated keypair.
         """
         parameters = {
-            "key_name": self.keypair_name,
-            "flavor": self.conf.instance_type,
-            "image": self.conf.image_ref,
-            "timeout": self.conf.build_timeout,
-            "subnet": self.net["subnets"][0],
+            'key_name': self.keypair_name,
+            'flavor': self.conf.instance_type,
+            'image': self.conf.image_ref,
+            'timeout': self.conf.build_timeout,
+            'subnet': self.subnet_v4,
         }
 
         # Launch stack