Пример #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
Пример #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 []
Пример #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
Пример #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
Пример #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))
Пример #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))
Пример #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
Пример #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
Пример #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
Пример #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)
Пример #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 []
Пример #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)