Add RETURN section, fix identation and apply flake8 recommendations (#20148)
parent
d8733a5455
commit
232cb764da
|
@ -105,6 +105,25 @@ EXAMPLES = '''
|
|||
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
|
||||
|
||||
# Shortcut for the imgadm(1M) command. While imgadm(1M) supports a
|
||||
|
@ -113,6 +132,7 @@ import re
|
|||
# the stacktrace, which breaks the parsers.
|
||||
IMGADM = 'imgadm'
|
||||
|
||||
|
||||
# Helper method to massage stderr
|
||||
def errmsg(stderr):
|
||||
match = re.match('^imgadm .*?: error \(\w+\): (.*): .*', stderr)
|
||||
|
@ -121,6 +141,7 @@ def errmsg(stderr):
|
|||
else:
|
||||
return 'Unexpected failure'
|
||||
|
||||
|
||||
def update_images(module):
|
||||
uuid = module.params['uuid']
|
||||
cmd = IMGADM + ' update'
|
||||
|
@ -135,6 +156,7 @@ def update_images(module):
|
|||
# Note that 'imgadm -v' produces unparseable JSON...
|
||||
return rc, stdout, errmsg(stderr), True
|
||||
|
||||
|
||||
def manage_sources(module, present):
|
||||
force = module.params['force']
|
||||
source = module.params['source']
|
||||
|
@ -181,6 +203,7 @@ def manage_sources(module, present):
|
|||
|
||||
return (rc, stdout, errmsg(stderr), changed)
|
||||
|
||||
|
||||
def manage_images(module, present):
|
||||
uuid = module.params['uuid']
|
||||
pool = module.params['pool']
|
||||
|
@ -236,6 +259,7 @@ def manage_images(module, present):
|
|||
|
||||
return (rc, stdout, errmsg(stderr), changed)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
|
@ -264,7 +288,7 @@ def main():
|
|||
|
||||
stderr = stdout = ''
|
||||
rc = 0
|
||||
result = { 'state': state }
|
||||
result = {'state': state}
|
||||
changed = False
|
||||
|
||||
# Perform basic UUID validation upfront.
|
||||
|
@ -298,7 +322,6 @@ def main():
|
|||
|
||||
module.exit_json(**result)
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue