Merge "Add ability to generate required parameters for manila in tempest conf"
diff --git a/_modules/runtest/tempest_sections/compute.py b/_modules/runtest/tempest_sections/compute.py
index 238ebb5..d4b468e 100644
--- a/_modules/runtest/tempest_sections/compute.py
+++ b/_modules/runtest/tempest_sections/compute.py
@@ -3,6 +3,35 @@
 
 from runtest import conditions
 
+MICROVERSION_RELEASE_MAPPING = {
+    'queens':
+        {
+            'min_microversion': '2.1',
+            'max_microversion': '2.60'
+        },
+    'pike':
+        {
+            'min_microversion': '2.1',
+            'max_microversion': '2.53'
+        },
+    'ocata':
+        {
+            'min_microversion': '2.1',
+            'max_microversion': '2.42'
+        },
+    'newton':
+        {
+            'min_microversion': '2.1',
+            'max_microversion': '2.42'
+        },
+    'mitaka':
+        {
+            'min_microversion': '2.1',
+            'max_microversion': '2.42'
+        }
+}
+
+
 class Compute(base_section.BaseSection):
 
     name = "compute"
@@ -26,7 +55,6 @@
         'volume_device_name',
     ]
 
-
     @property
     def build_interval(self):
         pass
@@ -127,7 +155,10 @@
 
     @property
     def max_microversion(self):
-        pass
+        c = conditions.BaseRule('nova.controller.enabled', 'eq', True)
+        nova_version = self.get_item_when_condition_match('nova.controller.version', c)
+        if nova_version and nova_version in MICROVERSION_RELEASE_MAPPING:
+            return MICROVERSION_RELEASE_MAPPING[nova_version]['max_microversion']
 
     @property
     def min_compute_nodes(self):
@@ -135,7 +166,10 @@
 
     @property
     def min_microversion(self):
-        pass
+        c = conditions.BaseRule('nova.controller.enabled', 'eq', True)
+        nova_version = self.get_item_when_condition_match('nova.controller.version', c)
+        if nova_version and nova_version in MICROVERSION_RELEASE_MAPPING:
+            return MICROVERSION_RELEASE_MAPPING[nova_version]['min_microversion']
 
     @property
     def ready_wait(self):
diff --git a/_modules/runtest/tempest_sections/dns_feature_enabled.py b/_modules/runtest/tempest_sections/dns_feature_enabled.py
index b3fb061..0f23ccb 100644
--- a/_modules/runtest/tempest_sections/dns_feature_enabled.py
+++ b/_modules/runtest/tempest_sections/dns_feature_enabled.py
@@ -1,6 +1,52 @@
 
 import base_section
 
+from runtest import conditions
+
+DNS_FEATURES_RELEASE_MAPPING = {
+    'queens':
+        {
+            'api_v1': False,
+            'api_v2': True,
+            'bug_1573141_fixed': True,
+            'api_v2_quotas': True,
+            'api_v2_root_recordsets': True
+        },
+    'pike':
+        {
+            'api_v1': False,
+            'api_v2': True,
+            'bug_1573141_fixed': True,
+            'api_v2_quotas': True,
+            'api_v2_root_recordsets': True
+        },
+    'ocata':
+        {
+            'api_v1': False,
+            'api_v2': True,
+            'bug_1573141_fixed': True,
+            'api_v2_quotas': True,
+            'api_v2_root_recordsets': True
+        },
+    'newton':
+        {
+            'api_v1': False,
+            'api_v2': True,
+            'bug_1573141_fixed': True,
+            'api_v2_quotas': True,
+            'api_v2_root_recordsets': True
+        },
+    'mitaka':
+        {
+            'api_v1': False,
+            'api_v2': True,
+            'bug_1573141_fixed': True,
+            'api_v2_quotas': True,
+            'api_v2_root_recordsets': True
+        }
+}
+
+
 class DnsFeatureEnabled(base_section.BaseSection):
 
     name = "dns_feature_enabled"
