From 775c5c7672e465322dd896dd443e0f790060c931 Mon Sep 17 00:00:00 2001 From: Iago Regiani Date: Tue, 6 Jul 2021 12:44:18 -0400 Subject: [PATCH] System host-upgrade has inadequate semantic checks System host-upgrade prompts the user to confirm the operation on a SX for any hostname typed, this adds validation to the inputted argument and rejects the command if the hostname or id typed is invalid. Also added validation to host-downgrade and kube-host-upgrade. Tested on a SX, changing the cgts-client and the validation was sucessfull rejecting invalid ids and hostnames. Closes-bug: #1934806 Signed-off-by: Iago Regiani Change-Id: Ia7f48fee1204e4e2178ef5a954621725512cc738 --- .../cgts-client/cgtsclient/tests/v1/test_ihost_shell.py | 2 ++ sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_ihost_shell.py b/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_ihost_shell.py index a017d54b59..f853ed0646 100644 --- a/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_ihost_shell.py +++ b/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_ihost_shell.py @@ -171,6 +171,7 @@ class HostTest(test_shell.ShellTest): def test_kube_host_upgrade_control_plane(self): self.make_env() + self.ihost_manager_list_result = [ihost(None, FAKE_IHOST_2, True)] self.kube_host_upgrade_manager_list_result = [ KubeHostUpgrade(None, FAKE_KUBE_HOST_UPGRADE, True), KubeHostUpgrade(None, FAKE_KUBE_HOST_UPGRADE_2, True), @@ -196,6 +197,7 @@ class HostTest(test_shell.ShellTest): def test_kube_host_upgrade_kubelet(self): self.make_env() + self.ihost_manager_list_result = [ihost(None, FAKE_IHOST_2, True)] self.kube_host_upgrade_manager_list_result = [ KubeHostUpgrade(None, FAKE_KUBE_HOST_UPGRADE, True), KubeHostUpgrade(None, FAKE_KUBE_HOST_UPGRADE_2, True), diff --git a/sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py b/sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py index 7c53d8e2db..ee43603398 100755 --- a/sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py +++ b/sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py @@ -760,6 +760,7 @@ def do_host_bulk_export(cc, args): help="Force the downgrade operation ") def do_host_downgrade(cc, args): """Perform software downgrade for the specified host.""" + ihost_utils._find_ihost(cc, args.hostid) system_type, system_mode = utils._get_system_info(cc) simplex = system_mode == constants.SYSTEM_MODE_SIMPLEX @@ -789,6 +790,7 @@ def do_host_downgrade(cc, args): help="Force the upgrade operation ") def do_host_upgrade(cc, args): """Perform software upgrade for a host.""" + ihost_utils._find_ihost(cc, args.hostid) system_type, system_mode = utils._get_system_info(cc) simplex = system_mode == constants.SYSTEM_MODE_SIMPLEX @@ -822,6 +824,7 @@ def do_host_upgrade(cc, args): help="Force the kubernetes upgrade operation ") def do_kube_host_upgrade(cc, args): """Perform kubernetes upgrade for a host.""" + ihost_utils._find_ihost(cc, args.hostid) if args.component == 'control-plane': host = cc.ihost.kube_upgrade_control_plane(args.hostid, args.force)