def main(argv): print 'Number of arguments:', len(sys.argv), 'arguments.' beHost = 'localhost' bePort = '8080' adminUser = '******' debugf = None updateversion = 'true' importCommon.debugFlag = False scheme = 'http' try: opts, args = getopt.getopt( argv, "i:p:u:d:v:h", ["ip=", "port=", "user="******"debug=", "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 ("-d", "--debug"): print arg debugf = bool(arg.lower() == "true" or arg.lower() == "yes") elif opt in ("-v", "--updateversion"): print arg if (arg.lower() == "false" or arg.lower() == "no"): updateversion = 'false' print 'scheme =', scheme, ',be host =', beHost, ', be port =', bePort, ', user ='******', debug =', debugf, ', updateversion =', updateversion if (debugf != None): print 'set debug mode to ' + str(debugf) importCommon.debugFlag = debugf 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) baseFileLocation = pathdir + "/../../../import/tosca/" fileLocation = baseFileLocation + "data-types/" importDataTypes(scheme, beHost, bePort, adminUser, False, fileLocation) print 'sleep until data type cache is updated' time.sleep(70) fileLocation = baseFileLocation + "capability-types/" importNormativeCapabilities(scheme, beHost, bePort, adminUser, False, fileLocation) fileLocation = baseFileLocation + "interface-lifecycle-types/" importNormativeInterfaceLifecycleType(scheme, beHost, bePort, adminUser, False, fileLocation) fileLocation = baseFileLocation + "categories/" importCategories(scheme, beHost, bePort, adminUser, False, fileLocation) fileLocation = baseFileLocation + "normative-types/" results = importNormativeTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion) handleResults(results, updateversion) fileLocation = baseFileLocation + "heat-types/" resultsHeat = importHeatTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion) handleResults(resultsHeat, updateversion) fileLocation = baseFileLocation + "nfv-types/" resultsHeat = importNfvTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion) handleResults(resultsHeat, updateversion) fileLocation = baseFileLocation + "onap-types/" resultsHeat = importOnapTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion) handleResults(resultsHeat, updateversion) fileLocation = baseFileLocation + "sol-types/" resultsHeat = importSolTypes(scheme, beHost, bePort, adminUser, fileLocation, updateversion) handleResults(resultsHeat, updateversion) fileLocation = baseFileLocation + "group-types/" importGroupTypes(scheme, beHost, bePort, adminUser, False, fileLocation) fileLocation = baseFileLocation + "policy-types/" importPolicyTypes(scheme, beHost, bePort, adminUser, False, fileLocation) errorAndExit(0, None)
def main(argv): print 'Number of arguments:', len(sys.argv), 'arguments.' be_host = 'localhost' be_port = '8080' admin_user = '******' debug_f = None update_version = 'true' importCommon.debugFlag = False scheme = 'http' try: opts, args = getopt.getopt( argv, "i:p:u:d:h:s:", ["ip=", "port=", "user="******"debug=", "scheme="]) 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 debug_f = bool(arg.lower() == "true" or arg.lower() == "yes") print 'scheme =', scheme, ', be host =', be_host, ', be port =', be_port, ', user ='******', debug =', debug_f if debug_f is not None: print 'set debug mode to ' + str(debug_f) importCommon.debugFlag = debug_f if be_host is None: usage() sys.exit(3) print sys.argv[0] path_dir = os.path.dirname(os.path.realpath(sys.argv[0])) debug("path dir =" + path_dir) base_file_location = path_dir + "/../../../import/tosca/" file_location = base_file_location + "categories/" importCategories(scheme, be_host, be_port, admin_user, False, file_location) file_location = base_file_location + "relationship-types/" importNormativeRelationships(scheme, be_host, be_port, admin_user, False, file_location) file_location = base_file_location + "data-types/" importDataTypes(scheme, be_host, be_port, admin_user, False, file_location) file_location = base_file_location + "policy-types/" importPolicyTypes(scheme, be_host, be_port, admin_user, False, file_location) file_location = base_file_location + "capability-types/" importNormativeCapabilities(scheme, be_host, be_port, admin_user, False, file_location) file_location = base_file_location + "group-types/" importGroupTypes(scheme, be_host, be_port, admin_user, False, file_location) file_location = base_file_location + "interface-lifecycle-types/" importNormativeInterfaceLifecycleType(scheme, be_host, be_port, admin_user, False, file_location) import_annotation_types(scheme, be_host, be_port, admin_user, False) 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) handleResults(results_heat) error_and_exit(0, None)