From ba2d5d7998902e4117af072283d0c67611a1e54a Mon Sep 17 00:00:00 2001
From: Mark Hamzy <hamzy@us.ibm.com>
Date: Mon, 20 Nov 2017 14:04:11 -0600
Subject: [PATCH] Support multiple architectures

Currently TripleO is hard coded for x86_64 architecture.  There are
files for Ironic IPA {bm-deploy-kernel,bm-deploy-ramdisk} and deploying
the overcloud image
{overcloud-full,overcloud-full-initrd,overcloud-full-vmlinuz}.

This needs to change to support other architectures like PowerPC.  I am
currently proposing that the images be consistently renamed to include
the uname string.

(undercloud) [stack@oscloud5 ~]$ openstack image list
...
| ... | ppc64le-bm-deploy-kernel      | active |
| ... | ppc64le-bm-deploy-ramdisk     | active |
| ... | ppc64le-overcloud-full        | active |
| ... | x86_64-bm-deploy-kernel       | active |
| ... | x86_64-bm-deploy-ramdisk      | active |
| ... | x86_64-overcloud-full         | active |
| ... | x86_64-overcloud-full-initrd  | active |
| ... | x86_64-overcloud-full-vmlinuz | active |
...

Change-Id: Ie5884895bb996e65bc0148908aa3cdf99b25d1b6
Depends-On: I46f287e02cedc31161f319608d837760fb99b561
Partial-Bug: 1738228
---
 .../tests/v1/overcloud_image/test_overcloud_image.py    | 17 +++++++++--------
 .../tests/v1/overcloud_node/test_overcloud_node.py      | 11 +++++------
 tripleoclient/v1/overcloud_deploy.py                    |  2 --
 tripleoclient/v1/overcloud_image.py                     |  5 +++--
 tripleoclient/v1/overcloud_node.py                      | 10 +---------
 5 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py b/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py
index 64cd93b..cc83434 100644
--- a/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py
+++ b/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py
@@ -223,11 +223,11 @@ class TestUploadOvercloudImage(TestPluginV1):
                        disk_format='qcow2',
                        container_format='bare',
                        visibility='public'),
-             mock.call(name='bm-deploy-kernel',
+             mock.call(name='x86_64-bm-deploy-kernel',
                        disk_format='aki',
                        container_format='bare',
                        visibility='public'),
-             mock.call(name='bm-deploy-ramdisk',
+             mock.call(name='x86_64-bm-deploy-ramdisk',
                        disk_format='ari',
                        container_format='bare',
                        visibility='public')
@@ -279,11 +279,11 @@ class TestUploadOvercloudImage(TestPluginV1):
                        disk_format='qcow2',
                        is_public=True),
              mock.call(data=b'IMGDATA',
-                       name='bm-deploy-kernel',
+                       name='x86_64-bm-deploy-kernel',
                        disk_format='aki',
                        is_public=True),
              mock.call(data=b'IMGDATA',
-                       name='bm-deploy-ramdisk',
+                       name='x86_64-bm-deploy-ramdisk',
                        disk_format='ari',
                        is_public=True)
              ], self.app.client_manager.image.images.create.call_args_list
@@ -317,9 +317,10 @@ class TestUploadOvercloudImage(TestPluginV1):
                       mock.ANY),
             mock.call('overcloud-full', '/foo/overcloud-full.qcow2',
                       mock.ANY),
-            mock.call('bm-deploy-kernel', '/foo/ironic-python-agent.kernel',
+            mock.call('x86_64-bm-deploy-kernel',
+                      '/foo/ironic-python-agent.kernel',
                       mock.ANY),
-            mock.call('bm-deploy-ramdisk',
+            mock.call('x86_64-bm-deploy-ramdisk',
                       '/foo/ironic-python-agent.initramfs',
                       mock.ANY),
             ]
@@ -426,11 +427,11 @@ class TestUploadOvercloudImageFull(TestPluginV1):
                        disk_format='qcow2',
                        container_format='bare',
                        visibility='public'),
