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 | 5 ++
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, 96 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 1ded0ba..5a1af0a 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: 675105097a69
62 +Create Date: 2016-03-01 23:18:58.712617
66 +# revision identifiers, used by Alembic.
67 +revision = 'f9b7fd91ac19'
68 +down_revision = '675105097a69'
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 1b47de4..e209e72 100644
99 --- a/nailgun/nailgun/db/sqlalchemy/models/release.py
100 +++ b/nailgun/nailgun/db/sqlalchemy/models/release.py
101 @@ -39,6 +39,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 description = Column(Unicode)
114 operating_system = Column(String(50), nullable=False)
116 diff --git a/nailgun/nailgun/fixtures/openstack.yaml b/nailgun/nailgun/fixtures/openstack.yaml
117 index 9674d66..d3226da 100644
118 --- a/nailgun/nailgun/fixtures/openstack.yaml
119 +++ b/nailgun/nailgun/fixtures/openstack.yaml
120 @@ -1904,6 +1904,7 @@
121 name: "Mitaka on CentOS 6.5"
123 version: "mitaka-9.0"
125 operating_system: "CentOS"
126 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."
128 @@ -1978,6 +1979,7 @@
130 name: "Mitaka on Ubuntu 14.04"
131 version: "mitaka-9.0"
133 operating_system: "Ubuntu"
134 description: "This option will install the OpenStack Mitaka packages using Ubuntu as a base operating system. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
136 @@ -2219,6 +2221,7 @@
138 name: "Mitaka on Ubuntu+UCA 14.04"
139 version: "mitaka-9.0"
141 description: "This option will install the OpenStack Mitaka 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."
144 @@ -2320,6 +2323,7 @@
146 name: "Mitaka on Ubuntu 14.04 (aarch64)"
147 version: "mitaka-9.0"
149 operating_system: "Ubuntu"
150 description: "This option will install the OpenStack Mitaka packages using Ubuntu as a base operating system. With high availability features built in, you are getting a robust, enterprise-grade OpenStack deployment."
152 @@ -2506,6 +2510,7 @@
154 name: "Mitaka on Ubuntu+UCA 14.04 (aarch64)"
155 version: "mitaka-9.0"
157 description: "This option will install the OpenStack Mitaka 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."
160 diff --git a/nailgun/nailgun/orchestrator/deployment_serializers.py b/nailgun/nailgun/orchestrator/deployment_serializers.py
161 index 699a599..6bb7990 100644
162 --- a/nailgun/nailgun/orchestrator/deployment_serializers.py
163 +++ b/nailgun/nailgun/orchestrator/deployment_serializers.py
164 @@ -300,7 +300,13 @@ class DeploymentMultinodeSerializer(object):
165 img_dir = '/usr/share/cirros-testvm/'
168 - image_data['img_path'] = '{0}cirros-x86_64-disk.img'.format(img_dir)
169 + arch = node.cluster.release.arch
170 + if arch == "amd64":
172 + elif arch == "arm64":
174 + image_data['img_path'] = '{0}cirros-{1}-disk.img'.format(img_dir,
177 glance_properties = []
179 diff --git a/nailgun/nailgun/orchestrator/provisioning_serializers.py b/nailgun/nailgun/orchestrator/provisioning_serializers.py
180 index 48a4753..b1f3ca6 100644
181 --- a/nailgun/nailgun/orchestrator/provisioning_serializers.py
182 +++ b/nailgun/nailgun/orchestrator/provisioning_serializers.py
183 @@ -307,7 +307,8 @@ class ProvisioningSerializer61(ProvisioningSerializer):
184 attrs['repo_setup']['repos'],
189 + cluster.release.arch))
191 # NOTE(kozhukalov): This pre-provision task is going to be
192 # removed by 7.0 because we need this only for classic way of
193 diff --git a/nailgun/nailgun/orchestrator/tasks_templates.py b/nailgun/nailgun/orchestrator/tasks_templates.py
194 index 51dfdf7..bc2bff9 100644
195 --- a/nailgun/nailgun/orchestrator/tasks_templates.py
196 +++ b/nailgun/nailgun/orchestrator/tasks_templates.py
197 @@ -210,7 +210,7 @@ def make_reboot_task(uids, task):
200 def make_provisioning_images_task(
201 - uids, repos, provision_data, cid, packages):
202 + uids, repos, provision_data, cid, packages, arch):
205 'image_data': provision_data['image_data'],
206 @@ -232,7 +232,8 @@ def make_provisioning_images_task(
207 "--image_build_dir /var/lib/fuel/ibp "
208 "--log-file /var/log/fuel-agent-env-{0}.log "
209 "--data_driver nailgun_build_image "
210 - "--input_data '{1}'").format(cid, conf),
211 + "--target_arch {1} "
212 + "--input_data '{2}'").format(cid, arch, conf),
213 'timeout': settings.PROVISIONING_IMAGES_BUILD_TIMEOUT,
216 diff --git a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
217 index 0f212e5..da50eac 100644
218 --- a/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
219 +++ b/nailgun/nailgun/test/integration/test_cluster_changes_handler.py
220 @@ -153,7 +153,7 @@ class TestHandlers(BaseIntegrationTest):
221 common_attrs['last_controller'] = controller_nodes[-1]['name']
222 common_attrs['storage']['pg_num'] = 128
224 - common_attrs['test_vm_image'] = {
225 + common_attrs['test_vm_image'] = [{
226 'container_format': 'bare',
228 'disk_format': 'qcow2',
229 @@ -165,7 +165,7 @@ class TestHandlers(BaseIntegrationTest):
230 """--property murano_image_info="""
231 """'{"title": "Murano Demo", "type": "cirros.demo"}'"""
237 'primary-controller': True,
238 @@ -565,7 +565,7 @@ class TestHandlers(BaseIntegrationTest):
239 common_attrs['last_controller'] = controller_nodes[-1]['name']
240 common_attrs['storage']['pg_num'] = 128
242 - common_attrs['test_vm_image'] = {
243 + common_attrs['test_vm_image'] = [{
244 'container_format': 'bare',
246 'disk_format': 'qcow2',
247 @@ -577,7 +577,7 @@ class TestHandlers(BaseIntegrationTest):
248 """--property murano_image_info="""
249 """'{"title": "Murano Demo", "type": "cirros.demo"}'"""
255 'primary-controller': True,
256 @@ -1049,7 +1049,7 @@ class TestHandlers(BaseIntegrationTest):
257 common_attrs['last_controller'] = controller_nodes[-1]['name']
258 common_attrs['storage']['pg_num'] = 128
260 - common_attrs['test_vm_image'] = {
261 + common_attrs['test_vm_image'] = [{
262 'container_format': 'bare',
264 'disk_format': 'qcow2',
265 @@ -1061,7 +1061,7 @@ class TestHandlers(BaseIntegrationTest):
266 """--property murano_image_info="""
267 """'{"title": "Murano Demo", "type": "cirros.demo"}'"""
273 'primary-controller': True,
274 diff --git a/nailgun/nailgun/test/integration/test_orchestrator_serializer.py b/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
275 index 5db8f4e..ef208cb 100644
276 --- a/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
277 +++ b/nailgun/nailgun/test/integration/test_orchestrator_serializer.py
278 @@ -2584,12 +2584,12 @@ class BaseDeploymentSerializer(BaseSerializerTest):
280 def check_no_murano_data(self):
281 glance_properties = self.serializer.generate_test_vm_image_data(
282 - self.env.nodes[0])['test_vm_image']['glance_properties']
283 + self.env.nodes[0])['test_vm_image'][0]['glance_properties']
284 self.assertNotIn('murano_image_info', glance_properties)
286 def check_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.assertIn('murano_image_info', glance_properties)
293 diff --git a/nailgun/nailgun/test/unit/test_tasks_templates.py b/nailgun/nailgun/test/unit/test_tasks_templates.py
294 index 4e81a19..d657518 100644
295 --- a/nailgun/nailgun/test/unit/test_tasks_templates.py
296 +++ b/nailgun/nailgun/test/unit/test_tasks_templates.py
297 @@ -140,7 +140,8 @@ class TestMakeTask(base.BaseTestCase):
307 @@ -177,7 +178,8 @@ class TestMakeTask(base.BaseTestCase):
308 cmd = result["parameters"]["cmd"].lstrip(
309 "fa_build_image --image_build_dir /var/lib/fuel/ibp "
310 "--log-file /var/log/fuel-agent-env-123.log "
311 - "--data_driver nailgun_build_image --input_data '").rstrip("'")
312 + "--data_driver nailgun_build_image --target_arch amd64"
313 + " --input_data '").rstrip("'")
314 self.assertEqual(jsonutils.loads(cmd), fuel_image_conf)
316 def test_generate_ironic_bootstrap_keys_task(self):