aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts
diff options
context:
space:
mode:
authorGitelman, Tal (tg851x) <tg851x@intl.att.com>2018-03-20 01:04:54 +0200
committerMichael Lando <ml636r@att.com>2018-03-19 23:09:14 +0000
commitfefa3e408f77289594e47edc878d1bee61fca90b (patch)
treefe8a7349a53e59085f6135f9b1d8729738d9a6ac /catalog-be/src/main/resources/scripts
parent41cf18e4eebdae0692b832278b5a48f90345eedc (diff)
Normative alignemet
Change-Id: I6115e20fe95662153903873d19439bc7cf0c2ff1 Issue-ID: SDC-1104 Signed-off-by: Gitelman, Tal (tg851x) <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/main/resources/scripts')
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/importNfvTypes.py113
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py2
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py16
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py16
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/importSolTypes.py99
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/onapTypesToUpgrade.json4
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/upgradeNfvTypes.py104
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py12
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/upgradeSolTypes.py104
9 files changed, 451 insertions, 19 deletions
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importNfvTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importNfvTypes.py
new file mode 100644
index 0000000000..019067b849
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/import/tosca/importNfvTypes.py
@@ -0,0 +1,113 @@
+import pycurl
+import sys, getopt
+from StringIO import StringIO
+import json
+import copy
+from importCommon import *
+from importNormativeTypes import *
+import importCommon
+
+#####################################################################################################################################################################################################
+# #
+# Import Nfv Types from a given file #
+# #
+# activation : #
+# python importNfvTypes.py [optional -s <scheme> | --scheme=<scheme>, default http] [-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-f <input file> | --ifile=<input file> ] #
+# #
+# shortest activation (be host = localhost, be port = 8080): #
+# python importUsers.py [-f <input file> | --ifile=<input file> ] #
+# #
+#####################################################################################################################################################################################################
+
+def importNfvTypes(scheme, beHost, bePort, adminUser, fileDir, updateversion):
+
+ nfvTypes = [ "underlayVpn",
+ "overlayTunnel",
+ "genericNeutronNet",
+ "allottedResource",
+ "extImageFile",
+ "extLocalStorage",
+ "extZteCP",
+ "extZteVDU",
+ "extZteVL",
+ "NSD",
+ "VDU",
+ "vduCompute",
+ "vduCpd",
+ "vduVirtualStorage",
+ "vnfVirtualLinkDesc"
+ ]
+
+ responseCodes = [200, 201]
+
+ if(updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+
+ results = []
+ for nfvType in nfvTypes:
+ result = createNormativeType(scheme, beHost, bePort, adminUser, fileDir, nfvType, updateversion)
+ results.append(result)
+ if ( result[1] == None or result[1] not in responseCodes) :
+ print "Failed creating heat type " + nfvType + ". " + str(result[1])
+ return results
+
+
+def main(argv):
+ print 'Number of arguments:', len(sys.argv), 'arguments.'
+
+ beHost = 'localhost'
+ bePort = '8080'
+ adminUser = 'jh0003'
+ updateversion = 'true'
+ scheme = 'http'
+
+ try:
+ opts, args = getopt.getopt(argv,"i:p:u:v:h:",["ip=","port=","user=","updateversion="])
+ except getopt.GetoptError:
+ usage()
+ errorAndExit(2, 'Invalid input')
+
+ for opt, arg in opts:
+ #print opt, arg
+ if opt == '-h':
+ usage()
+ sys.exit(3)
+ elif opt in ("-i", "--ip"):
+ beHost = arg
+ elif opt in ("-p", "--port"):
+ bePort = arg
+ elif opt in ("-u", "--user"):
+ adminUser = arg
+ elif opt in ("-s", "--scheme"):
+ scheme = arg
+ elif opt in ("-v", "--updateversion"):
+ if (arg.lower() == "false" or arg.lower() == "no"):
+ updateversion = 'false'
+
+ print 'scheme =',scheme,',be host =',beHost,', be port =', bePort,', user =', adminUser
+
+ if ( beHost == None ):
+ usage()
+ sys.exit(3)
+
+ results = importNfvTypes(scheme, beHost, bePort, adminUser, "../../../import/tosca/nfv-types/", updateversion)
+
+ print "-----------------------------"
+ for result in results:
+ print "{0:20} | {1:6}".format(result[0], result[1])
+ print "-----------------------------"
+
+ responseCodes = [200, 201]
+
+ if(updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+
+ failedNormatives = filter(lambda x: x[1] == None or x[1] not in responseCodes, results)
+ if (len(failedNormatives) > 0):
+ errorAndExit(1, None)
+ else:
+ errorAndExit(0, None)
+
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py
index df2cd49687..5b7b52d0a1 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py
+++ b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py
@@ -87,7 +87,7 @@ def usage():
def importNormativeTypes(scheme, beHost, bePort, adminUser, fileDir, updateversion):
- normativeTypes = [ "root", "compute", "softwareComponent", "webServer", "webApplication", "DBMS", "database", "objectStorage", "blockStorage", "containerRuntime", "containerApplication", "loadBalancer", "port", "network", "allottedResource"]
+ normativeTypes = [ "root", "compute", "softwareComponent", "webServer", "webApplication", "DBMS", "database", "objectStorage", "blockStorage", "containerRuntime", "containerApplication", "loadBalancer", "port", "network"]
#normativeTypes = [ "root" ]
responseCodes = [200, 201]
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py b/catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py
index eb55bf84bc..6144d69104 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py
+++ b/catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py
@@ -8,7 +8,9 @@ import time
from importNormativeElements import *
from importNormativeTypes import importNormativeTypes
from importHeatTypes import importHeatTypes
+from importNfvTypes import importNfvTypes
from importOnapTypes import importOnapTypes
+from importSolTypes import importSolTypes
from importNormativeCapabilities import importNormativeCapabilities
from importCategoryTypes import importCategories
from importNormativeInterfaceLifecycleTypes import importNormativeInterfaceLifecycleType
@@ -125,11 +127,19 @@ def main(argv):
fileLocation = baseFileLocation + "heat-types/"
resultsHeat = importHeatTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion)
handleResults(resultsHeat, updateversion)
-
+
+ fileLocation = baseFileLocation + "nfv-types/"
+ resultsHeat = importNfvTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion)
+ handleResults(resultsHeat, updateversion)
+
fileLocation = baseFileLocation + "onap-types/"
resultsHeat = importOnapTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion)
handleResults(resultsHeat, updateversion)
-
+
+ fileLocation = baseFileLocation + "sol-types/"
+ resultsHeat = importSolTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion)
+ handleResults(resultsHeat, updateversion)
+
fileLocation = baseFileLocation + "group-types/"
importGroupTypes(scheme, beHost, bePort, adminUser, False, fileLocation)
@@ -139,5 +149,5 @@ def main(argv):
errorAndExit(0, None)
if __name__ == "__main__":
- main(sys.argv[1:])
+ main(sys.argv[1:])
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py
index faad226d39..f703b4b4ac 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py
+++ b/catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py
@@ -20,19 +20,9 @@ import importCommon
#####################################################################################################################################################################################################
def importOnapTypes(scheme, beHost, bePort, adminUser, fileDir, updateversion):
-
- onapTypes = [ "extImageFile",
- "extLocalStorage",
- "extZteCP",
- "extZteVDU",
- "extZteVL",
- "NSD",
- "VDU",
- "vduCompute",
- "vduCpd",
- "vduVirtualStorage",
- "vnfVirtualLinkDesc"
- ]
+
+ #Add desired type names to the list
+ onapTypes = []
responseCodes = [200, 201]
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importSolTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importSolTypes.py
new file mode 100644
index 0000000000..0015a26655
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/import/tosca/importSolTypes.py
@@ -0,0 +1,99 @@
+import pycurl
+import sys, getopt
+from StringIO import StringIO
+import json
+import copy
+from importCommon import *
+from importNormativeTypes import *
+import importCommon
+
+#####################################################################################################################################################################################################
+# #
+# Import Sol Types from a given file #
+# #
+# activation : #
+# python importSolTypes.py [optional -s <scheme> | --scheme=<scheme>, default http] [-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-f <input file> | --ifile=<input file> ] #
+# #
+# shortest activation (be host = localhost, be port = 8080): #
+# python importUsers.py [-f <input file> | --ifile=<input file> ] #
+# #
+#####################################################################################################################################################################################################
+
+def importSolTypes(scheme, beHost, bePort, adminUser, fileDir, updateversion):
+
+ #Add desired type names to the list
+ solTypes = []
+
+ responseCodes = [200, 201]
+
+ if(updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+
+ results = []
+ for onapType in solTypes:
+ result = createNormativeType(scheme, beHost, bePort, adminUser, fileDir, onapType, updateversion)
+ results.append(result)
+ if ( result[1] == None or result[1] not in responseCodes) :
+ print "Failed creating heat type " + onapType + ". " + str(result[1])
+ return results
+
+
+def main(argv):
+ print 'Number of arguments:', len(sys.argv), 'arguments.'
+
+ beHost = 'localhost'
+ bePort = '8080'
+ adminUser = 'jh0003'
+ updateversion = 'true'
+ scheme = 'http'
+
+ try:
+ opts, args = getopt.getopt(argv,"i:p:u:v:h:",["ip=","port=","user=","updateversion="])
+ except getopt.GetoptError:
+ usage()
+ errorAndExit(2, 'Invalid input')
+
+ for opt, arg in opts:
+ #print opt, arg
+ if opt == '-h':
+ usage()
+ sys.exit(3)
+ elif opt in ("-i", "--ip"):
+ beHost = arg
+ elif opt in ("-p", "--port"):
+ bePort = arg
+ elif opt in ("-u", "--user"):
+ adminUser = arg
+ elif opt in ("-s", "--scheme"):
+ scheme = arg
+ elif opt in ("-v", "--updateversion"):
+ if (arg.lower() == "false" or arg.lower() == "no"):
+ updateversion = 'false'
+
+ print 'scheme =',scheme,',be host =',beHost,', be port =', bePort,', user =', adminUser
+
+ if ( beHost == None ):
+ usage()
+ sys.exit(3)
+
+ results = importSolTypes(scheme, beHost, bePort, adminUser, "../../../import/tosca/sol-types/", updateversion)
+
+ print "-----------------------------"
+ for result in results:
+ print "{0:20} | {1:6}".format(result[0], result[1])
+ print "-----------------------------"
+
+ responseCodes = [200, 201]
+
+ if(updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+
+ failedNormatives = filter(lambda x: x[1] == None or x[1] not in responseCodes, results)
+ if (len(failedNormatives) > 0):
+ errorAndExit(1, None)
+ else:
+ errorAndExit(0, None)
+
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/onapTypesToUpgrade.json b/catalog-be/src/main/resources/scripts/import/tosca/onapTypesToUpgrade.json
index 6045ddd6ff..9101291fc9 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/onapTypesToUpgrade.json
+++ b/catalog-be/src/main/resources/scripts/import/tosca/onapTypesToUpgrade.json
@@ -1,4 +1,8 @@
{
+ "nfv": [
+ ],
"onap": [
+ ],
+ "sol":[
]
} \ No newline at end of file
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/upgradeNfvTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/upgradeNfvTypes.py
new file mode 100644
index 0000000000..66d82f9e91
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeNfvTypes.py
@@ -0,0 +1,104 @@
+import pycurl
+import sys, getopt
+from StringIO import StringIO
+import json
+import copy
+from importCommon import *
+from importNormativeTypes import *
+import importCommon
+import json
+
+
+################################################################################################################################################################################################
+# #
+# Upgrades all Heat and Normative types confiugred in "typesToUpgrade.json" file #
+# #
+# activation #
+# python upgradeHeatAndNormativeTypes.py [-s <scheme> | --scheme=<scheme> ] [-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-f <input file> | --ifile=<input file> ] #
+# #
+# shortest activation (be host = localhost, be port = 8080): #
+# python upgradeHeatAndNormativeTypes.py [-f <input file> | --ifile=<input file> ] #
+# #
+################################################################################################################################################################################################
+def upgradeNfvTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseDir, updateversion):
+ responseCodes = [200, 201]
+ if (updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+ with open("onapTypesToUpgrade.json", 'r') as stream:
+ try:
+ types = json.load(stream)
+ nfvTypes = types["nfv"]
+ debug(nfvTypes)
+ nfvFileDir = baseDir + "nfv-types/"
+ debug(nfvFileDir)
+ results = []
+ for nfvType in nfvTypes:
+ result = createNormativeType(scheme, beHost, bePort, adminUser, nfvFileDir, nfvType.encode('ascii', 'ignore'), updateversion)
+ results.append(result)
+ if (result[1] == None or result[1] not in responseCodes):
+ print "Failed creating nfv type " + nfvType + ". " + str(result[1])
+ except yaml.YAMLError as exc:
+ print(exc)
+
+
+
+def main(argv):
+ print 'Number of arguments:', len(sys.argv), 'arguments.'
+
+ beHost = 'localhost'
+ bePort = '8080'
+ adminUser = 'jh0003'
+ updateversion = 'true'
+ scheme = 'http'
+
+ try:
+ opts, args = getopt.getopt(argv, "i:p:u:v:h:s:", ["ip=", "port=", "user=", "updateversion=","scheme="])
+ except getopt.GetoptError:
+ usage()
+ errorAndExit(2, 'Invalid input')
+
+ for opt, arg in opts:
+ # print opt, arg
+ if opt == '-h':
+ usage()
+ sys.exit(3)
+ elif opt in ("-i", "--ip"):
+ beHost = arg
+ elif opt in ("-p", "--port"):
+ bePort = arg
+ elif opt in ("-u", "--user"):
+ adminUser = arg
+ elif opt in ("-s", "--scheme"):
+ scheme = arg
+ elif opt in ("-v", "--updateversion"):
+ if (arg.lower() == "false" or arg.lower() == "no"):
+ updateversion = 'false'
+
+ print 'scheme =',scheme,', be host =',beHost, ', be port =', bePort, ', user =', adminUser
+
+ if (beHost == None):
+ usage()
+ sys.exit(3)
+
+ results = upgradeNfvTypesPerConfigFile(scheme, beHost, bePort, adminUser, "../../../import/tosca/", updateversion)
+
+ print "-----------------------------"
+ for result in results:
+ print "{0:20} | {1:6}".format(result[0], result[1])
+ print "-----------------------------"
+
+ responseCodes = [200, 201]
+
+ if (updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+
+ failedNormatives = filter(lambda x: x[1] == None or x[1] not in responseCodes, results)
+ if (len(failedNormatives) > 0):
+ errorAndExit(1, None)
+ else:
+ errorAndExit(0, None)
+
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
+
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py b/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py
index 21a477503c..5c57762c61 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py
+++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py
@@ -11,7 +11,9 @@ from importPolicyTypes import importPolicyTypes
from importGroupTypes import importGroupTypes
from importNormativeCapabilities import importNormativeCapabilities
from importNormativeInterfaceLifecycleTypes import importNormativeInterfaceLifecycleType
+from upgradeNfvTypes import upgradeNfvTypesPerConfigFile
from upgradeONAPTypes import upgradeOnapTypesPerConfigFile
+from upgradeSolTypes import upgradeSolTypesPerConfigFile
from importCommon import *
@@ -119,10 +121,16 @@ def main(argv):
resultsHeat = upgradeTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseFileLocation, updateversion)
handleResults(resultsHeat)
-
+
+ resultsHeat = upgradeNfvTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseFileLocation, updateOnapVersion)
+ handleResults(resultsHeat)
+
resultsHeat = upgradeOnapTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseFileLocation, updateOnapVersion)
handleResults(resultsHeat)
-
+
+ resultsHeat = upgradeSolTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseFileLocation, updateOnapVersion)
+ handleResults(resultsHeat)
+
errorAndExit(0, None)
if __name__ == "__main__":
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/upgradeSolTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/upgradeSolTypes.py
new file mode 100644
index 0000000000..25d9b4d1fc
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeSolTypes.py
@@ -0,0 +1,104 @@
+import pycurl
+import sys, getopt
+from StringIO import StringIO
+import json
+import copy
+from importCommon import *
+from importNormativeTypes import *
+import importCommon
+import json
+
+
+################################################################################################################################################################################################
+# #
+# Upgrades all Heat and Normative types confiugred in "typesToUpgrade.json" file #
+# #
+# activation #
+# python upgradeHeatAndNormativeTypes.py [-s <scheme> | --scheme=<scheme> ] [-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-f <input file> | --ifile=<input file> ] #
+# #
+# shortest activation (be host = localhost, be port = 8080): #
+# python upgradeHeatAndNormativeTypes.py [-f <input file> | --ifile=<input file> ] #
+# #
+################################################################################################################################################################################################
+def upgradeSolTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseDir, updateversion):
+ responseCodes = [200, 201]
+ if (updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+ with open("onapTypesToUpgrade.json", 'r') as stream:
+ try:
+ types = json.load(stream)
+ solTypes = types["sol"]
+ debug(solTypes)
+ solFileDir = baseDir + "sol-types/"
+ debug(solFileDir)
+ results = []
+ for solType in solTypes:
+ result = createNormativeType(scheme, beHost, bePort, adminUser, solFileDir, solType.encode('ascii', 'ignore'), updateversion)
+ results.append(result)
+ if (result[1] == None or result[1] not in responseCodes):
+ print "Failed creating sol type " + solType + ". " + str(result[1])
+ except yaml.YAMLError as exc:
+ print(exc)
+
+
+
+def main(argv):
+ print 'Number of arguments:', len(sys.argv), 'arguments.'
+
+ beHost = 'localhost'
+ bePort = '8080'
+ adminUser = 'jh0003'
+ updateversion = 'true'
+ scheme = 'http'
+
+ try:
+ opts, args = getopt.getopt(argv, "i:p:u:v:h:s:", ["ip=", "port=", "user=", "updateversion=","scheme="])
+ except getopt.GetoptError:
+ usage()
+ errorAndExit(2, 'Invalid input')
+
+ for opt, arg in opts:
+ # print opt, arg
+ if opt == '-h':
+ usage()
+ sys.exit(3)
+ elif opt in ("-i", "--ip"):
+ beHost = arg
+ elif opt in ("-p", "--port"):
+ bePort = arg
+ elif opt in ("-u", "--user"):
+ adminUser = arg
+ elif opt in ("-s", "--scheme"):
+ scheme = arg
+ elif opt in ("-v", "--updateversion"):
+ if (arg.lower() == "false" or arg.lower() == "no"):
+ updateversion = 'false'
+
+ print 'scheme =',scheme,', be host =',beHost, ', be port =', bePort, ', user =', adminUser
+
+ if (beHost == None):
+ usage()
+ sys.exit(3)
+
+ results = upgradeSolTypesPerConfigFile(scheme, beHost, bePort, adminUser, "../../../import/tosca/", updateversion)
+
+ print "-----------------------------"
+ for result in results:
+ print "{0:20} | {1:6}".format(result[0], result[1])
+ print "-----------------------------"
+
+ responseCodes = [200, 201]
+
+ if (updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+
+ failedNormatives = filter(lambda x: x[1] == None or x[1] not in responseCodes, results)
+ if (len(failedNormatives) > 0):
+ errorAndExit(1, None)
+ else:
+ errorAndExit(0, None)
+
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
+