Merge "Forbid removing portgroup mode"

This commit is contained in:
Jenkins 2016-12-22 00:11:35 +00:00 committed by Gerrit Code Review
commit fb2120e723
3 changed files with 16 additions and 3 deletions

View File

@ -188,6 +188,7 @@ class Portgroup(base.APIBase):
class PortgroupPatchType(types.JsonPatchType): class PortgroupPatchType(types.JsonPatchType):
_api_base = Portgroup _api_base = Portgroup
_extra_non_removable_attrs = {'/mode'}
@staticmethod @staticmethod
def internal_attrs(): def internal_attrs():

View File

@ -852,10 +852,21 @@ class TestPatch(test_api_base.BaseApiTest):
def test_update_portgroup_mode_properties_bad_api_version(self, mock_upd): def test_update_portgroup_mode_properties_bad_api_version(self, mock_upd):
self._test_update_portgroup_mode_properties_bad_api_version( self._test_update_portgroup_mode_properties_bad_api_version(
[{'path': '/mode', 'op': 'remove'}], mock_upd) [{'path': '/mode', 'op': 'add', 'value': '802.3ad'}], mock_upd)
self._test_update_portgroup_mode_properties_bad_api_version( self._test_update_portgroup_mode_properties_bad_api_version(
[{'path': '/properties/abc', 'op': 'add', 'value': 123}], mock_upd) [{'path': '/properties/abc', 'op': 'add', 'value': 123}], mock_upd)
def test_remove_mode_not_allowed(self, mock_upd):
response = self.patch_json('/portgroups/%s' % self.portgroup.uuid,
[{'path': '/mode',
'op': 'remove'}],
expect_errors=True,
headers=self.headers)
self.assertEqual(http_client.BAD_REQUEST, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertTrue(response.json['error_message'])
self.assertFalse(mock_upd.called)
class TestPost(test_api_base.BaseApiTest): class TestPost(test_api_base.BaseApiTest):
headers = {api_base.Version.string: str(api_v1.MAX_VER)} headers = {api_base.Version.string: str(api_v1.MAX_VER)}

View File

@ -1,8 +1,9 @@
--- ---
features: features:
- Adds ``mode`` and ``properties`` fields in the portgroup object. Both of - Adds ``mode`` and ``properties`` fields in the portgroup object. Both of
them are optional and can be set from the API. They are available starting them are optional and can be set from the API, though it is forbidden to
with API microversion 1.26. If the ``mode`` field of a portgroup is not remove the ``mode`` from the portgroup. They are available starting with
API microversion 1.26. If the ``mode`` field of a portgroup is not
specified in a POST request, its value will be set to the value of the specified in a POST request, its value will be set to the value of the
configuration option ``[DEFAULT]default_portgroup_mode``. The configuration configuration option ``[DEFAULT]default_portgroup_mode``. The configuration
option ``[DEFAULT]default_portgroup_mode`` has a value of ``active-backup`` option ``[DEFAULT]default_portgroup_mode`` has a value of ``active-backup``