fog-openstack
fog-openstack copied to clipboard
Can not reload glance image model
When create glance image model via glance v2 api, following error occurs.
E, [2016-04-11T07:51:38.359236 #5466] ERROR -- : identity is required for this operation (ArgumentError)
I think this issue related to this code.
I created test script.
This is the result.
$ bundle exec ruby upload-test-image.rb
Downloading Cirros image...
Image downloaded to /tmp/cirros-image-3beb792e87bdd9945c585ecff769fcd7
Extracting image contents to /tmp/cirros-0c6d09a913533a039b22b7286237d61a-dir...
Uploading AKI...
/Users/kei/git/src/github.com/fog/fog-openstack/vendor/bundle/ruby/2.0.0/gems/fog-core-1.37.0/lib/fog/core/attributes.rb:155:in `requires': identity is required for this operation (ArgumentError)
from /Users/kei/git/src/github.com/fog/fog-openstack/vendor/bundle/ruby/2.0.0/gems/fog-core-1.37.0/lib/fog/core/model.rb:40:in `reload'
from upload-test-image.rb:57:in `<main>'
Works for me without using 'reload'. I've not been to the bottom of it but why use reload at all?
Also, I use the file path to upload_data
not the data itself:
aki.upload_data "#{extract_path}/cirros-0.3.0-x86_64-vmlinuz"
And the image is effectively loaded and active:
p image.get_image_by_id(aki.id).body["status"]
"active"
So what's reload for?
@gildub, You are right, but the script that I have posted is just test. If I just get the state of glance image, I think that using the image.get_image_by_id is better.
The script can upload glance image via glance v2 api, but can not reload itself.
I use reload
in common method that checks resources, such as vm and volume.
Since reload
is not implemented for Image objects (Fog::Image::OpenStack::V2::Image) it goes through its superclass reload
method (Fog::OpenStack::Model) which doesn't work since no :identity attribute exists in the Image context.
I believe the super method is just a default and not meant to be used at all. @seanhandley or @geemus to confirm/help. If I understand it correctly, either the super needs to be empty or otherwise every inheriting class has to override it.
I noticed this while ago. I use reload e.g. for checking state of uploaded image, so it's nice to have, but there is a workaround. I might fix this, somewhere in the future, unless somebody else will step in. :-)
@Ladas, I hope to fix this problem.
@kei-yamazaki cool :-)
@Ladas, Oh, sorry my English is incorrect. I hope that you fix this problem!
@kei-yamazaki ah, ok :-) though not sure, when I will have time to do this :-)