1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

PEP8 fixes for smartos module

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2017-05-18 08:35:42 +05:30 committed by Toshio Kuratomi
parent 374872cac4
commit dd9db65a9a
4 changed files with 9 additions and 13 deletions

View file

@ -197,17 +197,17 @@ class Imgadm(object):
self.changed = True
else:
# Type is ignored by imgadm(1M) here
cmd += ' -d %s' % (source)
cmd += ' -d %s' % source
(rc, stdout, stderr) = self.module.run_command(cmd)
if rc != 0:
self.module.fail_json(msg='Failed to remove source: {0}'.format(self.errmsg(stderr)))
regex = 'Do not have image source "%s", no change' % (source)
regex = 'Do not have image source "%s", no change' % source
if re.match(regex, stdout):
self.changed = False
regex = 'Deleted ".*" image source "%s"' % (source)
regex = 'Deleted ".*" image source "%s"' % source
if re.match(regex, stdout):
self.changed = True

View file

@ -53,7 +53,6 @@ RETURN = '''
'''
import json
from ansible.module_utils.basic import AnsibleModule
@ -101,11 +100,9 @@ def main():
image_facts = ImageFacts(module)
data = {}
data['smartos_images'] = image_facts.return_all_installed_images()
data = dict(smartos_images=image_facts.return_all_installed_images())
module.exit_json(ansible_facts=data)
if __name__ == '__main__':
main()

View file

@ -366,7 +366,7 @@ def get_vm_prop(module, uuid, prop):
stdout_json = json.loads(stdout)
except Exception as e:
module.fail_json(
msg='Invalid JSON returned by vmadm for uuid lookup of {0}'.format(uuid),
msg='Invalid JSON returned by vmadm for uuid lookup of {0}'.format(prop),
details=to_native(e), exception=traceback.format_exc())
if len(stdout_json) > 0 and prop in stdout_json[0]:
@ -524,15 +524,15 @@ def create_payload(module, uuid):
# drop the mkstemp call and rely on ANSIBLE_KEEP_REMOTE_FILES to retain
# the payload (thus removing the `save_payload` option).
fname = tempfile.mkstemp()[1]
fh = open(fname, 'w')
os.chmod(fname, 0o400)
with open(fname, 'w') as fh:
fh.write(vmdef_json)
fh.close()
except Exception as e:
module.fail_json(msg='Could not save JSON payload: %s' % to_native(e), exception=traceback.format_exc())
return fname
def vm_state_transition(module, uuid, vm_state):
ret = set_vm_state(module, uuid, vm_state)

View file

@ -162,7 +162,6 @@ lib/ansible/modules/cloud/rackspace/rax_mon_check.py
lib/ansible/modules/cloud/rackspace/rax_mon_entity.py
lib/ansible/modules/cloud/rackspace/rax_mon_notification.py
lib/ansible/modules/cloud/rackspace/rax_mon_notification_plan.py
lib/ansible/modules/cloud/smartos/vmadm.py
lib/ansible/modules/cloud/softlayer/sl_vm.py
lib/ansible/modules/cloud/univention/udm_dns_record.py
lib/ansible/modules/cloud/univention/udm_dns_zone.py