3 from StringIO import StringIO
6 from importNormativeElements import createNormativeElement
7 from importCommon import *
9 #############################################################################################################################################################################################################
11 # Import all users from a given file #
14 # python importNormativeInterfaceLifecycleTypes.py [-s <scheme> | --scheme=<scheme> ] [-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-f <input file> | --ifile=<input file> ] #
16 # shortest activation (be host = localhost, be port = 8080): #
17 # python importNormativeInterfaceLifecycleTypes.py [-f <input file> | --ifile=<input file> ] #
19 #############################################################################################################################################################################################################
22 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> ]'
25 def importNormativeInterfaceLifecycleType(scheme, beHost, bePort, adminUser, exitOnSuccess, fileDir):
26 result = createNormativeElement(scheme, beHost, bePort, adminUser, fileDir, "/sdc2/rest/v1/catalog/uploadType/interfaceLifecycle", "interfaceLifecycleTypes", "interfaceLifecycleTypeZip")
29 printNameAndReturnCode(result[0], result[1])
32 if ( result[1] == None or result[1] not in [200, 201, 409] ):
35 if (exitOnSuccess == True):
40 print 'Number of arguments:', len(sys.argv), 'arguments.'
48 opts, args = getopt.getopt(argv,"i:p:u:h:s:",["ip=","port=","user=","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"):
67 print 'scheme =',scheme,', be host =',beHost,', be port =', bePort,', user =', adminUser
69 if ( beHost == None ):
73 importNormativeInterfaceLifecycleType(scheme, beHost, bePort, adminUser, True, "../../../import/tosca/interface-lifecycle-types//")
76 if __name__ == "__main__":