From 7a697663603a0d3a955076b1a36ce674e62d3ab7 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Wed, 6 Oct 2021 11:47:23 -0400 Subject: Add missing code for Metrics and PV/PVC elimination Earlier patch introducing MeterRegistry to AbstractComponentFunction was not initializing the lateinit property and causing NPE. Also add additional code to handle compatibility issues after the introduction of PV/PVC elminiation for CommandExecutor. This allows blueprintsprocessor to communicate with earlier versions of command- executor which still use the shared pvc. Issue-ID: CCSDK-3471 Change-Id: I84a04601c4fe09c5f3a06664ce877800a30531f1 Signed-off-by: Jozsef Csongvai --- .../src/main/python/command_executor_handler.py | 15 ++++++++++++--- ms/command-executor/src/main/python/utils.py | 11 ++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'ms/command-executor/src') diff --git a/ms/command-executor/src/main/python/command_executor_handler.py b/ms/command-executor/src/main/python/command_executor_handler.py index a862559cf..6a301574b 100644 --- a/ms/command-executor/src/main/python/command_executor_handler.py +++ b/ms/command-executor/src/main/python/command_executor_handler.py @@ -49,9 +49,12 @@ class CommandExecutorHandler(): self.uuid = utils.get_blueprint_uuid(request) self.request_id = utils.get_blueprint_requestid(request) self.sub_request_id = utils.get_blueprint_subRequestId(request) + self.blueprint_name_version = utils.blueprint_name_version(request) # for legacy support self.blueprint_name_version_uuid = utils.blueprint_name_version_uuid(request) self.execution_timeout = utils.get_blueprint_timeout(request) # onap/blueprints/deploy will be ephemeral now + # if the command matches “/opt/app/onap/blueprints/deploy/$cba_name/$cba_version/stuff_that_is_not_cba_uuid/” + # then prepend the $cba_uuid before “stuff_that_is_not_cba_uuid” self.blueprint_dir = self.BLUEPRINTS_DEPLOY_DIR + self.blueprint_name_version_uuid self.blueprint_tosca_meta_file = self.blueprint_dir + '/' + self.TOSCA_META_FILE self.extra = utils.getExtraLogData(request) @@ -243,11 +246,17 @@ class CommandExecutorHandler(): if request.properties is not None and len(request.properties) > 0: properties = " " + re.escape(MessageToJson(request.properties)) + # compatibility hack + # check if the path for the request.command does not contain UUID, then add it after cba_name/cba_version path. + updated_request_command = request.command + if self.blueprint_name_version in updated_request_command and self.blueprint_name_version_uuid not in updated_request_command: + updated_request_command = updated_request_command.replace(self.blueprint_name_version, self.blueprint_name_version_uuid) + ### TODO: replace with os.environ['VIRTUAL_ENV']? - if "ansible-playbook" in request.command: - cmd = cmd + "; " + request.command + " -e 'ansible_python_interpreter=" + self.blueprint_dir + "/bin/python'" + if "ansible-playbook" in updated_request_command: + cmd = cmd + "; " + updated_request_command + " -e 'ansible_python_interpreter=" + self.blueprint_dir + "/bin/python'" else: - cmd = cmd + "; " + request.command + properties + cmd = cmd + "; " + updated_request_command + properties ### extract the original header request into sys-env variables ### OriginatorID diff --git a/ms/command-executor/src/main/python/utils.py b/ms/command-executor/src/main/python/utils.py index e7924a936..d59f8cc47 100644 --- a/ms/command-executor/src/main/python/utils.py +++ b/ms/command-executor/src/main/python/utils.py @@ -26,12 +26,13 @@ RESULTS_LOG_KEY = "results_log" REUPLOAD_CBA_KEY = "reupload_cba" RESPONSE_MAX_SIZE = 4 * 1024 * 1024 # 4Mb - +# part of cba_name/version/uuid path def blueprint_name_version_uuid(request): - blueprint_name = request.identifiers.blueprintName - blueprint_version = request.identifiers.blueprintVersion - blueprint_uuid = request.identifiers.blueprintUUID - return blueprint_name + '/' + blueprint_version + '/' + blueprint_uuid + return get_blueprint_name(request) + '/' + get_blueprint_version(request) + '/' + get_blueprint_uuid(request) + +# return blueprint_name and version part of the path (needed for legacy cmd-exec support +def blueprint_name_version(request): + return get_blueprint_name(request) + '/' + get_blueprint_version(request) def get_blueprint_name(request): return request.identifiers.blueprintName -- cgit 1.2.3-korg