Ejemplo n.º 1
0
def run_command_silient(cmd):
  """This method executes the command in silient mode which
    ignore any errors
  """
  try:
    run_command(cmd)
  except Exception:
    log.warn("Executing command [%s] failed siliently.", cmd)
Ejemplo n.º 2
0
  def deploy_workflow_exit(self):
    """Method to complete the deployment workflow and
      update BMT and LSB on master branch accordingly
    """
    log.info("deploy workflow ==> enter [%s] state",
             self.current_context['state'])

    if self.current_context['prestate'] == STATE_ROLLBACK:
      # there is nothing to do if it moves from rollback
      # state to exit state. LSB and BMT is always rolled
      # back
      return

    lsb_file = self.xmt_mgr.get_xmt_file(xmt.XMT_TYPE_LSB)

    # update lsb table
    lsb_entries = self.xmt_mgr.construct_lsb_entries()
    self.xmt_mgr.save(xmt.XMT_TYPE_LSB, lsb_entries)
    msg = "jungar: update lsb on deploy branch"
    cmds = []
    cmds.append("git add " + lsb_file)
    cmds.append("git commit -m \'" + msg + "\'")
    utils.run_commands(cmds)

    # update the lsb and bmt table on master branch
    msg = "deploy: update bmt and lsb at the end of workflow"
    cmds = []
    cmds.append('git checkout master')
    cmds.append('git pull')
    cmds.append('git merge ' + self.opts['branch'] +
                " -m \"jungar: merge lsb and bmt to master\"")
    utils.run_commands(cmds)

    retries = 5
    while retries:
      try:
        utils.run_command("git push origin master")
        break
      except exp.CommandFailure:
        log.warn("Push changes to remote failed. Retry [%d/5]", retries)
        retries -= 1
        time.sleep(5)
    return