Default to host CPU architecture if none is supplied
Currently the only way to specify the CPU architecture of the overcloud images is by setting it in the appropriate yaml file. This is fine until you need to install a single package on multiple CPU architectures. Then you're either going to attempt to build the wrong image type or you have to edit the yaml files, which makes problems for upgrades. This change removes the default architecture from the yaml files and defaults to the appropriate DiB architecture based on running kernel. This enables builds on multiple CPU architectures from a single unmodified package Change-Id: I34f00a30c1e07869243fb95a437e05d6973a97da
This commit is contained in:
parent
f099e3c65c
commit
fba2902dc6
|
@ -1,7 +1,6 @@
|
|||
disk_images:
|
||||
-
|
||||
imagename: overcloud-hardened-full
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
distro: centos7
|
||||
elements:
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
disk_images:
|
||||
-
|
||||
imagename: overcloud-hardened-full
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
distro: rhel7
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
disk_images:
|
||||
-
|
||||
imagename: overcloud-hardened-full
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
elements:
|
||||
- dhcp-all-interfaces
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
disk_images:
|
||||
-
|
||||
imagename: overcloud-full
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
distro: centos7
|
||||
elements:
|
||||
|
@ -12,7 +11,6 @@ disk_images:
|
|||
- yum-plugin-priorities
|
||||
-
|
||||
imagename: ironic-python-agent
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
distro: centos7
|
||||
elements:
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
disk_images:
|
||||
-
|
||||
imagename: overcloud-full
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
distro: rhel7
|
||||
environment:
|
||||
FS_TYPE: xfs
|
||||
-
|
||||
imagename: ironic-python-agent
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
distro: rhel7
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
disk_images:
|
||||
-
|
||||
imagename: overcloud-full
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
elements:
|
||||
- baremetal
|
||||
|
@ -41,7 +40,6 @@ disk_images:
|
|||
DIB_PYTHON_VERSION: '2'
|
||||
-
|
||||
imagename: ironic-python-agent
|
||||
arch: amd64
|
||||
# This is bogus, but there's no initrd type in diskimage-builder
|
||||
type: qcow2
|
||||
# So we just override the extension instead
|
||||
|
|
|
@ -2,7 +2,6 @@ disk_images:
|
|||
-
|
||||
imagename: overcloud-odl
|
||||
builder: dib
|
||||
arch: amd64
|
||||
type: qcow2
|
||||
distro: rhel7
|
||||
elements:
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
The default architecure for image builds now defaults to the cpu of the
|
||||
host instead of x86_64/amd64. This allows for a single package of
|
||||
tripleo-common to be used across multiple architectures to generate images.
|
|
@ -0,0 +1,34 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Simple routines to map host architectures as expected by various components.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def kernel_arch():
|
||||
"""Return the kernel arch."""
|
||||
return os.uname()[4]
|
||||
|
||||
|
||||
def dib_arch():
|
||||
"""Return the kernel arch or the more appripriate DiB arch."""
|
||||
return {'x86_64': 'amd64'}.get(kernel_arch(), kernel_arch())
|
||||
|
||||
|
||||
def cirros_arch():
|
||||
"""Return the kernel arch or the more appripriate cirros arch."""
|
||||
return {'ppc64le': 'powerpc'}.get(kernel_arch(), kernel_arch())
|
|
@ -19,6 +19,7 @@ import re
|
|||
from oslo_log import log
|
||||
from oslo_utils import strutils
|
||||
|
||||
import tripleo_common.arch
|
||||
from tripleo_common.image.base import BaseImageManager
|
||||
from tripleo_common.image.exception import ImageSpecificationException
|
||||
from tripleo_common.image.image_builder import ImageBuilder
|
||||
|
@ -48,7 +49,7 @@ class ImageBuildManager(BaseImageManager):
|
|||
disk_images = self.load_config_files(self.DISK_IMAGES)
|
||||
|
||||
for image in disk_images:
|
||||
arch = image.get('arch', 'amd64')
|
||||
arch = image.get('arch', tripleo_common.arch.dib_arch())
|
||||
image_type = image.get('type', 'qcow2')
|
||||
image_name = image.get('imagename')
|
||||
builder = image.get('builder', 'dib')
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2017, Red Hat, 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.
|
||||
|
||||
"""
|
||||
Test cases for tripleo_common.arch module.
|
||||
"""
|
||||
|
||||
import mock
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from tripleo_common import arch
|
||||
|
||||
|
||||
class ArchTestCase(TestCase):
|
||||
def test_kernel_arch(self):
|
||||
for (expected, _arch) in [('x86_64', 'x86_64'),
|
||||
('ppc64le', 'ppc64le')]:
|
||||
with mock.patch('os.uname', return_value=('', '', '', '', _arch)):
|
||||
self.assertEqual(expected, arch.kernel_arch())
|
||||
|
||||
def test_dib_arch(self):
|
||||
for (expected, _arch) in [('amd64', 'x86_64'),
|
||||
('ppc64le', 'ppc64le')]:
|
||||
with mock.patch('os.uname', return_value=('', '', '', '', _arch)):
|
||||
self.assertEqual(expected, arch.dib_arch())
|
||||
|
||||
def test_cirros_arch(self):
|
||||
for (expected, _arch) in [('x86_64', 'x86_64'),
|
||||
('powerpc', 'ppc64le')]:
|
||||
with mock.patch('os.uname', return_value=('', '', '', '', _arch)):
|
||||
self.assertEqual(expected, arch.cirros_arch())
|
Loading…
Reference in New Issue