Cannot create volume from image using Fog

74 views
Skip to first unread message

J Ro

unread,
Oct 15, 2014, 9:18:28 AM10/15/14
to ruby...@googlegroups.com
Hi,

When I use cinder to create a volume from an image, it works.  Here is the debug HTTP request:

DEBUG:keystoneclient.session:REQ: curl -i -X POST http://XXX:8776/v1/96b7fa2fb01c47bb884a1f97e091b8a0/volumes -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: TOKEN_REDACTED" -d '{"volume": {"status": "creating", "availability_zone": null, "source_volid": null, "display_description": null, "snapshot_id": null, "user_id": null, "size": 20, "display_name": "volfromsnap", "imageRef": "da5e5085-db75-4b0b-90fd-c82e887f4a1a", "attach_status": "detached", "volume_type": null, "project_id": null, "metadata": {}}}'

However, when attempting this with fog, the imageRef is not being sent:

Ruby code:

v = volume_service.volumes.create(size: 20, display_name: 'tester123', display_description: 'Fog Testing1', options: {imageRef: 'da5e5085-db75-4b0b-90fd-c82e887f4a1a'})

HTTP Request:

POST /v1/c297330967f242549e184e648d657e6f/volumes HTTP/1.1

{"volume":{"display_name":"tester123","display_description":"Fog Testing1","size":20}}

From https://github.com/fog/fog/blob/master/lib/fog/openstack/requests/volume/create_volume.rb, it looks like these options should be parsed, but they are not being sent by the client.  Any ideas?

Thanks!

geemus (Wesley Beary)

unread,
Oct 15, 2014, 3:54:39 PM10/15/14
to ruby...@googlegroups.com
Hey, I don't have the most experience with the openstack side of things myself. Could you create an issue with this info on github? From there I can usually summon somebody with more direct experience to help out.
Thanks!
wes

--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rupak Ganguly

unread,
Oct 15, 2014, 7:14:19 PM10/15/14
to ruby...@googlegroups.com
Hi J,
  This code calls the model volume.create which takes attributes. So you should call it like so:

v = volume_service.volumes.create(size: 20, display_name: 'tester123', display_description: 'Fog Testing1', imageRef: 'da5e5085-db75-4b0b-90fd-c82e887f4a1a')

Just from the top of my head, so I might be incorrect. Let me know.

Thanks,
Rupak Ganguly

J Ro

unread,
Oct 27, 2014, 7:50:20 AM10/27/14
to ruby...@googlegroups.com
That did the trick - thanks!

Quentin Hartman

unread,
Feb 4, 2015, 6:42:53 PM2/4/15
to ruby...@googlegroups.com
I am running into a similar problem, and Rupak's solution below does not work for me. I've also tried using the create_volume method with no luck. Here's a snippet from an irb session:

 v = service.create_volume('test volume','A testing volume crete with fog', 200, options={imageRef:'851ebad1-4cfe-468f-94a7-08dfc6b2d29d'})
=> #<Excon::Response:0x00000002149e50 @data={:body=>{"volume"=>{"status"=>"creating", "displayDescription"=>"A testing volume crete with fog", "availabilityZone"=>"nova", "displayName"=>"test volume", "attachments"=>[{}], "volumeType"=>"None", "snapshotId"=>nil, "metadata"=>{}, "id"=>"2cce91b0-79a1-45b9-ac17-c6298ed69336", "createdAt"=>"2015-02-04T23:11:27.514360", "size"=>200}}, :headers=>{"Location"=>"http://openstack-api.local:8774/v2/b5901343f263457aab3ef432fae3c656/os-volumes/2cce91b0-79a1-45b9-ac17-c6298ed69336", "Content-Type"=>"application/json", "Content-Length"=>"330", "X-Compute-Request-Id"=>"req-4a15ea1a-4846-4a36-8dca-0dd7d59b8b61", "Date"=>"Wed, 04 Feb 2015 23:11:27 GMT"}, :status=>200, :reason_phrase=>"OK", :remote_ip=>"10.10.10.13", :local_port=>52750, :local_address=>"10.10.10.100"}, @body="{\"volume\": {\"status\": \"creating\", \"displayDescription\": \"A testing volume crete with fog\", \"availabilityZone\": \"nova\", \"displayName\": \"test volume\", \"attachments\": [{}], \"volumeType\": \"None\", \"snapshotId\": null, \"metadata\": {}, \"id\": \"2cce91b0-79a1-45b9-ac17-c6298ed69336\", \"createdAt\": \"2015-02-04T23:11:27.514360\", \"size\": 200}}", @headers={"Location"=>"http://openstack-api.local:8774/v2/b5901343f263457aab3ef432fae3c656/os-volumes/2cce91b0-79a1-45b9-ac17-c6298ed69336", "Content-Type"=>"application/json", "Content-Length"=>"330", "X-Compute-Request-Id"=>"req-4a15ea1a-4846-4a36-8dca-0dd7d59b8b61", "Date"=>"Wed, 04 Feb 2015 23:11:27 GMT"}, @status=200, @remote_ip="10.10.10.13", @local_port=52750, @local_address="10.10.10.100">

An empty volume gets correctly created, so I assume I am doing something wrong with passing the imageRef, but every permutation I've tried that makes any sense at all gives me the same result or worse.

Thanks!

QH
Reply all
Reply to author
Forward
0 new messages