aboutsummaryrefslogtreecommitdiffstats
path: root/patches/fuel-web/0002-Add-arch-to-nailgun-release-and-target-image.patch
blob: 3a6d5e4b805aacaa1a1b08d5131cf2a49fec18fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
From: Stanislaw Kardach <stanislaw.kardach@cavium.com>
Date: Sun, 18 Dec 2016 21:28:21 +0100
Subject: [PATCH] Add arch to nailgun release and target image

This is required so that the TestVM image is created using a cirros
image that is compatible with the architecture of the deployment setup.
As a bonus, it is also used when building the target image.

[ Alexandru Avadanii ]
Rebased onto Newton.

Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Signed-off-by: Stanislaw Kardach <stanislaw.kardach@cavium.com>
---
 nailgun/nailgun/consts.py                          |  5 ++
 .../alembic_migrations/versions/armband.py         | 53 ++++++++++++++++++++++
 nailgun/nailgun/db/sqlalchemy/models/release.py    |  8 ++++
 nailgun/nailgun/fixtures/openstack.yaml            |  5 ++
 .../nailgun/orchestrator/deployment_serializers.py |  8 +++-
 .../orchestrator/provisioning_serializers.py       |  3 +-
 nailgun/nailgun/orchestrator/tasks_templates.py    |  5 +-
 .../integration/test_cluster_changes_handler.py    | 12 ++---
 .../integration/test_orchestrator_serializer.py    |  4 +-
 nailgun/nailgun/test/unit/test_tasks_templates.py  |  6 ++-
 10 files changed, 95 insertions(+), 14 deletions(-)
 create mode 100644 nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py

diff --git a/nailgun/nailgun/consts.py b/nailgun/nailgun/consts.py
index ccbe860..a3875ce 100644
--- a/nailgun/nailgun/consts.py
+++ b/nailgun/nailgun/consts.py
@@ -38,6 +38,11 @@ RELEASE_OS = Enum(
     )
 )

