5 from importAnnotationTypes import import_annotation_types
6 from importCategoryTypes import importCategories
7 from importCommon import *
8 from importDataTypes import importDataTypes
9 from importGroupTypes import importGroupTypes
10 from importNormativeCapabilities import importNormativeCapabilities
11 from importNormativeInterfaceLifecycleTypes import importNormativeInterfaceLifecycleType
12 from importNormativeRelationships import importNormativeRelationships
13 from importPolicyTypes import importPolicyTypes
14 from upgradeHeatAndNormativeTypes import upgradeTypesPerConfigFile
17 #################################################################################################################################################################################################################################
19 # Upgrades the normative types #
22 # python upgradeNormative.py [-s <scheme> | --scheme=<scheme> ] [-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-u <user userId> | --user=<user userId> ] [-d <true|false> | --debug=<true|false>] #
25 # shortest activation (be host = localhost, be port = 8080, user = jh0003): #
26 # python upgradeNormative.py #
28 #################################################################################################################################################################################################################################
33 '[optional -s <scheme> | --scheme=<scheme>, default http] [-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-u <user userId> | --user=<user userId> ] [-d <true|false> | --debug=<true|false>]'
36 def handleResults(results):
38 for result in results:
39 print_name_and_return_code(result[0], result[1])
42 failed_results = filter(lambda x: x[1] is None or x[1] not in [200, 201, 409], results)
43 if len(list(failed_results)) > 0:
44 error_and_exit(1, None)
48 print 'Number of arguments:', len(sys.argv), 'arguments.'
54 update_version = 'true'
55 importCommon.debugFlag = False
59 opts, args = getopt.getopt(argv, "i:p:u:d:h:s:", ["ip=", "port=", "user=", "debug=", "scheme="])
60 except getopt.GetoptError:
62 error_and_exit(2, 'Invalid input')
69 elif opt in ("-i", "--ip"):
71 elif opt in ("-p", "--port"):
73 elif opt in ("-u", "--user"):
75 elif opt in ("-s", "--scheme"):
77 elif opt in ("-d", "--debug"):
79 debug_f = bool(arg.lower() == "true" or arg.lower() == "yes")
81 print 'scheme =', scheme, ', be host =', be_host, ', be port =', be_port, ', user =', admin_user, ', debug =', debug_f
83 if debug_f is not None:
84 print 'set debug mode to ' + str(debug_f)
85 importCommon.debugFlag = debug_f
92 path_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
93 debug("path dir =" + path_dir)
95 base_file_location = path_dir + "/../../../import/tosca/"
97 file_location = base_file_location + "categories/"
98 importCategories(scheme, be_host, be_port, admin_user, False, file_location)
100 file_location = base_file_location + "relationship-types/"
101 importNormativeRelationships(scheme, be_host, be_port, admin_user, False, file_location)
103 file_location = base_file_location + "data-types/"
104 importDataTypes(scheme, be_host, be_port, admin_user, False, file_location)
106 file_location = base_file_location + "policy-types/"
107 importPolicyTypes(scheme, be_host, be_port, admin_user, False, file_location)
109 file_location = base_file_location + "capability-types/"
110 importNormativeCapabilities(scheme, be_host, be_port, admin_user, False, file_location)
112 file_location = base_file_location + "group-types/"
113 importGroupTypes(scheme, be_host, be_port, admin_user, False, file_location)
115 file_location = base_file_location + "interface-lifecycle-types/"
116 importNormativeInterfaceLifecycleType(scheme, be_host, be_port, admin_user, False, file_location)
118 import_annotation_types(scheme, be_host, be_port, admin_user, False)
120 print 'sleep until data type cache is updated'
123 results_heat = upgradeTypesPerConfigFile(scheme, be_host, be_port, admin_user, base_file_location, update_version)
124 handleResults(results_heat)
126 error_and_exit(0, None)
129 if __name__ == "__main__":