Add ability to set deploy interface

Change-Id: If41cee96258a06982748bca134ec70c2cde6e51b
diff --git a/ironic_tempest_plugin/config.py b/ironic_tempest_plugin/config.py
index 96a7f74..f9fefc4 100644
--- a/ironic_tempest_plugin/config.py
+++ b/ironic_tempest_plugin/config.py
@@ -113,6 +113,9 @@
     cfg.ListOpt('enabled_hardware_types',
                 default=['ipmi'],
                 help="List of Ironic enabled hardware types."),
+    cfg.ListOpt('enabled_deploy_interfaces',
+                default=['iscsi', 'direct'],
+                help="List of Ironic enabled deploy interfaces."),
     cfg.IntOpt('adjusted_root_disk_size_gb',
                min=0,
                help="Ironic adjusted disk size to use in the standalone tests "
diff --git a/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py b/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
index 9712dba..c03b49b 100644
--- a/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
+++ b/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
@@ -387,6 +387,7 @@
                            'properties/local_gb',
                            'properties/memory_mb',
                            'driver',
+                           'deploy_interface',
                            'instance_uuid',
                            'resource_class')
         if not patch:
diff --git a/ironic_tempest_plugin/tests/scenario/baremetal_manager.py b/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
index bd6f1bd..b4a8169 100644
--- a/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
+++ b/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
@@ -140,9 +140,9 @@
 
     @classmethod
     @retry_on_conflict
-    def update_node_driver(cls, node_id, driver):
+    def update_node_driver(cls, node_id, driver, **interfaces):
         _, body = cls.baremetal_client.update_node(
-            node_id, driver=driver)
+            node_id, driver=driver, **interfaces)
         return body
 
     @classmethod
diff --git a/ironic_tempest_plugin/tests/scenario/baremetal_standalone_manager.py b/ironic_tempest_plugin/tests/scenario/baremetal_standalone_manager.py
index 1d19c47..0137db8 100644
--- a/ironic_tempest_plugin/tests/scenario/baremetal_standalone_manager.py
+++ b/ironic_tempest_plugin/tests/scenario/baremetal_standalone_manager.py
@@ -206,7 +206,7 @@
         return nodes[0]
 
     @classmethod
-    def boot_node(cls, driver, image_ref, image_checksum=None):
+    def boot_node(cls, driver, image_ref, image_checksum=None, **interfaces):
         """Boot ironic node.
 
         The following actions are executed:
@@ -222,10 +222,11 @@
         :param image_ref: Reference to user image to boot node with.
         :param image_checksum: md5sum of image specified in image_ref.
                                Needed only when direct HTTP link is provided.
+        :param interfaces: driver interfaces to set on the node
         :returns: Ironic node.
         """
         node = cls.get_and_reserve_node()
-        cls.update_node_driver(node['uuid'], driver)
+        cls.update_node_driver(node['uuid'], driver, **interfaces)
         network, subnet, router = cls.create_networks()
         n_port = cls.create_neutron_port(network_id=network['id'])
         cls.vif_attach(node_id=node['uuid'], vif_id=n_port['id'])
@@ -280,6 +281,9 @@
     # The node driver to use in the test
     driver = None
 
+    # The deploy interface to use by the HW type
+    deploy_interface = None
+
     # User image ref to boot node with.
     image_ref = None
 
@@ -307,6 +311,13 @@
                     'driver': cls.driver,
                     'enabled_drivers': CONF.baremetal.enabled_drivers,
                     'enabled_hw_types': CONF.baremetal.enabled_hardware_types})
+        if (cls.deploy_interface and cls.deploy_interface not in
+                CONF.baremetal.enabled_deploy_interfaces):
+            raise cls.skipException(
+                "Deploy interface %(iface)s required by test is not "
+                "in the list of enabled deploy interfaces %(enabled)s" % {
+                    'iface': cls.deploy_interface,
+                    'enabled': CONF.baremetal.enabled_deploy_interfaces})
         if not cls.wholedisk_image and CONF.baremetal.use_provision_network:
             raise cls.skipException(
                 'Partitioned images are not supported with multitenancy.')
@@ -322,8 +333,10 @@
         image_checksum = None
         if not uuidutils.is_uuid_like(cls.image_ref):
             image_checksum = cls.image_checksum
-        cls.node = cls.boot_node(cls.driver, cls.image_ref,
-                                 image_checksum=image_checksum)
+        boot_kwargs = {'image_checksum': image_checksum}
+        if cls.deploy_interface:
+            boot_kwargs['deploy_interface'] = cls.deploy_interface
+        cls.node = cls.boot_node(cls.driver, cls.image_ref, **boot_kwargs)
         cls.node_ip = cls.add_floatingip_to_node(cls.node['uuid'])
 
     @classmethod
diff --git a/ironic_tempest_plugin/tests/scenario/ironic_standalone/test_basic_ops.py b/ironic_tempest_plugin/tests/scenario/ironic_standalone/test_basic_ops.py
index f6e02e1..82438fa 100644
--- a/ironic_tempest_plugin/tests/scenario/ironic_standalone/test_basic_ops.py
+++ b/ironic_tempest_plugin/tests/scenario/ironic_standalone/test_basic_ops.py
@@ -121,7 +121,9 @@
 
 class BaremetalIpmiWholedisk(bsm.BaremetalStandaloneScenarioTest):
 
+    api_microversion = '1.31'  # to set the deploy_interface
     driver = 'ipmi'
+    deploy_interface = 'direct'
     image_ref = CONF.baremetal.whole_disk_image_ref
     wholedisk_image = True
 
@@ -134,7 +136,9 @@
 
 class BaremetalIpmiPartitioned(bsm.BaremetalStandaloneScenarioTest):
 
+    api_microversion = '1.31'  # to set the deploy_interface
     driver = 'ipmi'
+    deploy_interface = 'iscsi'
     image_ref = CONF.baremetal.partition_image_ref
     wholedisk_image = False