def substitute_thermos(cls, command, task, cluster, **kw): prefix_command = 'cd %s;' % cls.thermos_sandbox(cluster, **kw) thermos_namespace = ThermosContext( task_id=task.assignedTask.taskId, ports=task.assignedTask.assignedPorts) mesos_namespace = MesosContext(instance=task.assignedTask.instanceId) command = String(prefix_command + command) % Environment( thermos=thermos_namespace, mesos=mesos_namespace) return command.get()
def interpolate_cmd(task, cmd): """ :param task: Assigned task passed from Mesos Agent :param cmd: Command defined inside shell_command inside config. :return: Interpolated cmd with filled in values, for example ports. """ thermos_namespace = ThermosContext(task_id=task.taskId, ports=task.assignedPorts) mesos_namespace = MesosContext(instance=task.instanceId) command = String(cmd) % Environment(thermos=thermos_namespace, mesos=mesos_namespace) return command.get()