Exemple #1
0
    def __prepare(self):
        self.log.debug("initiating preparation")

        # create the spool directory
        self.__spool = self.__createSpool()

        # create the instance
        self.__inst = InstanceManager.getInstance().newInstance(self.__spool)
        self.__inst.task = self

        from xbe.xbed.task_activities import SetUpActivity, AcquireResourceActivity
        from xbe.util.activity import ComplexActivity, ThreadedActivity

        mac_pool = XBEDaemon.getInstance().macAddresses
        jail_package = XBEDaemon.getInstance().opts.jail_package
        mac_acquirer = ThreadedActivity(
            AcquireResourceActivity(mac_pool))
        setup_activity = ThreadedActivity(
            SetUpActivity(self.__spool, jail_package), (self.__jsdl_doc, self.__activity_logs["stage-in"]))

        complex_activity = ComplexActivity([setup_activity, mac_acquirer])
        self.mgr.registerActivity(self, complex_activity,
                                  on_finish=self._cb_stage_in_succeed,
                                  on_fail=self._eb_stage_in_failed,
                                  on_abort=None)
Exemple #2
0
 def do_InstanceAlive(self, xml, *a, **kw):
     msg = message.MessageBuilder.from_xml(xml.getroottree())
     inst_id = msg.inst_id()
     inst = InstanceManager.getInstance().lookupByUUID(msg.inst_id())
     if inst is not None:
         inst.update_alive()
     else:
         log.warn("got alive message from suspicious source")
Exemple #3
0
	  def do_life_sign(self, life_sign):
		  self.log.debug("instance %s is alive", self._instanceID)
		  inst = InstanceManager.getInstance().lookupByUUID(self._instanceID)
		  if inst is not None:
			  inst.life_sign(self, life_sign)
		  else:
			  self.log.warn("unknown instance: %s", self._instanceID)
			  self.requestShutdown(None, None)
Exemple #4
0
    def do_InstanceAvailable(self, xml, *args, **kw):
        inst_avail = message.MessageBuilder.from_xml(xml.getroottree())
        inst_id = inst_avail.inst_id()

        inst = InstanceManager.getInstance().lookupByUUID(inst_id)
        if inst is not None:
            inst.available(self)
        else:
            log.warn("got available message from suspicious source")
Exemple #5
0
 def do_ExecutionFailed(self, xml, *a, **kw):
     msg = message.MessageBuilder.from_xml(xml.getroottree())
     inst_id = msg.inst_id()
     inst = InstanceManager.getInstance().lookupByUUID(inst_id)
     if inst is not None:
         log.debug("execution on instance %s failed: %s" % (inst_id, msg.reason()))
         try:
             inst.task.signalExecutionFailed(Exception("execution failed", msg))
         except Exception, e:
             log.warn("could not signal execution failure: %s" % e)
Exemple #6
0
 def do_InstanceShuttingDown(self, xml, *a, **kw):
     msg = message.MessageBuilder.from_xml(xml.getroottree())
     inst_id = msg.inst_id()
     inst = InstanceManager.getInstance().lookupByUUID(inst_id)
     if inst is not None:
         log.info("instance is shutting down...")
         log.debug("execution on instance %s finished" % inst_id)
         try:
             inst.task.signalExecutionEnd(0)
         except Exception, e:
             log.warn("could not signal execution end: %s" % e)
Exemple #7
0
 def do_ExecutionFinished(self, xml, *args, **kw):
     msg = message.MessageBuilder.from_xml(xml.getroottree())
     inst_id = msg.inst_id()
     exitcode = msg.exitcode()
     inst = InstanceManager.getInstance().lookupByUUID(inst_id)
     if inst is not None:
         log.debug("execution on instance %s finished" % inst_id)
         try:
             inst.task.signalExecutionEnd(exitcode)
         except Exception, e:
             log.warn("could not signal execution end: %s" % e)
Exemple #8
0
	  def do_failed(self, failed):
		  self.log.info("execution on instance has failed: %d", failed.reason)
		  # send a failed ack to the instance
		  ack = xbemsg.XbeMessage()
		  ack.header.conversation_id = self._conv_id
		  ack.failed_ack.task = failed.task

		  inst = InstanceManager.getInstance().lookupByUUID(self._instanceID)
		  if inst is not None:
			  inst.task.signalExecutionFailed(failed.reason)
		  return ack
Exemple #9
0
 def __delete_instance(self, *a, **kw):
     InstanceManager.getInstance().removeInstance(self.__inst)
     del self.__inst.task
     del self.__inst
Exemple #10
0
	  def do_status(self, status):
		  self.log.info("received status information: %s", status)

		  inst = InstanceManager.getInstance().lookupByUUID(self._instanceID)
		  if inst is not None:
			  inst.task.signalStatus(status)