mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
parent
8d32d8d43d
commit
443bfc6a81
1 changed files with 23 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue