Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thanks a lot Jayaprakash. Your solution helped me. After giving --debug in the command, i am able to get the REST json format and able to create the instances.

$ nova --debug boot --flavor m1.tiny --image cirros-0.3.4-x86_64-uec --nic net-id=02159b65-a4ad-4c9e-a087-1f3426a333ae --security-group d

Rest API Code: ~~~~~~~~~~~~~~~~

headers = { 'Content-Type' : 'application/json', 'Accept' : 'application/json', 'X-OpenStack-Nova-API-Version' : '2.11', 'X-Auth-Token' : mytoken }

APIport=NOVAport CMDpath="/v2/"+tenantid+"/servers" url="http://"+hostIP+":"+APIport+CMDpath print "URL: ",url

body='{"server": {"name": "vm1", "imageRef": "8275248f-1d55-47f7-808b-1208cfd1045d", "flavorRef": "1", "max_count": 1, "min_count": 1, "networks": [{"uuid": "02159b65-a4ad-4c9e-a087-1f3426a333ae"}], "security_groups": [{"name": "default"}]}}'

req = urllib2.Request(url, body, headers)

response = urllib2.urlopen(req).read() decoded = json.loads(response.decode('utf8')) pret = json.dumps(decoded,sort_keys=True,indent=3) print "pret