Python Error message
GBANE FETIGUE
bemen77 at gmail.com
Thu Aug 4 11:31:22 EDT 2016
Hi,
I am running a python script to run some CURL commands, and return the response which is the applicationId and the versionId. I was able to do it. Now the versionId value supposed to be used on the second CURL as a value of the applications key which is an array. but it doesn't work.I 'll post the error after running the command as well as the script. It seems like I have an error somewhere because the curl works manually if i run.
ec2-user at ip-172-31-21-77 playbooks]$ python mmc-uploader.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2318 0 119 100 2199 496 9173 --:--:-- --:--:-- --:--:-- 9200
Your applicationId is: local$fc9277b0-a5b1-4602-8730-714ab7472744
Your versionId is: local$423da1c8-c4e1-47af-9395-57300f839670
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1259 100 1091 100 168 100k 15868 --:--:-- --:--:-- --:--:-- 106k
Final response<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.26 - Error report</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 415 - </h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.</u></p><hr class="line"><h3>Apache Tomcat/8.0.26</h3></body></html>
Seems the named id already exists!
That's the script :
from subprocess import check_output, STDOUT
import json
response = check_output(["curl", "--basic", "-u", "admin:admin", "-F", "file=@/var/lib/jenkins/workspace/Demo-Ci-cd-automation/playbooks/ms3-simple-hello-world-app-1.0.0-SNAPSHOT.zip", "-F", "name=ms3-simple-hello-world-app", "-F", "version=1.0.0", "--header", "\"Content-Type: multipart/form-data\"", "http://52.73.56.141:8080/mmc-console-3.6.2/api/repository"])
try:
parsed_response = json.loads(response)
print "Your applicationId is: " + parsed_response[u'applicationId']
version_id = parsed_response[u'versionId']
print "Your versionId is: " + version_id
except:
print 'Seems the named application already exists!'
print 'Seems the named versionId already exists!'
response = check_output(["curl", "--basic", "-u", "admin:admin", "-d", "'{\"name\" : \"ms3-simple-hello-world-app\" , \"servers\": [ \"local$d50bdc24-ff04-4327-9284-7bb708e21c25\" ], \"applications\": [ \"" + version_id + "\"]}'", "--header", "\'Content-Type: application/json\'", "http://52.73.56.141:8080/mmc-console-3.6.2/api/deployments"])
print 'Final response' + response
try:
parsed_response = json.loads(response)
deployid = parsed_response[u'id']
print "Your deployid is: " + deployid
except:
print 'Seems the named id already exists!'
More information about the Python-list
mailing list