Keystone has gone exactly the opposite way and uses what looks like the entire dict. I think that's way overkill. If you want the detail, process the list:
I guess the question I would ask is are you going to use the repr for decision making via the API, and the answer I lean toward is no. In that case, does the addition of a hostname in __repr__ provide any value over something like this in your code which doesn't rely on a magic method directly, rather uses the API as intended:
[str(s['name'] + "@" + s['host'] for s in c.services.list()]
I have a patch submitted that just uses the binary field on https://bugs.launchpad.net/python-cinderclient/+bug/1315606. I'm curious why this got a new bug number. I'm relatively new to the process, so if anyone could help me understand, I would appreciate. Should one of them be marked as a duplicate?
My tendency would be to keep the __repr__ simple, and just use the name. This aligns with the pattern used by nova:
In [64]: c.services.list()
Out[64]:
[<Service: nova-consoleauth>,
<Service: nova-conductor>,
<Service: nova-scheduler>,
<Service: nova-compute>,
<Service: nova-cert>,
<Service: nova-console>,
<Service: nova-compute>]
Keystone has gone exactly the opposite way and uses what looks like the entire dict. I think that's way overkill. If you want the detail, process the list:
In [69]: c.services.list() da492070941db2f 160f', u'name': u'glance'}>, 0c69a191f9610d0 ef30', u'name': u'ceilometer'}>, 13e9588f1a33f61 a11d', u'name': u'cinder'}>, 214980bf8aa8bc6 6e5a', u'name': u'nova_ec2'}>, 07f8e32b80847e3 bbff', u'name': u'swift'}>, f11b6bb648738ee e5c1', u'name': u'neutron'}>, 974af0b61cb1bed 9e57', u'name': u'swift_s3'}>, c9e979e73aa99c9 fdf6', u'name': u'heat'}>, 60fb7e988803062 271e', u'name': u'keystone'}>, ac1bed2aa1072aa 6e42', u'name': u'nova'}>]
Out[69]:
[<Service {u'type': u'image', u'description': u'Openstack Image Service', u'enabled': True, u'id': u'0b0fe44b60564
<Service {u'type': u'metering', u'description': u'Openstack Metering Service', u'enabled': True, u'id': u'3417cbf8ca7c4
<Service {u'type': u'volume', u'description': u'Cinder Service', u'enabled': True, u'id': u'3833e9efab5d4
<Service {u'type': u'ec2', u'description': u'EC2 Service', u'enabled': True, u'id': u'39130798096b4
<Service {u'type': u'object-store', u'description': u'Openstack Object-Store Service', u'enabled': True, u'id': u'6fc024ea43174
<Service {u'type': u'network', u'description': u'Neutron Networking Service', u'enabled': True, u'id': u'7b8eb446fff84
<Service {u'type': u's3', u'description': u'Openstack S3 Service', u'enabled': True, u'id': u'99e6ab7404a34
<Service {u'type': u'orchestration', u'description': u'Openstack Orchestration Service', u'enabled': True, u'id': u'c8d574752dfa4
<Service {u'type': u'identity', u'description': u'OpenStack Identity Service', u'enabled': True, u'id': u'd931233edecd4
<Service {u'type': u'compute', u'description': u'Openstack Compute Service', u'enabled': True, u'id': u'efb8e2617e8c4
I guess the question I would ask is are you going to use the repr for decision making via the API, and the answer I lean toward is no. In that case, does the addition of a hostname in __repr__ provide any value over something like this in your code which doesn't rely on a magic method directly, rather uses the API as intended:
[str(s['name'] + "@" + s['host'] for s in c.services.list()]
I have a patch submitted that just uses the binary field on https:/ /bugs.launchpad .net/python- cinderclient/ +bug/1315606. I'm curious why this got a new bug number. I'm relatively new to the process, so if anyone could help me understand, I would appreciate. Should one of them be marked as a duplicate?