- if not ccnr or ccnr.state < ResourceState.READY:
- # ccnr needs to wait until ccnd is deployed and running
- self.ec.schedule(reschedule_delay, self.deploy)
- else:
- # Invoke the actual deployment
- super(LinuxCCNContent, self).deploy()
-
- # As soon as the ccnr is running we can push the content
- # to the repository ( we don't want to lose time launching
- # writting the content to the repository later on )
- if self._state == ResourceState.READY:
- self._start_in_background()
- self._published = True
-
- def start(self):
- # CCNR should already be started by now.
- # Nothing to do but to set the state to STARTED
- if self._published:
- self._start_time = strfnow()
- self._state = ResourceState.STARTED
+ self.info("Deploying command '%s' " % command)
+
+ self.do_discover()
+ self.do_provision()
+
+ self.set_ready()
+
+ def upload_start_command(self):
+ command = self.get("command")
+ env = self.get("env")
+
+ self.info("Uploading command '%s'" % command)
+
+ # We want to make sure the content is published
+ # before the experiment starts.
+ # Run the command as a bash script in the background,
+ # in the host ( but wait until the command has
+ # finished to continue )
+ env = self.replace_paths(env)
+ command = self.replace_paths(command)
+
+ (out, err), proc = self.execute_command(command,
+ env, blocking = True)
+
+ if proc.poll():
+ msg = "Failed to execute command"
+ self.error(msg, out, err)
+ raise RuntimeError, msg
+
+ def do_start(self):
+ if self.state == ResourceState.READY:
+ command = self.get("command")
+ self.info("Starting command '%s'" % command)
+
+ self.set_started()