template_rm.py++
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Sun, 21 Dec 2014 12:49:19 +0000 (13:49 +0100)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Sun, 21 Dec 2014 12:49:19 +0000 (13:49 +0100)
doc/templates/template_rm.py

index 6eb0222..b37feb8 100644 (file)
@@ -134,6 +134,12 @@ class RMClass(ResourceManager):
 
         if other_rm.state < ResourceState.READY:
             self.ec.schedule(self.reschedule_delay, self.deploy)
+
+        elif other_rm.state == ResourceState.FAILED:
+            msg = "Failed to deploy resource"
+            self.error(msg)
+            raise RuntimeError(msg)
+
         else:
             self.do_discover()
             self.do_provision()
@@ -169,6 +175,13 @@ class RMClass(ResourceManager):
     def state(self):
         """ 
         Returns the state of the RM.
+
+        The state method should never raise an exception, instead if an
+        error occurs it should log the error and invoke the self.do_fail
+        method as follows:
+
+        self.error(msg, out, err)
+        self.do_fail()
         """
 
         return super(RMClass, self).state