summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py
diff options
context:
space:
mode:
authork.kedron <k.kedron@partner.samsung.com>2020-03-05 13:12:27 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-06-24 06:01:11 +0000
commitcb30f3a566b73c78c3ea666acfcd3f288098684a (patch)
tree38cd1acb83ddde2b927485611d130bbeec3c1a4b /catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py
parentbdbfc2e460ccb561c3e174260b2908b974996d4f (diff)
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 <k.kedron@partner.samsung.com> Change-Id: I02169eb7d0e3e90851ba1811536d1712c3b4145f
Diffstat (limited to 'catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py')
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py37
1 files changed, 37 insertions, 0 deletions
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()