예제 #1
0
def CheckLocalGFSMasterHealthz(testver):
    """ Check if GFS master is healthy

  Arguments:
    testver: 1 - the version is in test mode. 0 - otherwise.

  Returns:
    1 - GFS is healthy. 0 - otherwise.
  """

    gfsmasterport = core_utils.GetGFSMasterPort(testver)
    cmd = 'http://0:%s/healthz' % gfsmasterport
    out = core_utils.OpenURL(cmd)
    if out and out.startswith('ok'):
        return 1
    return 0
예제 #2
0
def GFSMasterChunkserversOp(cmd, ver, testver):
    """ GFS chunkservers operations, returns the output

  Arguments:
    cmd:     '?add=ent1:3840,ent2:3840'
    ver:     '4.6.5'
    testver: 1 - the version is in test mode. 0 - otherwise.

  Returns:
    'ent1:3840\nent2:3840\n'
  """

    gfsmasterport = core_utils.GetGFSMasterPort(testver)
    cmd = 'http://%s:%s/chunkservers%s' % (core_utils.MakeGFSMasterPath(ver),
                                           gfsmasterport, cmd)
    return core_utils.OpenURL(cmd)
예제 #3
0
def IsGFSRunning(ver, testver):
    """ if gfs_master process running on any node
  Arguments:
    ver:     '4.6.5'
    testver: 0 - not a test version. 1 - test version.
  Returns:
    1 - gfs_master processes running on some nodes. 0 - otherwise.
  """

    gfs_master_nodes, _ = core_utils.GFSMasterNodes()
    list_gfs_master_cmd = "lsof -i :%s " % core_utils.GetGFSMasterPort(testver)
    out = []
    enthome = '/export/hda3/%s' % ver
    status = E.execute(gfs_master_nodes, list_gfs_master_cmd, out, 300, 1, 0,
                       enthome)
    # ignore status for list
    return ''.join(out).find('LISTEN') != -1
예제 #4
0
def ForceGFSPrimaryMaster(testver, node):
    """ force a node to become the primary gfs_master

  There is no guarantee that the node will become the primary master.
  After the first attempt, this function checks if the node has become
  the primary master. If not, it will try again.

  Arguments:
    testver: 0 - not a test version. 1 - test version.
    node: 'ent1'
  """

    gfsmasterport = core_utils.GetGFSMasterPort(testver)
    cmd = 'http://%s:%s/forcemaster' % (node, gfsmasterport)
    for i in range(2):
        out = core_utils.OpenURL(cmd)
        if out and out.startswith('This node has become the master.'):
            break
예제 #5
0
def PrimaryMasterStatus(ver, testver):
    """ Return the primary gfs master's status page.

    Send the root("/") http request to gfs primary master and
    return the reply.

  Arguments:
    ver:     '4.6.5'
    testver: 1 - the version is in test mode. 0 - otherwise.

  Returns:
    Reply from the primary gfs master.
    None if the primary master is down.
  """

    gfsmasterport = core_utils.GetGFSMasterPort(testver)
    cmd = 'http://%s:%s' % (core_utils.MakeGFSMasterPath(ver), gfsmasterport)
    status = core_utils.OpenURL(cmd)
    return status
예제 #6
0
    def _GetExtraArguments(self):
        """Get a string of additional arguments to apply to borgmon.
    At the moment these are mostly election commissar arguments used to set up
    failover in the enterprise cluster environment.

    Returns:
      String of arguments to pass to borgmon
    """
        args = ""
        args += '--svelte_servers=localhost:6297 '
        args += '--svelte_retry_interval_ms=2147483647 '
        if core_utils.UseGFS(self.__total_nodes):
            gfs_port = core_utils.GetGFSMasterPort(self.__mode == TEST)
            args += '--gfs_aliases=ent=%s:%d ' % (core_utils.MakeGFSMasterPath(
                self.__ver), gfs_port)
        if core_utils.UseLockservice(self.__total_nodes):
            # enable election commissar failover in borgmon
            args += ('--use_commissar_failover --commissar_chubby_cell %s' %
                     core_utils.GetCellName(self.__ver))
        else:
            # disable election commissar failover in borgmon
            args += '--nouse_commissar_failover'
        return args