Esempio n. 1
0
 def __init__(self,
              job_run_id,
              name,
              node,
              bare_command=None,
              parent_context=None,
              output_path=None,
              cleanup=False,
              start_time=None,
              end_time=None,
              run_state=STATE_SCHEDULED,
              rendered_command=None,
              exit_status=None,
              action_runner=None):
     self.job_run_id = job_run_id
     self.action_name = name
     self.node = node
     self.start_time = start_time
     self.end_time = end_time
     self.exit_status = exit_status
     self.bare_command = bare_command
     self.rendered_command = rendered_command
     self.action_runner = action_runner or NoActionRunnerFactory
     self.machine = state.StateMachine(self.STATE_SCHEDULED,
                                       delegate=self,
                                       force_state=run_state)
     self.is_cleanup = cleanup
     self.output_path = output_path or filehandler.OutputPath()
     self.output_path.append(self.id)
     self.context = command_context.build_context(self, parent_context)
Esempio n. 2
0
 def test_notify_delegate(self):
     delegate = turtle.Turtle()
     handler = turtle.Turtle()
     self.machine = state.StateMachine(self.state_red, delegate=delegate)
     self.machine.attach(True, handler)
     self.machine.transition('true')
     assert_equal(handler.handler.calls,
                  [((delegate, self.state_green), {})])
Esempio n. 3
0
    def build_machine(self):
        # Going around and around in circles
        self.state_telling_false = NamedEventState('telling_false')

        self.state_telling_truth = NamedEventState(
            'telling_truth', true=self.state_telling_false)
        self.state_telling_false.update({'true': self.state_telling_truth})

        self.machine = state.StateMachine(self.state_telling_truth)
Esempio n. 4
0
    def __init__(self, config, node, instance_number, parent_context):
        self.config = config
        self.node = node
        self.instance_number = instance_number
        self.id = "%s.%s" % (config.name, self.instance_number)

        start_state = ServiceInstance.STATE_DOWN
        self.machine = state.StateMachine(start_state, delegate=self)
        self.parent_context = parent_context
        self.context = command_context.build_context(self, parent_context)
        self.failures = []
Esempio n. 5
0
 def __init__(self, id, command, serializer=None):
     self.id = id
     self.command = command
     self.machine = state.StateMachine(self.PENDING, delegate=self)
     self.exit_status = None
     self.start_time = None
     self.end_time = None
     self.stdout = filehandler.NullFileHandle
     self.stderr = filehandler.NullFileHandle
     if serializer:
         self.stdout = serializer.open(self.STDOUT)
         self.stderr = serializer.open(self.STDERR)
Esempio n. 6
0
    def build_machine(self):
        # Generalized rules of a conversation
        # If they are talking, we should listen
        # If they are listening, we should talk
        # If they are ignoring us we should get angry

        self.state_ignoring = NamedEventState('ignoring')
        self.state_talking = NamedEventState('talking')
        self.state_angry = NamedEventState('angry')

        self.state_listening = NamedEventState('listening',
                                               listening=self.state_talking)

        self.state_talking.update({
            'ignoring': self.state_angry,
            'talking': self.state_listening,
        })

        self.machine = state.StateMachine(self.state_listening)
Esempio n. 7
0
    def build_machine(self):
        self.state_green = NamedEventState('green')
        self.state_red = NamedEventState('red', true=self.state_green)

        self.machine = state.StateMachine(self.state_red)