1 From: Stanislaw Kardach <stanislaw.kardach@cavium.com>
2 Date: Sun, 18 Dec 2016 21:28:21 +0100
3 Subject: [PATCH] Add arch to nailgun release and target image
5 This is required so that the TestVM image is created using a cirros
6 image that is compatible with the architecture of the deployment setup.
7 As a bonus, it is also used when building the target image.
12 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
13 Signed-off-by: Stanislaw Kardach <stanislaw.kardach@cavium.com>
15 nailgun/nailgun/consts.py | 5 ++
16 .../alembic_migrations/versions/armband.py | 53 ++++++++++++++++++++++
17 nailgun/nailgun/db/sqlalchemy/models/release.py | 8 ++++
18 nailgun/nailgun/fixtures/openstack.yaml | 5 ++
19 .../nailgun/orchestrator/deployment_serializers.py | 8 +++-
20 .../orchestrator/provisioning_serializers.py | 3 +-
21 nailgun/nailgun/orchestrator/tasks_templates.py | 5 +-
22 .../integration/test_cluster_changes_handler.py | 12 ++---
23 .../integration/test_orchestrator_serializer.py | 4 +-
24 nailgun/nailgun/test/unit/test_tasks_templates.py | 6 ++-
25 10 files changed, 95 insertions(+), 14 deletions(-)
26 create mode 100644 nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py
28 diff --git a/nailgun/nailgun/consts.py b/nailgun/nailgun/consts.py
29 index ccbe860..a3875ce 100644
30 --- a/nailgun/nailgun/consts.py
31 +++ b/nailgun/nailgun/consts.py
32 @@ -38,6 +38,11 @@ RELEASE_OS = Enum(
36 +RELEASE_ARCHS = Enum(
44 diff --git a/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py b/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py
46 index 0000000..6e42b3f
48 +++ b/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py
50 +# Copyright 2016 Cavium, Inc.
52 +# Licensed under the Apache License, Version 2.0 (the "License"); you may
53 +# not use this file except in compliance with the License. You may obtain
54 +# a copy of the License at
56 +# http://www.apache.org/licenses/LICENSE-2.0
58 +# Unless required by applicable law or agreed to in writing, software
59 +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
60 +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
61 +# License for the specific language governing permissions and limitations
66 +Revision ID: f9b7fd91ac19
67 +Revises: c6edea552f1e
68 +Create Date: 2016-03-01 23:18:58.712617
72 +# revision identifiers, used by Alembic.
73 +revision = 'f9b7fd91ac19'
74 +down_revision = 'c6edea552f1e'
76 +from alembic import op
77 +from nailgun.utils.migration import drop_enum
78 +import sqlalchemy as sa
90 + remove_release_arch()
91 + map(drop_enum, ENUMS)
94 +def add_release_arch():
95 + arch_enum = sa.Enum('amd64', 'arm64', name='release_arch')
96 + arch_enum.create(op.get_bind(), checkfirst=False)
97 + op.add_column('releases', sa.Column('arch', arch_enum, nullable=False,
98 + server_default='amd64'))
101 +def remove_release_arch():
102 + op.drop_column('releases', 'arch')
103 diff --git a/nailgun/nailgun/db/sqlalchemy/models/release.py b/nailgun/nailgun/db/sqlalchemy/models/release.py
104 index a069b61..882d32c 100644
105 --- a/nailgun/nailgun/db/sqlalchemy/models/release.py
106 +++ b/nailgun/nailgun/db/sqlalchemy/models/release.py
107 @@ -40,6 +40,14 @@ class Release(Base):
108 id = Column(Integer, primary_key=True)
109 name = Column(Unicode(100), nullable=False)
110 version = Column(String(30), nullable=False)
113 + *consts.RELEASE_ARCHS,
114 + name='release_arch'
117 + default=consts.RELEASE_ARCHS.amd64
119 description = Column(Unicode)
120 operating_system = Column(String(50), nullable=False)
122 diff --git a/nailgun/nailgun/fixtures/openstack.yaml b/nailgun/nailgun/fixtures/openstack.yaml
123 index ba967d7..c1d2a71 100644
124 --- a/nailgun/nailgun/fixtures/openstack.yaml
125 +++ b/nailgun/nailgun/fixtures/openstack.yaml
126 @@ -2113,6 +2113,7 @@
127 name: "Newton on CentOS 6.5"
129 version: "newton-10.0"
131 operating_system: "CentOS"
132 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."
134 @@ -2186,6 +2187,7 @@
136 name: "Newton on Ubuntu 16.04"
137 version: "newton-10.0"
139 operating_system: "Ubuntu"
140 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."
142 @@ -2417,6 +2419,7 @@
144 name: "Newton on Ubuntu+UCA 16.04"
145 version: "newton-10.0"
147 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."
150 @@ -2517,6 +2520,7 @@
152 name: "Newton on Ubuntu 16.04 (aarch64)"
153 version: "newton-10.0"
155 operating_system: "Ubuntu"
156 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."
158 @@ -2754,6 +2758,7 @@
160 name: "Newton on Ubuntu+UCA 16.04 (aarch64)"
161 version: "newton-10.0"
163 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."
166 diff --git a/nailgun/nailgun/orchestrator/deployment_serializers.py b/nailgun/nailgun/orchestrator/deployment_serializers.py
167 index f983ae3..2f9cec2 100644
168 --- a/nailgun/nailgun/orchestrator/deployment_serializers.py
169 +++ b/nailgun/nailgun/orchestrator/deployment_serializers.py
170 @@ -261,7 +261,13 @@ class DeploymentMultinodeSerializer(object):
171 img_dir = '/usr/share/cirros-testvm/'
174 - image_data['img_path'] = '{0}cirros-x86_64-disk.img'.format(img_dir)
175 + arch = node.cluster.release.arch
176 + if arch == "amd64":
178 + elif arch == "arm64":
180 + image_data['img_path'] = '{0}cirros-{1}-disk.img'.format(img_dir,
185 diff --git a/nailgun/nailgun/orchestrator/provisioning_serializers.py b/nailgun/nailgun/orchestrator/provisioning_serializers.py
186 index 7b2c6ac..f2c05e1 100644
187 --- a/nailgun/nailgun/orchestrator/provisioning_serializers.py
188 +++ b/nailgun/nailgun/orchestrator/provisioning_serializers.py
189 @@ -329,7 +329,8 @@ class ProvisioningSerializer61(ProvisioningSerializer):
190 attrs['repo_setup']['repos'],
195 + cluster.release.arch))
197 PriorityStrategy().one_by_one(tasks)
199 diff --git a/nailgun/nailgun/orchestrator/tasks_templates.py b/nailgun/nailgun/orchestrator/tasks_templates.py
200 index 8252891..84bebe6 100644
201 --- a/nailgun/nailgun/orchestrator/tasks_templates.py
202 +++ b/nailgun/nailgun/orchestrator/tasks_templates.py
203 @@ -208,7 +208,7 @@ def make_reboot_task(uids, task):
206 def make_provisioning_images_task(
207 - uids, repos, provision_data, cid, packages):
208 + uids, repos, provision_data, cid, packages, arch):
211 'image_data': provision_data['image_data'],
212 @@ -230,7 +230,8 @@ def make_provisioning_images_task(
213 "--image_build_dir /var/lib/fuel/ibp "
214 "--log-file /var/log/fuel-agent-env-{0}.log "
215 "--data_driver nailgun_build_image "
216 - "--input_data '{1}'").format(cid, conf),
217 + "--target_arch {1} "
218 + "--input_data '{2}'").format(cid, arch, conf),
219 'timeout': settings.PROVISIONING_IMAGES_BUILD_TIMEOUT,
222 diff --git a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
223 index d7e964e..bce8289 100644
224 --- a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
225 +++ b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
226 @@ -148,7 +148,7 @@ class TestHandlers(BaseIntegrationTest):
227 common_attrs['last_controller'] = controller_nodes[-1]['name']
228 common_attrs['storage']['pg_num'] = 128
230 - common_attrs['test_vm_image'] = {
231 + common_attrs['test_vm_image'] = [{
232 'container_format': 'bare',
234 'disk_format': 'qcow2',
235 @@ -164,7 +164,7 @@ class TestHandlers(BaseIntegrationTest):
236 'murano_image_info': """'{"title": "Murano Demo", "type":"""
237 """ "cirros.demo"}'""",
243 'primary-controller': True,
244 @@ -565,7 +565,7 @@ class TestHandlers(BaseIntegrationTest):
245 common_attrs['last_controller'] = controller_nodes[-1]['name']
246 common_attrs['storage']['pg_num'] = 128
248 - common_attrs['test_vm_image'] = {
249 + common_attrs['test_vm_image'] = [{
250 'container_format': 'bare',
252 'disk_format': 'qcow2',
253 @@ -581,7 +581,7 @@ class TestHandlers(BaseIntegrationTest):
254 'murano_image_info': """'{"title": "Murano Demo", "type":"""
255 """ "cirros.demo"}'""",
261 'primary-controller': True,
262 @@ -1053,7 +1053,7 @@ class TestHandlers(BaseIntegrationTest):
263 common_attrs['last_controller'] = controller_nodes[-1]['name']
264 common_attrs['storage']['pg_num'] = 128
266 - common_attrs['test_vm_image'] = {
267 + common_attrs['test_vm_image'] = [{
268 'container_format': 'bare',
270 'disk_format': 'qcow2',
271 @@ -1069,7 +1069,7 @@ class TestHandlers(BaseIntegrationTest):
272 'murano_image_info': """'{"title": "Murano Demo", "type":"""
273 """ "cirros.demo"}'""",
279 'primary-controller': True,
280 diff --git a/nailgun/nailgun/test/integration/test_orchestrator_serializer.py b/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
281 index f399602..6034f30 100644
282 --- a/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
283 +++ b/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
284 @@ -2565,12 +2565,12 @@ class BaseDeploymentSerializer(BaseSerializerTest):
286 def check_no_murano_data(self):
287 glance_properties = self.serializer.generate_test_vm_image_data(
288 - self.env.nodes[0])['test_vm_image']['glance_properties']
289 + self.env.nodes[0])['test_vm_image'][0]['glance_properties']
290 self.assertNotIn('murano_image_info', glance_properties)
292 def check_murano_data(self):
293 glance_properties = self.serializer.generate_test_vm_image_data(
294 - self.env.nodes[0])['test_vm_image']['glance_properties']
295 + self.env.nodes[0])['test_vm_image'][0]['glance_properties']
296 self.assertIn('murano_image_info', glance_properties)
299 diff --git a/nailgun/nailgun/test/unit/test_tasks_templates.py b/nailgun/nailgun/test/unit/test_tasks_templates.py
300 index 4db183f..4f5d2cb 100644
301 --- a/nailgun/nailgun/test/unit/test_tasks_templates.py
302 +++ b/nailgun/nailgun/test/unit/test_tasks_templates.py
303 @@ -140,7 +140,8 @@ class TestMakeTask(base.BaseTestCase):
313 @@ -177,7 +178,8 @@ class TestMakeTask(base.BaseTestCase):
314 cmd = result["parameters"]["cmd"].lstrip(
315 "fa_build_image --image_build_dir /var/lib/fuel/ibp "
316 "--log-file /var/log/fuel-agent-env-123.log "
317 - "--data_driver nailgun_build_image --input_data '").rstrip("'")
318 + "--data_driver nailgun_build_image --target_arch amd64"
319 + " --input_data '").rstrip("'")
320 self.assertEqual(jsonutils.loads(cmd), fuel_image_conf)
322 def test_generate_ironic_bootstrap_keys_task(self):