Commit beda1fe7 authored by Wong Hoi Sing Edison's avatar Wong Hoi Sing Edison Committed by Guillaume Abrioux
Browse files

library: flake8 ceph-ansible modules



This commit ensure all ceph-ansible modules pass flake8 properly.
Signed-off-by: default avatarWong Hoi Sing Edison <hswong3i@pantarei-design.com>
parent d191ba38
......@@ -112,7 +112,7 @@ option:
default: unlimited
bucketmaxobjects:
description:
- with bucket quota enabled specify maximum number of objects # noqa E501
- with bucket quota enabled specify maximum number of objects # noqa: E501
required: false
default: unlimited
buckets:
......@@ -263,7 +263,7 @@ error_messages:
returned: always
type: list
sample: [
"test2: could not modify user: unable to modify user, cannot add duplicate email\n" # noqa E501
"test2: could not modify user: unable to modify user, cannot add duplicate email\n" # noqa: E501
]
failed_users:
......@@ -334,36 +334,36 @@ def create_users(rgw, users, result):
if email:
if autogenkey:
try:
rgw.create_user(username, fullname, email=email, key_type='s3', # noqa E501
rgw.create_user(username, fullname, email=email, key_type='s3', # noqa: E501
generate_key=autogenkey,
max_buckets=maxbucket, suspended=suspend) # noqa E501
max_buckets=maxbucket, suspended=suspend) # noqa: E501
except radosgw.exception.RadosGWAdminError as e:
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
fail_flag = True
else:
try:
rgw.create_user(username, fullname, email=email, key_type='s3', # noqa E501
access_key=accesskey, secret_key=secretkey, # noqa E501
max_buckets=maxbucket, suspended=suspend) # noqa E501
rgw.create_user(username, fullname, email=email, key_type='s3', # noqa: E501
access_key=accesskey, secret_key=secretkey, # noqa: E501
max_buckets=maxbucket, suspended=suspend) # noqa: E501
except radosgw.exception.RadosGWAdminError as e:
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
fail_flag = True
else:
if autogenkey:
try:
rgw.create_user(username, fullname, key_type='s3',
generate_key=autogenkey,
max_buckets=maxbucket, suspended=suspend) # noqa E501
max_buckets=maxbucket, suspended=suspend) # noqa: E501
except radosgw.exception.RadosGWAdminError as e:
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
fail_flag = True
else:
try:
rgw.create_user(username, fullname, key_type='s3',
access_key=accesskey, secret_key=secretkey, # noqa E501
max_buckets=maxbucket, suspended=suspend) # noqa E501
access_key=accesskey, secret_key=secretkey, # noqa: E501
max_buckets=maxbucket, suspended=suspend) # noqa: E501
except radosgw.exception.RadosGWAdminError as e:
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
fail_flag = True
if not fail_flag and userquota:
......@@ -371,15 +371,15 @@ def create_users(rgw, users, result):
rgw.set_quota(username, 'user', max_objects=usermaxobjects,
max_size_kb=usermaxsize, enabled=True)
except radosgw.exception.RadosGWAdminError as e:
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
fail_flag = True
if not fail_flag and bucketquota:
try:
rgw.set_quota(username, 'bucket', max_objects=bucketmaxobjects, # noqa E501
rgw.set_quota(username, 'bucket', max_objects=bucketmaxobjects, # noqa: E501
max_size_kb=bucketmaxsize, enabled=True)
except radosgw.exception.RadosGWAdminError as e:
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
fail_flag = True
if fail_flag:
......@@ -450,12 +450,12 @@ def create_buckets(rgw, buckets, result):
except radosgw.exception.RadosGWAdminError:
pass
failed_buckets.append(bucket)
result['error_messages'].append(bucket + ' could not be linked' + ', NoSuchUser ' + user) # noqa E501
result['error_messages'].append(bucket + ' could not be linked' + ', NoSuchUser ' + user) # noqa: E501
else:
# something went wrong
failed_buckets.append(bucket)
result['error_messages'].append(bucket + ' could not be created') # noqa E501
result['error_messages'].append(bucket + ' could not be created') # noqa: E501
result['added_buckets'] = ", ".join(added_buckets)
result['failed_buckets'] = ", ".join(failed_buckets)
......@@ -467,7 +467,7 @@ def create_bucket(rgw, bucket):
host=rgw._connection[0],
port=rgw.port,
is_secure=rgw.is_secure,
calling_format=boto.s3.connection.OrdinaryCallingFormat(), # noqa E501
calling_format=boto.s3.connection.OrdinaryCallingFormat(), # noqa: E501
)
try:
......@@ -489,23 +489,23 @@ def main():
admin_access_key=dict(type='str', required=True),
admin_secret_key=dict(type='str', required=True),
buckets=dict(type='list', required=False, elements='dict',
options=dict(bucket=dict(type='str', required=True), # noqa E501
user=dict(type='str', required=True))), # noqa E501
options=dict(bucket=dict(type='str', required=True), # noqa: E501
user=dict(type='str', required=True))), # noqa: E501
users=dict(type='list', required=False, elements='dict',
options=dict(username=dict(type='str', required=True), # noqa E501
fullname=dict(type='str', required=True), # noqa E501
email=dict(type='str', required=False), # noqa E501
maxbucket=dict(type='int', required=False, default=1000), # noqa E501
suspend=dict(type='bool', required=False, default=False), # noqa E501
autogenkey=dict(type='bool', required=False, default=True), # noqa E501
accesskey=dict(type='str', required=False), # noqa E501
secretkey=dict(type='str', required=False), # noqa E501
userquota=dict(type='bool', required=False, default=False), # noqa E501
usermaxsize=dict(type='str', required=False, default='-1'), # noqa E501
usermaxobjects=dict(type='int', required=False, default=-1), # noqa E501
bucketquota=dict(type='bool', required=False, default=False), # noqa E501
bucketmaxsize=dict(type='str', required=False, default='-1'), # noqa E501
bucketmaxobjects=dict(type='int', required=False, default=-1)))) # noqa E501
options=dict(username=dict(type='str', required=True), # noqa: E501
fullname=dict(type='str', required=True), # noqa: E501
email=dict(type='str', required=False), # noqa: E501
maxbucket=dict(type='int', required=False, default=1000), # noqa: E501
suspend=dict(type='bool', required=False, default=False), # noqa: E501
autogenkey=dict(type='bool', required=False, default=True), # noqa: E501
accesskey=dict(type='str', required=False), # noqa: E501
secretkey=dict(type='str', required=False), # noqa: E501
userquota=dict(type='bool', required=False, default=False), # noqa: E501
usermaxsize=dict(type='str', required=False, default='-1'), # noqa: E501
usermaxobjects=dict(type='int', required=False, default=-1), # noqa: E501
bucketquota=dict(type='bool', required=False, default=False), # noqa: E501
bucketmaxsize=dict(type='str', required=False, default='-1'), # noqa: E501
bucketmaxobjects=dict(type='int', required=False, default=-1)))) # noqa: E501
# the AnsibleModule object
module = AnsibleModule(argument_spec=fields,
......@@ -533,8 +533,8 @@ def main():
# radosgw connection
rgw = radosgw.connection.RadosGWAdminConnection(host=rgw_host,
port=port,
access_key=admin_access_key, # noqa E501
secret_key=admin_secret_key, # noqa E501
access_key=admin_access_key, # noqa: E501
secret_key=admin_secret_key, # noqa: E501
aws_signature='AWS4',
is_secure=is_secure)
......
......@@ -108,9 +108,9 @@ def sort_osd_crush_location(location, module):
"region",
"root",
]
return sorted(location, key=lambda crush: crush_bucket_types.index(crush[0])) # noqa E501
return sorted(location, key=lambda crush: crush_bucket_types.index(crush[0])) # noqa: E501
except ValueError as error:
fatal("{} is not a valid CRUSH bucket, valid bucket types are {}".format(error.args[0].split()[0], crush_bucket_types), module) # noqa E501
fatal("{} is not a valid CRUSH bucket, valid bucket types are {}".format(error.args[0].split()[0], crush_bucket_types), module) # noqa: E501
def create_and_move_buckets_list(cluster, location, containerized=None):
......@@ -122,10 +122,10 @@ def create_and_move_buckets_list(cluster, location, containerized=None):
for item in location:
bucket_type, bucket_name = item
# ceph osd crush add-bucket maroot root
cmd_list.append(generate_cmd(cluster, "add-bucket", bucket_name, bucket_type, containerized)) # noqa E501
cmd_list.append(generate_cmd(cluster, "add-bucket", bucket_name, bucket_type, containerized)) # noqa: E501
if previous_bucket:
# ceph osd crush move monrack root=maroot
cmd_list.append(generate_cmd(cluster, "move", previous_bucket, "%s=%s" % (bucket_type, bucket_name), containerized)) # noqa E501
cmd_list.append(generate_cmd(cluster, "move", previous_bucket, "%s=%s" % (bucket_type, bucket_name), containerized)) # noqa: E501
previous_bucket = item[1]
return cmd_list
......@@ -172,7 +172,7 @@ def run_module():
startd = datetime.datetime.now()
# run the Ceph command to add buckets
rc, cmd, out, err = exec_commands(module, create_and_move_buckets_list(cluster, location, containerized)) # noqa E501
rc, cmd, out, err = exec_commands(module, create_and_move_buckets_list(cluster, location, containerized)) # noqa: E501
endd = datetime.datetime.now()
delta = endd - startd
......
......@@ -17,9 +17,15 @@ __metaclass__ = type
from ansible.module_utils.basic import AnsibleModule
try:
from ansible.module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized, exec_command
from ansible.module_utils.ca_common import exit_module, \
generate_ceph_cmd, \
is_containerized, \
exec_command
except ImportError:
from module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized, exec_command
from module_utils.ca_common import exit_module, \
generate_ceph_cmd, \
is_containerized, \
exec_command
import datetime
import json
......@@ -71,7 +77,8 @@ options:
description:
- The ceph bucket type for replicated rule.
required: false
choices: ['osd', 'host', 'chassis', 'rack', 'row', 'pdu', 'pod', 'room', 'datacenter', 'zone', 'region', 'root']
choices: ['osd', 'host', 'chassis', 'rack', 'row', 'pdu', 'pod',
'room', 'datacenter', 'zone', 'region', 'root']
device_class:
description:
- The ceph device class for replicated rule.
......@@ -135,7 +142,10 @@ def create_rule(module, container_image=None):
if profile:
args.append(profile)
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'], args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'],
args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -150,7 +160,10 @@ def get_rule(module, container_image=None):
args = ['dump', name, '--format=json']
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'], args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'],
args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -165,7 +178,10 @@ def remove_rule(module, container_image=None):
args = ['rm', name]
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'], args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'],
args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -175,11 +191,11 @@ def main():
argument_spec=dict(
name=dict(type='str', required=True),
cluster=dict(type='str', required=False, default='ceph'),
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
rule_type=dict(type='str', required=False, choices=['replicated', 'erasure']),
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
rule_type=dict(type='str', required=False, choices=['replicated', 'erasure']), # noqa: E501
bucket_root=dict(type='str', required=False),
bucket_type=dict(type='str', required=False, choices=['osd', 'host', 'chassis', 'rack', 'row', 'pdu', 'pod',
'room', 'datacenter', 'zone', 'region', 'root']),
bucket_type=dict(type='str', required=False, choices=['osd', 'host', 'chassis', 'rack', 'row', 'pdu', 'pod', # noqa: E501
'room', 'datacenter', 'zone', 'region', 'root']), # noqa: E501
device_class=dict(type='str', required=False),
profile=dict(type='str', required=False)
),
......@@ -214,28 +230,28 @@ def main():
container_image = is_containerized()
if state == "present":
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image)) # noqa: E501
if rc != 0:
rc, cmd, out, err = exec_command(module, create_rule(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, create_rule(module, container_image=container_image)) # noqa: E501
changed = True
else:
rule = json.loads(out)
if (rule['type'] == 1 and rule_type == 'erasure') or (rule['type'] == 3 and rule_type == 'replicated'):
module.fail_json(msg="Can not convert crush rule {} to {}".format(name, rule_type), changed=False, rc=1)
if (rule['type'] == 1 and rule_type == 'erasure') or (rule['type'] == 3 and rule_type == 'replicated'): # noqa: E501
module.fail_json(msg="Can not convert crush rule {} to {}".format(name, rule_type), changed=False, rc=1) # noqa: E501
elif state == "absent":
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image)) # noqa: E501
if rc == 0:
rc, cmd, out, err = exec_command(module, remove_rule(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, remove_rule(module, container_image=container_image)) # noqa: E501
changed = True
else:
rc = 0
out = "Crush Rule {} doesn't exist".format(name)
elif state == "info":
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image)) # noqa: E501
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
if __name__ == '__main__':
......
......@@ -22,7 +22,7 @@ try:
exec_command, \
exit_module
except ImportError:
from module_utils.ca_common import generate_ceph_cmd, is_containerized, exec_command, exit_module
from module_utils.ca_common import generate_ceph_cmd, is_containerized, exec_command, exit_module # noqa: E501
import datetime
import json
......@@ -122,7 +122,11 @@ def create_user(module, container_image=None):
args = ['ac-user-create', '-i', '-', name]
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image, interactive=True)
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
args=args,
cluster=cluster,
container_image=container_image,
interactive=True)
return cmd
......@@ -140,7 +144,10 @@ def set_roles(module, container_image=None):
args.extend(roles)
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
args=args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -155,7 +162,11 @@ def set_password(module, container_image=None):
args = ['ac-user-set-password', '-i', '-', name]
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image, interactive=True)
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
args=args,
cluster=cluster,
container_image=container_image,
interactive=True)
return cmd
......@@ -170,7 +181,10 @@ def get_user(module, container_image=None):
args = ['ac-user-show', name, '--format=json']
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
args=args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -185,7 +199,10 @@ def remove_user(module, container_image=None):
args = ['ac-user-delete', name]
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
args=args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -194,11 +211,11 @@ def run_module():
module_args = dict(
cluster=dict(type='str', required=False, default='ceph'),
name=dict(type='str', required=True),
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
password=dict(type='str', required=False, no_log=True),
roles=dict(type='list',
required=False,
choices=['administrator', 'read-only', 'block-manager', 'rgw-manager', 'cluster-manager', 'pool-manager', 'cephfs-manager'],
choices=['administrator', 'read-only', 'block-manager', 'rgw-manager', 'cluster-manager', 'pool-manager', 'cephfs-manager'], # noqa: E501
default=[]),
)
......@@ -232,33 +249,33 @@ def run_module():
container_image = is_containerized()
if state == "present":
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image)) # noqa: E501
if rc == 0:
user = json.loads(out)
user['roles'].sort()
roles.sort()
if user['roles'] != roles:
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image)) # noqa: E501
changed = True
rc, cmd, out, err = exec_command(module, set_password(module, container_image=container_image), stdin=password)
rc, cmd, out, err = exec_command(module, set_password(module, container_image=container_image), stdin=password) # noqa: E501
else:
rc, cmd, out, err = exec_command(module, create_user(module, container_image=container_image), stdin=password)
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, create_user(module, container_image=container_image), stdin=password) # noqa: E501
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image)) # noqa: E501
changed = True
elif state == "absent":
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image)) # noqa: E501
if rc == 0:
rc, cmd, out, err = exec_command(module, remove_user(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, remove_user(module, container_image=container_image)) # noqa: E501
changed = True
else:
rc = 0
out = "Dashboard User {} doesn't exist".format(name)
elif state == "info":
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image)) # noqa: E501
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
def main():
......
......@@ -121,7 +121,7 @@ def get_profile(module, name, cluster='ceph', container_image=None):
return cmd
def create_profile(module, name, k, m, stripe_unit, cluster='ceph', force=False, container_image=None):
def create_profile(module, name, k, m, stripe_unit, cluster='ceph', force=False, container_image=None): # noqa: E501
'''
Create a profile
'''
......@@ -198,9 +198,10 @@ def run_module():
container_image = is_containerized()
if state == "present":
rc, cmd, out, err = exec_command(module, get_profile(module, name, cluster, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_profile(module, name, cluster, container_image=container_image)) # noqa: E501
if rc == 0:
# the profile already exists, let's check whether we have to update it
# the profile already exists, let's check whether we have to
# update it
current_profile = json.loads(out)
if current_profile['k'] != k or \
current_profile['m'] != m or \
......@@ -212,7 +213,7 @@ def run_module():
m,
stripe_unit,
cluster,
force=True, container_image=container_image))
force=True, container_image=container_image)) # noqa: E501
changed = True
else:
# the profile doesn't exist, it has to be created
......@@ -220,14 +221,14 @@ def run_module():
name,
k,
m,
stripe_unit,
stripe_unit, # noqa: E501
cluster,
container_image=container_image))
container_image=container_image)) # noqa: E501
if rc == 0:
changed = True
elif state == "absent":
rc, cmd, out, err = exec_command(module, delete_profile(module, name, cluster, container_image=container_image))
rc, cmd, out, err = exec_command(module, delete_profile(module, name, cluster, container_image=container_image)) # noqa: E501
if not err:
out = 'Profile {} removed.'.format(name)
changed = True
......@@ -235,7 +236,7 @@ def run_module():
rc = 0
out = "Skipping, the profile {} doesn't exist".format(name)
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
def main():
......
......@@ -119,7 +119,10 @@ def create_fs(module, container_image=None):
args = ['new', name, metadata, data]
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(sub_cmd=['fs'],
args=args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -134,7 +137,10 @@ def get_fs(module, container_image=None):
args = ['get', name, '--format=json']
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(sub_cmd=['fs'],
args=args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -149,7 +155,10 @@ def remove_fs(module, container_image=None):
args = ['rm', name, '--yes-i-really-mean-it']
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(sub_cmd=['fs'],
args=args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -164,7 +173,10 @@ def fail_fs(module, container_image=None):
args = ['fail', name]
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(sub_cmd=['fs'],
args=args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -180,7 +192,10 @@ def set_fs(module, container_image=None):
args = ['set', name, 'max_mds', str(max_mds)]
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
cmd = generate_ceph_cmd(sub_cmd=['fs'],
args=args,
cluster=cluster,
container_image=container_image)
return cmd
......@@ -189,7 +204,7 @@ def run_module():
module_args = dict(
cluster=dict(type='str', required=False, default='ceph'),
name=dict(type='str', required=True),
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
data=dict(type='str', required=False),
metadata=dict(type='str', required=False),
max_mds=dict(type='int', required=False),
......@@ -224,25 +239,25 @@ def run_module():
container_image = is_containerized()
if state == "present":
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image)) # noqa: E501
if rc == 0:
fs = json.loads(out)
if max_mds and fs["mdsmap"]["max_mds"] != max_mds:
rc, cmd, out, err = exec_command(module, set_fs(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, set_fs(module, container_image=container_image)) # noqa: E501
if rc == 0:
changed = True
else:
rc, cmd, out, err = exec_command(module, create_fs(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, create_fs(module, container_image=container_image)) # noqa: E501
if max_mds and max_mds > 1:
exec_command(module, set_fs(module, container_image=container_image))
exec_command(module, set_fs(module, container_image=container_image)) # noqa: E501
if rc == 0:
changed = True
elif state == "absent":
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image))
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image)) # noqa: E501
if rc == 0:
exec_command(module, fail_fs(module, container_image=container_image))