diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-01-22 19:27:34 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-01-22 19:27:34 +0000 |
commit | 9c203d2bb7d5435f2c9b5924e428d4eb644730ac (patch) | |
tree | 041b972170af9abb1f54afc3f0015dabaa2f9979 /neutronclient/neutron | |
parent | 4f731c2fb520e997712ecde3cbad11459f5d4f37 (diff) | |
parent | a97f28f18729a55f3cdc0c7c21d6a183d6b01a1c (diff) | |
download | python-neutronclient-9c203d2bb7d5435f2c9b5924e428d4eb644730ac.tar.gz |
Merge "Add code for load balancer status tree"
Diffstat (limited to 'neutronclient/neutron')
-rw-r--r-- | neutronclient/neutron/v2_0/lb/v2/loadbalancer.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py b/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py index bfa4f9c..5a60eb4 100644 --- a/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py +++ b/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. # +from oslo_serialization import jsonutils from neutronclient._i18n import _ from neutronclient.neutron import v2_0 as neutronV20 @@ -128,3 +129,31 @@ class RetrieveLoadBalancerStats(neutronV20.ShowCommand): # here covert the data dict to the 1-1 vector format below: # [(field1, field2, field3, ...), (value1, value2, value3, ...)] return list(zip(*sorted(stats.items()))) + + +class RetrieveLoadBalancerStatus(neutronV20.NeutronCommand): + """Retrieve status for a given loadbalancer. + + The only output is a formatted JSON tree, and the table format + does not support this type of data. + """ + resource = 'loadbalancer' + + def get_parser(self, prog_name): + parser = super(RetrieveLoadBalancerStatus, self).get_parser(prog_name) + parser.add_argument( + self.resource, metavar=self.resource.upper(), + help=_('ID or name of %s to show.') % self.resource) + + return parser + + def take_action(self, parsed_args): + self.log.debug('run(%s)' % parsed_args) + neutron_client = self.get_client() + lb_id = neutronV20.find_resourceid_by_name_or_id( + neutron_client, self.resource, parsed_args.loadbalancer) + params = {} + data = neutron_client.retrieve_loadbalancer_status(lb_id, **params) + res = data['statuses'] + if 'statuses' in data: + print(jsonutils.dumps(res, indent=4)) |