+RELEASE_ARCHS = Enum(
+    'amd64',
+    'arm64'
+)
+
 CLUSTER_MODES = Enum(
     'multinode',
     'ha_full',
diff --git a/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py b/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py
new file mode 100644
index 0000000..6e42b3f
--- /dev/null
+++ b/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py
@@ -0,0 +1,53 @@
+#    Copyright 2016 Cavium, Inc.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+"""Armband patches
+
+Revision ID: f9b7fd91ac19
+Revises: c6edea552f1e
+Create Date: 2016-03-01 23:18:58.712617
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'f9b7fd91ac19'
+down_revision = 'c6edea552f1e'
+
+from alembic import op
+from nailgun.utils.migration import drop_enum
+import sqlalchemy as sa
+
+ENUMS = (
+    'release_arch',
+)
+
+
+def upgrade():
+    add_release_arch()
+
+
+def downgrade():
+    remove_release_arch()
+    map(drop_enum, ENUMS)
+
+
+def add_release_arch():
+    arch_enum = sa.Enum('amd64', 'arm64', name='release_arch')
+    arch_enum.create(op.get_bind(), checkfirst=False)
+    op.add_column('releases', sa.Column('arch', arch_enum, nullable=False,
+                  server_default='amd64'))
+
+
+def remove_release_arch():
+    op.drop_column('releases', 'arch')
diff --git a/nailgun/nailgun/db/sqlalchemy/models/release.py b/nailgun/nailgun/db/sqlalchemy/models/release.py
index a069b61..882d32c 100644
--- a/nailgun/nailgun/db/sqlalchemy/models/release.py
+++ b/nailgun/nailgun/db/sqlalchemy/models/release.py
@@ -40,6 +40,14 @@ class Release(Base):
     id = Column(Integer, primary_key=True)
     name = Column(Unicode(100), nullable=False)
     version = Column(String(30), nullable=False)
+    arch = Column(
+        Enum(
+            *consts.RELEASE_ARCHS,
+            name='release_arch'
+        ),
+        nullable=False,
+        default=consts.RELEASE_ARCHS.amd64
+    )
     description = Column(Unicode)
     operating_system = Column(String(50), nullable=False)
     state = Column(
diff --git a/nailgun/nailgun/fixtures/openstack.yaml b/nailgun/nailgun/fixtures/openstack.yaml
index ba967d7..c1d2a71 100644
--- a/nailgun/nailgun/fixtures/openstack.yaml
+++ b/nailgun/nailgun/fixtures/openstack.yaml
@@ -2113,6 +2113,7 @@
     name: "Newton on CentOS 6.5"
     state: "unavailable"
     version: "newton-10.0"
+    arch: "amd64"
     operating_system: "CentOS"
     description: "This option will install the OpenStack Mitaka packages using a CentOS based operating system. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
     attributes_metadata:
@@ -2186,6 +2187,7 @@
   fields:
     name: "Newton on Ubuntu 16.04"
     version: "newton-10.0"
+    arch: "amd64"
     operating_system: "Ubuntu"
     description: "This option will install the OpenStack Newton packages using Ubuntu as a base operating system. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
     attributes_metadata:
@@ -2417,6 +2419,7 @@
   fields:
     name: "Newton on Ubuntu+UCA 16.04"
     version: "newton-10.0"
+    arch: "amd64"
     description: "This option will install the OpenStack Newton packages using Ubuntu as a base operating system, including Ubuntu Cloud Archive OpenStack packages. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
     attributes_metadata:
       editable:
@@ -2517,6 +2520,7 @@
   fields:
     name: "Newton on Ubuntu 16.04 (aarch64)"
     version: "newton-10.0"
+    arch: "arm64"
     operating_system: "Ubuntu"
     description: "This option will install the OpenStack Newton packages using Ubuntu as a base operating system. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
     attributes_metadata:
@@ -2754,6 +2758,7 @@
   fields:
     name: "Newton on Ubuntu+UCA 16.04 (aarch64)"
     version: "newton-10.0"
+    arch: "arm64"
     description: "This option will install the OpenStack Newton packages using Ubuntu as a base operating system, including Ubuntu Cloud Archive OpenStack packages. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
     attributes_metadata:
       editable:
diff --git a/nailgun/nailgun/orchestrator/deployment_serializers.py b/nailgun/nailgun/orchestrator/deployment_serializers.py
index f983ae3..2f9cec2 100644
--- a/nailgun/nailgun/orchestrator/deployment_serializers.py
+++ b/nailgun/nailgun/orchestrator/deployment_serializers.py
@@ -261,7 +261,13 @@ class DeploymentMultinodeSerializer(object):
             img_dir = '/usr/share/cirros-testvm/'
         else:
             img_dir = '/opt/vm/'
-        image_data['img_path'] = '{0}cirros-x86_64-disk.img'.format(img_dir)
+        arch = node.cluster.release.arch
+        if arch == "amd64":
+            arch = "x86_64"
+        elif arch == "arm64":
+            arch = "aarch64"
+        image_data['img_path'] = '{0}cirros-{1}-disk.img'.format(img_dir,
+            arch)

         properties_data = {}

diff --git a/nailgun/nailgun/orchestrator/provisioning_serializers.py b/nailgun/nailgun/orchestrator/provisioning_serializers.py
index 7b2c6ac..f2c05e1 100644
--- a/nailgun/nailgun/orchestrator/provisioning_serializers.py
+++ b/nailgun/nailgun/orchestrator/provisioning_serializers.py
@@ -329,7 +329,8 @@ class ProvisioningSerializer61(ProvisioningSerializer):
                     attrs['repo_setup']['repos'],
                     attrs['provision'],
                     cluster.id,
-                    packages))
+                    packages,
+                    cluster.release.arch))

         PriorityStrategy().one_by_one(tasks)
         return tasks
diff --git a/nailgun/nailgun/orchestrator/tasks_templates.py b/nailgun/nailgun/orchestrator/tasks_templates.py
index 8252891..84bebe6 100644
--- a/nailgun/nailgun/orchestrator/tasks_templates.py
+++ b/nailgun/nailgun/orchestrator/tasks_templates.py
@@ -208,7 +208,7 @@ def make_reboot_task(uids, task):


 def make_provisioning_images_task(
-        uids, repos, provision_data, cid, packages):
+        uids, repos, provision_data, cid, packages, arch):
     conf = {
         'repos': repos,
         'image_data': provision_data['image_data'],
@@ -230,7 +230,8 @@ def make_provisioning_images_task(
                     "--image_build_dir /var/lib/fuel/ibp "
                     "--log-file /var/log/fuel-agent-env-{0}.log "
                     "--data_driver nailgun_build_image "
-                    "--input_data '{1}'").format(cid, conf),
+                    "--target_arch {1} "
+                    "--input_data '{2}'").format(cid, arch, conf),
             'timeout': settings.PROVISIONING_IMAGES_BUILD_TIMEOUT,
             'retries': 1}})