-             mock.call(name='bm-deploy-kernel',
+             mock.call(name='x86_64-bm-deploy-kernel',
                        disk_format='aki',
                        container_format='bare',
                        visibility='public'),
-             mock.call(name='bm-deploy-ramdisk',
+             mock.call(name='x86_64-bm-deploy-ramdisk',
                        disk_format='ari',
                        container_format='bare',
                        visibility='public')
diff --git a/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py b/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py
index 97b85c3..1d6ad63 100644
--- a/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py
+++ b/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py
@@ -379,10 +379,8 @@ class TestImportNode(fakes.TestOvercloudNode):
         call_list = [mock.call(
             'tripleo.baremetal.v1.register_or_update', workflow_input={
                 'nodes_json': nodes_list,
-                'kernel_name': None if no_deploy_image else 'bm-deploy-kernel',
-                'ramdisk_name': (None
-                                 if no_deploy_image else 'bm-deploy-ramdisk'),
-                'instance_boot_option': 'local' if local else 'netboot'
+                'instance_boot_option': 'local' if local else 'netboot',
+                'no_deploy_image': no_deploy_image
             }
         )]
 
@@ -469,6 +467,7 @@ class TestConfigureNode(fakes.TestOvercloudNode):
         # Get the command object to test
         self.cmd = overcloud_node.ConfigureNode(self.app, None)
 
+        # @TODO(hamzy)
         self.workflow_input = {'kernel_name': 'bm-deploy-kernel',
                                'ramdisk_name': 'bm-deploy-ramdisk',
                                'instance_boot_option': None,
@@ -657,7 +656,7 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
             'tripleo.baremetal.v1.discover_and_enroll_nodes',
             workflow_input={'ip_addresses': '10.0.0.0/24',
                             'credentials': [['admin', 'password']],
-                            'kernel_name': 'bm-deploy-kernel',
+                            'kernel_name': 'bm-deploy-kernel',  # @TODO(hamzy)
                             'ramdisk_name': 'bm-deploy-ramdisk',
                             'instance_boot_option': 'local'}
         )
@@ -675,7 +674,7 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
             'tripleo.baremetal.v1.discover_and_enroll_nodes',
             workflow_input={'ip_addresses': ['10.0.0.1', '10.0.0.2'],
                             'credentials': [['admin', 'password']],
-                            'kernel_name': 'bm-deploy-kernel',
+                            'kernel_name': 'bm-deploy-kernel',  # @TODO(hamzy)
                             'ramdisk_name': 'bm-deploy-ramdisk',
                             'instance_boot_option': 'local'}
         )
diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py
index 2b6bc6f..9a088a1 100644
--- a/tripleoclient/v1/overcloud_deploy.py
+++ b/tripleoclient/v1/overcloud_deploy.py
@@ -644,8 +644,6 @@ class DeployOvercloud(command.Command):
         self.log.debug("Starting _pre_verify_capabilities")
 
         validation_params = {
-            'deploy_kernel_name': 'bm-deploy-kernel',
-            'deploy_ramdisk_name': 'bm-deploy-ramdisk',
             'roles_info': utils.get_roles_info(parsed_args),
             'stack_id': parsed_args.stack,
             'parameters': parameters,
diff --git a/tripleoclient/v1/overcloud_image.py b/tripleoclient/v1/overcloud_image.py
index 69020b7..11413c7 100644
--- a/tripleoclient/v1/overcloud_image.py
+++ b/tripleoclient/v1/overcloud_image.py
@@ -267,6 +267,7 @@ class UploadOvercloudImage(command.Command):
         glance_client_adaptor = self._get_glance_client_adaptor()
 
         self._env_variable_or_set('AGENT_NAME', 'ironic-python-agent')
+        self._env_variable_or_set('AGENT_ARCH', 'x86_64')
 
         self.log.debug("checking if image files exist")
 
@@ -374,7 +375,7 @@ class UploadOvercloudImage(command.Command):
 
         self.log.debug("uploading bm images to glance")
 
-        deploy_kernel_name = 'bm-deploy-kernel'
+        deploy_kernel_name = '%s-bm-deploy-kernel' % os.environ['AGENT_ARCH']
         deploy_kernel_extension = '.kernel'
         deploy_kernel_file = os.path.join(parsed_args.image_path,
                                           os.environ['AGENT_NAME'] +
@@ -389,7 +390,7 @@ class UploadOvercloudImage(command.Command):
                     parsed_args.image_path,
                     deploy_kernel_file))
 
-        deploy_ramdisk_name = 'bm-deploy-ramdisk'
+        deploy_ramdisk_name = '%s-bm-deploy-ramdisk' % os.environ['AGENT_ARCH']
         deploy_ramdisk_extension = '.initramfs'
         deploy_ramdisk_file = os.path.join(parsed_args.image_path,
                                            os.environ['AGENT_NAME'] +
diff --git a/tripleoclient/v1/overcloud_node.py b/tripleoclient/v1/overcloud_node.py
index 0ff413c..f1a19d6 100644
--- a/tripleoclient/v1/overcloud_node.py
+++ b/tripleoclient/v1/overcloud_node.py
@@ -213,18 +213,10 @@ class ImportNode(command.Command):
 
         nodes_config = oooutils.parse_env_file(parsed_args.env_file)
 
-        if parsed_args.no_deploy_image:
-            deploy_kernel = None
-            deploy_ramdisk = None
-        else:
-            deploy_kernel = 'bm-deploy-kernel'
-            deploy_ramdisk = 'bm-deploy-ramdisk'
-
         nodes = baremetal.register_or_update(
             self.app.client_manager,
             nodes_json=nodes_config,
-            kernel_name=deploy_kernel,
-            ramdisk_name=deploy_ramdisk,
+            no_deploy_image=parsed_args.no_deploy_image,
             instance_boot_option=parsed_args.instance_boot_option
         )
 
-- 
2.14.3

