diff options
Diffstat (limited to 'catalog-be/src/main/resources/scripts')
4 files changed, 112 insertions, 1 deletions
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py index e7eaa8610b..0530502376 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py @@ -51,7 +51,8 @@ def importHeatTypes(beHost, bePort, adminUser, fileDir, updateversion): "subInterface", "contrailV2VLANSubInterface", "multiFlavorVFC", - "vnfConfiguration" + "vnfConfiguration", + "underlayVpn" ] responseCodes = [200, 201] diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeAll.py b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeAll.py index ec9e93e6e4..3d7d9a9bbf 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeAll.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeAll.py @@ -8,6 +8,7 @@ import time from importNormativeElements import * from importNormativeTypes import importNormativeTypes from importHeatTypes import importHeatTypes +from importOnapTypes import importOnapTypes from importNormativeCapabilities import importNormativeCapabilities from importCategoryTypes import importCategories from importNormativeInterfaceLifecycleTypes import importNormativeInterfaceLifecycleType @@ -121,6 +122,10 @@ def main(argv): fileLocation = baseFileLocation + "heat-types/" resultsHeat = importHeatTypes(beHost, bePort, adminUser, fileLocation, updateversion) handleResults(resultsHeat, updateversion) + + fileLocation = baseFileLocation + "onap-types/" + resultsHeat = importOnapTypes(beHost, bePort, adminUser, fileLocation, updateversion) + handleResults(resultsHeat, updateversion) fileLocation = baseFileLocation + "group-types/" importGroupTypes(beHost, bePort, adminUser, False, fileLocation) 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:]) + + diff --git a/catalog-be/src/main/resources/scripts/import/tosca/upgradeNormativeVersionAll.py b/catalog-be/src/main/resources/scripts/import/tosca/upgradeNormativeVersionAll.py index 72198ceab6..d45b27e755 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/upgradeNormativeVersionAll.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeNormativeVersionAll.py @@ -85,6 +85,10 @@ def main(argv): fileLocation = baseFileLocation + "heat-types/" resultsHeat = importHeatTypes(beHost, bePort, adminUser, fileLocation, updateversion) handleResults(resultsHeat, updateversion) + + fileLocation = baseFileLocation + "onap-types/" + resultsOnap = importOnapTypes(beHost, bePort, adminUser, fileLocation, updateversion) + handleResults(resultsOnap, updateversion) errorAndExit(0, None) |