diff options
author | Lingxian Kong <anlin.kong@gmail.com> | 2020-06-03 11:21:12 +1200 |
---|---|---|
committer | Lingxian Kong <anlin.kong@gmail.com> | 2020-06-03 15:23:55 +1200 |
commit | 99126428cef64e5b985c66903d3c8444beed0f91 (patch) | |
tree | b28fd4cac92e49d067b26680d4e1c27e1206ef36 /troveclient/osc/v1/database_instances.py | |
parent | e2bf7cff227eb464550aac1f94b504265c5ed26a (diff) | |
download | python-troveclient-99126428cef64e5b985c66903d3c8444beed0f91.tar.gz |
Support role for listing instances4.0.0
Change-Id: Ia3e8d5d65bc134f3c7bc62ca9c170018be54660c
Diffstat (limited to 'troveclient/osc/v1/database_instances.py')
-rw-r--r-- | troveclient/osc/v1/database_instances.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/troveclient/osc/v1/database_instances.py b/troveclient/osc/v1/database_instances.py index 9eecb18..f363cb1 100644 --- a/troveclient/osc/v1/database_instances.py +++ b/troveclient/osc/v1/database_instances.py @@ -34,16 +34,24 @@ def set_attributes_for_print(instances): else: setattr(instance, 'size', '-') + if hasattr(instance, 'ip'): + addresses = ', '.join(instance.ip) + setattr(instance, 'addresses', addresses) + + # If 'replica_of' not in instance, the client will invoke a GET + # instance request to API. + if hasattr(instance, 'replica_of'): + setattr(instance, 'role', 'replica') + + if hasattr(instance, 'replicas'): + setattr(instance, 'role', 'master') + if hasattr(instance, 'datastore'): if instance.datastore.get('version'): setattr(instance, 'datastore_version', instance.datastore['version']) setattr(instance, 'datastore', instance.datastore['type']) - if hasattr(instance, 'ip'): - addresses = ', '.join(instance.ip) - setattr(instance, 'addresses', addresses) - return instances @@ -82,10 +90,10 @@ def set_attributes_for_print_detail(instance): class ListDatabaseInstances(command.Lister): _description = _("List database instances") columns = ['ID', 'Name', 'Datastore', 'Datastore Version', 'Status', - 'Addresses', 'Flavor ID', 'Size', 'Region'] + 'Addresses', 'Flavor ID', 'Size', 'Region', 'Role'] admin_columns = [ 'ID', 'Name', 'Tenant ID', 'Datastore', 'Datastore Version', 'Status', - 'Addresses', 'Flavor ID', 'Size' + 'Addresses', 'Flavor ID', 'Size', 'Role' ] def get_parser(self, prog_name): |