Add prestage --for-sw-deploy/--for-install options

Add --for-sw-deploy and --for-install option to dcmanager prestage
command.

The --for-install option is the default value. In the future we may want
to remove the --for-install switch entirely, as it is superfluous. For
now, we will leave it in - it can either be explicitly used or omitted
entirely.

Test Cases

NOTE: Testing is only complete for the 'dcmanager subcloud prestage'
commands. There has been no testing with any of the prestage
orchestration commands.

PASS:
- Invoke dcmanager prestage with --for-sw-deploy. Ensure
  for_sw_deploy=true is added to the payload.
- Invoke dcmanager prestage with --for-install. Ensure
  for_install=true is added to the payload.
- Invoke dcmanager prestage with neither option. Ensure
  for_install=true is added to the payload.
- Invoke dcmanager prestage with both options. Ensure
  the prestage operation is rejected.

Story: 2010676
Task: 50323
Depends-on: https://review.opendev.org/c/starlingx/distcloud/+/921634

Change-Id: I9185a4382d00efa32146412a66b0c89b725f29ad
Signed-off-by: Kyle MacLeod <kyle.macleod@windriver.com>
This commit is contained in:
Kyle MacLeod 2024-06-09 23:18:26 -04:00
parent 4eaaee8e71
commit c0183431c6
2 changed files with 69 additions and 0 deletions

View File

@ -991,10 +991,33 @@ class PrestageSubcloud(base.DCManagerShowOne):
"--release",
required=False,
help="software release used to prestage the subcloud with. "
"Format: YY.MM or YY.MM.nn. "
"If not specified, the current software release of "
"the subcloud will be used.",
)
parser.add_argument(
"--for-install",
required=False,
action="store_true",
help=(
"Prestage for installation. This is the default prestaging option."
),
)
# Prestaging for deployment means prestaging for upgrade
# With USM there is no install phase for upgrades. This operation
# therefore targets the live ostree repo on the subcloud (not
# /opt/platform-backup)
parser.add_argument(
"--for-sw-deploy",
required=False,
action="store_true",
help=(
"Prestage for software deploy operations. If not specified, "
"prestaging is targeted towards full installation."
),
)
return parser
def _get_resources(self, parsed_args):
@ -1017,6 +1040,16 @@ class PrestageSubcloud(base.DCManagerShowOne):
if parsed_args.release:
data["release"] = parsed_args.release
if parsed_args.for_sw_deploy:
if parsed_args.for_install:
error_msg = (
"Options --for-install and --for-sw-deploy cannot be combined"
)
raise exceptions.DCManagerClientException(error_msg)
data["for_sw_deploy"] = "true"
else:
# for_install is the default
data["for_install"] = "true"
try:
result = subcloud_manager.prestage_subcloud(
@ -1025,6 +1058,9 @@ class PrestageSubcloud(base.DCManagerShowOne):
update_fields_values(result)
return result
except exceptions.DCManagerClientException:
raise
except Exception as exc:
print(exc)
error_msg = f"Unable to prestage subcloud {subcloud_ref}"

View File

@ -15,6 +15,7 @@
import base64
from dcmanagerclient import exceptions
from dcmanagerclient import utils
from dcmanagerclient.commands.v1 import sw_update_manager
@ -73,10 +74,31 @@ class CreateSwPrestageStrategy(
required=False,
help=(
"software release used to prestage the subcloud with. "
"Format: YY.MM or YY.MM.nn. "
"If not specified, the current software release of "
"the subcloud will be used."
),
)
parser.add_argument(
"--for-install",
required=False,
action="store_true",
help=(
"Prestage for installation. This is the default prestaging option."
),
)
# Prestaging for deployment means prestaging for upgrade
# For this operation, there is NO INSTALL phase anymore with USM
# - targets the live ostree repo on the subcloud (not /opt/platform-backup)
parser.add_argument(
"--for-sw-deploy",
required=False,
action="store_true",
help=(
"Prestage for software deploy operations. If not specified, "
"prestaging is targeted towards full installation."
),
)
return parser
@ -100,6 +122,17 @@ class CreateSwPrestageStrategy(
if parsed_args.release is not None:
kwargs_dict["release"] = parsed_args.release
if parsed_args.for_sw_deploy:
if parsed_args.for_install:
error_msg = (
"Options --for-install and --for-sw-deploy cannot be combined"
)
raise exceptions.DCManagerClientException(error_msg)
kwargs_dict["for_sw_deploy"] = "true"
else:
# for_install is the default
kwargs_dict["for_install"] = "true"
# override validate_force_params defined in CreateSwUpdateStrategy
def validate_force_params(self, parsed_args):
pass