diff options
Diffstat (limited to 'catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports')
5 files changed, 206 insertions, 0 deletions
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/__init__.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/__init__.py diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py new file mode 100644 index 0000000000..4d4eeaff6e --- /dev/null +++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 + +import os +import sys + +import sdcBePy.common.logger as logger +from sdcBePy.common.normative.main import process_element_list, process_type_list +from sdcBePy.common.sdcBeProxy import SdcBeProxy +from sdcBePy.tosca.main import get_args, usage +from sdcBePy.tosca.models.normativeElementsList import get_normative_element_candidate_list, \ + get_normative_element_with_metadata_list +from sdcBePy.tosca.models.normativeTypesList import get_normative_type_candidate_list + + +def main(): + scheme, be_host, be_port, admin_user, update_version, debug = get_args() + + if debug is False: + print('Disabling debug mode') + logger.debugFlag = debug + + try: + sdc_be_proxy = SdcBeProxy(be_host, be_port, scheme, admin_user, debug) + except AttributeError: + usage() + sys.exit(3) + + # use to run script form this dir (not like the command) + # base_file_location = os.getcwd() + "/../../../../import/tosca/" + base_file_location = os.getcwd() + os.path.sep + logger.debug("working directory =" + base_file_location) + + process_element_list(get_normative_element_candidate_list(base_file_location), sdc_be_proxy) + process_type_list(get_normative_type_candidate_list(base_file_location), sdc_be_proxy, update_version) + process_element_list(get_normative_element_with_metadata_list(base_file_location), sdc_be_proxy) + + logger.log("Script end ->", "All normatives imported successfully!") + logger.error_and_exit(0, None) + + +if __name__ == "__main__": + main() diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py new file mode 100644 index 0000000000..424c0ca7c5 --- /dev/null +++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py @@ -0,0 +1,37 @@ +import os +import sys +from argparse import ArgumentParser + +from sdcBePy.common.normative.toscaTypes import process_and_create_normative_types +from sdcBePy.tosca.main import usage, get_args +from sdcBePy.tosca.models.normativeTypeCandidate import NormativeTypeCandidate + + +def get_normative_prams(): + parser = ArgumentParser() + + path = os.path.dirname(__file__) + parser.add_argument('--location', default=path + os.path.sep) + parser.add_argument('--element', "-e", required=True) + + args = parser.parse_args() + + return args.location, [args.element] + + +def main(): + scheme, be_host, be_port, admin_user, _, debug = get_args() + + candidate = NormativeTypeCandidate(*get_normative_prams()) + try: + process_and_create_normative_types(candidate, + scheme, be_host, be_port, admin_user, + debug=debug, + exit_on_success=True) + except AttributeError: + usage() + sys.exit(3) + + +if __name__ == '__main__': + main() diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py new file mode 100644 index 0000000000..1bdb1504b2 --- /dev/null +++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 + +import sys + +from sdcBePy.common.normative.toscaElements import process_and_create_normative_element +from sdcBePy.tosca.main import get_args, usage +from sdcBePy.tosca.models.normativeElementsList import get_capability, get_data, get_relationship, \ + get_interface_lifecycle, get_categories, get_group, get_policy, get_annotation + + +def run(candidate): + scheme, be_host, be_port, admin_user, _, debug = get_args() + try: + process_and_create_normative_element(candidate, + scheme, be_host, be_port, admin_user, + debug=debug, + exit_on_success=True) + except AttributeError: + usage() + sys.exit(3) + + +def run_import_data(): + data_candidate = get_data() + run(data_candidate) + + +def run_import_capabilities(): + capability_candidate = get_capability() + run(capability_candidate) + + +def run_import_relationship(): + relationship_candidate = get_relationship() + run(relationship_candidate) + + +def run_import_interface_lifecycle(): + interface_lifecycle_candidate = get_interface_lifecycle() + run(interface_lifecycle_candidate) + + +def run_import_categories(): + categories_candidate = get_categories() + run(categories_candidate) + + +def run_import_group(): + group_candidate = get_group() + run(group_candidate) + + +def run_import_policy(): + policy_candidate = get_policy() + run(policy_candidate) + + +def run_import_annotation(): + annotation_candidate = get_annotation() + run(annotation_candidate) + + +if __name__ == '__main__': + run_import_data() + # run_import_capabilities() + # run_import_relationship() + # run_import_interface_lifecycle() + # run_import_categories() + # run_import_group() + # run_import_policy() + # run_import_annotation() diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeType.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeType.py new file mode 100644 index 0000000000..ee4e05b21a --- /dev/null +++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeType.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import sys + +from sdcBePy.common.normative.toscaTypes import process_and_create_normative_types +from sdcBePy.tosca.main import get_args, usage +from sdcBePy.tosca.models.normativeTypesList import get_normative, get_heat, get_nfv, get_onap, get_sol + + +def run(candidate, exit_on_success=True): + scheme, be_host, be_port, admin_user, update_version, debug = get_args() + try: + process_and_create_normative_types(candidate, + scheme, + be_host, + be_port, + admin_user, + update_version=update_version, + debug=debug, + exit_on_success=exit_on_success) + except AttributeError: + usage() + sys.exit(3) + + +def run_import_normative(): + normative_candidate = get_normative() + run(normative_candidate) + + +def run_import_heat(): + heat_candidate = get_heat() + run(heat_candidate) + + +def run_import_nfv(): + nfv_candidate = get_nfv() + run(nfv_candidate) + + +def run_import_onap(): + onap_candidate = get_onap() + run(onap_candidate) + + +def run_import_sol(): + sol_candidate = get_sol() + run(sol_candidate) + + +if __name__ == '__main__': + run_import_normative() + # run_import_heat() + # run_import_nfv() + # run_import_onap() + # run_import_sol() |