diff options
Diffstat (limited to 'catalog-be/src/main')
4 files changed, 98 insertions, 118 deletions
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importCommon.py b/catalog-be/src/main/resources/scripts/import/tosca/importCommon.py index ed92ca8b3d..74bdf806f0 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importCommon.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importCommon.py @@ -27,6 +27,10 @@ def debug(desc, *args): print desc, join_strings(args) +def is_debug(): + return debugFlag + + def log(desc, arg=None): print desc, arg 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 6eea374716..0fcaf58ee6 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py @@ -27,6 +27,8 @@ def createNormativeType(scheme, beHost, bePort, adminUser, fileDir, ELEMENT_NAME buffer = StringIO() c = pycurl.Curl() + if is_debug(): + c.setopt(pycurl.VERBOSE, 1) url = scheme + '://' + beHost + ':' + bePort + '/sdc2/rest/v1/catalog/upload/multipart' if updateversion != None: @@ -70,6 +72,7 @@ def createNormativeType(scheme, beHost, bePort, adminUser, fileDir, ELEMENT_NAME #c.setopt(c.WRITEFUNCTION, lambda x: None) c.setopt(c.WRITEFUNCTION, buffer.write) + #print("before perform") res = c.perform() diff --git a/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json b/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json index ffda46e042..4d59e0248d 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json +++ b/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json @@ -1,35 +1,4 @@ { - "heat": [ - "AbstractSubstitute", - "cinderVolume", - "contrailAbstractSubstitute", - "contrailCompute", - "contrailNetworkRules", - "contrailPort", - "contrailV2NetworkRules", - "contrailV2VirtualMachineInterface", - "contrailVirtualNetwork", - "contrailV2VLANSubInterface", - "contrailV2VLANSubInterfaceV2", - "contrailVirtualNetwork", - "extContrailCP", - "extCp", - "extNeutronCP", - "extVirtualMachineInterfaceCP", - "extVl", - "forwardingPath", - "Generic_PNF", - "Generic_Service", - "Generic_VF", - "Generic_VFC", - "globalCompute", - "globalPort", - "neutronNet", - "neutronPort", - "novaServer", - "securityRules" - ], - "normative": [ - "loadBalancer" - ] + "heat": [], + "normative": [] } 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 222d22d1f1..59fece9376 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py @@ -1,8 +1,4 @@ -import pycurl -import sys, getopt, os -from StringIO import StringIO -import json -import copy +import os import time from importCategoryTypes import importCategories from upgradeHeatAndNormativeTypes import upgradeTypesPerConfigFile @@ -16,10 +12,10 @@ from upgradeNfvTypes import upgradeNfvTypesPerConfigFile from upgradeONAPTypes import upgradeOnapTypesPerConfigFile from upgradeSolTypes import upgradeSolTypesPerConfigFile - from importCommon import * import importCommon + ################################################################################################################################################################################################# # # # Upgrades the normative types # @@ -34,109 +30,117 @@ import importCommon ################################################################################################################################################################################################# def usage(): - print sys.argv[0], '[-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-u <user userId> | --user=<user userId> ] [-d <true|false> | --debug=<true|false>]' + print sys.argv[ + 0], '[-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-u <user userId> | --user=<user ' \ + 'userId> ] [-d <true|false> | --debug=<true|false>] ' + -def handleResults(results): - if results is not None: - print_frame_line() - for result in results: - print_name_and_return_code(result[0], result[1]) - - print_frame_line() +def handle_results(results): + if results is not None: + print_frame_line() + for result in results: + print_name_and_return_code(result[0], result[1]) + + print_frame_line() + + failed_results = filter(lambda x: x[1] is None or x[1] not in [200, 201, 409], results) + if len(failed_results) > 0: + error_and_exit(1, None) - failedResults = filter(lambda x: x[1] == None or x[1] not in [200, 201, 409], results) - if (len(failedResults) > 0): - error_and_exit(1, None) def main(argv): - print 'Number of arguments:', len(sys.argv), 'arguments.' + print 'Number of arguments:', len(sys.argv), 'arguments.' + + be_host = 'localhost' + be_port = '8080' + admin_user = 'jh0003' + is_debug = None + update_version = 'true' + update_onap_version = 'false' + importCommon.debugFlag = False + scheme = 'http' - beHost = 'localhost' - bePort = '8080' - adminUser = 'jh0003' - debugf = None - updateversion = 'true' - updateOnapVersion = 'false' - importCommon.debugFlag = False - scheme = 'http' + try: + opts, args = getopt.getopt(argv, "i:p:u:d:v:h:s", + ["scheme=", "ip=", "port=", "user=", "debug=", "updateversion="]) + except getopt.GetoptError: + usage() + error_and_exit(2, 'Invalid input') - try: - opts, args = getopt.getopt(argv, "i:p:u:d:v:h:s", - ["scheme=", "ip=", "port=", "user=", "debug=", "updateversion="]) - except getopt.GetoptError: - usage() - error_and_exit(2, 'Invalid input') + for opt, arg in opts: + # print opt, arg + if opt == '-h': + usage() + sys.exit(3) + elif opt in ("-i", "--ip"): + be_host = arg + elif opt in ("-p", "--port"): + be_port = arg + elif opt in ("-u", "--user"): + admin_user = arg + elif opt in ("-s", "--scheme"): + scheme = arg + elif opt in ("-d", "--debug"): + print arg + is_debug = bool(arg.lower() == "true" or arg.lower() == "yes") - 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 ("-d", "--debug"): - print arg - debugf = bool(arg.lower() == "true" or arg.lower() == "yes") + print 'scheme =', scheme, ',be host =', be_host, ', be port =', be_port, ', user =', admin_user, ', debug =', is_debug - print 'scheme =',scheme,',be host =',beHost,', be port =', bePort,', user =', adminUser, ', debug =', debugf + if is_debug is not None: + print 'set debug mode to ' + str(is_debug) + importCommon.debugFlag = is_debug - if (debugf != None): - print 'set debug mode to ' + str(debugf) - importCommon.debugFlag = debugf + if be_host is None: + usage() + sys.exit(3) - if ( beHost == None ): - usage() - sys.exit(3) + print sys.argv[0] + pathdir = os.path.dirname(os.path.realpath(sys.argv[0])) + debug("path dir =" + pathdir) - print sys.argv[0] - pathdir = os.path.dirname(os.path.realpath(sys.argv[0])) - debug("path dir =" + pathdir) + base_file_location = pathdir + "/../../../import/tosca/" - baseFileLocation = pathdir + "/../../../import/tosca/" + file_location = base_file_location + "categories/" + importCategories(scheme, be_host, be_port, admin_user, False, file_location) - fileLocation = baseFileLocation + "categories/" - importCategories(scheme, beHost, bePort, adminUser, False, fileLocation) + file_location = base_file_location + "relationship-types/" + importNormativeRelationships(scheme, be_host, be_port, admin_user, False, file_location) - fileLocation = baseFileLocation + "relationship-types/" - importNormativeRelationships(scheme, beHost, bePort, adminUser, False, fileLocation) + file_location = base_file_location + "data-types/" + importDataTypes(scheme, be_host, be_port, admin_user, False, file_location) - fileLocation = baseFileLocation + "data-types/" - importDataTypes(scheme, beHost, bePort, adminUser, False, fileLocation) + file_location = base_file_location + "policy-types/" + importPolicyTypes(scheme, be_host, be_port, admin_user, False, file_location) - fileLocation = baseFileLocation + "policy-types/" - importPolicyTypes(scheme, beHost, bePort, adminUser, False, fileLocation) + file_location = base_file_location + "group-types/" + importGroupTypes(scheme, be_host, be_port, admin_user, False, file_location) - fileLocation = baseFileLocation + "group-types/" - importGroupTypes(scheme, beHost, bePort, adminUser, False, fileLocation) + file_location = base_file_location + "capability-types/" + importNormativeCapabilities(scheme, be_host, be_port, admin_user, False, file_location) - fileLocation = baseFileLocation + "capability-types/" - importNormativeCapabilities(scheme, beHost, bePort, adminUser, False, fileLocation) + file_location = base_file_location + "interface-lifecycle-types/" + importNormativeInterfaceLifecycleType(scheme, be_host, be_port, admin_user, False, file_location) - fileLocation = baseFileLocation + "interface-lifecycle-types/" - importNormativeInterfaceLifecycleType(scheme, beHost, bePort, adminUser, False, fileLocation) + print 'sleep until data type cache is updated' + time.sleep(70) - print 'sleep until data type cache is updated' - time.sleep( 70 ) + results_heat = upgradeTypesPerConfigFile(scheme, be_host, be_port, admin_user, base_file_location, update_version) + handle_results(results_heat) - resultsHeat = upgradeTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseFileLocation, updateversion) - handleResults(resultsHeat) + results_heat = upgradeNfvTypesPerConfigFile(scheme, be_host, be_port, admin_user, base_file_location, + update_onap_version) + handle_results(results_heat) - resultsHeat = upgradeNfvTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseFileLocation, updateOnapVersion) - handleResults(resultsHeat) + results_heat = upgradeOnapTypesPerConfigFile(scheme, be_host, be_port, admin_user, base_file_location, + update_onap_version) + handle_results(results_heat) - resultsHeat = upgradeOnapTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseFileLocation, updateOnapVersion) - handleResults(resultsHeat) + results_heat = upgradeSolTypesPerConfigFile(scheme, be_host, be_port, admin_user, base_file_location, + update_onap_version) + handle_results(results_heat) - resultsHeat = upgradeSolTypesPerConfigFile(scheme, beHost, bePort, adminUser, baseFileLocation, updateOnapVersion) - handleResults(resultsHeat) + error_and_exit(0, None) - error_and_exit(0, None) if __name__ == "__main__": - main(sys.argv[1:]) + main(sys.argv[1:]) |