Ejemplo n.º 1
0
    def get_disk_mapping(self):

        ##connect to the disk mapper and get a list of vb_ids and associated pathnames
        map_available = False
        for i in range(5):
            fetch_map_cmd = "curl \'http://" + self.dm_host + "/api?action=get_ss_mapping&storage_server=" + self.ip_address + "\'" + " -o /tmp/currentmap"
            status, output = util.getcommandoutput(fetch_map_cmd)

            if status > 0:
                self.logger.log(
                    "Failure: Unable to fetch disk mapping. Command %s output %s"
                    % (fetch_map_cmd, output))
                if i >= 5:
                    break
                continue
            elif status == 0:
                try:
                    map = open("/tmp/currentmap", "r")
                    buffer = map.read()
                    current_map = json.loads(buffer)
                    map.close()
                    map_available = True
                    break
                except Exception, e:
                    self.logger.log("Unable to read file %s" % str(e))
                    break
Ejemplo n.º 2
0
def list_files(dirname):
    status, output = getcommandoutput(
        'find %s -type f \( -name "*.mbb" -o -name "*.split" -o -name "manifest.del" -o -name "done" -o -name "complete" -o -name "done-*" -o -name "merged-*" \)'
        % dirname)
    if status == 0:
        return [x for x in output.split('\n') if x != '']
    else:
        return []
Ejemplo n.º 3
0
def download_file(s3path, localpath):
    dl_cmd = "%s get %s %s" %(consts.PATH_S3CMD_ZYNGA_EXEC, s3path, localpath) 
    status, output = getcommandoutput(dl_cmd)
    if status == 0:
        try:
            if 'Error' in open(localpath).read():
                status = 1
        except Exception, e:
            status = 2
Ejemplo n.º 4
0
def download_file(s3path, localpath):
    dl_cmd = "%s get %s %s" % (consts.PATH_S3CMD_ZYNGA_EXEC, s3path, localpath)
    status, output = getcommandoutput(dl_cmd)
    if status == 0:
        try:
            if 'Error' in open(localpath).read():
                status = 1
        except Exception, e:
            status = 2
Ejemplo n.º 5
0
def get_storageserver_map(mapping_server):
    """
    Fetch the server to storage server mapping
    from mapping server API
    """
    cmd = "curl -s -L http://%s/%s" %(mapping_server, consts.BLOBRESTORE_API_PATH)
    status, output = getcommandoutput(cmd)
    if status == 0:
        try:
            return json.loads(str(output))
        except Exception, e:
            sys.exit("ERROR: Unable to parse host to storage server map (%s)" \
                    %str(e))
Ejemplo n.º 6
0
def get_storageserver_map(mapping_server):
    """
    Fetch the server to storage server mapping
    from mapping server API
    """
    cmd = "curl -s -L http://%s/%s" % (mapping_server,
                                       consts.BLOBRESTORE_API_PATH)
    status, output = getcommandoutput(cmd)
    if status == 0:
        try:
            return json.loads(str(output))
        except Exception, e:
            sys.exit("ERROR: Unable to parse host to storage server map (%s)" \
                    %str(e))
Ejemplo n.º 7
0
    def __init__(self, vbs_server):
        cmd = "curl -s -L http://%s/%s" %(vbs_server, consts.VBS_API_PATH)
        status, output = getcommandoutput(cmd)
        if status > 0:
            log("ERROR: Unable to contact VBS: %s" %(vbs_server))
            sys.exit(1)

        j = json.loads(output)
        vbsmap = j['buckets'][0]['vBucketServerMap']['vBucketMap']
        srvlist = j['buckets'][0]['vBucketServerMap']['serverList']
        self.vbmap = {}

        for i,v in enumerate(vbsmap):
            ip, port = srvlist[v[0]].split(':')
            mc = MemcachedClient(host=ip, port=int(port))
            self.vbmap[i] = mc
Ejemplo n.º 8
0
    def __init__(self, vbs_server):
        cmd = "curl -s -L http://%s/%s" % (vbs_server, consts.VBS_API_PATH)
        status, output = getcommandoutput(cmd)
        if status > 0:
            log("ERROR: Unable to contact VBS: %s" % (vbs_server))
            sys.exit(1)

        j = json.loads(output)
        vbsmap = j['buckets'][0]['vBucketServerMap']['vBucketMap']
        srvlist = j['buckets'][0]['vBucketServerMap']['serverList']
        self.vbmap = {}

        for i, v in enumerate(vbsmap):
            ip, port = srvlist[v[0]].split(':')
            mc = MemcachedClient(host=ip, port=int(port))
            self.vbmap[i] = mc
Ejemplo n.º 9
0
    def get_disk_mapping(self):

        ##connect to the disk mapper and get a list of vb_ids and associated pathnames
        map_available = False
        for i in range(5):
            fetch_map_cmd = "curl \'http://" + self.dm_host + "/api?action=get_ss_mapping&storage_server=" + self.ip_address + "\'" + " -o /tmp/currentmap"
            status,output = util.getcommandoutput(fetch_map_cmd)

            if status > 0:
                self.logger.log("Failure: Unable to fetch disk mapping. Command %s output %s" %(fetch_map_cmd, output))
                if i >= 5:
                    break
                continue
            elif status == 0:
                try:
                    map = open("/tmp/currentmap", "r")
                    buffer = map.read()
                    current_map = json.loads(buffer)
                    map.close()
                    map_available = True
                    break
                except Exception, e:
                    self.logger.log("Unable to read file %s" %str(e))
                    break
Ejemplo n.º 10
0
def remote_cmd(server, cmd):
    cmd = 'ssh -i %s -o PasswordAuthentication=no -o StrictHostKeyChecking=no storageserver@%s "%s"' \
            %(SSH_KEY_PATH, server, cmd)

    return getcommandoutput(cmd)
Ejemplo n.º 11
0
def list_files(dirname):
    status, output = getcommandoutput('find %s -type f \( -name "*.mbb" -o -name "*.split" -o -name "manifest.del" -o -name "done" -o -name "complete" -o -name "done-*" -o -name "merged-*" \)' %dirname)
    if status == 0:
        return [ x for x in output.split('\n') if x != '']
    else:
        return []
Ejemplo n.º 12
0
def remote_cmd(server, cmd):
    cmd = 'ssh -i %s -o PasswordAuthentication=no -o StrictHostKeyChecking=no storageserver@%s "%s"' \
            %(SSH_KEY_PATH, server, cmd)

    return getcommandoutput(cmd)