Example #1
0
  def deploy_workflow_rollback(self):
    """Method to start rollback action.
      When rollback completes, it moves to exit state.
    """
    log.info("deploy workflow ==> enter [%s] state",
             self.current_context['state'])
    # rollback to the beginning state
    utils.run_command_silient("git reset --hard deploy_start")

    log.info("wait for rollback completion...")
    time.sleep(self.opts['wait'] * 5)

    self.current_context['state'] = STATE_EXIT
    self.current_context['prestate'] = STATE_ROLLBACK
Example #2
0
  def run(self):
    """This method is the main loop for deployment
      state machine
    """
    log.info(">== deployment workflow starts.")

    deploy_state = self.current_context['state']
    log.debug("deploy_state: %s", deploy_state)
    try:
      while deploy_state != STATE_EXIT:
        action = DeployWorkflow.deploy_state_machine[deploy_state]
        action(self)
        deploy_state = self.current_context['state']
      # go through "exit" state to complete the state machine
      DeployWorkflow.deploy_state_machine[deploy_state](self)
    except Exception:
      # rollback to the beginning state
      utils.run_command_silient("git reset --hard deploy_start")
    finally:
      utils.run_command_silient("git tag -d deploy_start")
      utils.run_command_silient("git checkout master")

    log.info("<== deployment workflow completed.")