summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts/sdcBePy/tosca
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
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')
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/__init__.py0
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/beConfig.json5
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/onapTypesToUpgrade.json9
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/typesToUpgrade.json4
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/__init__.py0
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/run.py42
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runGenericNormative.py37
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py71
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeType.py56
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py56
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/__init__.py0
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeElementCandidate.py18
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeElementsList.py76
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py60
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeTypeCandidate.py14
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeTypesList.py161
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/__init__.py0
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py59
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/runUpgradeNormative.py59
19 files changed, 727 insertions, 0 deletions
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/__init__.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/__init__.py
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/beConfig.json b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/beConfig.json
new file mode 100644
index 0000000000..f8c740b94f
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/beConfig.json
@@ -0,0 +1,5 @@
+{
+ "beHost": "localhost",
+ "bePort": "8080",
+ "adminUser": "jh0003"
+} \ No newline at end of file
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/onapTypesToUpgrade.json b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/onapTypesToUpgrade.json
new file mode 100644
index 0000000000..cbe581acd2
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/onapTypesToUpgrade.json
@@ -0,0 +1,9 @@
+{
+ "nfv": [
+ "allottedResource"
+ ],
+ "onap": [
+ ],
+ "sol":[
+ ]
+} \ No newline at end of file
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/typesToUpgrade.json b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/typesToUpgrade.json
new file mode 100644
index 0000000000..5dd20011c0
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/data/typesToUpgrade.json
@@ -0,0 +1,4 @@
+{
+ "heat": [],
+ "normative": []
+} \ No newline at end of file
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()
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py
new file mode 100644
index 0000000000..2535ba6d77
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py
@@ -0,0 +1,56 @@
+import json
+import os
+import sys
+from argparse import ArgumentParser
+
+
+def usage():
+ print(sys.argv[0],
+ '[-s <scheme> | --scheme=<scheme> ] [-i <be host> | --ip=<be host>] [-p <be port> | '
+ '--port=<be port> ] [-u <user userId> | --user=<user userId> ] [-d <true|false> | '
+ '--debug=<true|false>] [-v <true|false> | --updateVersion=<true|false>]')
+
+
+def load_be_config(conf_path):
+ with open(conf_path, 'r') as f:
+ return json.load(f)
+
+
+def parse_param():
+ parser = ArgumentParser()
+
+ path = os.path.dirname(__file__)
+ parser.add_argument('--conf', default=os.path.join(path, 'data', 'beConfig.json'))
+
+ parser.add_argument('--ip', "-i")
+ parser.add_argument('--port', "-p")
+ parser.add_argument('--adminUser', "-a")
+ parser.add_argument('--https', action='store_true')
+ parser.add_argument('--updateVersion', action='store_false')
+ parser.add_argument('--debug', action='store_true')
+
+ args, _ = parser.parse_known_args()
+
+ return [args.conf, 'https' if args.https else 'http',
+ args.ip, args.port, args.adminUser, args.updateVersion,
+ args.debug]
+
+
+def get_args():
+ print('Number of arguments:', len(sys.argv), 'arguments.')
+
+ conf_path, scheme, be_host, be_port, admin_user, update_version, debug = parse_param()
+ defaults = load_be_config(conf_path)
+
+ # Use defaults if param not provided by the user
+ if be_host is None:
+ be_host = defaults["beHost"]
+ if be_port is None:
+ be_port = defaults["bePort"]
+ if admin_user is None:
+ admin_user = defaults["adminUser"]
+
+ print('scheme =', scheme, ',be host =', be_host, ', be port =', be_port, ', user =', admin_user,
+ ', debug =', debug, ', update_version =', update_version)
+
+ return scheme, be_host, be_port, admin_user, update_version, debug
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/__init__.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/__init__.py
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeElementCandidate.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeElementCandidate.py
new file mode 100644
index 0000000000..96526ce82a
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeElementCandidate.py
@@ -0,0 +1,18 @@
+from sdcBePy.common.helpers import check_arguments_not_none
+
+
+class NormativeElementCandidate:
+
+ def __init__(self, file_dir, url_suffix,
+ element_name, element_from_name, with_metadata=False):
+ if not check_arguments_not_none(file_dir, url_suffix, element_name, element_from_name):
+ raise AttributeError("The file_dir, url_suffix, element_name, element_from_name are missing")
+
+ self.file_dir = file_dir
+ self.url_suffix = url_suffix
+ self.element_name = element_name
+ self.element_form_name = element_from_name
+ self.with_metadata = with_metadata
+
+ def get_parameters(self):
+ return self.file_dir, self.url_suffix, self.element_name, self.element_form_name, self.with_metadata
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeElementsList.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeElementsList.py
new file mode 100644
index 0000000000..cfef95d427
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeElementsList.py
@@ -0,0 +1,76 @@
+from sdcBePy.tosca.models.normativeElementCandidate import NormativeElementCandidate
+
+
+def get_normative_element_candidate_list(base_file_location):
+ return [
+ get_data(base_file_location),
+ get_capability(base_file_location),
+ get_relationship(base_file_location),
+ get_interface_lifecycle(base_file_location),
+ get_categories(base_file_location)
+ ]
+
+
+def get_normative_element_with_metadata_list(base_file_location):
+ return [
+ get_group(base_file_location),
+ get_policy(base_file_location)
+ ]
+
+
+def get_data(base_file_location="/"):
+ return NormativeElementCandidate(base_file_location + "data-types/",
+ "/sdc2/rest/v1/catalog/uploadType/datatypes",
+ "dataTypes",
+ "dataTypesZip")
+
+
+def get_capability(base_file_location="/"):
+ return NormativeElementCandidate(base_file_location + "capability-types/",
+ "/sdc2/rest/v1/catalog/uploadType/capability",
+ "capabilityTypes",
+ "capabilityTypeZip")
+
+
+def get_relationship(base_file_location="/"):
+ return NormativeElementCandidate(base_file_location + "relationship-types/",
+ "/sdc2/rest/v1/catalog/uploadType/relationship",
+ "relationshipTypes",
+ "relationshipTypeZip")
+
+
+def get_interface_lifecycle(base_file_location="../../../import/tosca/"):
+ return NormativeElementCandidate(base_file_location + "interface-lifecycle-types/",
+ "/sdc2/rest/v1/catalog/uploadType/interfaceLifecycle",
+ "interfaceLifecycleTypes",
+ "interfaceLifecycleTypeZip")
+
+
+def get_categories(base_file_location="/"):
+ return NormativeElementCandidate(base_file_location + "categories/",
+ "/sdc2/rest/v1/catalog/uploadType/categories",
+ "categoryTypes",
+ "categoriesZip")
+
+
+def get_group(base_file_location="/"):
+ return NormativeElementCandidate(base_file_location + "group-types/",
+ "/sdc2/rest/v1/catalog/uploadType/grouptypes",
+ "groupTypes",
+ "groupTypesZip",
+ with_metadata=True)
+
+
+def get_policy(base_file_location="/"):
+ return NormativeElementCandidate(base_file_location + "policy-types/",
+ "/sdc2/rest/v1/catalog/uploadType/policytypes",
+ "policyTypes",
+ "policyTypesZip",
+ with_metadata=True)
+
+
+def get_annotation(base_file_location="/"):
+ return NormativeElementCandidate(base_file_location + "annotation-types",
+ "/sdc2/rest/v1/catalog/uploadType/annotationtypes",
+ "annotationTypesZip",
+ "annotationTypes")
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"))
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeTypeCandidate.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeTypeCandidate.py
new file mode 100644
index 0000000000..929ec4f864
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeTypeCandidate.py
@@ -0,0 +1,14 @@
+from sdcBePy.common.helpers import check_arguments_not_none
+
+
+class NormativeTypeCandidate:
+
+ def __init__(self, file_dir, normative_types_list):
+ if not check_arguments_not_none(file_dir, normative_types_list):
+ raise AttributeError("The file_dir, normative_types_list are missing")
+
+ self.file_dir = file_dir
+ self.normative_types_list = normative_types_list
+
+ def get_parameters(self):
+ return self.file_dir, self.normative_types_list
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeTypesList.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeTypesList.py
new file mode 100644
index 0000000000..eea25436b3
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeTypesList.py
@@ -0,0 +1,161 @@
+from sdcBePy.tosca.models.normativeTypeCandidate import NormativeTypeCandidate
+
+
+def get_normative_type_candidate_list(base_file_location):
+ return [
+ get_normative(base_file_location),
+ get_heat(base_file_location),
+ get_nfv(base_file_location),
+ get_onap(base_file_location),
+ get_sol(base_file_location)
+ ]
+
+
+def get_normative(base_file_location="/"):
+ return NormativeTypeCandidate(base_file_location + "normative-types/",
+ ["root",
+ "compute",
+ "softwareComponent",
+ "webServer",
+ "webApplication",
+ "DBMS",
+ "database",
+ "objectStorage",
+ "blockStorage",
+ "containerRuntime",
+ "containerApplication",
+ "loadBalancer",
+ "port", "network"])
+
+
+def get_heat(base_file_location="/"):
+ return NormativeTypeCandidate(base_file_location + "heat-types/",
+ ["globalNetwork",
+ "globalPort",
+ "globalCompute",
+ "volume",
+ "cinderVolume",
+ "contrailVirtualNetwork",
+ "neutronNet",
+ "neutronPort",
+ "novaServer",
+ "extVl",
+ "internalVl",
+ "extCp",
+ "vl",
+ "eline",
+ "abstractSubstitute",
+ "Generic_VFC",
+ "Generic_VF",
+ "Generic_CR",
+ "Generic_PNF",
+ "Generic_Service",
+ "contrailNetworkRules",
+ "contrailPort",
+ "portMirroring",
+ "serviceProxy",
+ "contrailV2NetworkRules",
+ "contrailV2VirtualNetwork",
+ "securityRules",
+ "contrailAbstractSubstitute",
+ "contrailCompute",
+ "contrailV2VirtualMachineInterface",
+ "subInterface",
+ "contrailV2VLANSubInterface",
+ "multiFlavorVFC",
+ "vnfConfiguration",
+ "extCp2",
+ "extNeutronCP",
+ "extContrailCP",
+ "portMirroringByPolicy",
+ "forwardingPath",
+ "configuration",
+ "VRFObject",
+ "extVirtualMachineInterfaceCP",
+ "VLANNetworkReceptor",
+ "VRFEntry",
+ "subInterfaceV2",
+ "contrailV2VLANSubInterfaceV2",
+ "fabricConfiguration"])
+
+
+def get_nfv(base_file_location="/"):
+ return NormativeTypeCandidate(base_file_location + "nfv-types/",
+ ["underlayVpn",
+ "overlayTunnel",
+ "genericNeutronNet",
+ "allottedResource",
+ "extImageFile",
+ "extLocalStorage",
+ "extZteCP",
+ "extZteVDU",
+ "extZteVL",
+ "NSD",
+ "VDU",
+ "vduCompute",
+ "Cp",
+ "vduVirtualStorage",
+ "vduVirtualBlockStorage",
+ "vduVirtualFileStorage",
+ "vduVirtualObjectStorage",
+ "vduVirtualStorage",
+ "vnfVirtualLink",
+ "vnfExtCp",
+ "vduCp",
+ "VNF",
+ "PonUni",
+ "OltNni",
+ "OntNni"])
+
+
+def get_onap(base_file_location="/"):
+ return NormativeTypeCandidate(base_file_location + "onap-types/",
+ # Add desired type names to the list
+ [])
+
+
+def get_sol(base_file_location="/"):
+ return NormativeTypeCandidate(base_file_location + "onap-types/",
+ # Add desired type names to the list
+ [])
+
+
+def get_heat1707(base_file_location="/"):
+ return NormativeTypeCandidate(base_file_location + "heat-types/",
+ ["volume",
+ "cinderVolume",
+ "extVl",
+ "extCp",
+ "Generic_VFC",
+ "Generic_VF",
+ "Generic_PNF",
+ "Generic_Service",
+ "globalPort",
+ "globalNetwork",
+ "contrailV2VirtualMachineInterface",
+ "contrailV2VLANSubInterface",
+ "contrailPort",
+ "contrailV2VirtualNetwork",
+ "contrailVirtualNetwork",
+ "neutronNet",
+ "neutronPort",
+ "multiFlavorVFC",
+ "vnfConfiguration"])
+
+
+def get_heat1702_3537(base_file_location="/"):
+ return NormativeTypeCandidate(base_file_location + "heat-types/",
+ ["contrailPort",
+ "contrailV2VirtualMachineInterface",
+ "neutronPort",
+ "contrailCompute",
+ "novaServer",
+ "contrailV2VirtualNetwork",
+ "contrailVirtualNetwork",
+ "neutronNet"])
+
+
+def get_heat_version(base_file_location="/"):
+ return NormativeTypeCandidate(base_file_location + "heat_types/",
+ ["contrailV2VirtualMachineInterface",
+ "neutronPort"])
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/__init__.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/__init__.py
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py
new file mode 100644
index 0000000000..6d90a1c085
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/run.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+from sdcBePy.common import logger
+from sdcBePy.common.logger import error_and_exit
+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.normativeToUpdateList import TypesToUpdate, get_heat_and_normative_to_update_list, \
+ get_nfv_onap_sol_to_update_list
+
+
+def main():
+ scheme, be_host, be_port, admin_user, _, debug = get_args()
+
+ update_version = True
+ update_onap_version = False
+
+ if debug is False:
+ print('Disabling debug mode')
+ logger.debugFlag = debug
+
+ try:
+ sdc_be_proxy = SdcBeProxy(be_host, be_port, scheme, admin_user, debug=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() + "/"
+ logger.debug("working directory =" + base_file_location)
+ process_element_list(get_normative_element_candidate_list(base_file_location), sdc_be_proxy)
+ process_element_list(get_normative_element_with_metadata_list(base_file_location), sdc_be_proxy)
+
+ all_types = get_all_types()
+
+ heat_and_normative_list = get_heat_and_normative_to_update_list(all_types, base_file_location)
+ process_type_list(heat_and_normative_list, sdc_be_proxy, update_version)
+
+ nfv_onap_sol_list = get_nfv_onap_sol_to_update_list(all_types, base_file_location)
+ process_type_list(nfv_onap_sol_list, sdc_be_proxy, update_onap_version)
+
+ logger.log("Updating end ->", "All normatives updated successfully!")
+ error_and_exit(0, None)
+
+
+def get_all_types():
+ path = os.path.dirname(__file__)
+ return TypesToUpdate([path + "/../data/typesToUpgrade.json",
+ path + "/../data/onapTypesToUpgrade.json"])
+
+
+if __name__ == "__main__":
+ main()
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/runUpgradeNormative.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/runUpgradeNormative.py
new file mode 100644
index 0000000000..4b0d0cc8a2
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/upgrade/runUpgradeNormative.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+
+from sdcBePy.tosca.imports.runNormativeType import run
+from sdcBePy.tosca.models.normativeToUpdateList import get_heat, get_normative, get_nfv, get_onap, get_sol
+from sdcBePy.tosca.models.normativeTypesList import get_heat1707, get_heat1702_3537, get_heat_version
+from sdcBePy.tosca.upgrade.run import get_all_types
+
+all_types = get_all_types()
+
+
+def run_upgrade_heat():
+ normative_candidate = get_heat(all_types)
+ run(normative_candidate)
+
+
+def run_upgrade_normative():
+ normative_candidate = get_normative(all_types)
+ run(normative_candidate)
+
+
+def run_upgrade_nfv():
+ normative_candidate = get_nfv(all_types)
+ run(normative_candidate)
+
+
+def run_upgrade_onap():
+ normative_candidate = get_onap(all_types)
+ run(normative_candidate)
+
+
+def run_upgrade_sol():
+ normative_candidate = get_sol(all_types)
+ run(normative_candidate)
+
+
+def run_upgrade_heat1707():
+ normative_candidate = get_heat1707()
+ run(normative_candidate)
+
+
+def run_upgrade_heat1707_3537():
+ normative_candidate = get_heat1702_3537()
+ run(normative_candidate)
+
+
+def run_upgrade_heat_version():
+ normative_candidate = get_heat_version()
+ run(normative_candidate)
+
+
+if __name__ == '__main__':
+ run_upgrade_heat()
+ # run_upgrade_normative()
+ # run_upgrade_nfv()
+ # run_upgrade_onap()
+ # run_upgrade_sol()
+ # run_upgrade_heat1707()
+ # run_upgrade_heat1707_3537()
+ # run_upgrade_heat_version()