3 from StringIO import StringIO
6 from importNormativeElements import createNormativeElement
7 from importCommon import *
10 #################################################################################################################################################################################################
12 # Import normative capabilities #
15 # python importNormativeCapabilities.py [-s <scheme> | --scheme=<scheme> ] [-i <be host> | --ip=<be host>] [-p <be port> | --port=<be port> ] [-f <input file> | --ifile=<input file> ] #
17 # shortest activation (be host = localhost, be port = 8080): #
18 # python importNormativeCapabilities.py [-f <input file> | --ifile=<input file> ] #
20 #################################################################################################################################################################################################
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> ]'
27 def importNormativeCapabilities(scheme, beHost, bePort, adminUser, exitOnSuccess, fileDir):
28 result = createNormativeElement(scheme, beHost, bePort, adminUser, fileDir, "/sdc2/rest/v1/catalog/uploadType/capability", "capabilityTypes", "capabilityTypeZip")
31 printNameAndReturnCode(result[0], result[1])
34 if ( result[1] == None or result[1] not in [200, 201, 409] ):
35 importCommon.errorAndExit(1, None)
37 if (exitOnSuccess == True):
38 importCommon.errorAndExit(0, None)
42 print 'Number of arguments:', len(sys.argv), 'arguments.'
50 opts, args = getopt.getopt(argv,"i:p:u:h:s:",["ip=","port=","user=","scheme="])
51 except getopt.GetoptError:
53 importCommon.errorAndExit(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"):
69 print 'scheme =',scheme,', be host =',beHost,', be port =', bePort,', user =', adminUser
71 if ( beHost == None ):
75 importNormativeCapabilities(scheme, beHost, bePort, adminUser, True, "../../../import/tosca/capability-types/")
78 if __name__ == "__main__":