From 2f1668540331beb7a586919ec5f32b8d6b3881dd Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 26 Jul 2017 12:14:54 -0400 Subject: [PATCH] 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 --- novaclient/tests/unit/v2/test_services.py | 9 +-------- novaclient/v2/services.py | 5 ----- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/novaclient/tests/unit/v2/test_services.py b/novaclient/tests/unit/v2/test_services.py index 0c0434afd..ddc75eeb1 100644 --- a/novaclient/tests/unit/v2/test_services.py +++ b/novaclient/tests/unit/v2/test_services.py @@ -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 = '' % s.id - else: - stringified = '' % s.binary - self.assertEqual(stringified, str(s)) + self.assertEqual('' % s.id, str(s)) def test_list_services_with_hostname(self): svs = self.cs.services.list(host='host2') diff --git a/novaclient/v2/services.py b/novaclient/v2/services.py index 3fe877d32..f3d1255dc 100644 --- a/novaclient/v2/services.py +++ b/novaclient/v2/services.py @@ -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 "" % self.binary return "" % self.id def _add_details(self, info):