1 From: Stanislaw Kardach <stanislaw.kardach@caviumnetworks.com>
2 Date: Wed, 24 Feb 2016 20:11:54 +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.
9 nailgun/nailgun/consts.py | 5 ++
10 .../alembic_migrations/versions/armband.py | 53 ++++++++++++++++++++++
11 nailgun/nailgun/db/sqlalchemy/models/release.py | 8 ++++
12 nailgun/nailgun/fixtures/openstack.yaml | 3 ++
13 .../nailgun/orchestrator/deployment_serializers.py | 9 +++-
14 .../orchestrator/provisioning_serializers.py | 3 +-
15 nailgun/nailgun/orchestrator/tasks_templates.py | 5 +-
16 .../integration/test_cluster_changes_handler.py | 12 ++---
17 .../integration/test_orchestrator_serializer.py | 4 +-
18 nailgun/nailgun/test/unit/test_tasks_templates.py | 6 ++-
19 10 files changed, 94 insertions(+), 14 deletions(-)
20 create mode 100644 nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py
22 diff --git a/nailgun/nailgun/consts.py b/nailgun/nailgun/consts.py
23 index bb69168..2c19ec9 100644
24 --- a/nailgun/nailgun/consts.py
25 +++ b/nailgun/nailgun/consts.py
26 @@ -38,6 +38,11 @@ RELEASE_OS = Enum(
30 +RELEASE_ARCHS = Enum(
38 diff --git a/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py b/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py
40 index 0000000..8cca69c
42 +++ b/nailgun/nailgun/db/migration/alembic_migrations/versions/armband.py
44 +# Copyright 2016 Cavium, Inc.
46 +# Licensed under the Apache License, Version 2.0 (the "License"); you may
47 +# not use this file except in compliance with the License. You may obtain
48 +# a copy of the License at
50 +# http://www.apache.org/licenses/LICENSE-2.0
52 +# Unless required by applicable law or agreed to in writing, software
53 +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
54 +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
55 +# License for the specific language governing permissions and limitations
60 +Revision ID: f9b7fd91ac19
61 +Revises: 43b2cb64dae6
62 +Create Date: 2016-03-01 23:18:58.712617
66 +# revision identifiers, used by Alembic.
67 +revision = 'f9b7fd91ac19'
68 +down_revision = '43b2cb64dae6'
70 +from alembic import op
71 +from nailgun.utils.migration import drop_enum
72 +import sqlalchemy as sa
84 + remove_release_arch()
85 + map(drop_enum, ENUMS)
88 +def add_release_arch():
89 + arch_enum = sa.Enum('amd64', 'arm64', name='release_arch')
90 + arch_enum.create(op.get_bind(), checkfirst=False)
91 + op.add_column('releases', sa.Column('arch', arch_enum, nullable=False,
92 + server_default='amd64'))
95 +def remove_release_arch():
96 + op.drop_column('releases', 'arch')
97 diff --git a/nailgun/nailgun/db/sqlalchemy/models/release.py b/nailgun/nailgun/db/sqlalchemy/models/release.py
98 index 96cf2ed..62ac2c1 100644
99 --- a/nailgun/nailgun/db/sqlalchemy/models/release.py
100 +++ b/nailgun/nailgun/db/sqlalchemy/models/release.py
101 @@ -38,6 +38,14 @@ class Release(Base):
102 id = Column(Integer, primary_key=True)
103 name = Column(Unicode(100), nullable=False)
104 version = Column(String(30), nullable=False)
107 + *consts.RELEASE_ARCHS,
108 + name='release_arch'
111 + default=consts.RELEASE_ARCHS.amd64
113 can_update_from_versions = Column(JSON, default=[],
114 nullable=False, server_default='[]')
115 description = Column(Unicode)
116 diff --git a/nailgun/nailgun/fixtures/openstack.yaml b/nailgun/nailgun/fixtures/openstack.yaml
117 index a330f4e..9da1346 100644
118 --- a/nailgun/nailgun/fixtures/openstack.yaml
119 +++ b/nailgun/nailgun/fixtures/openstack.yaml
120 @@ -1913,6 +1913,7 @@
121 name: "Liberty on CentOS 6.5"
123 version: "liberty-8.0"
125 can_update_from_versions: []
126 operating_system: "CentOS"
127 description: "This option will install the OpenStack Liberty packages using a CentOS based operating system. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
128 @@ -1986,6 +1987,7 @@
130 name: "Liberty on Ubuntu 14.04"
131 version: "liberty-8.0"
133 can_update_from_versions: []
134 operating_system: "Ubuntu"
135 description: "This option will install the OpenStack Liberty packages using Ubuntu as a base operating system. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
136 @@ -2084,6 +2086,7 @@
138 name: "Liberty on Ubuntu 14.04 (aarch64)"
139 version: "liberty-8.0"
141 can_update_from_versions: []
142 operating_system: "Ubuntu"
143 description: "This option will install the OpenStack Liberty packages using Ubuntu as a base operating system. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
144 diff --git a/nailgun/nailgun/orchestrator/deployment_serializers.py b/nailgun/nailgun/orchestrator/deployment_serializers.py
145 index 375a1ce..b8b38e2 100644
146 --- a/nailgun/nailgun/orchestrator/deployment_serializers.py
147 +++ b/nailgun/nailgun/orchestrator/deployment_serializers.py
148 @@ -291,7 +291,14 @@ class DeploymentMultinodeSerializer(object):
149 img_dir = '/usr/share/cirros-testvm/'
152 - image_data['img_path'] = '{0}cirros-x86_64-disk.img'.format(img_dir)
153 + release = self.current_release(node.cluster)
154 + arch = release.arch
155 + if arch == "amd64":
157 + elif arch == "arm64":
159 + image_data['img_path'] = '{0}cirros-{1}-disk.img'.format(img_dir,
162 glance_properties = []
164 diff --git a/nailgun/nailgun/orchestrator/provisioning_serializers.py b/nailgun/nailgun/orchestrator/provisioning_serializers.py
165 index 04ae0b0..c927f03 100644
166 --- a/nailgun/nailgun/orchestrator/provisioning_serializers.py
167 +++ b/nailgun/nailgun/orchestrator/provisioning_serializers.py
168 @@ -313,7 +313,8 @@ class ProvisioningSerializer61(ProvisioningSerializer):
169 [consts.MASTER_NODE_UID],
170 attrs['repo_setup']['repos'],
174 + cluster.release.arch))
176 # NOTE(kozhukalov): This pre-provision task is going to be
177 # removed by 7.0 because we need this only for classic way of
178 diff --git a/nailgun/nailgun/orchestrator/tasks_templates.py b/nailgun/nailgun/orchestrator/tasks_templates.py
179 index 39f2067..cd2278c 100644
180 --- a/nailgun/nailgun/orchestrator/tasks_templates.py
181 +++ b/nailgun/nailgun/orchestrator/tasks_templates.py
182 @@ -207,7 +207,7 @@ def make_reboot_task(uids, task):
183 'timeout': task['parameters']['timeout']}}
186 -def make_provisioning_images_task(uids, repos, provision_data, cid):
187 +def make_provisioning_images_task(uids, repos, provision_data, cid, arch):
190 'image_data': provision_data['image_data'],
191 @@ -224,7 +224,8 @@ def make_provisioning_images_task(uids, repos, provision_data, cid):
192 "--image_build_dir /var/lib/fuel/ibp "
193 "--log-file /var/log/fuel-agent-env-{0}.log "
194 "--data_driver nailgun_build_image "
195 - "--input_data '{1}'").format(cid, conf),
196 + "--target_arch {1} "
197 + "--input_data '{2}'").format(cid, arch, conf),
198 'timeout': settings.PROVISIONING_IMAGES_BUILD_TIMEOUT,
201 diff --git a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
202 index 56bd307..34b4ce3 100644
203 --- a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
204 +++ b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
205 @@ -159,7 +159,7 @@ class TestHandlers(BaseIntegrationTest):
206 common_attrs['last_controller'] = controller_nodes[-1]['name']
207 common_attrs['storage']['pg_num'] = 128
209 - common_attrs['test_vm_image'] = {
210 + common_attrs['test_vm_image'] = [{
211 'container_format': 'bare',
213 'disk_format': 'qcow2',
214 @@ -171,7 +171,7 @@ class TestHandlers(BaseIntegrationTest):
215 """--property murano_image_info="""
216 """'{"title": "Murano Demo", "type": "cirros.demo"}'"""
222 'primary-controller': True,
223 @@ -575,7 +575,7 @@ class TestHandlers(BaseIntegrationTest):
224 common_attrs['last_controller'] = controller_nodes[-1]['name']
225 common_attrs['storage']['pg_num'] = 128
227 - common_attrs['test_vm_image'] = {
228 + common_attrs['test_vm_image'] = [{
229 'container_format': 'bare',
231 'disk_format': 'qcow2',
232 @@ -587,7 +587,7 @@ class TestHandlers(BaseIntegrationTest):
233 """--property murano_image_info="""
234 """'{"title": "Murano Demo", "type": "cirros.demo"}'"""
240 'primary-controller': True,
241 @@ -1062,7 +1062,7 @@ class TestHandlers(BaseIntegrationTest):
242 common_attrs['last_controller'] = controller_nodes[-1]['name']
243 common_attrs['storage']['pg_num'] = 128
245 - common_attrs['test_vm_image'] = {
246 + common_attrs['test_vm_image'] = [{
247 'container_format': 'bare',
249 'disk_format': 'qcow2',
250 @@ -1074,7 +1074,7 @@ class TestHandlers(BaseIntegrationTest):
251 """--property murano_image_info="""
252 """'{"title": "Murano Demo", "type": "cirros.demo"}'"""
258 'primary-controller': True,
259 diff --git a/nailgun/nailgun/test/integration/test_orchestrator_serializer.py b/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
260 index 8ce987a..e75b3c2 100644
261 --- a/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
262 +++ b/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
263 @@ -2656,12 +2656,12 @@ class BaseDeploymentSerializer(base.BaseIntegrationTest):
265 def check_no_murano_data(self):
266 glance_properties = self.serializer.generate_test_vm_image_data(
267 - self.env.nodes[0])['test_vm_image']['glance_properties']
268 + self.env.nodes[0])['test_vm_image'][0]['glance_properties']
269 self.assertNotIn('murano_image_info', glance_properties)
271 def check_murano_data(self):
272 glance_properties = self.serializer.generate_test_vm_image_data(
273 - self.env.nodes[0])['test_vm_image']['glance_properties']
274 + self.env.nodes[0])['test_vm_image'][0]['glance_properties']
275 self.assertIn('murano_image_info', glance_properties)
278 diff --git a/nailgun/nailgun/test/unit/test_tasks_templates.py b/nailgun/nailgun/test/unit/test_tasks_templates.py
279 index a38e975..9cb9171 100644
280 --- a/nailgun/nailgun/test/unit/test_tasks_templates.py
281 +++ b/nailgun/nailgun/test/unit/test_tasks_templates.py
282 @@ -133,7 +133,8 @@ class TestMakeTask(base.BaseTestCase):
292 @@ -168,7 +169,8 @@ class TestMakeTask(base.BaseTestCase):
293 cmd = result["parameters"]["cmd"].lstrip(
294 "fa_build_image --image_build_dir /var/lib/fuel/ibp "
295 "--log-file /var/log/fuel-agent-env-123.log "
296 - "--data_driver nailgun_build_image --input_data '").rstrip("'")
297 + "--data_driver nailgun_build_image --target_arch amd64"
298 + " --input_data '").rstrip("'")
299 self.assertEqual(jsonutils.loads(cmd), fuel_image_conf)
301 def test_generate_ironic_bootstrap_keys_task(self):