示例#1
0
def get_swap_info(dispatcher):
    xml = confxml()
    result = {}

    for mirror in xml.xpath("/mesh/class[name='MIRROR']/geom"):
        name = mirror.find('name').text
        if not re.match(r'^swap\d+$', name):
            continue

        swap = {
            'name': name,
            'disks': []
        }

        for cons in mirror.findall('consumer'):
            prov = cons.find('provider').attrib['ref']
            prov = xml.xpath(".//provider[@id='{0}']".format(prov))[0]
            disk_geom = prov.find('geom').attrib['ref']
            disk_geom = xml.xpath(".//geom[@id='{0}']".format(disk_geom))[0]
            disk_id = dispatcher.call_sync(
                'disk.path_to_id',
                os.path.join('/dev', disk_geom.find('name').text[:-2])
            )

            if disk_id:
                swap['disks'].append(disk_id)

        result[name] = swap

    return result
示例#2
0
def get_swap_info(dispatcher):
    xml = confxml()
    result = {}

    for mirror in xml.xpath("/mesh/class[name='MIRROR']/geom"):
        name = mirror.find('name').text
        if not re.match(r'^swap\d+$', name):
            continue

        swap = {
            'name': name,
            'disks': []
        }

        for cons in mirror.findall('consumer'):
            prov = cons.find('provider').attrib['ref']
            prov = xml.xpath(".//provider[@id='{0}']".format(prov))[0]
            disk_geom = prov.find('geom').attrib['ref']
            disk_geom = xml.xpath(".//geom[@id='{0}']".format(disk_geom))[0]
            disk_id = dispatcher.call_sync(
                'disk.path_to_id',
                os.path.join('/dev', disk_geom.find('name').text[:-2])
            )

            if disk_id:
                swap['disks'].append(disk_id)

        result[name] = swap

    return result