Add centos bootstrap to fuel-bootstrap-cli list
Change-Id: Ie9be1afb40209ae8703cddfaf39d6cd3a8e82905 Closes-Bug: #1527494
This commit is contained in:
parent
f4c22a341c
commit
1ad68c4472
@ -16,6 +16,7 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import tarfile
|
||||
import tempfile
|
||||
@ -37,6 +38,12 @@ ACTIVE = 'active'
|
||||
|
||||
|
||||
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 = []
|
||||
LOG.debug("Searching images in %s", CONF.bootstrap_images_dir)
|
||||
for name in os.listdir(CONF.bootstrap_images_dir):
|
||||
@ -46,9 +53,32 @@ def get_all():
|
||||
data.append(parse(name))
|
||||
except errors.IncorrectImage as e:
|
||||
LOG.debug("Image [%s] is skipped due to %s", name, e)
|
||||
data.append(get_centos_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):
|
||||
LOG.debug("Trying to parse [%s] image", image_uuid)
|
||||
dir_path = full_path(image_uuid)
|
||||
|
Loading…
Reference in New Issue
Block a user