Fixed volume status for >= 3.7 in glusterfs.py

Fixes #28193
This commit is contained in:
Claudiu Popescu 2015-12-01 00:17:14 +02:00
parent 8d32d8d43d
commit 443bfc6a81

View file

@ -29,6 +29,15 @@ def __virtual__():
return (False, 'glusterfs server is not installed')
def _get_minor_version():
cmd = 'gluster --version'
result = __salt__['cmd.run'](cmd).splitlines()
for line_number in range(len(result)):
line = result[line_number]
if line.startswith('glusterfs'):
return int(line.split()[1].split('.')[1])
def list_peers():
'''
Return a list of gluster peers
@ -225,6 +234,8 @@ def status(name):
salt '*' glusterfs.status myvolume
'''
# Get minor version
minor_version = _get_minor_version()
# Get volume status
cmd = 'gluster volume status {0}'.format(name)
result = __salt__['cmd.run'](cmd).splitlines()
@ -244,7 +255,10 @@ def status(name):
line = line.rstrip() + result[line_number]
# Parse Brick data
brick, port, online, pid = line.split()[1:]
if minor_version >= 7:
brick, port, port_rdma, online, pid = line.split()[1:]
else:
brick, port, online, pid = line.split()[1:]
host, path = brick.split(':')
data = {'port': port, 'pid': pid, 'host': host, 'path': path}
if online == 'Y':
@ -260,7 +274,10 @@ def status(name):
line = line.rstrip() + result[line_number]
# Parse NFS Server data
host, port, online, pid = line.split()[3:]
if minor_version >= 7:
host, port, port_rdma, online, pid = line.split()[3:]
else:
host, port, online, pid = line.split()[3:]
data = {'port': port, 'pid': pid}
if online == 'Y':
data['online'] = True
@ -275,7 +292,10 @@ def status(name):
line = line.rstrip() + result[line_number]
# Parse NFS Server data
host, port, online, pid = line.split()[3:]
if minor_version >= 7:
host, port, port_rdma, online, pid = line.split()[3:]
else:
host, port, online, pid = line.split()[3:]
data = {'port': port, 'pid': pid}
if online == 'Y':
data['online'] = True