From 2dbe21382cf65d26b18b4d8c30e5cfdeefa7cedb Mon Sep 17 00:00:00 2001 From: Sylvain Afchain Date: Thu, 30 Jan 2014 12:36:05 +0100 Subject: [PATCH] Add shared parameter for metering labels With this patch metering labels can be set as shared so that the rules associated with this label will be applied to all routers for all tenants. Partially implements blueprint l3-metering-mgnt-ext Change-Id: I23f9fb9cf17c7a20069616bb1c4ae19a5dc55d68 --- neutronclient/neutron/v2_0/metering.py | 9 ++++++++- neutronclient/tests/unit/test_cli20_metering.py | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/neutronclient/neutron/v2_0/metering.py b/neutronclient/neutron/v2_0/metering.py index 9744ce06e..66fa29f5e 100644 --- a/neutronclient/neutron/v2_0/metering.py +++ b/neutronclient/neutron/v2_0/metering.py @@ -25,7 +25,7 @@ class ListMeteringLabel(neutronv20.ListCommand): resource = 'metering_label' log = logging.getLogger(__name__ + '.ListMeteringLabel') - list_columns = ['id', 'name', 'description'] + list_columns = ['id', 'name', 'description', 'shared'] pagination_support = True sorting_support = True @@ -51,6 +51,10 @@ class CreateMeteringLabel(neutronv20.CreateCommand): parser.add_argument( '--description', help=_('Description of metering label to create')) + parser.add_argument( + '--shared', + action='store_true', + help=_('Set the label as shared')) def args2body(self, parsed_args): body = {'metering_label': { @@ -61,6 +65,9 @@ class CreateMeteringLabel(neutronv20.CreateCommand): if parsed_args.description: body['metering_label'].update( {'description': parsed_args.description}) + if parsed_args.shared: + body['metering_label'].update( + {'shared': True}) return body diff --git a/neutronclient/tests/unit/test_cli20_metering.py b/neutronclient/tests/unit/test_cli20_metering.py index 12622f9c0..995c29b6f 100644 --- a/neutronclient/tests/unit/test_cli20_metering.py +++ b/neutronclient/tests/unit/test_cli20_metering.py @@ -29,9 +29,9 @@ class CLITestV20MeteringJSON(test_cli20.CLITestV20Base): name = 'my label' myid = 'myid' description = 'my description' - args = [name, '--description', description] - position_names = ['name', 'description'] - position_values = [name, description] + args = [name, '--description', description, '--shared'] + position_names = ['name', 'description', 'shared'] + position_values = [name, description, True] self._test_create_resource(resource, cmd, name, myid, args, position_names, position_values)