diff options
author | 2018-03-20 01:04:54 +0200 | |
---|---|---|
committer | 2018-03-19 23:09:14 +0000 | |
commit | fefa3e408f77289594e47edc878d1bee61fca90b (patch) | |
tree | fe8a7349a53e59085f6135f9b1d8729738d9a6ac /catalog-be/src/main/resources/scripts/import/tosca/importSolTypes.py | |
parent | 41cf18e4eebdae0692b832278b5a48f90345eedc (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/import/tosca/importSolTypes.py')
-rw-r--r-- | catalog-be/src/main/resources/scripts/import/tosca/importSolTypes.py | 99 |
1 files changed, 99 insertions, 0 deletions
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:]) |