Create optional filesystems on resize request
Current zero-touch provisioning support only handles Day1 host-fs-resize operations. If an optional filesystem is attempted to be resized and does not exist, create it first then resize it. NOTE: Can revert this once zero-touch provisioning supports host-fs-add for Day1 operations. Test Plan: PASS - Install/bootstrap/provision AIO-SX. Observe no optional filesystem are present. Run host-fs-modify for both the 'instances' and 'image-conversion' filesystem. Observe host-fs-list have the filesystems created with the appropriate size. Observe 'image-conversion' created immediately. Observe 'instances' created on unlock (staged) of the host and created immediately when host is unlocked. Change-Id: Ifdceee617407bf08565dfd02a055d53b7e733c83 Story: 2010444 Task: 46999 Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
parent
3e7d68dc8c
commit
8c25091a58
|
@ -251,12 +251,21 @@ class HostFsController(rest.RestController):
|
|||
elif p_obj['path'] == '/size':
|
||||
size = p_obj['value']
|
||||
|
||||
# TODO(rchurch): Remove optional filesystem creation once Zero Touch
|
||||
# provisioning properly supports optional creation API. Currently it
|
||||
# only supports resize operations of existing filesystems. Here we
|
||||
# will skip this semantic check, run through the others, then create
|
||||
# the new optional filesystem
|
||||
create_first = False
|
||||
if fs_name not in [fs['name'] for fs in current_host_fs_list]:
|
||||
msg = _("HostFs update failed: invalid filesystem "
|
||||
"'%s' " % fs_display_name)
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
if fs_name not in constants.FS_CREATION_ALLOWED:
|
||||
msg = _("HostFs update failed: invalid filesystem "
|
||||
"'%s' " % fs_display_name)
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
else:
|
||||
create_first = True
|
||||
|
||||
elif not cutils.is_int_like(size):
|
||||
if not cutils.is_int_like(size):
|
||||
msg = _("HostFs update failed: filesystem '%s' "
|
||||
"size must be an integer " % fs_display_name)
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
|
@ -271,9 +280,24 @@ class HostFsController(rest.RestController):
|
|||
"pending, please retry again later.")
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
|
||||
current_size = [fs['size'] for
|
||||
fs in current_host_fs_list
|
||||
if fs['name'] == fs_name][0]
|
||||
# TODO(rchurch): Remove optional filesystem creation once Zero Touch
|
||||
# provisioning properly supports optional creation API.
|
||||
if create_first:
|
||||
try:
|
||||
new_fs = {'name': fs_name, 'size': 1, 'ihost_uuid': ihost_uuid,
|
||||
constants.FS_OP: constants.FS_OP_RESIZE}
|
||||
_create(new_fs)
|
||||
except exception.SysinvException as e:
|
||||
LOG.exception(e)
|
||||
raise wsme.exc.ClientSideError(_("Invalid data: failed to create a"
|
||||
" filesystem"))
|
||||
current_size = 1
|
||||
# Re-populate host-fs-list
|
||||
current_host_fs_list = pecan.request.dbapi.host_fs_get_by_ihost(ihost_uuid)
|
||||
else:
|
||||
current_size = [fs['size'] for
|
||||
fs in current_host_fs_list
|
||||
if fs['name'] == fs_name][0]
|
||||
|
||||
if int(size) <= int(current_size):
|
||||
msg = _("HostFs update failed: size for filesystem '%s' "
|
||||
|
@ -349,6 +373,7 @@ class HostFsController(rest.RestController):
|
|||
host_fs_uuid).as_dict()
|
||||
ihost_uuid = host_fs['ihost_uuid']
|
||||
host = pecan.request.dbapi.ihost_get(ihost_uuid)
|
||||
host_fs[constants.FS_OP] = constants.FS_OP_DELETE
|
||||
staged = _delete(host_fs)
|
||||
|
||||
try:
|
||||
|
@ -376,6 +401,7 @@ class HostFsController(rest.RestController):
|
|||
|
||||
try:
|
||||
host_fs = host_fs.as_dict()
|
||||
host_fs[constants.FS_OP] = constants.FS_OP_CREATE
|
||||
(staged, host_fs) = _create(host_fs)
|
||||
|
||||
ihost_uuid = host_fs['ihost_uuid']
|
||||
|
@ -390,9 +416,11 @@ class HostFsController(rest.RestController):
|
|||
# TODO(rchurch): Need to add a state/status column to the host_fs DB
|
||||
# so status information can be passed to the end-user
|
||||
if staged:
|
||||
LOG.info("STAGING: %s filesystem to be created at unlock" % host_fs['name'])
|
||||
LOG.info("STAGING: %s filesystem on host %s to be created at unlock" % (
|
||||
host_fs['name'], host.hostname))
|
||||
else:
|
||||
LOG.info("REQUEST: %s filesystem will be created NOW" % host_fs['name'])
|
||||
LOG.info("REQUEST: %s filesystem on host %s will be created NOW" % (
|
||||
host_fs['name'], host.hostname))
|
||||
pecan.request.rpcapi.update_host_filesystem_config(
|
||||
pecan.request.context,
|
||||
host=host,
|
||||
|
@ -435,7 +463,12 @@ def _check_host_fs(host_fs):
|
|||
# this filesystem and instances from the nova-local volume group can't exist
|
||||
# at the same time as they share a common mount point. No runtime changes to
|
||||
# nova-local are currently allowed.
|
||||
if (constants.WORKER in ihost['subfunctions'] and
|
||||
#
|
||||
# The exception is to support zero-touch provisioning after initial unlock
|
||||
# when the filesystem will be created and resized. A conflict with
|
||||
# nova-local if initially provisioned will be caught below.
|
||||
if (host_fs[constants.FS_OP] != constants.FS_OP_RESIZE and
|
||||
constants.WORKER in ihost['subfunctions'] and
|
||||
host_fs['name'] == constants.FILESYSTEM_NAME_INSTANCES and
|
||||
(ihost['administrative'] != constants.ADMIN_LOCKED or
|
||||
ihost['ihost_action'] == constants.UNLOCK_ACTION)):
|
||||
|
|
|
@ -650,6 +650,11 @@ SUPPORTED_REPLICATED_FILEYSTEM_LIST = [
|
|||
FILESYSTEM_NAME_DOCKER_DISTRIBUTION,
|
||||
]
|
||||
|
||||
FS_OP = 'operation'
|
||||
FS_OP_CREATE = 'create'
|
||||
FS_OP_DELETE = 'delete'
|
||||
FS_OP_RESIZE = 'resize'
|
||||
|
||||
# Storage: Volume Group Types
|
||||
LVG_NOVA_LOCAL = 'nova-local'
|
||||
LVG_CGTS_VG = 'cgts-vg'
|
||||
|
|
Loading…
Reference in New Issue