From cb30f3a566b73c78c3ea666acfcd3f288098684a Mon Sep 17 00:00:00 2001 From: "k.kedron" Date: Thu, 5 Mar 2020 13:12:27 +0100 Subject: Refactoring the sdc-BE-init python scripts Deeper refactoring of python script: - create the python package with init script - support for python 3.x - reuse code - new design - support for .json conf file - update the docker chef script Issue-ID: SDC-2784 Signed-off-by: Krystian Kedron Change-Id: I02169eb7d0e3e90851ba1811536d1712c3b4145f --- .../sdcBePy/tosca/imports/runGenericNormative.py | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py (limited to 'catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py') 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() -- cgit 1.2.3-korg