Merge "Make create_inventory() handle name change"

This commit is contained in:
Jenkins 2016-06-09 20:27:00 +00:00 committed by Gerrit Code Review
commit e092ca6716
2 changed files with 6 additions and 7 deletions

View File

@ -326,13 +326,8 @@ class ComputeNode(base.NovaPersistentObject, base.NovaObject):
except db_exc.DBDuplicateEntry:
rp = objects.ResourceProvider.get_by_uuid(self._context, self.uuid)
if rp.name != rp_name:
# FIXME(danms): We probably need a .save() operation on RP
# so that we can update this
LOG.warning(_LW('Compute node %(uuid)s changed name '
'from %(old)s to %(new)s'),
{'uuid': self.uuid,
'old': rp.name,
'new': rp_name})
rp.name = rp_name
rp.save()
return rp

View File

@ -65,3 +65,7 @@ class ComputeNodeTestCase(test.TestCase):
rp = self.cn._ensure_resource_provider()
self.assertEqual('compute-%s-%s' % ('foo', self.cn.uuid),
rp.name)
self.cn.host = 'bar'
rp = self.cn._ensure_resource_provider()
self.assertEqual('compute-%s-%s' % ('bar', self.cn.uuid),
rp.name)