Merge "Add Ironic to the tempest.conf configuration"
diff --git a/_modules/runtest/tempest_sections/baremetal.py b/_modules/runtest/tempest_sections/baremetal.py
index d93c210..016e216 100644
--- a/_modules/runtest/tempest_sections/baremetal.py
+++ b/_modules/runtest/tempest_sections/baremetal.py
@@ -1,6 +1,38 @@
 
 import base_section
 
+from runtest import conditions
+
+
+IRONIC_MICROVERSION_RELEASE_MAPPING = {
+    'queens':
+        {
+            'min_microversion': '1.1',
+            'max_microversion': '1.38'
+        },
+    'pike':
+        {
+            'min_microversion': '1.1',
+            'max_microversion': '1.34'
+        },
+    'ocata':
+        {
+            'min_microversion': '1.1',
+            'max_microversion': '1.31'
+        },
+    'newton':
+        {
+            'min_microversion': '1.1',
+            'max_microversion': '1.22'
+        },
+    'mitaka':
+        {
+            'min_microversion': '1.1',
+            'max_microversion': '1.16'
+        }
+}
+
+
 class Baremetal(base_section.BaseSection):
 
     name = "baremetal"
@@ -11,6 +43,7 @@
         'catalog_type',
         'deploywait_timeout',
         'driver',
+        'enabled_deploy_interfaces',
         'enabled_drivers',
         'enabled_hardware_types',
         'endpoint_type',
@@ -51,12 +84,34 @@
         pass
 
     @property
