- # Add a start after condition so CCNR will not start
- # before CCND does
- self.ec.register_condition(self.guid, ResourceAction.START,
- ccnd.guid, ResourceState.STARTED)
-
- # Invoke the actual deployment
- super(LinuxCCNContent, self).deploy()
+ if not self.get("command"):
+ self.set("command", self._start_command)
+
+ if not self.get("env"):
+ self.set("env", self._environment)
+
+ # set content to stdin, so the content will be
+ # uploaded during provision
+ self.set("stdin", self.get("content"))
+
+ command = self.get("command")
+
+ self.info("Deploying command '%s' " % command)
+
+ self.discover()
+ self.provision()
+
+ self.debug("----- READY ---- ")
+ 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
+
+ @failtrap
+ def start(self):
+ if self.state == ResourceState.READY:
+ command = self.get("command")
+ self.info("Starting command '%s'" % command)
+
+ self.set_started()
+ else:
+ msg = " Failed to execute command '%s'" % command
+ self.error(msg, out, err)
+ raise RuntimeError, msg