3 from StringIO import StringIO
6 from importNormativeElements import createNormativeElement
7 from importCommon import *
10 #################################################################################################################################################################################################
12 # Import normative relationships
16 # python importNormativeRelationships.py [-s <scheme> | --scheme=<scheme> ] [-i <be host> | --ip=<be host>] [-p
17 # <be port> | --port=<be port> ] [-f <input file> | --ifile=<input file> ] #
19 # shortest activation (be host = localhost, be port = 8080): #
20 # python importNormativeRelationships.py [-f <input file> | --ifile=<input file> ]
23 #################################################################################################################################################################################################
27 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> ]'
30 def importNormativeRelationships(scheme, beHost, bePort, adminUser, exitOnSuccess, fileDir):
31 result = createNormativeElement(scheme, beHost, bePort, adminUser, fileDir, "/sdc2/rest/v1/catalog/uploadType/relationship", "relationshipTypes", "relationshipTypeZip")
34 print_name_and_return_code(result[0], result[1])
37 if ( result[1] == None or result[1] not in [200, 201, 409] ):
38 importCommon.error_and_exit(1, None)
40 if (exitOnSuccess == True):
41 importCommon.error_and_exit(0, None)
45 print 'Number of arguments:', len(sys.argv), 'arguments.'
53 opts, args = getopt.getopt(argv,"i:p:u:h:s:",["ip=","port=","user=","scheme="])
54 except getopt.GetoptError:
56 importCommon.error_and_exit(2, 'Invalid input')
63 elif opt in ("-i", "--ip"):
65 elif opt in ("-p", "--port"):
67 elif opt in ("-u", "--user"):
69 elif opt in ("-s", "--scheme"):
72 print 'scheme =',scheme,', be host =',beHost,', be port =', bePort,', user =', adminUser
74 if ( beHost == None ):
78 importNormativeRelationships(scheme, beHost, bePort, adminUser, True, "../../../import/tosca/relationship-types/")
81 if __name__ == "__main__":