def status(name):
    '''
    Check the status of a gluster volume.

    name
        Volume name

    CLI Example:

    .. code-block:: bash

        salt '*' glusterfs.status myvolume
    '''
    # Get volume status
    root = _gluster_xml('volume status {0}'.format(name))
    if not _gluster_ok(root):
        # Most probably non-existing volume, the error output is logged
        # This return value is easy to test and intuitive
        return None

    ret = {'bricks': {}, 'nfs': {}, 'healers': {}}

    def etree_legacy_wrap(t):
        ret = _etree_to_dict(t)
        ret['online'] = (ret['status'] == '1')
        ret['host'] = ret['hostname']
        return ret

    # Build a hash to map hostname to peerid
    hostref = {}
    for node in _iter(root, 'node'):
        peerid = node.find('peerid').text
        hostname = node.find('hostname').text
        if hostname not in ('NFS Server', 'Self-heal Daemon'):
            hostref[peerid] = hostname

    for node in _iter(root, 'node'):
        hostname = node.find('hostname').text
        if hostname not in ('NFS Server', 'Self-heal Daemon'):
            path = node.find('path').text
            ret['bricks'][
                '{0}:{1}'.format(hostname, path)] = etree_legacy_wrap(node)
        elif hostname == 'NFS Server':
            peerid = node.find('peerid').text
            true_hostname = hostref[peerid]
            ret['nfs'][true_hostname] = etree_legacy_wrap(node)
        else:
            peerid = node.find('peerid').text
            true_hostname = hostref[peerid]
            ret['healers'][true_hostname] = etree_legacy_wrap(node)

    return ret
def status ( name ) : root = _gluster_xml ( 'volume status {0}' . format ( name ) ) if not _gluster_ok ( root ) : return None ret = { 'bricks' : { } , 'nfs' : { } , 'healers' : { } } def etree_legacy_wrap ( t ) : ret = _etree_to_dict ( t ) ret [ 'online' ] = ( ret [ 'status' ] == '1' ) ret [ 'host' ] = ret [ 'hostname' ] return ret hostref = { } for node in _iter ( root , 'node' ) : peerid = node . find ( 'peerid' ) . text hostname = node . find ( 'hostname' ) . text if hostname not in ( 'NFS Server' , 'Self-heal Daemon' ) : hostref [ peerid ] = hostname for node in _iter ( root , 'node' ) : hostname = node . find ( 'hostname' ) . text if hostname not in ( 'NFS Server' , 'Self-heal Daemon' ) : path = node . find ( 'path' ) . text ret [ 'bricks' ] [ '{0}:{1}' . format ( hostname , path ) ] = etree_legacy_wrap ( node ) elif hostname == 'NFS Server' : peerid = node . find ( 'peerid' ) . text true_hostname = hostref [ peerid ] ret [ 'nfs' ] [ true_hostname ] = etree_legacy_wrap ( node ) else : peerid = node . find ( 'peerid' ) . text true_hostname = hostref [ peerid ] ret [ 'healers' ] [ true_hostname ] = etree_legacy_wrap ( node ) return ret
Check the status of a gluster volume.

    name
        Volume name

    CLI Example:

    .. code-block:: bash

        salt '*' glusterfs.status myvolume