From cbfb9e34689ef3798b859b86b45f646a3905294e Mon Sep 17 00:00:00 2001 From: mmachado Date: Thu, 28 Nov 2024 19:06:06 -0300 Subject: [PATCH] Disable sw-patch apply/remove/host-install/delete sw-patch apply/remove/host-install/delete operations are no longer needed as legacy patching has been replaced by USM. sw-patch upload and query are still supported as well as dcmanager patch-strategy orchestration for subclouds still using legacy patching. All tests below include a verification that the operations are not allowed. Test Plan: PASS: AIO-SX bootstrap and unlock PASS: AIO-SX upgrade legacy to usm Story: 2010676 Task: 51438 Change-Id: If538743c5c3c4e8f7fbba79cda87a66be47d4a36 Signed-off-by: mmachado --- sw-patch/bin/sw-patch.completion | 29 +-- .../cgcs-patch/cgcs_patch/patch_client.py | 229 ------------------ 2 files changed, 1 insertion(+), 257 deletions(-) diff --git a/sw-patch/bin/sw-patch.completion b/sw-patch/bin/sw-patch.completion index 4bca798d..f2f21f5e 100644 --- a/sw-patch/bin/sw-patch.completion +++ b/sw-patch/bin/sw-patch.completion @@ -19,13 +19,10 @@ function _swpatch() # The available sw-patch subcommands # local subcommands=" - apply commit - delete query query-dependencies query-hosts - remove show upload upload-dir @@ -36,13 +33,6 @@ function _swpatch() report-app-dependencies query-app-dependencies " - if [ -f /etc/platform/.initial_config_complete ]; then - # Post-config, so the host-install commands are accessible - subcommands="${subcommands} host-install host-install-async" - else - # Pre-config, so the install-local command is accessible - subcommands="${subcommands} install-local" - fi # Appends the '/' when completing dir names set mark-directories on @@ -52,29 +42,12 @@ function _swpatch() # Complete the arguments to the subcommands. # case "$subcommand" in - apply|delete|show|what-requires|is-applied|is-available) + show|what-requires|is-applied|is-available) # Query the list of known patches local patches=$(sw-patch completion patches 2>/dev/null) COMPREPLY=( $(compgen -W "${patches}" -- ${cur}) ) return 0 ;; - remove) - # Query the list of known patches - local patches=$(sw-patch completion patches 2>/dev/null) - COMPREPLY=( $(compgen -W "--skipappcheck ${patches}" -- ${cur}) ) - return 0 - ;; - host-install|host-install-async|drop-host) - if [ "${prev}" = "${subcommand}" -o "${prev}" = "--force" ]; then - # Query the list of known hosts - local names=$(sw-patch completion hosts 2>/dev/null) - COMPREPLY=( $(compgen -W "${names}" -- ${cur}) ) - else - # Only one host can be specified, so no more completion - COMPREPLY=( $(compgen -- ${cur}) ) - fi - return 0 - ;; upload) # Allow dirs and files with .patch extension for completion COMPREPLY=( $(compgen -f -o plusdirs -X '!*.patch' -- ${cur}) ) diff --git a/sw-patch/cgcs-patch/cgcs_patch/patch_client.py b/sw-patch/cgcs-patch/cgcs_patch/patch_client.py index 87666533..74b58800 100644 --- a/sw-patch/cgcs-patch/cgcs_patch/patch_client.py +++ b/sw-patch/cgcs-patch/cgcs_patch/patch_client.py @@ -33,23 +33,12 @@ IPV6_FAMILY = 6 help_upload = "Upload one or more patches to the patching system." help_upload_dir = "Upload patches from one or more directories to the patching system." -help_apply = "Apply one or more patches. This adds the specified patches " + \ - "to the repository, making the update(s) available to the " + \ - "hosts in the system. Use --all to apply all available patches." -help_remove = "Remove one or more patches. This removes the specified " + \ - "patches from the repository." -help_delete = "Delete one or more patches from the patching system." help_query = "Query system patches. Optionally, specify 'query applied' " + \ "to query only those patches that are applied, or 'query available' " + \ "to query those that are not." help_show = "Show details for specified patches." help_what_requires = "List patches that require the specified patches." help_query_hosts = "Query patch states for hosts in the system." -help_host_install = "Trigger patch install/remove on specified host. " + \ - "To force install on unlocked node, use the --force option." -help_host_install_async = "Trigger patch install/remove on specified host. " + \ - "To force install on unlocked node, use the --force option." + \ - " Note: This command returns immediately upon dispatching installation request." help_patch_args = "Patches are specified as a space-separated list of patch IDs." help_install_local = "Trigger patch install/remove on the local host. " + \ "This command can only be used for patch installation prior to initial " + \ @@ -96,21 +85,6 @@ def print_help(): print(textwrap.fill(" {0:<15} ".format("upload-dir:") + help_upload_dir, width=TERM_WIDTH, subsequent_indent=' ' * 20)) print("") - print(textwrap.fill(" {0:<15} ".format("apply:") + help_apply, - width=TERM_WIDTH, subsequent_indent=' ' * 20)) - print(textwrap.fill(help_patch_args, - width=TERM_WIDTH, initial_indent=' ' * 20, subsequent_indent=' ' * 20)) - print("") - print(textwrap.fill(" {0:<15} ".format("remove:") + help_remove, - width=TERM_WIDTH, subsequent_indent=' ' * 20)) - print(textwrap.fill(help_patch_args, - width=TERM_WIDTH, initial_indent=' ' * 20, subsequent_indent=' ' * 20)) - print("") - print(textwrap.fill(" {0:<15} ".format("delete:") + help_delete, - width=TERM_WIDTH, subsequent_indent=' ' * 20)) - print(textwrap.fill(help_patch_args, - width=TERM_WIDTH, initial_indent=' ' * 20, subsequent_indent=' ' * 20)) - print("") print(textwrap.fill(" {0:<15} ".format("query:") + help_query, width=TERM_WIDTH, subsequent_indent=' ' * 20)) print("") @@ -123,12 +97,6 @@ def print_help(): print(textwrap.fill(" {0:<15} ".format("query-hosts:") + help_query_hosts, width=TERM_WIDTH, subsequent_indent=' ' * 20)) print("") - print(textwrap.fill(" {0:<15} ".format("host-install:") + help_host_install, - width=TERM_WIDTH, subsequent_indent=' ' * 20)) - print("") - print(textwrap.fill(" {0:<15} ".format("host-install-async:") + help_host_install_async, - width=TERM_WIDTH, subsequent_indent=' ' * 20)) - print("") print(textwrap.fill(" {0:<15} ".format("install-local:") + help_install_local, width=TERM_WIDTH, subsequent_indent=' ' * 20)) print("") @@ -446,126 +414,6 @@ def patch_upload_req(debug, args): return rc -def patch_apply_req(debug, args): - if len(args) == 0: - print_help() - - # Ignore interrupts during this function - signal.signal(signal.SIGINT, signal.SIG_IGN) - - extra_opts = [] - - if "--skip-semantic" in args: - idx = args.index("--skip-semantic") - - # Get rid of the --skip-semantic - args.pop(idx) - - # Append the extra opts - extra_opts.append("skip-semantic=yes") - - if len(extra_opts) == 0: - extra_opts_str = '' - else: - extra_opts_str = '?%s' % '&'.join(extra_opts) - - patches = "/".join(args) - url = "http://%s/patch/apply/%s%s" % (api_addr, patches, extra_opts_str) - - headers = {} - append_auth_token_if_required(headers) - req = requests.post(url, headers=headers) - - if debug: - print_result_debug(req) - else: - print_patch_op_result(req) - - return check_rc(req) - - -def patch_remove_req(debug, args): - if len(args) == 0: - print_help() - - # Ignore interrupts during this function - signal.signal(signal.SIGINT, signal.SIG_IGN) - - extra_opts = [] - - # The removeunremovable option is hidden and should not be added to help - # text or customer documentation. It is for emergency use only - under - # supervision of the design team. - if "--removeunremovable" in args: - idx = args.index("--removeunremovable") - - # Get rid of the --removeunremovable - args.pop(idx) - - # Append the extra opts - extra_opts.append('removeunremovable=yes') - - if "--skipappcheck" in args: - idx = args.index("--skipappcheck") - - # Get rid of the --skipappcheck - args.pop(idx) - - # Append the extra opts - extra_opts.append("skipappcheck=yes") - - if "--skip-semantic" in args: - idx = args.index("--skip-semantic") - - # Get rid of the --skip-semantic - args.pop(idx) - - # Append the extra opts - extra_opts.append("skip-semantic=yes") - - if len(extra_opts) == 0: - extra_opts_str = '' - else: - extra_opts_str = '?%s' % '&'.join(extra_opts) - - patches = "/".join(args) - url = "http://%s/patch/remove/%s%s" % (api_addr, patches, extra_opts_str) - - headers = {} - append_auth_token_if_required(headers) - req = requests.post(url, headers=headers) - - if debug: - print_result_debug(req) - else: - print_patch_op_result(req) - - return check_rc(req) - - -def patch_delete_req(debug, args): - if len(args) == 0: - print_help() - - # Ignore interrupts during this function - signal.signal(signal.SIGINT, signal.SIG_IGN) - - patches = "/".join(args) - - url = "http://%s/patch/delete/%s" % (api_addr, patches) - - headers = {} - append_auth_token_if_required(headers) - req = requests.post(url, headers=headers) - - if debug: - print_result_debug(req) - else: - print_patch_op_result(req) - - return check_rc(req) - - def patch_commit_req(debug, args): if len(args) == 0: print_help() @@ -974,73 +822,6 @@ def wait_for_install_complete(agent_ip): return rc -def host_install(debug, args): # pylint: disable=unused-argument - force = False - rc = 0 - - if "--force" in args: - force = True - args.remove("--force") - - if len(args) != 1: - print_help() - - agent_ip = args[0] - - # Issue host_install_async request and poll for results - url = "http://%s/patch/host_install_async/%s" % (api_addr, agent_ip) - - if force: - url += "/force" - - req = requests.post(url) - - if req.status_code == 200: - data = json.loads(req.text) - if 'error' in data and data["error"] != "": - print("Error:") - print(data["error"]) - rc = 1 - else: - rc = wait_for_install_complete(agent_ip) - elif req.status_code == 500: - print("An internal error has occurred. Please check /var/log/patching.log for details") - rc = 1 - else: - m = re.search("(Error message:.*)", req.text, re.MULTILINE) - print(m.group(0)) - rc = 1 - - return rc - - -def host_install_async(debug, args): - force = False - - if "--force" in args: - force = True - args.remove("--force") - - if len(args) != 1: - print_help() - - agent_ip = args[0] - - url = "http://%s/patch/host_install_async/%s" % (api_addr, agent_ip) - - if force: - url += "/force" - - req = requests.post(url) - - if debug: - print_result_debug(req) - else: - print_patch_op_result(req) - - return check_rc(req) - - def drop_host(debug, args): if len(args) != 1: print_help() @@ -1479,12 +1260,6 @@ def main(): else: if action == "upload": rc = patch_upload_req(debug, sys.argv[2:]) - elif action == "apply": - rc = patch_apply_req(debug, sys.argv[2:]) - elif action == "remove": - rc = patch_remove_req(debug, sys.argv[2:]) - elif action == "delete": - rc = patch_delete_req(debug, sys.argv[2:]) elif action == "commit": rc = patch_commit_req(debug, sys.argv[2:]) elif action == "query": @@ -1497,10 +1272,6 @@ def main(): what_requires(debug, sys.argv[2:]) elif action == "query-dependencies": query_dependencies(debug, sys.argv[2:]) - elif action == "host-install": - rc = host_install(debug, sys.argv[2:]) - elif action == "host-install-async": - rc = host_install_async(debug, sys.argv[2:]) elif action == "drop-host": rc = drop_host(debug, sys.argv[2:]) elif action == "upload-dir":