Add RETURN section, fix identation and apply flake8 recommendations (#20148)
parent
d8733a5455
commit
232cb764da
|
@ -105,6 +105,25 @@ EXAMPLES = '''
|
||||||
state: absent
|
state: absent
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
RETURN = '''
|
||||||
|
source:
|
||||||
|
description: Source that is managed.
|
||||||
|
returned: When not managing an image.
|
||||||
|
type: string
|
||||||
|
sample: https://datasets.project-fifo.net
|
||||||
|
uuid:
|
||||||
|
description: UUID for an image operated on.
|
||||||
|
returned: When not managing an image source.
|
||||||
|
type: string
|
||||||
|
sample: 70e3ae72-96b6-11e6-9056-9737fd4d0764
|
||||||
|
state:
|
||||||
|
description: State of the target, after execution.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: 'present'
|
||||||
|
'''
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Shortcut for the imgadm(1M) command. While imgadm(1M) supports a
|
# Shortcut for the imgadm(1M) command. While imgadm(1M) supports a
|
||||||
|
@ -113,6 +132,7 @@ import re
|
||||||
# the stacktrace, which breaks the parsers.
|
# the stacktrace, which breaks the parsers.
|
||||||
IMGADM = 'imgadm'
|
IMGADM = 'imgadm'
|
||||||
|
|
||||||
|
|
||||||
# Helper method to massage stderr
|
# Helper method to massage stderr
|
||||||
def errmsg(stderr):
|
def errmsg(stderr):
|
||||||
match = re.match('^imgadm .*?: error \(\w+\): (.*): .*', stderr)
|
match = re.match('^imgadm .*?: error \(\w+\): (.*): .*', stderr)
|
||||||
|
@ -121,6 +141,7 @@ def errmsg(stderr):
|
||||||
else:
|
else:
|
||||||
return 'Unexpected failure'
|
return 'Unexpected failure'
|
||||||
|
|
||||||
|
|
||||||
def update_images(module):
|
def update_images(module):
|
||||||
uuid = module.params['uuid']
|
uuid = module.params['uuid']
|
||||||
cmd = IMGADM + ' update'
|
cmd = IMGADM + ' update'
|
||||||
|
@ -135,6 +156,7 @@ def update_images(module):
|
||||||
# Note that 'imgadm -v' produces unparseable JSON...
|
# Note that 'imgadm -v' produces unparseable JSON...
|
||||||
return rc, stdout, errmsg(stderr), True
|
return rc, stdout, errmsg(stderr), True
|
||||||
|
|
||||||
|
|
||||||
def manage_sources(module, present):
|
def manage_sources(module, present):
|
||||||
force = module.params['force']
|
force = module.params['force']
|
||||||
source = module.params['source']
|
source = module.params['source']
|
||||||
|
@ -181,6 +203,7 @@ def manage_sources(module, present):
|
||||||
|
|
||||||
return (rc, stdout, errmsg(stderr), changed)
|
return (rc, stdout, errmsg(stderr), changed)
|
||||||
|
|
||||||
|
|
||||||
def manage_images(module, present):
|
def manage_images(module, present):
|
||||||
uuid = module.params['uuid']
|
uuid = module.params['uuid']
|
||||||
pool = module.params['pool']
|
pool = module.params['pool']
|
||||||
|
@ -236,6 +259,7 @@ def manage_images(module, present):
|
||||||
|
|
||||||
return (rc, stdout, errmsg(stderr), changed)
|
return (rc, stdout, errmsg(stderr), changed)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
|
@ -298,7 +322,6 @@ def main():
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue