3 #from time import sleep
5 from datetime import datetime
18 ##############################
20 ##############################
22 command="curl -s -o /dev/null -I -w \"%{http_code}\" -i http://localhost:8080/sdc2/rest/v1/user/jh0003"
24 proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE )
25 (out, err) = proc.communicate()
30 def checkConsumer(consumerName):
31 command="curl -s -o /dev/null -I -w \"%{http_code}\" -i -H \"Accept: application/json; charset=UTF-8\" -H \"Content-Type: application/json\" -H \"USER_ID: jh0003\" http://localhost:8080/sdc2/rest/v1/consumers/" + consumerName
33 proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE )
34 (out, err) = proc.communicate()
39 def createConsumer( consumerName, consumerSalt, consumerPass ):
40 print '[INFO] ' + consumerName
41 command="curl -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\" http://localhost:8080/sdc2/rest/v1/consumers/ -d '{\"consumerName\": '" + consumerName + "', \"consumerSalt\": '" + consumerSalt + "',\"consumerPassword\": '" + consumerPass + "'}'"
43 proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE)
45 (out, err) = proc.communicate()
52 ##############################
54 ##############################
55 consumersList = [ "aai" , "appc" , "dcae" , "mso" , "sdnc" , "vid" ]
56 salt = "9cd4c3ad2a6f6ce3f3414e68b5157e63"
57 password = "35371c046f88c603ccba152cb3db34ec4475cb2e5713f2fc0a43bf18a5243495"
61 ##############################
63 ##############################
66 myResult = checkBackend()
68 print '[INFO]: Backend is up and running'
72 currentTime = datetime.now()
73 print '[ERROR]: ' + currentTime.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + ' Backend not responding, try #' + str(i) + bcolors.ENDC
77 print '[ERROR]: ' + time.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + 'Backend is DOWN :-(' + bcolors.ENDC
80 for consumer in consumersList:
81 myResult = checkConsumer(consumer)
83 print '[INFO]: ' + consumer + ' already exists'
85 myResult = createConsumer( consumer, salt, password )
87 print '[INFO]: ' + consumer + ' created, result: [' + myResult + ']'
89 print '[ERROR]: ' + bcolors.FAIL + consumer + bcolors.ENDC + ' error creating , result: [' + myResult + ']'