@@ -14,14 +60,17 @@
         'bug_1573141_fixed',
     ]
 
-
     @property
     def api_admin(self):
-        pass
+        c = conditions.BaseRule('designate.server.enabled', 'eq', True, multiple='any')
+        return self.get_item_when_condition_match('designate.server.admin_api.enabled', c)
 
     @property
     def api_v1(self):
-        pass
+        c = conditions.BaseRule('designate.server.enabled', 'eq', True, multiple='any')
+        designate_version = self.get_item_when_condition_match('designate.server.version', c)
+        if designate_version and designate_version in DNS_FEATURES_RELEASE_MAPPING:
+            return DNS_FEATURES_RELEASE_MAPPING[designate_version]['api_v1']
 
     @property
     def api_v1_servers(self):
@@ -29,16 +78,28 @@
 
     @property
     def api_v2(self):
-        pass
+        c = conditions.BaseRule('designate.server.enabled', 'eq', True, multiple='any')
+        designate_version = self.get_item_when_condition_match('designate.server.version', c)
+        if designate_version and designate_version in DNS_FEATURES_RELEASE_MAPPING:
+            return DNS_FEATURES_RELEASE_MAPPING[designate_version]['api_v2']
 
     @property
     def api_v2_quotas(self):
-        pass
+        c = conditions.BaseRule('designate.server.enabled', 'eq', True, multiple='any')
+        designate_version = self.get_item_when_condition_match('designate.server.version', c)
+        if designate_version and designate_version in DNS_FEATURES_RELEASE_MAPPING:
+            return DNS_FEATURES_RELEASE_MAPPING[designate_version]['api_v2_quotas']
 
     @property
     def api_v2_root_recordsets(self):
-        pass
+        c = conditions.BaseRule('designate.server.enabled', 'eq', True, multiple='any')
+        designate_version = self.get_item_when_condition_match('designate.server.version', c)
+        if designate_version and designate_version in DNS_FEATURES_RELEASE_MAPPING:
+            return DNS_FEATURES_RELEASE_MAPPING[designate_version]['api_v2_root_recordsets']
 
     @property
     def bug_1573141_fixed(self):
-        pass
+        c = conditions.BaseRule('designate.server.enabled', 'eq', True, multiple='any')
+        designate_version = self.get_item_when_condition_match('designate.server.version', c)
+        if designate_version and designate_version in DNS_FEATURES_RELEASE_MAPPING:
+            return DNS_FEATURES_RELEASE_MAPPING[designate_version]['bug_1573141_fixed']
diff --git a/_modules/runtest/tempest_sections/heat_plugin.py b/_modules/runtest/tempest_sections/heat_plugin.py
index 219b226..7bd1196 100644
--- a/_modules/runtest/tempest_sections/heat_plugin.py
+++ b/_modules/runtest/tempest_sections/heat_plugin.py
@@ -3,6 +3,12 @@
 
 from runtest import conditions
 
+
+DEFAULT_HEAT_PLUGIN_PARAMETERS = {
+    'auth_version': 3
+}
+
+
 class HeatPlugin(base_section.BaseSection):
 
     name = "heat_plugin"
@@ -82,7 +88,15 @@
 
     @property
     def auth_version(self):
-        pass
+        admin_identity = \
+            'keystone.client.os_client_config.cfgs.root.content.clouds.admin_identity.{}'
+        c = conditions.BaseRule('keystone.client.enabled', 'eq', True)
+        AUTH_VERSION = self.get_item_when_condition_match(
+            admin_identity.format('identity_api_version'), c)
+        if AUTH_VERSION:
+            return AUTH_VERSION
+        else:
+            return DEFAULT_HEAT_PLUGIN_PARAMETERS['auth_version']
 
     @property
     def boot_config_env(self):
@@ -126,7 +140,12 @@
 
     @property
     def floating_network_name(self):
