Don't update the name of keystone resources if name don't change
If the names of keystone resource no change when updating, do not to update them. Change-Id: I4ec6497fdd6859a0fc106538bbad4d299c66a26e Closes-Bug: #1522330
This commit is contained in:
parent
768839d5d5
commit
8b83e14d84
@ -111,7 +111,10 @@ class KeystoneEndpoint(resource.Resource):
|
||||
service = prop_diff.get(self.SERVICE)
|
||||
interface = prop_diff.get(self.INTERFACE)
|
||||
url = prop_diff.get(self.SERVICE_URL)
|
||||
name = prop_diff.get(self.NAME) or self.physical_resource_name()
|
||||
name = None
|
||||
# Don't update the name if no change
|
||||
if self.NAME in prop_diff:
|
||||
name = prop_diff[self.NAME] or self.physical_resource_name()
|
||||
enabled = prop_diff.get(self.ENABLED)
|
||||
|
||||
self.client().endpoints.update(
|
||||
|
@ -91,7 +91,11 @@ class KeystoneGroup(resource.Resource,
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if prop_diff:
|
||||
name = prop_diff.get(self.NAME) or self.physical_resource_name()
|
||||
name = None
|
||||
# Don't update the name if no change
|
||||
if self.NAME in prop_diff:
|
||||
name = prop_diff[self.NAME] or self.physical_resource_name()
|
||||
|
||||
description = prop_diff.get(self.DESCRIPTION)
|
||||
domain = (prop_diff.get(self.DOMAIN) or
|
||||
self._stored_properties_data.get(self.DOMAIN))
|
||||
|
@ -100,7 +100,11 @@ class KeystoneProject(resource.Resource):
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if prop_diff:
|
||||
name = prop_diff.get(self.NAME) or self.physical_resource_name()
|
||||
name = None
|
||||
# Don't update the name if no change
|
||||
if self.NAME in prop_diff:
|
||||
name = prop_diff[self.NAME] or self.physical_resource_name()
|
||||
|
||||
description = prop_diff.get(self.DESCRIPTION)
|
||||
enabled = prop_diff.get(self.ENABLED)
|
||||
domain = (prop_diff.get(self.DOMAIN) or
|
||||
|
@ -60,8 +60,10 @@ class KeystoneRole(resource.Resource):
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if prop_diff:
|
||||
name = prop_diff.get(self.NAME) or self.physical_resource_name()
|
||||
self.client().roles.update(role=self.resource_id, name=name)
|
||||
# Don't update the name if no change
|
||||
if self.NAME in prop_diff:
|
||||
name = prop_diff[self.NAME] or self.physical_resource_name()
|
||||
self.client().roles.update(role=self.resource_id, name=name)
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
|
@ -83,8 +83,10 @@ class KeystoneService(resource.Resource):
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if prop_diff:
|
||||
name = (prop_diff.get(self.NAME) or
|
||||
self.physical_resource_name())
|
||||
name = None
|
||||
# Don't update the name if no change
|
||||
if self.NAME in prop_diff:
|
||||
name = prop_diff[self.NAME] or self.physical_resource_name()
|
||||
description = prop_diff.get(self.DESCRIPTION)
|
||||
type = prop_diff.get(self.TYPE)
|
||||
enabled = prop_diff.get(self.ENABLED)
|
||||
|
@ -193,6 +193,26 @@ class KeystoneEndpointTest(common.HeatTestCase):
|
||||
enabled=None
|
||||
)
|
||||
|
||||
def test_endpoint_handle_update_only_enabled(self):
|
||||
rsrc = self._setup_endpoint_resource('test_endpoint_update_enabled')
|
||||
rsrc.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
|
||||
|
||||
prop_diff = {endpoint.KeystoneEndpoint.ENABLED: True}
|
||||
|
||||
rsrc.handle_update(json_snippet=None,
|
||||
tmpl_diff=None,
|
||||
prop_diff=prop_diff)
|
||||
|
||||
self.endpoints.update.assert_called_once_with(
|
||||
endpoint=rsrc.resource_id,
|
||||
region=None,
|
||||
interface=None,
|
||||
service=None,
|
||||
url=None,
|
||||
name=None,
|
||||
enabled=prop_diff[endpoint.KeystoneEndpoint.ENABLED]
|
||||
)
|
||||
|
||||
def test_resource_mapping(self):
|
||||
rsrc = self._setup_endpoint_resource('test_resource_mapping')
|
||||
mapping = endpoint.resource_mapping()
|
||||
|
@ -269,8 +269,6 @@ class KeystoneGroupTest(common.HeatTestCase):
|
||||
def test_group_handle_update_default(self):
|
||||
self.test_group.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
|
||||
self.test_group._stored_properties_data = dict(domain='default')
|
||||
self.test_group.physical_resource_name = mock.MagicMock()
|
||||
self.test_group.physical_resource_name.return_value = 'foo'
|
||||
|
||||
prop_diff = {group.KeystoneGroup.DESCRIPTION: 'Test Project updated'}
|
||||
|
||||
@ -282,7 +280,7 @@ class KeystoneGroupTest(common.HeatTestCase):
|
||||
# domain is set from stored properties used during creation.
|
||||
self.groups.update.assert_called_once_with(
|
||||
group=self.test_group.resource_id,
|
||||
name='foo',
|
||||
name=None,
|
||||
description=prop_diff[group.KeystoneGroup.DESCRIPTION],
|
||||
domain_id='default'
|
||||
)
|
||||
|
@ -317,8 +317,6 @@ class KeystoneProjectTest(common.HeatTestCase):
|
||||
def test_project_handle_update_default(self):
|
||||
self.test_project.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
|
||||
self.test_project._stored_properties_data = dict(domain='default')
|
||||
self.test_project.physical_resource_name = mock.MagicMock()
|
||||
self.test_project.physical_resource_name.return_value = 'foo'
|
||||
|
||||
prop_diff = {project.KeystoneProject.DESCRIPTION:
|
||||
'Test Project updated',
|
||||
@ -332,12 +330,29 @@ class KeystoneProjectTest(common.HeatTestCase):
|
||||
# domain is set from stored properties used during creation.
|
||||
self.projects.update.assert_called_once_with(
|
||||
project=self.test_project.resource_id,
|
||||
name='foo',
|
||||
name=None,
|
||||
description=prop_diff[project.KeystoneProject.DESCRIPTION],
|
||||
enabled=prop_diff[project.KeystoneProject.ENABLED],
|
||||
domain='default'
|
||||
)
|
||||
|
||||
def test_project_handle_update_only_enabled(self):
|
||||
self.test_project.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
|
||||
self.test_project._stored_properties_data = dict(domain='default')
|
||||
prop_diff = {project.KeystoneProject.ENABLED: False}
|
||||
|
||||
self.test_project.handle_update(json_snippet=None,
|
||||
tmpl_diff=None,
|
||||
prop_diff=prop_diff)
|
||||
|
||||
self.projects.update.assert_called_once_with(
|
||||
project=self.test_project.resource_id,
|
||||
name=None,
|
||||
description=None,
|
||||
enabled=prop_diff[project.KeystoneProject.ENABLED],
|
||||
domain='default'
|
||||
)
|
||||
|
||||
def test_show_resource(self):
|
||||
project = mock.Mock()
|
||||
project.to_dict.return_value = {'attr': 'val'}
|
||||
|
@ -178,6 +178,24 @@ class KeystoneServiceTest(common.HeatTestCase):
|
||||
enabled=None
|
||||
)
|
||||
|
||||
def test_service_handle_update_only_enabled(self):
|
||||
rsrc = self._setup_service_resource('test_update_enabled_only')
|
||||
rsrc.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
|
||||
|
||||
prop_diff = {service.KeystoneService.ENABLED: False}
|
||||
|
||||
rsrc.handle_update(json_snippet=None,
|
||||
tmpl_diff=None,
|
||||
prop_diff=prop_diff)
|
||||
|
||||
self.services.update.assert_called_once_with(
|
||||
service=rsrc.resource_id,
|
||||
name=None,
|
||||
description=None,
|
||||
type=None,
|
||||
enabled=prop_diff[service.KeystoneService.ENABLED]
|
||||
)
|
||||
|
||||
def test_resource_mapping(self):
|
||||
rsrc = self._setup_service_resource(
|
||||
'test_resource_mapping')
|
||||
|
Loading…
Reference in New Issue
Block a user