+    def enabled_deploy_interfaces(self):
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        enabled_deploy_interfaces = self.get_item_when_condition_match('ironic.conductor.enabled_deploy_interfaces', c)
+        if enabled_deploy_interfaces:
+            return enabled_deploy_interfaces
+        else:
+            return "iscsi,direct"
+
+    @property
     def enabled_drivers(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        enabled_drivers = self.get_item_when_condition_match('ironic.conductor.enabled_drivers', c)
+        # ironic.conductor.enabled_drivers returns a list if it has several drivers
+        # in other cases it returns a string or None
+        if enabled_drivers:
+            if type(enabled_drivers) == list:
+                return ",".join(map(str, enabled_drivers))
+            return enabled_drivers
+        return
 
     @property
     def enabled_hardware_types(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        enabled_hardware_types = self.get_item_when_condition_match('ironic.conductor.enabled_hardware_types', c)
+        if enabled_hardware_types:
+            return enabled_hardware_types
+        else:
+            return "ipmi"
 
     @property
     def endpoint_type(self):
@@ -64,11 +119,17 @@
 
     @property
     def max_microversion(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        baremetal_version = self.get_item_when_condition_match('ironic.conductor.version', c)
+        if baremetal_version and baremetal_version in IRONIC_MICROVERSION_RELEASE_MAPPING:
+            return IRONIC_MICROVERSION_RELEASE_MAPPING[baremetal_version]['max_microversion']
 
     @property
     def min_microversion(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        baremetal_version = self.get_item_when_condition_match('ironic.conductor.version', c)
+        if baremetal_version and baremetal_version in IRONIC_MICROVERSION_RELEASE_MAPPING:
+            return IRONIC_MICROVERSION_RELEASE_MAPPING[baremetal_version]['min_microversion']
 
     @property
     def partition_image_ref(self):
diff --git a/_modules/runtest/tempest_sections/baremetal_feature_enabled.py b/_modules/runtest/tempest_sections/baremetal_feature_enabled.py
index 3f83520..0e04108 100644
--- a/_modules/runtest/tempest_sections/baremetal_feature_enabled.py
+++ b/_modules/runtest/tempest_sections/baremetal_feature_enabled.py
@@ -1,6 +1,9 @@
 
 import base_section
 
+from runtest import conditions
+
+
 class BaremetalFeatureEnabled(base_section.BaseSection):
 
     name = "baremetal_feature_enabled"
@@ -11,4 +14,10 @@
 
     @property
     def ipxe_enabled(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ipxe_enabled = self.get_item_when_condition_match('ironic.conductor.ipxe_enabled', c)
+        if ipxe_enabled:
+            return True
+        else:
+            return False
+
diff --git a/_modules/runtest/tempest_sections/compute.py b/_modules/runtest/tempest_sections/compute.py
index 783f997..d131018 100644
--- a/_modules/runtest/tempest_sections/compute.py
+++ b/_modules/runtest/tempest_sections/compute.py
@@ -73,7 +73,11 @@
 
     @property
     def fixed_network_name(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        fixed_network_name = self.get_item_when_condition_match('ironic.conductor.neutron.provisioning_network', c)
+        if fixed_network_name:
+            return fixed_network_name
+        return
 
     @property
     def flavor_ref(self):
diff --git a/_modules/runtest/tempest_sections/compute_feature_enabled.py b/_modules/runtest/tempest_sections/compute_feature_enabled.py
index 53a4404..3fd36f8 100644
--- a/_modules/runtest/tempest_sections/compute_feature_enabled.py
+++ b/_modules/runtest/tempest_sections/compute_feature_enabled.py
@@ -70,6 +70,12 @@
 
     @property
     def block_migration_for_live_migration(self):
+        # Ironic does not support block migration for live migration
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
         c = conditions.BaseRule('cinder.volume.enabled', 'eq', True)
         backends = self.get_item_when_condition_match(
             'cinder.volume.backend', c)
@@ -84,7 +90,11 @@
 
     @property
     def change_password(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def cold_migration(self):
@@ -96,11 +106,19 @@
 
     @property
     def console_output(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def disk_config(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def enable_instance_password(self):
@@ -108,14 +126,27 @@
 
     @property
     def interface_attach(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def live_migrate_back_and_forth(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def live_migration(self):
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
         return conditions.BaseRule('*.nova.compute.enabled', 'eq', True,
                                    multiple='multiple').check(self.pillar)
 
@@ -129,11 +160,19 @@
 
     @property
     def pause(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def personality(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def rdp_console(self):
@@ -141,10 +180,19 @@
 
     @property
     def rescue(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def resize(self):
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
         # NOTE(vsaienko) allow_resize_to_same_host is hardcoded to True in
         # nova formula, update when value is configurable.
         res = conditions.BaseRule('*.nova.compute.enabled', 'eq', True,
@@ -161,11 +209,19 @@
 
     @property
     def shelve(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def snapshot(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def spice_console(self):
@@ -173,7 +229,11 @@
 
     @property
     def suspend(self):
-        pass
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
 
     @property
     def swap_volume(self):
@@ -183,6 +243,11 @@
     def vnc_console(self):
         # The vnc is enabled by default in nova-formula, so rely on compute presence.
         #TODO: fix when value is unhardcoded.
+        c = conditions.BaseRule('ironic.conductor.enabled', 'eq', True)
+        ironic = self.get_item_when_condition_match(
+            'ironic.conductor.enabled', c)
+        if ironic:
+            return False
         return conditions.BaseRule('*.nova.compute.enabled', 'eq', True,
                             multiple='any').check(self.pillar)
 
diff --git a/metadata/service/tempest/init.yml b/metadata/service/tempest/init.yml
index 136b897..162d983 100644
--- a/metadata/service/tempest/init.yml
+++ b/metadata/service/tempest/init.yml
@@ -1,12 +1,14 @@
 classes:
+  - service.runtest.tempest.artifactory
   - service.runtest.tempest.glance
   - service.runtest.tempest.nova
   - service.runtest.tempest.neutron
-  - service.runtest.tempest.artifactory
 applications:
   - runtest
 parameters:
   _param:
+    runtest_tempest_convert_to_uuid_flavor_ref: 'm1.extra_tiny_test'
+    runtest_tempest_convert_to_uuid_flavor_ref_alt: 'm1.tiny_test'
     glance_image_cirros_name: 'TestCirros-0.3.5'
     glance_image_fedora_name: 'TestFedora-27-1.6'
     glance_image_manila_name: 'manila-service-image-master'
@@ -79,9 +81,9 @@
       convert_to_uuid:
         compute:
           image_ref: ${_param:glance_image_cirros_name}
-          flavor_ref: 'm1.extra_tiny_test'
-          flavor_ref_alt: 'm1.tiny_test'
           image_ref_alt: ${_param:glance_image_cirros_name}
+          flavor_ref: ${_param:runtest_tempest_convert_to_uuid_flavor_ref}
+          flavor_ref_alt: ${_param:runtest_tempest_convert_to_uuid_flavor_ref_alt}
           image_ref_nfs: ${_param:glance_image_manila_name}
         network:
           public_network_id: ${_param:runtest_tempest_public_net}
diff --git a/metadata/service/tempest/ironic.yml b/metadata/service/tempest/ironic.yml
index fe75b3e..ba31b60 100644
--- a/metadata/service/tempest/ironic.yml
+++ b/metadata/service/tempest/ironic.yml
@@ -1,7 +1,22 @@
 parameters:
+  _param:
+    runtest_tempest_convert_to_uuid_flavor_ref: baremetal
+  runtest:
+    tempest:
+      network:
+        project_networks_reachable: false
+        floating_network_name: 'public'
+        shared_physical_network: true
+      auth:
+        create_isolated_networks: false
+      baremetal:
+        power_timeout: 600
+        deploywait_timeout: 600
+        active_timeout: 600
+        unprovision_timeout: 600
   nova:
     client:
-      enabled: True
+      enabled: true
       server:
         admin_identity:
           flavor:
@@ -17,7 +32,7 @@
           router:
             baremetal-router:
               tenant: admin
-              admin_state_up: True
+              admin_state_up: true
               gateway_network: ${_param:runtest_tempest_public_net}
               interfaces:
                 - baremetal-subnet
diff --git a/metadata/service/tempest/nova.yml b/metadata/service/tempest/nova.yml
index 0dce923..b4dc560 100644
--- a/metadata/service/tempest/nova.yml
+++ b/metadata/service/tempest/nova.yml
@@ -1,4 +1,7 @@
 parameters:
+  _param:
+    runtest_tempest_convert_to_uuid_flavor_ref: m1.extra_tiny_test
+    runtest_tempest_convert_to_uuid_flavor_ref_alt: m1.tiny_test
   nova:
     client:
       enabled: True
@@ -12,4 +15,4 @@
             m1.extra_tiny_test:
               ram: 256
               disk: 1
-              vcpus: 1
\ No newline at end of file
+              vcpus: 1