summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.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/models/normativeToUpdateList.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/models/normativeToUpdateList.py')
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py
new file mode 100644
index 0000000000..a2830185d5
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py
@@ -0,0 +1,60 @@
+import json
+
+from sdcBePy.tosca.models.normativeTypeCandidate import NormativeTypeCandidate
+
+
+class TypesToUpdate:
+
+ def __init__(self, files):
+ self.types_list = {}
+ self.load_files(files)
+
+ def load_files(self, files):
+ for file in files:
+ with open(file, 'r') as stream:
+ _types = json.load(stream)
+ for type_key, type_value in _types.items():
+ self.types_list[type_key] = type_value
+
+ def get_type(self, key):
+ return self.types_list[key]
+
+
+def get_heat_and_normative_to_update_list(types, base_file_location):
+ return [
+ get_heat(types, base_file_location),
+ get_normative(types, base_file_location)
+ ]
+
+
+def get_nfv_onap_sol_to_update_list(types, base_file_location):
+ return [
+ get_nfv(types, base_file_location),
+ get_onap(types, base_file_location),
+ get_sol(types, base_file_location)
+ ]
+
+
+def get_heat(types, base_location="/"):
+ return NormativeTypeCandidate(base_location + "heat-types/",
+ types.get_type("heat"))
+
+
+def get_normative(types, base_location="/"):
+ return NormativeTypeCandidate(base_location + "normative-types/",
+ types.get_type("normative"))
+
+
+def get_nfv(types, base_location="/"):
+ return NormativeTypeCandidate(base_location + "nfv-types/",
+ types.get_type("nfv"))
+
+
+def get_onap(types, base_location="/"):
+ return NormativeTypeCandidate(base_location + "onap-types/",
+ types.get_type("onap"))
+
+
+def get_sol(types, base_location="/"):
+ return NormativeTypeCandidate(base_location + "sol-types/",
+ types.get_type("sol"))