Comment 0 for bug 1415700

Revision history for this message
tinytmy (tangmeiyan77) wrote :

It used host_name key in
https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/contrib/hosts.py#L40
used host key in
https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/contrib/hosts.py#L266-L267
Why not unite the key.

And this lead to novaclient bug such as:
>>> from novaclient.v1_1 import client
>>> nc = client.Client("admin","password","admin","http://192.168.1.100:5000/v2.0")
>>> nc.hosts.get("controller")
[<Host: controller>, <Host: controller>, <Host: controller>, <Host: controller>]

>>> nc.hosts.list()
[Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/hosts.py", line 24, in __repr__
    return "<Host: %s>" % self.host
  File "/usr/lib/python2.7/dist-packages/novaclient/openstack/common/apiclient/base.py", line 489, in __getattr__
    raise AttributeError(k)
AttributeError: host

-----------------------------------
Maybe some people think it is the novaclient bug.
In this patch https://review.openstack.org/#/c/110087/,
it fix the host.get(), but lead to host.list() cann't work.
Maybe we can add some judge such as(if .eg) in the function of
https://github.com/openstack/python-novaclient/blob/master/novaclient/v1_1/hosts.py#L24,
but I think unite the key to 'host' in nova is much better, if such we don't need to change novaclient and
nova code looks better.