woorea / openstack-java-sdk

OpenStack Java SDK
Apache License 2.0
194 stars 198 forks source link

Glance API: Adding of an image #47

Open SemmZemm opened 11 years ago

SemmZemm commented 11 years ago

When I try to create an image instead of sending the parameters in the headers like that (like glance client)

POST /v1/images HTTP/1.1
Host: 127.0.0.1:35332
Accept-Encoding: identity
x-image-meta-name: newimg
x-image-meta-image_format: iso
x-image-meta-container_format: bare 
x-image-meta-is_public: False
Content-Type: application/octet-stream
X-Auth-Token: ae0128d95b564ddcbfb47765fda75f3e
User-Agent: python-glanceclient 

openstack-java-sdk sends it like that

X-Auth-Token: bd4a316f4cc44269a3c48c588a78805c
Accept: application/json
Content-Length: 230
Content-Type: application/json
Host: 127.0.0.1:35332
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.2 (java 1.5) 

{
  "image" : {
    "name" : "DamnSmallLinux",
    "properties" : { },
    "protected" : false,
    "public" : false,
    "deleted" : false,
    "disk_format" : "iso",
    "container_format" : "bare",
    "is_public" : false
  }
} 

As a result creating image doesn't work. I receive

<html>
 <head>
  <title>400 Bad Request</title>
 </head>
 <body>
  <h1>400 Bad Request</h1>
  Invalid disk format 'None' for image.<br /><br />

 </body>
</html> 

Indeed once message (even one with all correct headers) has a body you get this error.

If you look here: http://docs.openstack.org/developer/glance/glanceapi.html you'll see well described headers. Moreover

  • x-image-meta-name

This header is required. Its value should be the name of the image

Thanks in advance!

Tested with OpenStack 2012.2.3 on Fedora 18

simon3z commented 11 years ago

I think this was fixed recently. Can you check again? Thanks.

SemmZemm commented 11 years ago

Sorry, always migrated to jclouds + self written REST Requests. If I'll test it I write you.

yibolaughing commented 11 years ago

when I create an image ,I send the parameters in the headers,but I get the problem,like that

LoggingFilter - Request received on thread main 1 > POST http://192.168.1.232:9292/v2/images 1 > x-Image-Meta-Owner: null 1 > x-Image-Meta-Name: os-java-glance-test 1 > x-Image-Meta-Container_format: bare 1 > x-Image-Meta-Id: null 1 > X-Auth-Token: ***** 1 > x-Image-Meta-Disk_format: raw 1 > x-Image-Meta-Checksum: null 1 > x-Image-Meta-Is_public: true 1 > Accept: application/json 1 > x-Image-Meta-Size: null

LoggingFilter - Response received on thread main 2 < 400 2 < X-Openstack-Request-Id: req-34ff5612-dedd-41bd-8677-4ca274bdb0b5 2 < Date: Tue, 09 Jul 2013 04:29:23 GMT 2 < Content-Length: 47 2 < Content-Type: text/plain; charset=UTF-8 2 < Connection: keep-alive 400 Bad Request

Body expected in request.

as the response said ,the request need body ,so ,how to fill the body@

yibolaughing commented 11 years ago

I have Solved. change the url is http://192.168.1.232:9292/v1/images,it works!