From 75401416dbe89fd232c61e0485cbc1b04ffaf163 Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Mon, 29 Dec 2014 17:34:05 +0800 Subject: [PATCH] Add 'shared' property for OS::Neutron::MeteringLabel Add 'shared' property for OS::Neutron::MeteringLabel. Change-Id: I942927b8308c952b5ffe421cf8c27da2a1b39531 Closes-Bug: #1406215 --- heat/engine/resources/neutron/metering.py | 20 +++++++++++++++----- heat/tests/test_neutron_metering.py | 13 +++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/heat/engine/resources/neutron/metering.py b/heat/engine/resources/neutron/metering.py index 956284ba4d..9d49e6a9f1 100644 --- a/heat/engine/resources/neutron/metering.py +++ b/heat/engine/resources/neutron/metering.py @@ -27,15 +27,15 @@ class MeteringLabel(neutron.NeutronResource): support_status = support.SupportStatus(version='2014.1') PROPERTIES = ( - NAME, DESCRIPTION, + NAME, DESCRIPTION, SHARED, ) = ( - 'name', 'description', + 'name', 'description', 'shared', ) ATTRIBUTES = ( - NAME_ATTR, DESCRIPTION_ATTR, + NAME_ATTR, DESCRIPTION_ATTR, SHARED_ATTR, ) = ( - 'name', 'description', + 'name', 'description', 'shared', ) properties_schema = { @@ -46,7 +46,14 @@ class MeteringLabel(neutron.NeutronResource): DESCRIPTION: properties.Schema( properties.Schema.STRING, _('Description of the metering label.'), - ) + ), + SHARED: properties.Schema( + properties.Schema.BOOLEAN, + _('Whether the metering label should be shared ' + 'across all tenants.'), + default=False, + support_status=support.SupportStatus(version='2015.1'), + ), } attributes_schema = { @@ -56,6 +63,9 @@ class MeteringLabel(neutron.NeutronResource): DESCRIPTION_ATTR: attributes.Schema( _('Description of the metering label.') ), + SHARED_ATTR: attributes.Schema( + _('Shared status of the metering label.') + ), } def handle_create(self): diff --git a/heat/tests/test_neutron_metering.py b/heat/tests/test_neutron_metering.py index b0127887dd..0a800e1365 100644 --- a/heat/tests/test_neutron_metering.py +++ b/heat/tests/test_neutron_metering.py @@ -33,7 +33,8 @@ metering_template = ''' "Type": "OS::Neutron::MeteringLabel", "Properties": { "name": "TestLabel", - "description": "Description of TestLabel" + "description": "Description of TestLabel", + "shared": True, } }, "rule": { @@ -69,7 +70,8 @@ class MeteringLabelTest(common.HeatTestCase): neutronclient.Client.create_metering_label({ 'metering_label': { 'name': 'TestLabel', - 'description': 'Description of TestLabel'} + 'description': 'Description of TestLabel', + 'shared': True} }).AndReturn({'metering_label': {'id': '1234'}}) snippet = template_format.parse(metering_template) @@ -89,7 +91,8 @@ class MeteringLabelTest(common.HeatTestCase): neutronclient.Client.create_metering_label({ 'metering_label': { 'name': 'TestLabel', - 'description': 'Description of TestLabel'} + 'description': 'Description of TestLabel', + 'shared': True} }).AndRaise(exceptions.NeutronClientException()) self.m.ReplayAll() @@ -150,12 +153,14 @@ class MeteringLabelTest(common.HeatTestCase): ).AndReturn( {'metering_label': {'name': 'TestLabel', - 'description': 'Description of TestLabel'}}) + 'description': 'Description of TestLabel', + 'shared': True}}) self.m.ReplayAll() scheduler.TaskRunner(rsrc.create)() self.assertEqual('TestLabel', rsrc.FnGetAtt('name')) self.assertEqual('Description of TestLabel', rsrc.FnGetAtt('description')) + self.assertEqual(True, rsrc.FnGetAtt('shared')) self.m.VerifyAll()