Add --local option to load-import
Currently, load-import uploads .iso and .sig to sysinv-api, which may be a very slow operation that may cause sysinv-api timeouts, specially with larger iso sizes. This commit adds a new --local option that instructs the client to bypass the step that transfers the load via sysinv-api, instead sending the .iso and .sig absolute paths on the active controller filesystem so that conductor uses this information to import the load locally. Test Plan PASS: import the load with --local option and verify: - Load information is populated on /var/www/pages/feed - Load is updated on the database to importing -> imported PASS: import the load with --local option passing an invalid file format and verify: - load-import returns "signature could not be verified" error - Conductor logs "signature could not be verified" error PASS: import the load with --local option passing an invalid file path and verify: - load-import returns "file not found" error PASS: import the load with --local option and upgrade AIO-DX PASS: import the load with --local option on systemcontroller and verify load uploaded to /var/www/pages/feed and /opt/dc-vault/loads Regression PASS: import the load without --local option and verify: - Load information is populated on /var/www/pages/feed - Load is updated on the database to importing -> imported PASS: import the load without --local option passing an invalid file format and verify: - load-import returns "signature could not be verified" error - Conductor logs "signature could not be verified" error PASS: import the load without --local option passing an invalid file path and verify: - load-import returns "file not found" error Story: 2009303 Task: 45886 Relates-To: https://review.opendev.org/c/starlingx/distcloud/+/851616 Change-Id: I1fde3799e3eba8cb772c8e01b0b225d8539e1311 Signed-off-by: Heitor Matsui <HeitorVieira.Matsui@windriver.com>
This commit is contained in:
parent
cade2e2393
commit
360f48cd48
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2022 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -11,7 +11,7 @@ from cgtsclient import exc
|
|||||||
CREATION_ATTRIBUTES = ['software_version', 'compatible_version',
|
CREATION_ATTRIBUTES = ['software_version', 'compatible_version',
|
||||||
'required_patches']
|
'required_patches']
|
||||||
|
|
||||||
IMPORT_ATTRIBUTES = ['path_to_iso', 'path_to_sig', 'active']
|
IMPORT_ATTRIBUTES = ['path_to_iso', 'path_to_sig', 'active', 'local']
|
||||||
|
|
||||||
|
|
||||||
class Load(base.Resource):
|
class Load(base.Resource):
|
||||||
@ -55,11 +55,17 @@ class LoadManager(base.Manager):
|
|||||||
if key in IMPORT_ATTRIBUTES:
|
if key in IMPORT_ATTRIBUTES:
|
||||||
if key == 'active':
|
if key == 'active':
|
||||||
active = value
|
active = value
|
||||||
|
elif key == 'local':
|
||||||
|
local = value
|
||||||
else:
|
else:
|
||||||
load_info[key] = value
|
load_info[key] = value
|
||||||
else:
|
else:
|
||||||
raise exc.InvalidAttribute(key)
|
raise exc.InvalidAttribute(key)
|
||||||
|
|
||||||
|
if local is True:
|
||||||
|
load_info['active'] = active
|
||||||
|
return self._create(path, body=load_info)
|
||||||
|
|
||||||
json_data = self._upload_multipart(
|
json_data = self._upload_multipart(
|
||||||
path, body=load_info, data={'active': active}, check_exceptions=True)
|
path, body=load_info, data={'active': active}, check_exceptions=True)
|
||||||
return self.resource_class(self, json_data)
|
return self.resource_class(self, json_data)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
# Copyright (c) 2015-2022 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -73,8 +73,18 @@ def do_load_delete(cc, args):
|
|||||||
help=("Perform an active load import operation. "
|
help=("Perform an active load import operation. "
|
||||||
"Applicable only for SystemController to allow import of "
|
"Applicable only for SystemController to allow import of "
|
||||||
"an active load for subcloud install"))
|
"an active load for subcloud install"))
|
||||||
|
@utils.arg('--local',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help=("Import the load locally from the active controller. "
|
||||||
|
"To use this option, first upload the .iso and .sig files to "
|
||||||
|
"the active controller and then specify the absolute path of "
|
||||||
|
"both files as 'isopath' and 'sigpath'"))
|
||||||
def do_load_import(cc, args):
|
def do_load_import(cc, args):
|
||||||
"""Import a load."""
|
"""Import a load."""
|
||||||
|
|
||||||
|
local = args.local
|
||||||
|
|
||||||
# If absolute path is not specified, we assume it is the relative path.
|
# If absolute path is not specified, we assume it is the relative path.
|
||||||
# args.isopath will then be set to the absolute path
|
# args.isopath will then be set to the absolute path
|
||||||
if not os.path.isabs(args.isopath):
|
if not os.path.isabs(args.isopath):
|
||||||
@ -105,7 +115,7 @@ def do_load_import(cc, args):
|
|||||||
"old or unused load before importing a new one."))
|
"old or unused load before importing a new one."))
|
||||||
|
|
||||||
patch = {'path_to_iso': args.isopath, 'path_to_sig': args.sigpath,
|
patch = {'path_to_iso': args.isopath, 'path_to_sig': args.sigpath,
|
||||||
'active': active}
|
'active': active, 'local': local}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print("This operation will take a while. Please wait.")
|
print("This operation will take a while. Please wait.")
|
||||||
|
Loading…
Reference in New Issue
Block a user