diff options
author | k.kedron <k.kedron@partner.samsung.com> | 2020-03-05 13:12:27 +0100 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-06-24 06:01:11 +0000 |
commit | cb30f3a566b73c78c3ea666acfcd3f288098684a (patch) | |
tree | 38cd1acb83ddde2b927485611d130bbeec3c1a4b /catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/consumers.py.erb | |
parent | bdbfc2e460ccb561c3e174260b2908b974996d4f (diff) |
Refactoring the sdc-BE-init python scripts
Deeper refactoring of python script:
- create the python package with init script
- support for python 3.x
- reuse code
- new design
- support for .json conf file
- update the docker chef script
Issue-ID: SDC-2784
Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
Change-Id: I02169eb7d0e3e90851ba1811536d1712c3b4145f
Diffstat (limited to 'catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/consumers.py.erb')
-rw-r--r-- | catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/consumers.py.erb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/consumers.py.erb b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/consumers.py.erb index b09b71948a..02ca9a8109 100644 --- a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/consumers.py.erb +++ b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/consumers.py.erb @@ -28,7 +28,7 @@ def checkBackend(): proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE ) (out, err) = proc.communicate() result = out.strip() - return result + return str(result, "UTF-8") def checkConsumer(consumerName): @@ -37,18 +37,18 @@ def checkConsumer(consumerName): proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE ) (out, err) = proc.communicate() result = out.strip() - return result + return str(result, "UTF-8") def createConsumer( consumerName, consumerSalt, consumerPass ): - print '[INFO] ' + consumerName + print('[INFO] ' + consumerName) command="curl -k -s -o /dev/null -w \"%{http_code}\" -X POST -i -H \"Accept: application/json; charset=UTF-8\" -H \"Content-Type: application/json\" -H \"USER_ID: jh0003\" "+PROTOCOL+"://" + BE_IP + ":" + BE_PORT + "/sdc2/rest/v1/consumers/ -d '{\"consumerName\": '" + consumerName + "', \"consumerSalt\": '" + consumerSalt + "',\"consumerPassword\": '" + consumerPass + "'}'" proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE) (out, err) = proc.communicate() result = out.strip() - return result + return str(result, "UTF-8") @@ -69,25 +69,25 @@ beStat=0 for i in range(1,10): myResult = checkBackend() if myResult == '200': - print '[INFO]: Backend is up and running' + print('[INFO]: Backend is up and running') beStat=1 break else: currentTime = datetime.now() - print '[ERROR]: ' + currentTime.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + ' Backend not responding, try #' + str(i) + bcolors.ENDC + print('[ERROR]: ' + currentTime.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + ' Backend not responding, try #' + str(i) + bcolors.ENDC) time.sleep(10) if beStat == 0: - print '[ERROR]: ' + time.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + 'Backend is DOWN :-(' + bcolors.ENDC + print('[ERROR]: ' + time.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + 'Backend is DOWN :-(' + bcolors.ENDC) exit() for consumer in consumersList: myResult = checkConsumer(consumer) if myResult == '200': - print '[INFO]: ' + consumer + ' already exists' + print('[INFO]: ' + consumer + ' already exists') else: myResult = createConsumer( consumer, salt, password ) if myResult == '201': - print '[INFO]: ' + consumer + ' created, result: [' + myResult + ']' + print('[INFO]: ' + consumer + ' created, result: [' + myResult + ']') else: - print '[ERROR]: ' + bcolors.FAIL + consumer + bcolors.ENDC + ' error creating , result: [' + myResult + ']' + print('[ERROR]: ' + bcolors.FAIL + consumer + bcolors.ENDC + ' error creating , result: [' + myResult + ']') |