fix host resource repr to use 'host' attribute

This change fixes an AttributeError raised when attempting to
represent a host resource as a string.

Change-Id: I33369b20ed7f5219c3b507107b8f3a37b46eacee
Closes-Bug: #1327005
This commit is contained in:
melanie witt 2014-07-28 18:54:01 +00:00
parent 50b1068ba6
commit 9ce03a98eb
2 changed files with 5 additions and 1 deletions

View File

@ -78,3 +78,7 @@ class HostsTest(utils.FixturedTestCase):
host.shutdown()
self.assert_called(
'GET', '/os-hosts/sample_host/shutdown')
def test_hosts_repr(self):
hs = self.cs.hosts.get('host')
self.assertEqual('<Host: dummy>', repr(hs[0]))

View File

@ -21,7 +21,7 @@ from novaclient import base
class Host(base.Resource):
def __repr__(self):
return "<Host: %s>" % self.host_name
return "<Host: %s>" % self.host
def _add_details(self, info):
dico = 'resource' in info and info['resource'] or info