From 11157b812d39904a1aee70ed47a2931b8da3f20c Mon Sep 17 00:00:00 2001 From: Eugene Nikanorov Date: Thu, 25 Jul 2013 15:53:48 +0400 Subject: [PATCH] Add provider attribute to lb-pool-create command Also add formatter for the provider attribute, so if provider is empty or absent, it displayed as 'N/A' Change-Id: I5e07942e83c48eff1c04c7d00bd9c98658dcfb58 --- neutronclient/neutron/v2_0/lb/pool.py | 12 ++++++++++-- neutronclient/tests/unit/lb/test_cli20_pool.py | 8 +++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/neutronclient/neutron/v2_0/lb/pool.py b/neutronclient/neutron/v2_0/lb/pool.py index 49b6fe7be..13ff7a395 100644 --- a/neutronclient/neutron/v2_0/lb/pool.py +++ b/neutronclient/neutron/v2_0/lb/pool.py @@ -22,13 +22,18 @@ import logging from neutronclient.neutron import v2_0 as neutronV20 +def _format_provider(pool): + return pool.get('provider') or 'N/A' + + class ListPool(neutronV20.ListCommand): """List pools that belong to a given tenant.""" resource = 'pool' log = logging.getLogger(__name__ + '.ListPool') - list_columns = ['id', 'name', 'lb_method', 'protocol', + list_columns = ['id', 'name', 'provider', 'lb_method', 'protocol', 'admin_state_up', 'status'] + _formatters = {'provider': _format_provider} pagination_support = True sorting_support = True @@ -73,6 +78,9 @@ class CreatePool(neutronV20.CreateCommand): '--subnet-id', metavar='SUBNET', required=True, help='the subnet on which the members of the pool will be located') + parser.add_argument( + '--provider', + help='provider name of loadbalancer service') def args2body(self, parsed_args): _subnet_id = neutronV20.find_resourceid_by_name_or_id( @@ -85,7 +93,7 @@ class CreatePool(neutronV20.CreateCommand): } neutronV20.update_dict(parsed_args, body[self.resource], ['description', 'lb_method', 'name', - 'protocol', 'tenant_id']) + 'protocol', 'tenant_id', 'provider']) return body diff --git a/neutronclient/tests/unit/lb/test_cli20_pool.py b/neutronclient/tests/unit/lb/test_cli20_pool.py index 7bc64da46..1c0203d71 100644 --- a/neutronclient/tests/unit/lb/test_cli20_pool.py +++ b/neutronclient/tests/unit/lb/test_cli20_pool.py @@ -60,17 +60,19 @@ class CLITestV20LbPoolJSON(test_cli20.CLITestV20Base): subnet_id = 'subnet-id' tenant_id = 'my-tenant' my_id = 'my-id' + provider = 'lbaas' args = ['--admin-state-down', '--description', description, '--lb-method', lb_method, '--name', name, '--protocol', protocol, '--subnet-id', subnet_id, - '--tenant-id', tenant_id] + '--tenant-id', tenant_id, + '--provider', provider] position_names = ['admin_state_up', 'description', 'lb_method', 'name', - 'protocol', 'subnet_id', 'tenant_id'] + 'protocol', 'subnet_id', 'tenant_id', 'provider'] position_values = [False, description, lb_method, name, - protocol, subnet_id, tenant_id] + protocol, subnet_id, tenant_id, provider] self._test_create_resource(resource, cmd, name, my_id, args, position_names, position_values)