]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix the conversion from instance to resource name
authorAngus Salkeld <asalkeld@redhat.com>
Tue, 5 Jun 2012 00:36:21 +0000 (10:36 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Tue, 5 Jun 2012 00:36:21 +0000 (10:36 +1000)
Change-Id: Iaca10eb5468bd7b64b6a66f87fc6f7066053cb27
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
heat/engine/instance.py

index f0935b3ef0f6dd386b3404323c25a5eb927a43f8..e5da25a70b756c28657412d73d24a77efbfaf55e 100644 (file)
@@ -25,7 +25,7 @@ from novaclient.exceptions import NotFound
 from heat.engine.resources import Resource
 from heat.common import exception
 
-logger = logging.getLogger(__file__)
+logger = logging.getLogger('heat.engine.instance')
 # If ../heat/__init__.py exists, add ../ to Python search path, so that
 # it will override what happens to be installed in /usr/(local/)lib/python...
 possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
@@ -64,9 +64,21 @@ class Restarter(Resource):
         self.state_set(self.DELETE_COMPLETE)
 
     def alarm(self):
-        logger.notice('%s Alarm, restarting resource: %s' %
-                      (self.name, self.properties['InstanceId']))
-        self.stack.restart_resource(self.properties['InstanceId'])
+        self.calculate_properties()
+        victim = None
+        for rname, r in self.stack.resources.items():
+            if r.instance_id == self.properties['InstanceId']:
+                victim = r
+                break
+
+        if victim is None:
+            logger.info('%s Alarm, can not find instance %s' %
+                    (self.name, self.properties['InstanceId']))
+            return
+
+        logger.info('%s Alarm, restarting resource: %s' %
+                    (self.name, victim.name))
+        self.stack.restart_resource(victim.name)
 
 
 class Instance(Resource):