4 from importCommon import *
5 from importNormativeTypes import createNormativeType
8 #################################################################################################################################################################################################################################
10 # Upgrades the normative types #
13 # 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>] #
16 # shortest activation (be host = localhost, be port = 8080, user = jh0003): #
17 # python upgradeNormative.py #
19 #################################################################################################################################################################################################################################
24 '[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>]'
27 def handleResults(results):
29 for result in results:
30 print_name_and_return_code(result[0], result[1])
33 failed_results = filter(lambda x: x[1] is None or x[1] not in [200, 201, 409], results)
34 if len(list(failed_results)) > 0:
35 error_and_exit(1, None)
39 print 'Number of arguments:', len(sys.argv), 'arguments.'
45 update_version = 'true'
46 importCommon.debugFlag = False
50 opts, args = getopt.getopt(argv, "i:p:u:d:h:s:", ["ip=", "port=", "user=", "debug=", "scheme="])
51 except getopt.GetoptError:
53 error_and_exit(2, 'Invalid input')
60 elif opt in ("-i", "--ip"):
62 elif opt in ("-p", "--port"):
64 elif opt in ("-u", "--user"):
66 elif opt in ("-s", "--scheme"):
68 elif opt in ("-d", "--debug"):
70 debug_f = bool(arg.lower() == "true" or arg.lower() == "yes")
72 print 'scheme =', scheme, ', be host =', be_host, ', be port =', be_port, ', user =', admin_user, ', debug =', debug_f
74 if debug_f is not None:
75 print 'set debug mode to ' + str(debug_f)
76 importCommon.debugFlag = debug_f
83 path_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
84 debug("path dir =" + path_dir)
86 base_file_location = path_dir + "/../../../import/tosca/"
89 ##########################################################################
90 # ---------------------------------for release 1702---------------------- #
91 ##########################################################################
93 file_location = base_file_location + "heat-types/"
94 result = createNormativeType(scheme, be_host, be_port, admin_user, file_location, "contrailPort", update_version)
95 results.append(result)
97 file_location = base_file_location + "heat-types/"
98 result = createNormativeType(scheme, be_host, be_port, admin_user, file_location,
99 "contrailV2VirtualMachineInterface", update_version)
100 results.append(result)
102 file_location = base_file_location + "heat-types/"
103 result = createNormativeType(scheme, be_host, be_port, admin_user, file_location, "neutronPort", update_version)
104 results.append(result)
106 file_location = base_file_location + "heat-types/"
107 result = createNormativeType(scheme, be_host, be_port, admin_user, file_location, "contrailCompute", update_version)
108 results.append(result)
110 file_location = base_file_location + "heat-types/"
111 result = createNormativeType(scheme, be_host, be_port, admin_user, file_location, "novaServer", update_version)
112 results.append(result)
114 file_location = base_file_location + "heat-types/"
115 result = createNormativeType(scheme, be_host, be_port, admin_user, file_location, "contrailV2VirtualNetwork",
117 results.append(result)
119 file_location = base_file_location + "heat-types/"
120 result = createNormativeType(scheme, be_host, be_port, admin_user, file_location, "contrailVirtualNetwork",
122 results.append(result)
124 file_location = base_file_location + "heat-types/"
125 result = createNormativeType(scheme, be_host, be_port, admin_user, file_location, "neutronNet", update_version)
126 results.append(result)
128 handleResults(results)
130 error_and_exit(0, None)
133 if __name__ == "__main__":