Changed image data format in fuel_agent
Made it explicit and clear. User may define as many file system images as he/she needs. Every image is to have its own uri, format, container and other metadata. Currently, it is possible to mix different image formats. For example, image for a root file system might be an ext4 fs image while /var image - TAR archive. Change-Id: Ib957ff62e3613fed1e2826f322a056be7803fa48
This commit is contained in:
@@ -261,28 +261,21 @@ class Nailgun(object):
|
||||
def image_scheme(self, partition_scheme):
|
||||
data = self.data
|
||||
image_scheme = objects.ImageScheme()
|
||||
# We assume for every file system user may provide a separate
|
||||
# file system image. For example if partitioning scheme has
|
||||
# /, /boot, /var/lib file systems then we will try to get images
|
||||
# for all those mount points. Images data are to be defined
|
||||
# at provision.json -> ['ks_meta']['image_data']
|
||||
for fs in partition_scheme.fss:
|
||||
if fs.mount == 'swap':
|
||||
if fs.mount not in data['ks_meta']['image_data']:
|
||||
continue
|
||||
# We assume for every file system user needs to provide
|
||||
# file system image. For example if partitioning scheme has
|
||||
# /, /boot, /var/lib file systems then will try to download
|
||||
# profile.img.gz, profile-boot.img.gz and profile-var-lib.img.gz
|
||||
# files and copy them to corresponding volumes.
|
||||
uri = 'http://%s/targetimages/%s%s.img.gz' % (
|
||||
data['ks_meta']['master_ip'],
|
||||
data['profile'].split('_')[0],
|
||||
# / => ''
|
||||
# /boot => '-boot'
|
||||
# /var/lib => '-var-lib'
|
||||
'-'.join(fs.mount.split('/')).rstrip('-')
|
||||
)
|
||||
image_data = data['ks_meta']['image_data'][fs.mount]
|
||||
image_scheme.add_image(
|
||||
uri=uri,
|
||||
uri=image_data['uri'],
|
||||
target_device=fs.device,
|
||||
# In the future we will get image_format and container format
|
||||
# from provision.json, but currently it is hard coded.
|
||||
image_format='ext4',
|
||||
container='gzip',
|
||||
image_format=image_data['format'],
|
||||
container=image_data['container'],
|
||||
)
|
||||
return image_scheme
|
||||
|
||||
@@ -17,6 +17,7 @@ import os
|
||||
from oslo.config import cfg
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.openstack.common import log as logging
|
||||
from fuel_agent.utils import artifact_utils as au
|
||||
from fuel_agent.utils import fs_utils as fu
|
||||
from fuel_agent.utils import grub_utils as gu
|
||||
@@ -51,6 +52,8 @@ opts = [
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(opts)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Manager(object):
|
||||
def __init__(self, data):
|
||||
@@ -151,13 +154,14 @@ class Manager(object):
|
||||
processing.append(image.target_device)
|
||||
# For every file system in partitioning scheme we call
|
||||
# make_fs utility. That means we do not care whether fs image
|
||||
# is available for a particular file system.
|
||||
# is available for a particular file system or not.
|
||||
# If image is not available we assume user wants to
|
||||
# leave this file system un-touched.
|
||||
try:
|
||||
processing.process()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
LOG.warn('Exception while processing image: uri=%s exc=%s' %
|
||||
(image.uri, e.message))
|
||||
|
||||
def mount_target(self, chroot):
|
||||
# Here we are going to mount all file systems in partition scheme.
|
||||
|
||||
@@ -131,7 +131,7 @@ class TestManager(test_base.BaseTestCase):
|
||||
def test_do_configdrive(self, mock_lbd, mock_u_ras, mock_u_e):
|
||||
mock_lbd.return_value = test_nailgun.LIST_BLOCK_DEVICES_SAMPLE
|
||||
self.mgr.do_parsing()
|
||||
self.assertEqual(4, len(self.mgr.image_scheme.images))
|
||||
self.assertEqual(1, len(self.mgr.image_scheme.images))
|
||||
self.mgr.do_configdrive()
|
||||
mock_u_ras_expected_calls = [
|
||||
mock.call(CONF.nc_template_path, 'cloud_config_ubuntu.jinja2',
|
||||
@@ -155,7 +155,7 @@ class TestManager(test_base.BaseTestCase):
|
||||
'%s/%s' % (CONF.tmp_path, 'user-data'),
|
||||
'%s/%s' % (CONF.tmp_path, 'meta-data'))]
|
||||
self.assertEqual(mock_u_e_expected_calls, mock_u_e.call_args_list)
|
||||
self.assertEqual(5, len(self.mgr.image_scheme.images))
|
||||
self.assertEqual(2, len(self.mgr.image_scheme.images))
|
||||
cf_drv_img = self.mgr.image_scheme.images[-1]
|
||||
self.assertEqual('file://%s' % CONF.config_drive_path, cf_drv_img.uri)
|
||||
self.assertEqual('/dev/sda7',
|
||||
@@ -200,7 +200,7 @@ class TestManager(test_base.BaseTestCase):
|
||||
self.mgr.do_configdrive()
|
||||
self.mgr.do_copyimage()
|
||||
imgs = self.mgr.image_scheme.images
|
||||
self.assertEqual(5, len(imgs))
|
||||
self.assertEqual(2, len(imgs))
|
||||
expected_processors_list = []
|
||||
for img in imgs[:-1]:
|
||||
expected_processors_list += [
|
||||
|
||||
@@ -84,9 +84,13 @@ PROVISION_SAMPLE_DATA = {
|
||||
"power_address": "10.20.0.253",
|
||||
"name_servers": "\"10.20.0.2\"",
|
||||
"ks_meta": {
|
||||
"image_uri": "http://fake_image_url",
|
||||
"image_format": "ext4",
|
||||
"image_container": "gzip",
|
||||
"image_data": {
|
||||
"/": {
|
||||
"uri": "http://fake_image_url",
|
||||
"format": "ext4",
|
||||
"container": "gzip"
|
||||
}
|
||||
},
|
||||
"timezone": "America/Los_Angeles",
|
||||
"master_ip": "10.20.0.2",
|
||||
"mco_enable": 1,
|
||||
@@ -480,16 +484,14 @@ class TestNailgun(test_base.BaseTestCase):
|
||||
i_scheme = self.drv.image_scheme(p_scheme)
|
||||
expected_images = []
|
||||
for fs in p_scheme.fss:
|
||||
if fs.mount == 'swap':
|
||||
if fs.mount not in PROVISION_SAMPLE_DATA['ks_meta']['image_data']:
|
||||
continue
|
||||
i_data = PROVISION_SAMPLE_DATA['ks_meta']['image_data'][fs.mount]
|
||||
expected_images.append(image.Image(
|
||||
uri='http://%s/targetimages/%s%s.img.gz' % (
|
||||
self.drv.data['ks_meta']['master_ip'],
|
||||
self.drv.data['profile'].split('_')[0],
|
||||
'-'.join(fs.mount.split('/')).rstrip('-')),
|
||||
uri=i_data['uri'],
|
||||
target_device=fs.device,
|
||||
image_format='ext4',
|
||||
container='gzip'
|
||||
image_format=i_data['format'],
|
||||
container=i_data['container'],
|
||||
))
|
||||
expected_images = sorted(expected_images, key=lambda x: x.uri)
|
||||
for i, img in enumerate(sorted(i_scheme.images, key=lambda x: x.uri)):
|
||||
|
||||
Reference in New Issue
Block a user