From 360f48cd480eb5e6ae916a2c9f150e5e7bffe2b4 Mon Sep 17 00:00:00 2001 From: Heitor Matsui Date: Tue, 26 Jul 2022 16:00:22 -0300 Subject: [PATCH] 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 --- .../cgts-client/cgts-client/cgtsclient/v1/load.py | 10 ++++++++-- .../cgts-client/cgtsclient/v1/load_shell.py | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/sysinv/cgts-client/cgts-client/cgtsclient/v1/load.py b/sysinv/cgts-client/cgts-client/cgtsclient/v1/load.py index 77d89f6549..4eb80a33eb 100644 --- a/sysinv/cgts-client/cgts-client/cgtsclient/v1/load.py +++ b/sysinv/cgts-client/cgts-client/cgtsclient/v1/load.py @@ -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 # @@ -11,7 +11,7 @@ from cgtsclient import exc CREATION_ATTRIBUTES = ['software_version', 'compatible_version', '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): @@ -55,11 +55,17 @@ class LoadManager(base.Manager): if key in IMPORT_ATTRIBUTES: if key == 'active': active = value + elif key == 'local': + local = value else: load_info[key] = value else: raise exc.InvalidAttribute(key) + if local is True: + load_info['active'] = active + return self._create(path, body=load_info) + json_data = self._upload_multipart( path, body=load_info, data={'active': active}, check_exceptions=True) return self.resource_class(self, json_data) diff --git a/sysinv/cgts-client/cgts-client/cgtsclient/v1/load_shell.py b/sysinv/cgts-client/cgts-client/cgtsclient/v1/load_shell.py index c029566613..ec9c44ddd1 100644 --- a/sysinv/cgts-client/cgts-client/cgtsclient/v1/load_shell.py +++ b/sysinv/cgts-client/cgts-client/cgtsclient/v1/load_shell.py @@ -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 # @@ -73,8 +73,18 @@ def do_load_delete(cc, args): help=("Perform an active load import operation. " "Applicable only for SystemController to allow import of " "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): """Import a load.""" + + local = args.local + # If absolute path is not specified, we assume it is the relative path. # args.isopath will then be set to the absolute path 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.")) patch = {'path_to_iso': args.isopath, 'path_to_sig': args.sigpath, - 'active': active} + 'active': active, 'local': local} try: print("This operation will take a while. Please wait.")