glance.images.get inappropriate return
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance Client |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Hello colleagues,
while working with glanceclient library, I faced an issue: when trying to find snapshot_id of the image, I'm calling glance.images.get and this call returns type of Image where block_devices_
{
'container_format': 'bare',
'size': 0,
'block_
'locations': [{'url': 'swift+
it looks strange since other properties are of different type (Integer (like 'size') or even List (like 'location')) and adds complexity to working with the result. It's better to have 'block_
image = glance.
for bd in image.block_
if bd['boot_index'] == 0:
snapshot_id = bd['snapshot_id']
So, the question is: is 'String' type of block_device_
Thank you.
Changed in python-glanceclient: | |
status: | Incomplete → Invalid |
At the moment, such workaround is possible:
import ast
s = '[{"guest_format": null, "boot_index": 0, "delete_ on_termination" : false, "no_device": null, "snapshot_id": "7fc78b3e- fa23-4710- 914b-575ee0444c 88", "device_name": "/dev/sda", "disk_bus": "scsi", "image_id": null, "source_type": "snapshot", "tag": null, "device_type": "disk", "volume_id": null, "destination_type": "volume", "volume_size": 10}]' .replace( 'true', 'True') .replace( 'false' , 'False') eval(s1)
print( bd['snapshot_ id'])
s1 = s.replace('null', 'None')
bdm = ast.literal_
for bd in bdm:
if bd['boot_index'] == 0:
but such evaluation of result is very risky business.