From: Zane Bitter Date: Mon, 17 Jun 2013 10:24:49 +0000 (+0200) Subject: Use physical resource names with a short_id X-Git-Tag: 2014.1~484 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9e2ecf756815d69e5b7fe851f4c38fa4a23e9661;p=openstack-build%2Fheat-build.git Use physical resource names with a short_id The short_id is a random, but stable, 12-character alphanumeric ID. This will allow two resources of the same name to exist concurrently. That is necessary for resources to be replaced during an update without interruption. Change-Id: If32904a47c6f8fb651e317ce91f2a04f6eadcc0b --- diff --git a/heat/engine/resource.py b/heat/engine/resource.py index cc5f560f..3c3b1fd6 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -21,6 +21,7 @@ from heat.common import exception from heat.openstack.common import excutils from heat.db import api as db_api from heat.common import identifier +from heat.common import short_id from heat.engine import timestamp from heat.engine.properties import Properties @@ -397,7 +398,11 @@ class Resource(object): self.state_set(self.UPDATE_COMPLETE) def physical_resource_name(self): - return '%s-%s' % (self.stack.name, self.name) + assert self.id is not None + + return '%s-%s-%s' % (self.stack.name, + self.name, + short_id.get_id(self.id)) def validate(self): logger.info('Validating %s' % str(self)) diff --git a/heat/tests/utils.py b/heat/tests/utils.py index 85d6791f..396f5490 100644 --- a/heat/tests/utils.py +++ b/heat/tests/utils.py @@ -75,10 +75,23 @@ class PhysName(object): self.resource_name = resource_name def __eq__(self, physical_name): - return physical_name == repr(self) + try: + stack, res, short_id = str(physical_name).rsplit('-', 2) + except ValueError: + return False + + if self.stack_name != stack or self.resource_name != res: + return False + + if len(short_id) != 12: + return False + + return True def __ne__(self, physical_name): return not self.__eq__(physical_name) def __repr__(self): - return '%s-%s' % (self.stack_name, self.resource_name) + return '%s-%s-%s' % (self.stack_name, + self.resource_name, + 'x' * 12)