aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-09-27 19:31:12 +0300
committerMichael Lando <ml636r@att.com>2017-09-27 19:31:12 +0300
commitb35130e8fa3e8eca9352d4cfac2889a32743541c (patch)
tree261aed098f3201d624400e853d1cde16e5531bbb /catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py
parentd2acdcaa8e7d43b92f2955a84bc679c31a46d9c8 (diff)
add new global types
add global types needed for volte use case Change-Id: I5613bbc942cb71f59168eee2a8386163a58446fe Issue-ID: SDC-192 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py')
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py101
1 files changed, 101 insertions, 0 deletions
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py
new file mode 100644
index 0000000000..44b63a795b
--- /dev/null
+++ b/catalog-be/src/main/resources/scripts/import/tosca/importOnapTypes.py
@@ -0,0 +1,101 @@
+import pycurl
+import sys, getopt
+from StringIO import StringIO
+import json
+import copy
+from importCommon import *
+from importNormativeTypes import *
+import importCommon
+
+################################################################################################################################################
+# #
+# Import all users from a given file #
+# #
+# activation : #
+# python importUsers.py [-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 importOnapTypes(beHost, bePort, adminUser, fileDir, updateversion):
+
+ onapTypes = [ "vduCompute",
+ "vduCpd",
+ "vduVirtualStorage",
+ "vnfVirtualLinkDesc"
+ ]
+
+ responseCodes = [200, 201]
+
+ if(updateversion == 'false'):
+ responseCodes = [200, 201, 409]
+
+ results = []
+ for onapType in onapTypes:
+ result = createNormativeType(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'
+
+ 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 ("-v", "--updateversion"):
+ if (arg.lower() == "false" or arg.lower() == "no"):
+ updateversion = 'false'
+
+ print 'be host =',beHost,', be port =', bePort,', user =', adminUser
+
+ if ( beHost == None ):
+ usage()
+ sys.exit(3)
+
+ results = importOnapTypes(beHost, bePort, adminUser, "../../../import/tosca/onap-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:])
+
+