mirror of https://github.com/ceph/ceph-ansible.git
ceph_pool: add support check mode
Signed-off-by: Seena Fallah <seenafallah@gmail.com>
(cherry picked from commit a45defd386
)
debug-8
parent
fecc615d02
commit
27f8dfcb0f
|
@ -589,17 +589,6 @@ def run_module():
|
||||||
'min_size': {'value': min_size}
|
'min_size': {'value': min_size}
|
||||||
}
|
}
|
||||||
|
|
||||||
if module.check_mode:
|
|
||||||
module.exit_json(
|
|
||||||
changed=False,
|
|
||||||
stdout='',
|
|
||||||
stderr='',
|
|
||||||
rc=0,
|
|
||||||
start='',
|
|
||||||
end='',
|
|
||||||
delta='',
|
|
||||||
)
|
|
||||||
|
|
||||||
startd = datetime.datetime.now()
|
startd = datetime.datetime.now()
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
|
@ -617,7 +606,8 @@ def run_module():
|
||||||
user,
|
user,
|
||||||
user_key,
|
user_key,
|
||||||
container_image=container_image)) # noqa: E501
|
container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
changed = rc != 0
|
||||||
|
if not changed:
|
||||||
running_pool_details = get_pool_details(module,
|
running_pool_details = get_pool_details(module,
|
||||||
cluster,
|
cluster,
|
||||||
name,
|
name,
|
||||||
|
@ -636,9 +626,8 @@ def run_module():
|
||||||
delta.pop('pg_num', None)
|
delta.pop('pg_num', None)
|
||||||
delta.pop('pgp_num', None)
|
delta.pop('pgp_num', None)
|
||||||
|
|
||||||
if len(delta) == 0:
|
changed = len(delta) > 0
|
||||||
out = "Skipping pool {}.\nUpdating either 'size' on an erasure-coded pool or 'pg_num'/'pgp_num' on a pg autoscaled pool is incompatible".format(name) # noqa: E501
|
if changed and not module.check_mode:
|
||||||
else:
|
|
||||||
rc, cmd, out, err = update_pool(module,
|
rc, cmd, out, err = update_pool(module,
|
||||||
cluster,
|
cluster,
|
||||||
name,
|
name,
|
||||||
|
@ -646,11 +635,7 @@ def run_module():
|
||||||
user_key,
|
user_key,
|
||||||
delta,
|
delta,
|
||||||
container_image=container_image) # noqa: E501
|
container_image=container_image) # noqa: E501
|
||||||
if rc == 0:
|
elif not module.check_mode:
|
||||||
changed = True
|
|
||||||
else:
|
|
||||||
out = "Pool {} already exists and there is nothing to update.".format(name) # noqa: E501
|
|
||||||
else:
|
|
||||||
rc, cmd, out, err = exec_command(module,
|
rc, cmd, out, err = exec_command(module,
|
||||||
create_pool(cluster,
|
create_pool(cluster,
|
||||||
user,
|
user,
|
||||||
|
@ -675,7 +660,6 @@ def run_module():
|
||||||
if user_pool_config['min_size']['value']:
|
if user_pool_config['min_size']['value']:
|
||||||
# not implemented yet
|
# not implemented yet
|
||||||
pass
|
pass
|
||||||
changed = True
|
|
||||||
|
|
||||||
elif state == "list":
|
elif state == "list":
|
||||||
rc, cmd, out, err = exec_command(module,
|
rc, cmd, out, err = exec_command(module,
|
||||||
|
@ -693,17 +677,14 @@ def run_module():
|
||||||
name, user,
|
name, user,
|
||||||
user_key,
|
user_key,
|
||||||
container_image=container_image)) # noqa: E501
|
container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
changed = rc == 0
|
||||||
|
if changed and not module.check_mode:
|
||||||
rc, cmd, out, err = exec_command(module,
|
rc, cmd, out, err = exec_command(module,
|
||||||
remove_pool(cluster,
|
remove_pool(cluster,
|
||||||
name,
|
name,
|
||||||
user,
|
user,
|
||||||
user_key,
|
user_key,
|
||||||
container_image=container_image)) # noqa: E501
|
container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
|
||||||
else:
|
|
||||||
rc = 0
|
|
||||||
out = "Skipped, since pool {} doesn't exist".format(name)
|
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd,
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd,
|
||||||
changed=changed)
|
changed=changed)
|
||||||
|
|
Loading…
Reference in New Issue