Add centos bootstrap to fuel-bootstrap-cli list

Change-Id: Ie9be1afb40209ae8703cddfaf39d6cd3a8e82905
Closes-Bug: #1527494
This commit is contained in:
Artur Svechnikov 2015-12-17 10:56:10 +03:00
parent f4c22a341c
commit 1ad68c4472

View File

@ -16,6 +16,7 @@
import logging import logging
import os import os
import re
import shutil import shutil
import tarfile import tarfile
import tempfile import tempfile
@ -37,6 +38,12 @@ ACTIVE = 'active'
def get_all(): def get_all():
"""Return info about all valid bootstrap images
:return: array of dict
"""
# TODO(asvechnikov): need to change of determining active bootstrap
# cobbler profile must be used
data = [] data = []
LOG.debug("Searching images in %s", CONF.bootstrap_images_dir) LOG.debug("Searching images in %s", CONF.bootstrap_images_dir)
for name in os.listdir(CONF.bootstrap_images_dir): for name in os.listdir(CONF.bootstrap_images_dir):
@ -46,9 +53,32 @@ def get_all():
data.append(parse(name)) data.append(parse(name))
except errors.IncorrectImage as e: except errors.IncorrectImage as e:
LOG.debug("Image [%s] is skipped due to %s", name, e) LOG.debug("Image [%s] is skipped due to %s", name, e)
data.append(get_centos_data())
return data return data
def _cobbler_profile():
"""Parse current active profile from cobbler system
:return: string
"""
stdout, _ = utils.execute('dockerctl', 'shell', 'cobbler', 'cobbler',
'system', 'report', '--name', 'default')
regex = r"(?P<label>Profile)\s*:\s*(?P<profile>[^\s]+)"
return re.search(regex, stdout).group('profile')
def get_centos_data():
"""Return info about centos image
:return: dict
"""
return {'uuid': 'centos',
'label': 'deprecated',
'status': ACTIVE if 'ubuntu' not in _cobbler_profile() else ''}
def parse(image_uuid): def parse(image_uuid):
LOG.debug("Trying to parse [%s] image", image_uuid) LOG.debug("Trying to parse [%s] image", image_uuid)
dir_path = full_path(image_uuid) dir_path = full_path(image_uuid)