Fix Serivce class AttributeError

When we str(service_object), an AttributeError occurred like this:
========================
  File "/opt/stack/python-novaclient/novaclient/v1_1/services.py", line
24, in __repr__
    return "<Service: %s>" % self.service
  File
"/opt/stack/python-novaclient/novaclient/openstack/common/apiclient/base.py",
 line 463, in __getattr__
    raise AttributeError(k)
AttributeError: service
========================
This commit fixes it.

Change-Id: I496d522591273bf1b1e7dbadf19afaf5e64e41e3
Closes-Bug: #1276408
This commit is contained in:
Masayuki Igawa 2014-02-04 15:53:16 +09:00
parent 810857849e
commit 5e3a3a193b
2 changed files with 2 additions and 1 deletions

View File

@ -37,6 +37,7 @@ class ServicesTest(utils.TestCase):
self.assertIsInstance(s, self._get_service_type())
self.assertEqual(s.binary, 'nova-compute')
self.assertEqual(s.host, 'host1')
self.assertTrue(str(s).startswith('<Service: '))
def test_list_services_with_hostname(self):
svs = self.cs.services.list(host='host2')

View File

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