diff --git a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
index d7e964e..bce8289 100644
--- a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
+++ b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
@@ -148,7 +148,7 @@ class TestHandlers(BaseIntegrationTest):
         common_attrs['last_controller'] = controller_nodes[-1]['name']
         common_attrs['storage']['pg_num'] = 128

-        common_attrs['test_vm_image'] = {
+        common_attrs['test_vm_image'] = [{
             'container_format': 'bare',
             'public': 'true',
             'disk_format': 'qcow2',
@@ -164,7 +164,7 @@ class TestHandlers(BaseIntegrationTest):
                 'murano_image_info': """'{"title": "Murano Demo", "type":"""
                 """ "cirros.demo"}'""",
             },
-        }
+        }]

         critical_mapping = {
             'primary-controller': True,
@@ -565,7 +565,7 @@ class TestHandlers(BaseIntegrationTest):
         common_attrs['last_controller'] = controller_nodes[-1]['name']
         common_attrs['storage']['pg_num'] = 128

-        common_attrs['test_vm_image'] = {
+        common_attrs['test_vm_image'] = [{
             'container_format': 'bare',
             'public': 'true',
             'disk_format': 'qcow2',
@@ -581,7 +581,7 @@ class TestHandlers(BaseIntegrationTest):
                 'murano_image_info': """'{"title": "Murano Demo", "type":"""
                 """ "cirros.demo"}'""",
             },
-        }
+        }]

         critical_mapping = {
             'primary-controller': True,
@@ -1053,7 +1053,7 @@ class TestHandlers(BaseIntegrationTest):
         common_attrs['last_controller'] = controller_nodes[-1]['name']
         common_attrs['storage']['pg_num'] = 128

-        common_attrs['test_vm_image'] = {
+        common_attrs['test_vm_image'] = [{
             'container_format': 'bare',
             'public': 'true',
             'disk_format': 'qcow2',
@@ -1069,7 +1069,7 @@ class TestHandlers(BaseIntegrationTest):
                 'murano_image_info': """'{"title": "Murano Demo", "type":"""
                 """ "cirros.demo"}'""",
             },
-        }
+        }]

         critical_mapping = {
             'primary-controller': True,
diff --git a/nailgun/nailgun/test/integration/test_orchestrator_serializer.py b/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
index f399602..6034f30 100644
--- a/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
+++ b/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
@@ -2565,12 +2565,12 @@ class BaseDeploymentSerializer(BaseSerializerTest):

     def check_no_murano_data(self):
         glance_properties = self.serializer.generate_test_vm_image_data(
-            self.env.nodes[0])['test_vm_image']['glance_properties']
+            self.env.nodes[0])['test_vm_image'][0]['glance_properties']
         self.assertNotIn('murano_image_info', glance_properties)

     def check_murano_data(self):
         glance_properties = self.serializer.generate_test_vm_image_data(
-            self.env.nodes[0])['test_vm_image']['glance_properties']
+            self.env.nodes[0])['test_vm_image'][0]['glance_properties']
         self.assertIn('murano_image_info', glance_properties)

     @staticmethod
diff --git a/nailgun/nailgun/test/unit/test_tasks_templates.py b/nailgun/nailgun/test/unit/test_tasks_templates.py
index 4db183f..4f5d2cb 100644
--- a/nailgun/nailgun/test/unit/test_tasks_templates.py
+++ b/nailgun/nailgun/test/unit/test_tasks_templates.py
@@ -140,7 +140,8 @@ class TestMakeTask(base.BaseTestCase):
                     }
                 }},
             cid=123,
-            packages=packages
+            packages=packages,
+            arch='amd64'
         )

         fuel_image_conf = {
@@ -177,7 +178,8 @@ class TestMakeTask(base.BaseTestCase):
         cmd = result["parameters"]["cmd"].lstrip(
             "fa_build_image --image_build_dir /var/lib/fuel/ibp "
             "--log-file /var/log/fuel-agent-env-123.log "
-            "--data_driver nailgun_build_image --input_data '").rstrip("'")
+            "--data_driver nailgun_build_image --target_arch amd64"
+            " --input_data '").rstrip("'")
         self.assertEqual(jsonutils.loads(cmd), fuel_image_conf)

     def test_generate_ironic_bootstrap_keys_task(self):