Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions plugins/modules/gluster_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,17 @@ def set_volume_option(name, option, parameter):
run_gluster(['volume', 'set', name, option, parameter])


def add_bricks(name, new_bricks, stripe, replica, force):
def add_bricks(name, new_bricks, stripe, replica, arbiter, force):
args = ['volume', 'add-brick', name]
if stripe:
args.append('stripe')
args.append(str(stripe))
if replica:
args.append('replica')
args.append(str(replica))
if arbiter:
args.append('arbiter')
args.append(str(arbiter))
args.extend(new_bricks)
if force:
args.append('force')
Expand Down Expand Up @@ -423,13 +426,16 @@ def remove_bricks(name, removed_bricks, force):
"Commit operation needs to be followed.")


def reduce_config(name, removed_bricks, replicas, force):
def reduce_config(name, removed_bricks, replica, arbiter, force):
out = run_gluster(['volume', 'heal', name, 'info'])
summary = out.split("\n")
for line in summary:
if 'Number' in line and int(line.split(":")[1].strip()) != 0:
module.fail_json(msg="Operation aborted, self-heal in progress.")
args = ['volume', 'remove-brick', name, 'replica', replicas]
args = ['volume', 'remove-brick', name, 'replica', str(replica)]
if arbiter:
args.append('arbiter')
args.append(str(arbiter))
args.extend(removed_bricks)
if force:
args.append('force')
Expand Down Expand Up @@ -571,12 +577,12 @@ def main():
removed_bricks.append(brick)

if new_bricks:
add_bricks(volume_name, new_bricks, stripes, replicas, force)
add_bricks(volume_name, new_bricks, stripes, replicas, arbiters, force)
changed = True

if removed_bricks:
if replicas and int(replicas) < int(volumes[volume_name]['replicas']):
reduce_config(volume_name, removed_bricks, str(replicas), force)
reduce_config(volume_name, removed_bricks, replicas, arbiters, force)
else:
remove_bricks(volume_name, removed_bricks, force)
changed = True
Expand Down