Change Service repr to use self.id always
Before this change, the Service object repr was the binary for microversion < 2.53. With microversion >= 2.53, the Service repr became the id, which is a UUID. Using the binary never really made sense since if you have multiple nova-compute services, the binary is going to be the same for all of them in the repr and nothing is distinguishable. This changes the Service repr to just use the id, which is going to be the integer id value if microversion < 2.53 and the UUID id value if microversion >= 2.53. There is no release note for this change since the repr should not be treated as a contractual API. Change-Id: I3a7de2683e339295022efb279828ab1a91b3b62e
This commit is contained in:
@@ -34,18 +34,11 @@ class ServicesTest(utils.TestCase):
|
||||
svs = self.cs.services.list()
|
||||
self.assert_request_id(svs, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.cs.assert_called('GET', '/os-services')
|
||||
expect_uuid_id = (
|
||||
api_versions.APIVersion(self.api_version) >=
|
||||
api_versions.APIVersion('2.53'))
|
||||
for s in svs:
|
||||
self.assertIsInstance(s, self._get_service_type())
|
||||
self.assertEqual('nova-compute', s.binary)
|
||||
self.assertEqual('host1', s.host)
|
||||
if expect_uuid_id:
|
||||
stringified = '<Service: %s>' % s.id
|
||||
else:
|
||||
stringified = '<Service: %s>' % s.binary
|
||||
self.assertEqual(stringified, str(s))
|
||||
self.assertEqual('<Service: %s>' % s.id, str(s))
|
||||
|
||||
def test_list_services_with_hostname(self):
|
||||
svs = self.cs.services.list(host='host2')
|
||||
|
@@ -20,15 +20,10 @@ from six.moves import urllib
|
||||
|
||||
from novaclient import api_versions
|
||||
from novaclient import base
|
||||
from novaclient import utils
|
||||
|
||||
|
||||
class Service(base.Resource):
|
||||
def __repr__(self):
|
||||
# If the id is int-like, then represent the service using it's binary
|
||||
# name, otherwise use the UUID ID.
|
||||
if utils.is_integer_like(self.id):
|
||||
return "<Service: %s>" % self.binary
|
||||
return "<Service: %s>" % self.id
|
||||
|
||||
def _add_details(self, info):
|
||||
|
Reference in New Issue
Block a user