3 #from time import sleep
5 from datetime import datetime
20 ##############################
22 ##############################
24 command="curl -s -o /dev/null -I -w \"%{http_code}\" -i http://" + BE_IP + ":8080/sdc2/rest/v1/user/jh0003"
26 proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE )
27 (out, err) = proc.communicate()
32 def checkConsumer(consumerName):
33 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://" + BE_IP + ":8080/sdc2/rest/v1/consumers/" + consumerName
35 proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE )
36 (out, err) = proc.communicate()
41 def createConsumer( consumerName, consumerSalt, consumerPass ):
42 print '[INFO] ' + consumerName
43 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://" + BE_IP + ":8080/sdc2/rest/v1/consumers/ -d '{\"consumerName\": '" + consumerName + "', \"consumerSalt\": '" + consumerSalt + "',\"consumerPassword\": '" + consumerPass + "'}'"
45 proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE)
47 (out, err) = proc.communicate()
54 ##############################
56 ##############################
57 consumersList = [ "aai" , "appc" , "dcae" , "mso" , "sdnc" , "vid" , "cognita", "clamp" , "vfc" , "workflow" , "policy" , "pomba" ]
58 salt = "9cd4c3ad2a6f6ce3f3414e68b5157e63"
59 password = "35371c046f88c603ccba152cb3db34ec4475cb2e5713f2fc0a43bf18a5243495"
63 ##############################
65 ##############################
68 myResult = checkBackend()
70 print '[INFO]: Backend is up and running'
74 currentTime = datetime.now()
75 print '[ERROR]: ' + currentTime.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + ' Backend not responding, try #' + str(i) + bcolors.ENDC
79 print '[ERROR]: ' + time.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + 'Backend is DOWN :-(' + bcolors.ENDC
82 for consumer in consumersList:
83 myResult = checkConsumer(consumer)
85 print '[INFO]: ' + consumer + ' already exists'
87 myResult = createConsumer( consumer, salt, password )
89 print '[INFO]: ' + consumer + ' created, result: [' + myResult + ']'
91 print '[ERROR]: ' + bcolors.FAIL + consumer + bcolors.ENDC + ' error creating , result: [' + myResult + ']'