-        pass
+        c = conditions.BaseRule('neutron.client.enabled', 'eq', True)
+        networks = self.get_item_when_condition_match(
+            'neutron.client.server.admin_identity.network', c)
+        for network_name, network in networks.items():
+            if network['router_external'] is True:
+                return network_name
 
     @property
     def heat_config_notify_script(self):
@@ -138,7 +157,11 @@
 
     @property
     def instance_type(self):
-        pass
+        c = conditions.BaseRule('nova.client.enabled', 'eq', True)
+        flavors = self.get_item_when_condition_match(
+            'nova.client.server.admin_identity.flavor', c)
+        instance_type_name, _ = sorted(flavors.items(), key=lambda (k, v): (v, k))[-1]
+        return instance_type_name
 
     @property
     def ip_version_for_ssh(self):
@@ -154,7 +177,11 @@
 
     @property
     def minimal_instance_type(self):
-        pass
+        c = conditions.BaseRule('nova.client.enabled', 'eq', True)
+        flavors = self.get_item_when_condition_match(
+            'nova.client.server.admin_identity.flavor', c)
+        minimal_instance_type_name, _ = sorted(flavors.items(), key=lambda (k, v): (v, k))[0]
+        return minimal_instance_type_name
 
     @property
     def network_for_ssh(self):
@@ -190,6 +217,7 @@
     def sighup_config_edit_retries(self):
         pass
 
+
     @property
     def sighup_timeout(self):
         pass
diff --git a/_modules/runtest/tempest_sections/network.py b/_modules/runtest/tempest_sections/network.py
index 9b4aea0..cdf3daa 100644
--- a/_modules/runtest/tempest_sections/network.py
+++ b/_modules/runtest/tempest_sections/network.py
@@ -53,7 +53,12 @@
 
     @property
     def floating_network_name(self):
-        pass
+        c = conditions.BaseRule('neutron.client.enabled', 'eq', True)
+        networks = self.get_item_when_condition_match(
+            'neutron.client.server.admin_identity.network', c)
+        for network_name, network in networks.items():
+            if network['router_external'] is True:
+                return network_name
 
     @property
     def port_vnic_type(self):
diff --git a/metadata/service/tempest/init.yml b/metadata/service/tempest/init.yml
index e4959a5..5f38c3f 100644
--- a/metadata/service/tempest/init.yml
+++ b/metadata/service/tempest/init.yml
@@ -75,36 +75,19 @@
         log_file: ${_param:runtest_tempest_log_file}
       compute:
         build_timeout: 600
-        min_microversion: 2.1
-        max_microversion: 2.53
       dashboard:
         # Set to true until Horizon CA bundle pass would be allowed
         disable_ssl_certificate_validation: true
       identity:
         disable_ssl_certificate_validation: false
-      network:
-        floating_network_name: ${_param:runtest_tempest_public_net}
       orchestration:
         max_template_size: 5440000
         max_resources_per_stack: 20000
-      dns_feature_enabled:
-        # Switch this to designate_admin_api_enabled once [1] is promoted to stable packages
-        # [1] https://gerrit.mcp.mirantis.net/gitweb?p=salt-formulas/designate.git;a=commit;h=96a3f43f6cf1149559e54a00b5548bdf46333749
-        api_admin: false
-        api_v1: false
-        api_v2: true
-        api_v2_quotas: true
-        api_v2_root_recordsets: true
-        bug_1573141_fixed: true
       volume-feature-enabled:
         backup: false
       heat_plugin:
-        floating_network_name: ${_param:runtest_tempest_public_net}
         skip_scenario_test_list: ${_param:runtest_heat_plugin_skip_scenario_test_list}
         skip_functional_test_list: ${_param:runtest_heat_plugin_skip_functional_test_list}
-        instance_type: 'm1.tiny_test'
-        minimal_instance_type: 'm1.extra_tiny_test'
-        auth_version: 3
         project_domain_id: default
         user_domain_id: default
         disable_ssl_certificate_validation: False