diff options
author | 2018-07-19 18:25:12 +0300 | |
---|---|---|
committer | 2018-07-25 15:03:36 +0000 | |
commit | 924b33856a717a70570e9108596716a781e39ec0 (patch) | |
tree | 27951fd24b1d5e6217580254c49d6f02efc3185a /catalog-be/src/main/resources/scripts/import/tosca/importGroupTypes.py | |
parent | 6c3541e2f1a64a7140b7bb54ff5aa546facbb14f (diff) |
Align normatives and scripts
Change-Id: I5e15e3c5adaf13a5b785613d20411f5d0e42e264
Issue-ID: SDC-1544
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/main/resources/scripts/import/tosca/importGroupTypes.py')
-rw-r--r-- | catalog-be/src/main/resources/scripts/import/tosca/importGroupTypes.py | 107 |
1 files changed, 54 insertions, 53 deletions
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importGroupTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importGroupTypes.py index 9daa990fc5..0a94bbef95 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importGroupTypes.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importGroupTypes.py @@ -1,11 +1,10 @@ -import pycurl -import sys, getopt -from StringIO import StringIO -import json -import copy -from importNormativeElements import createNormativeElement +import getopt +import sys from importCommon import * +from importNormativeElements import createNormativeElement + + ##################################################################################################################################################################################### # # # Import tosca data types # @@ -19,59 +18,61 @@ from importCommon import * ##################################################################################################################################################################################### def usage(): - 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> ]' + 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> ]' + +def importGroupTypes(scheme, be_host, be_port, admin_user, exit_on_success, file_dir): + result = createNormativeElement(scheme, be_host, be_port, admin_user, file_dir, + "/sdc2/rest/v1/catalog/uploadType/grouptypes", "groupTypes", "groupTypesZip", True) -def importGroupTypes(scheme, beHost, bePort, adminUser, exitOnSuccess, fileDir): - result = createNormativeElement(scheme, beHost, bePort, adminUser, fileDir, "/sdc2/rest/v1/catalog/uploadType/grouptypes", "groupTypes", "groupTypesZip") + print_frame_line() + print_name_and_return_code(result[0], result[1]) + print_frame_line() - printFrameLine() - printNameAndReturnCode(result[0], result[1]) - printFrameLine() + if result[1] is None or result[1] not in [200, 201, 409]: + error_and_exit(1, None) + else: + if exit_on_success: + error_and_exit(0, None) - if ( result[1] == None or result[1] not in [200, 201, 409] ): - errorAndExit(1, None) - else: - if (exitOnSuccess == True): - errorAndExit(0, None) def main(argv): - print 'Number of arguments:', len(sys.argv), 'arguments.' - - beHost = 'localhost' - bePort = '8080' - adminUser = 'jh0003' - scheme = 'http' - - try: - opts, args = getopt.getopt(argv,"i:p:u:h:s:",["ip=","port=","user=","scheme="]) - except getopt.GetoptError: - usage() - errorAndExit(2, 'Invalid input') - - for opt, arg in opts: - #print opt, arg - if opt == '-h': - usage() - sys.exit(3) - elif opt in ("-i", "--ip"): - beHost = arg - elif opt in ("-p", "--port"): - bePort = arg - elif opt in ("-u", "--user"): - adminUser = arg - elif opt in ("-s", "--scheme"): - scheme = arg - - print 'scheme =',scheme,', be host =',beHost,', be port =', bePort,', user =', adminUser - - if ( beHost == None ): - usage() - sys.exit(3) - - importGroupTypes(scheme, beHost, bePort, adminUser, True, "../../../import/tosca/group-types/") + print 'Number of arguments:', len(sys.argv), 'arguments.' + be_host = 'localhost' + be_port = '8080' + admin_user = 'jh0003' + scheme = 'http' -if __name__ == "__main__": - main(sys.argv[1:]) + try: + opts, args = getopt.getopt(argv, "i:p:u:h:s:", ["ip=", "port=", "user=", "scheme="]) + except getopt.GetoptError: + usage() + error_and_exit(2, 'Invalid input') + for opt, arg in opts: + # print opt, arg + if opt == '-h': + usage() + sys.exit(3) + elif opt in ("-i", "--ip"): + be_host = arg + elif opt in ("-p", "--port"): + be_port = arg + elif opt in ("-u", "--user"): + admin_user = arg + elif opt in ("-s", "--scheme"): + scheme = arg + + print 'scheme =', scheme, ', be host =', be_host, ', be port =', be_port, ', user =', admin_user + + if be_host is None: + usage() + sys.exit(3) + + importGroupTypes(scheme, be_host, be_port, admin_user, True, "../../../import/tosca/group-types/") + + +if __name__ == "__main__": + main(sys.argv[1:]) |