summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2017-07-26 12:14:54 -0400
committerMatt Riedemann <mriedem.os@gmail.com>2017-07-26 12:14:54 -0400
commit2f1668540331beb7a586919ec5f32b8d6b3881dd (patch)
tree0f845880ac71e6cc813a32c663ceaaf2533e2144
parent5745beae5c456aafef82ab7af94b452875409760 (diff)
downloadpython-novaclient-2f1668540331beb7a586919ec5f32b8d6b3881dd.tar.gz
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
-rw-r--r--novaclient/tests/unit/v2/test_services.py9
-rw-r--r--novaclient/v2/services.py5
2 files changed, 1 insertions, 13 deletions
diff --git a/novaclient/tests/unit/v2/test_services.py b/novaclient/tests/unit/v2/test_services.py
index 0c0434af..ddc75eeb 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 = '<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')
diff --git a/novaclient/v2/services.py b/novaclient/v2/services.py
index 3fe877d3..f3d1255d 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 "<Service: %s>" % self.binary
return "<Service: %s>" % self.id
def _add_details(self, info):