Project update to change enabled only when provided
The project update call considers enabled=True as the default, causing the project to always become enabled unless enabled=False is passed explicitly. This patch removes that default and only touches the enable field when it is explicitly provided as enabled=False or enabled=True. Closes-Bug: #2001080 Change-Id: I0a3b926b42be0321d06ebc370e4f51eba4150a50
This commit is contained in:
parent
baaf415567
commit
f4668b7c6f
10
releasenotes/notes/bug-2001080-de52ead3c5466792.yaml
Normal file
10
releasenotes/notes/bug-2001080-de52ead3c5466792.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
prelude: >
|
||||
Fixed a bug where a project was always enabled upon update, unless
|
||||
``enabled=False`` is passed explicitly.
|
||||
fixes:
|
||||
- |
|
||||
[`bug 2001080 <https://storyboard.openstack.org/#!/story/2001080>`_]
|
||||
Project update will only update the enabled field of projects when
|
||||
``enabled=True`` or ``enabled=False`` is passed explicitly. The previous
|
||||
behavior had ``enabled=True`` as the default.
|
@ -893,7 +893,7 @@ class OpenStackCloud(
|
||||
domain_id=domain_id)
|
||||
|
||||
@_utils.valid_kwargs('description')
|
||||
def update_project(self, name_or_id, enabled=True, domain_id=None,
|
||||
def update_project(self, name_or_id, enabled=None, domain_id=None,
|
||||
**kwargs):
|
||||
with _utils.shade_exceptions(
|
||||
"Error in updating project {project}".format(
|
||||
@ -902,12 +902,10 @@ class OpenStackCloud(
|
||||
if not proj:
|
||||
raise OpenStackCloudException(
|
||||
"Project %s not found." % name_or_id)
|
||||
|
||||
if enabled is not None:
|
||||
kwargs.update({'enabled': enabled})
|
||||
# NOTE(samueldmq): Current code only allow updates of description
|
||||
# or enabled fields.
|
||||
# FIXME(samueldmq): enable=True is the default, meaning it will
|
||||
# enable a disabled project if you simply update other fields
|
||||
if self.cloud_config.get_api_version('identity') == '3':
|
||||
data = self._identity_client.patch(
|
||||
'/projects/' + proj['id'], json={'project': kwargs})
|
||||
|
@ -67,18 +67,32 @@ class TestProject(base.KeystoneBaseFunctionalTestCase):
|
||||
params = {
|
||||
'name': project_name,
|
||||
'description': 'test_update_project',
|
||||
'enabled': True
|
||||
}
|
||||
if self.identity_version == '3':
|
||||
params['domain_id'] = \
|
||||
self.operator_cloud.get_domain('default')['id']
|
||||
|
||||
project = self.operator_cloud.create_project(**params)
|
||||
updated_project = self.operator_cloud.update_project(project_name,
|
||||
description='new')
|
||||
updated_project = self.operator_cloud.update_project(
|
||||
project_name, enabled=False, description='new')
|
||||
self.assertIsNotNone(updated_project)
|
||||
self.assertEqual(project['id'], updated_project['id'])
|
||||
self.assertEqual(project['name'], updated_project['name'])
|
||||
self.assertEqual(updated_project['description'], 'new')
|
||||
self.assertTrue(project['enabled'])
|
||||
self.assertFalse(updated_project['enabled'])
|
||||
|
||||
# Revert the description and verify the project is still disabled
|
||||
updated_project = self.operator_cloud.update_project(
|
||||
project_name, description=params['description'])
|
||||
self.assertIsNotNone(updated_project)
|
||||
self.assertEqual(project['id'], updated_project['id'])
|
||||
self.assertEqual(project['name'], updated_project['name'])
|
||||
self.assertEqual(project['description'],
|
||||
updated_project['description'])
|
||||
self.assertTrue(project['enabled'])
|
||||
self.assertFalse(updated_project['enabled'])
|
||||
|
||||
def test_delete_project(self):
|
||||
project_name = self.new_project_name + '_delete'
|
||||
|
Loading…
Reference in New Issue
Block a user