From d5e49cb8579e65a2ab6711c8942d8a65d6baf75a Mon Sep 17 00:00:00 2001 From: Dan Wendlandt Date: Tue, 11 Sep 2012 01:26:57 -0700 Subject: [PATCH] make subnets attribute of a network read-only bug 1046173 writing to the subnets attribute is not supported, so rather than making it looks like we accept it but ignoring it, we should explicitly reject requests to specify it on network create/update. Change-Id: I5b6f0f35794c9d5606befb97a89c6c6c97ee3dbf --- quantum/api/v2/attributes.py | 2 +- quantum/tests/unit/test_api_v2.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/quantum/api/v2/attributes.py b/quantum/api/v2/attributes.py index 0aee016097..1425375faf 100644 --- a/quantum/api/v2/attributes.py +++ b/quantum/api/v2/attributes.py @@ -174,7 +174,7 @@ RESOURCE_ATTRIBUTE_MAP = { 'is_visible': True}, 'name': {'allow_post': True, 'allow_put': True, 'default': '', 'is_visible': True}, - 'subnets': {'allow_post': True, 'allow_put': True, + 'subnets': {'allow_post': False, 'allow_put': False, 'default': [], 'is_visible': True}, 'admin_state_up': {'allow_post': True, 'allow_put': True, diff --git a/quantum/tests/unit/test_api_v2.py b/quantum/tests/unit/test_api_v2.py index 5fcc0b818f..af23f157e5 100644 --- a/quantum/tests/unit/test_api_v2.py +++ b/quantum/tests/unit/test_api_v2.py @@ -361,8 +361,7 @@ class JSONV2TestCase(APIv2TestBase): net_id = _uuid() initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid()}} full_input = {'network': {'admin_state_up': True, - 'shared': False, - 'subnets': []}} + 'shared': False}} full_input['network'].update(initial_input['network']) return_value = {'id': net_id, 'status': "ACTIVE"} @@ -394,7 +393,7 @@ class JSONV2TestCase(APIv2TestBase): env = {'quantum.context': context.Context('', tenant_id)} # tenant_id should be fetched from env initial_input = {'network': {'name': 'net1'}} - full_input = {'network': {'admin_state_up': True, 'subnets': [], + full_input = {'network': {'admin_state_up': True, 'shared': False, 'tenant_id': tenant_id}} full_input['network'].update(initial_input['network']) @@ -806,8 +805,7 @@ class ExtensionTestCase(unittest.TestCase): net_id = _uuid() initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid(), 'v2attrs:something_else': "abc"}} - data = {'network': {'admin_state_up': True, 'subnets': [], - 'shared': False}} + data = {'network': {'admin_state_up': True, 'shared': False}} data['network'].update(initial_input['network']) return_value = {'subnets': [], 'status': "ACTIVE",