3 from StringIO import StringIO
6 from importNormativeElements import createNormativeElement
8 from importCommon import *
9 ################################################################################################################################################
11 # Import all users from a given file #
14 # python importUsers.py [-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 importUsers.py [-f <input file> | --ifile=<input file> ] #
19 ################################################################################################################################################
22 print sys.argv[0], '[-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-u <user userId> | --user=<user userId> ]'
25 def importCategories(beHost, bePort, adminUser, exitOnSuccess, fileDir):
26 result = createNormativeElement(beHost, bePort, adminUser, fileDir, "/sdc2/rest/v1/catalog/uploadType/categories", "categoryTypes", "categoriesZip")
29 printNameAndReturnCode(result[0], result[1])
32 if ( result[1] == None or result[1] not in [200, 201, 409] ):
35 if (exitOnSuccess == True):
39 print 'Number of arguments:', len(sys.argv), 'arguments.'
46 opts, args = getopt.getopt(argv,"i:p:u:h:",["ip=","port=","user="])
47 except getopt.GetoptError:
49 errorAndExit(2, 'Invalid input')
56 elif opt in ("-i", "--ip"):
58 elif opt in ("-p", "--port"):
60 elif opt in ("-u", "--user"):
63 print 'be host =',beHost,', be port =', bePort,', user =', adminUser
65 if ( beHost == None ):
69 importCategories(beHost, bePort, adminUser, True, "../../../import/tosca/categories/")
72 if __name__ == "__main__":