table columns can have inconsistent ordering
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
placement-osc-plugin |
Invalid
|
Undecided
|
Unassigned |
Bug Description
When making a request to show inventory, with osc-placement 1.3.0 the columns are shown with different order:
-=-=-
jarvis@
/usr/local/
""")
+------
| resource_class | total | max_unit | min_unit | allocation_ratio | reserved | step_size |
+------
| DISK_GB | 292 | 291 | 1 | 1.0 | 0 | 1 |
| MEMORY_MB | 32767 | 32767 | 1 | 1.5 | 512 | 1 |
| VCPU | 8 | 8 | 1 | 16.0 | 0 | 1 |
+------
jarvis@
/usr/local/
""")
+------
| resource_class | min_unit | allocation_ratio | reserved | total | step_size | max_unit |
+------
| MEMORY_MB | 1 | 1.5 | 512 | 32767 | 1 | 32767 |
| VCPU | 1 | 16.0 | 0 | 8 | 1 | 8 |
| DISK_GB | 1 | 1.0 | 0 | 292 | 1 | 291 |
+------
-=-=-
This is disconcerting and disorienting. Presumably total should come after resource_class and then the rest can be bikeshedded.
Looks like you were on a py35 host, I'm having a hard time reproducing this on a py27 host, but this would likely be the issue - these keys are not sorted and coming from a dict:
https:/ /github. com/openstack/ osc-placement/ blob/ffc2ee4c09 089baa65702abb6 926a62f2cdf9996 /osc_placement/ resources/ inventory. py#L67
https:/ /github. com/openstack/ osc-placement/ blob/ffc2ee4c09 089baa65702abb6 926a62f2cdf9996 /osc_placement/ resources/ inventory. py#L316
It would be easy enough to sort those fields but yeah if you want total to come after resource_class that's a bit more tricky.
I also tried using --sort-column but it doesn't seem to have an effect:
stack@train:~$ openstack resource provider inventory list dbe783b2- 8780-4bef- a758-d7a853118e 25 --sort-column total ------- ---+--- ------- ------- -+----- -----+- ------- --+---- ------- +------ ----+-- -----+ ------- ---+--- ------- ------- -+----- -----+- ------- --+---- ------- +------ ----+-- -----+ ------- ---+--- ------- ------- -+----- -----+- ------- --+---- ------- +------ ----+-- -----+
+------
| resource_class | allocation_ratio | max_unit | reserved | step_size | min_unit | total |
+------
| VCPU | 16.0 | 8 | 0 | 1 | 1 | 8 |
| DISK_GB | 1.0 | 193 | 0 | 1 | 1 | 193 |
| MEMORY_MB | 1.5 | 7975 | 512 | 1 | 1 | 7975 |
+------