diff options
author | k.kedron <k.kedron@partner.samsung.com> | 2020-02-28 14:26:07 +0100 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-03-23 09:48:56 +0000 |
commit | 5944b441468500fffa7111b5dea9181461ae1303 (patch) | |
tree | 9b358b2d25a309c1d6dfd86227ec75b52b2ccefa /catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py | |
parent | ec7da6aea30a1b73d1e0f5f75d2b6119ed8fa251 (diff) |
Refactoring the sdc-BE-init python scripts
Adjust to the correct python syntax.
Remove not used imports.
Also fixed:
- the indents
- checking that all normative imported correctly logic
Issue-ID: SDC-2784
Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
Change-Id: If7edc867f3cb591be157073fbc12b9842b200023
Diffstat (limited to 'catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py')
-rw-r--r-- | catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py index 7adcf333c7..a6040d0215 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py @@ -1,11 +1,7 @@ -import pycurl -import sys, getopt -from StringIO import StringIO -import json -import copy -from importNormativeElements import createNormativeElement -from importCommon import * import importCommon +from importCommon import * +from importNormativeElements import createNormativeElement + ################################################################################################################################################################################################# # # @@ -24,60 +20,63 @@ import importCommon 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 importNormativeRelationships(scheme, beHost, bePort, adminUser, exitOnSuccess, fileDir): - result = createNormativeElement(scheme, beHost, bePort, adminUser, fileDir, "/sdc2/rest/v1/catalog/uploadType/relationship", "relationshipTypes", "relationshipTypeZip") +def importNormativeRelationships(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/relationship", "relationshipTypes", + "relationshipTypeZip") print_frame_line() print_name_and_return_code(result[0], result[1]) print_frame_line() - if ( result[1] == None or result[1] not in [200, 201, 409] ): + if result[1] is None or result[1] not in [200, 201, 409]: importCommon.error_and_exit(1, None) else: - if (exitOnSuccess == True): + if exit_on_success is True: importCommon.error_and_exit(0, None) def main(argv): print 'Number of arguments:', len(sys.argv), 'arguments.' - beHost = 'localhost' - bePort = '8080' - adminUser = 'jh0003' + be_host = 'localhost' + be_port = '8080' + admin_user = 'jh0003' scheme = 'http' try: - opts, args = getopt.getopt(argv,"i:p:u:h:s:",["ip=","port=","user=","scheme="]) + opts, args = getopt.getopt(argv, "i:p:u:h:s:", ["ip=", "port=", "user=", "scheme="]) except getopt.GetoptError: usage() importCommon.error_and_exit(2, 'Invalid input') for opt, arg in opts: - #print opt, arg + # print opt, arg if opt == '-h': usage() sys.exit(3) elif opt in ("-i", "--ip"): - beHost = arg + be_host = arg elif opt in ("-p", "--port"): - bePort = arg + be_port = arg elif opt in ("-u", "--user"): - adminUser = arg + admin_user = arg elif opt in ("-s", "--scheme"): scheme = arg - print 'scheme =',scheme,', be host =',beHost,', be port =', bePort,', user =', adminUser + print 'scheme =', scheme, ', be host =', be_host, ', be port =', be_port, ', user =', admin_user - if ( beHost == None ): + if be_host is None: usage() sys.exit(3) - importNormativeRelationships(scheme, beHost, bePort, adminUser, True, "../../../import/tosca/relationship-types/") + importNormativeRelationships(scheme, be_host, be_port, admin_user, True, + "../../../import/tosca/relationship-types/") if __name__ == "__main__": main(sys.argv[1:]) - |