If you want to use Python to to create a server image, use this as your inspiration:
#!/usr/bin/python
import base64
import urllib
import httplib
import json
import os
from urlparse import urlparse
### --8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--
###
### insert the 'Get OpenStack Credentials' snippet here
###
### --8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--
###
### Revert server resize
###
# HTTP connection #2
srvID = 1 # server ID number
imgName = "tornado-app-server"
metaDict = {"version": "1.0.0", "creator": "joe"}
url2 = apiurlt[1]
params2 = urllib.urlencode(json.dumps({"createImage": {"name": imgName, "metadata": metaDict}}))
headers2 = { "X-Auth-Token":apitoken, "Content-type":"application/json" }
if (usehttps == True):
conn2 = httplib.HTTPSConnection(url2, key_file='../cert/priv.pem', cert_file='../cert/srv_test.crt')
else:
conn2 = httplib.HTTPConnection(url2)
conn2.request("POST", "%s/servers/%s/action" % (apiurlt[2], srvID), params2, headers2)
# HTTP response #2
response2 = conn2.getresponse()
data2 = response2.read()
conn2.close()
