Flavor attribute 'swap' returns unicode'' instead of int 0
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Invalid
|
Medium
|
Brin Zhang |
Bug Description
Description
===========
When a flavor is created in Horizon with 'Swap Disk (MB)' -> 0.
Nova python API returns unicode'' on flavor.swap attribute.
When swap disk is changed to 10.
API returns -> int 10 instead of unicode.
Steps to reproduce
==================
- In horizon create a new flavor with swap disk 0
- connect to the nova python API.
fl = nova.flavors.
print fl.swap
print(type(
output:
<type 'unicode'>
Expected result
===============
int 0
Actual result
=============
unicode ''
Environment
===========
ubuntu@
15.1.5
ubuntu@
ii nova-api-os-compute 2:15.1.
ii nova-common 2:15.1.
ii nova-conductor 2:15.1.
ii nova-consoleauth 2:15.1.
ii nova-novncproxy 2:15.1.
ii nova-placement-api 2:15.1.
ii nova-scheduler 2:15.1.
ii python-nova 2:15.1.
xx@xx-dev:
openstack 3.14.2
summary: |
- Flavor attribute returns unicode'' when 0 + Flavor attribute 'swap' returns unicode'' when 0 instead of int |
summary: |
- Flavor attribute 'swap' returns unicode'' when 0 instead of int + Flavor attribute 'swap' returns unicode'' instead of int 0 |
tags: | added: api |
Changed in nova: | |
importance: | Undecided → Medium |
Hmm, it looks like the API does allow passing a string for the flavor swap size:
https:/ /github. com/openstack/ nova/blob/ 5c18dc108ee12dc c2a3eaf2aa2d7e2 be339ff261/ nova/api/ validation/ parameter_ types.py# L453
That's unfortunate. However, it should get stored in the database as an integer:
https:/ /github. com/openstack/ nova/blob/ 5c18dc108ee12dc c2a3eaf2aa2d7e2 be339ff261/ nova/objects/ flavor. py#L214
https:/ /github. com/openstack/ nova/blob/ 5c18dc108ee12dc c2a3eaf2aa2d7e2 be339ff261/ nova/db/ sqlalchemy/ api_models. py#L193
So I'm not sure why it's coming back as a string.
As for this code:
fl = nova.flavors. find(name= "your flavor")
What are you using? python-novaclient?
If you do a curl GET /flavors/ {flavor_ id} on the flavor what do you get back for the swap entry?