From 451a3400b76511393c62a444f588a4ed15f4a549 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 19 Feb 2017 10:28:42 +0200 Subject: Initial OpenECOMP SDC commit Change-Id: I0924d5a6ae9cdc161ae17c68d3689a30d10f407b Signed-off-by: Michael Lando --- .../scripts/import/tosca/importHeatTypes.py | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py (limited to 'catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py') diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py new file mode 100644 index 0000000000..07eacf8d61 --- /dev/null +++ b/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.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 all users from a given file # +# # +# activation : # +# python importUsers.py [-i | --ip=] [-p | --port= ] [-f | --ifile= ] # +# # +# shortest activation (be host = localhost, be port = 8080): # +# python importUsers.py [-f | --ifile= ] # +# # +################################################################################################################################################ + +def importHeatTypes(beHost, bePort, adminUser, fileDir, updateversion): + + heatTypes = [ "cinderVolume", +# "contrailVirtualNetwork", + "neutronNet", + "neutronPort", + "novaServer", + "vl", + "eline", + "abstractSubstitute", +# "contrailNetworkRules", +# "contrailPort", +# "contrailV2NetworkRules", +# "contrailV2VirtualNetwork", + "securityRules" +# "contrailAbstractSubstitute", +# "contrailCompute", +# "contrailV2VirtualMachineInterface" + ] + + responseCodes = [200, 201] + + if(updateversion == 'false'): + responseCodes = [200, 201, 409] + + results = [] + for heatType in heatTypes: + result = createNormativeType(beHost, bePort, adminUser, fileDir, heatType, updateversion) + results.append(result) + if ( result[1] == None or result[1] not in responseCodes) : + print "Failed creating heat type " + heatType + ". " + 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 = importHeatTypes(beHost, bePort, adminUser, "../../../import/tosca/heat-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:]) + + -- cgit 1.2.3-korg