3 from StringIO import StringIO
6 from importCommon import *
7 from importNormativeTypes import createNormativeType
10 #################################################################################################################################################################################################################################
12 # Upgrades the normative types #
15 # 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>] #
18 # shortest activation (be host = localhost, be port = 8080, user = jh0003): #
19 # python upgradeNormative.py #
21 #################################################################################################################################################################################################################################
24 print sys.argv[0], '[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>]'
26 def handleResults(results, updateversion):
28 for result in results:
29 printNameAndReturnCode(result[0], result[1])
32 failedResults = filter(lambda x: x[1] == None or x[1] not in [200, 201, 409], results)
33 if (len(failedResults) > 0):
37 print 'Number of arguments:', len(sys.argv), 'arguments.'
43 updateversion = 'true'
44 importCommon.debugFlag = False
48 opts, args = getopt.getopt(argv,"i:p:u:d:h:s:",["ip=","port=","user=","debug=","scheme="])
49 except getopt.GetoptError:
51 errorAndExit(2, 'Invalid input')
58 elif opt in ("-i", "--ip"):
60 elif opt in ("-p", "--port"):
62 elif opt in ("-u", "--user"):
64 elif opt in ("-s", "--scheme"):
66 elif opt in ("-d", "--debug"):
68 debugf = bool(arg.lower() == "true" or arg.lower() == "yes")
70 print 'scheme =',scheme,', be host =',beHost,', be port =', bePort,', user =', adminUser, ', debug =', debugf
73 print 'set debug mode to ' + str(debugf)
74 importCommon.debugFlag = debugf
76 if ( beHost == None ):
81 pathdir = os.path.dirname(os.path.realpath(sys.argv[0]))
82 debug("path dir =" + pathdir)
84 baseFileLocation = pathdir + "/../../../import/tosca/"
88 ##########################################################################
89 #---------------------------------for release 1702---------------------- #
90 ##########################################################################
93 fileLocation = baseFileLocation + "heat-types/"
94 result = createNormativeType(scheme, beHost, bePort, adminUser, fileLocation, "contrailPort", updateversion)
95 results.append(result)
97 fileLocation = baseFileLocation + "heat-types/"
98 result = createNormativeType(scheme, beHost, bePort, adminUser, fileLocation, "contrailV2VirtualMachineInterface", updateversion)
99 results.append(result)
101 fileLocation = baseFileLocation + "heat-types/"
102 result = createNormativeType(scheme, beHost, bePort, adminUser, fileLocation, "neutronPort", updateversion)
103 results.append(result)
105 fileLocation = baseFileLocation + "heat-types/"
106 result = createNormativeType(scheme, beHost, bePort, adminUser, fileLocation, "contrailCompute", updateversion)
107 results.append(result)
109 fileLocation = baseFileLocation + "heat-types/"
110 result = createNormativeType(scheme, beHost, bePort, adminUser, fileLocation, "novaServer", updateversion)
111 results.append(result)
113 fileLocation = baseFileLocation + "heat-types/"
114 result = createNormativeType(scheme, beHost, bePort, adminUser, fileLocation, "contrailV2VirtualNetwork", updateversion)
115 results.append(result)
117 fileLocation = baseFileLocation + "heat-types/"
118 result = createNormativeType(scheme, beHost, bePort, adminUser, fileLocation, "contrailVirtualNetwork", updateversion)
119 results.append(result)
121 fileLocation = baseFileLocation + "heat-types/"
122 result = createNormativeType(scheme, beHost, bePort, adminUser, fileLocation, "neutronNet", updateversion)
123 results.append(result)
126 handleResults(results, 'false')
128 errorAndExit(0, None)
130 if __name__ == "__main__":