Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Abhijeet Kasurde authored on 2017/05/18 12:05:42... | ... |
@@ -197,17 +197,17 @@ class Imgadm(object): |
197 | 197 |
self.changed = True |
198 | 198 |
else: |
199 | 199 |
# Type is ignored by imgadm(1M) here |
200 |
- cmd += ' -d %s' % (source) |
|
200 |
+ cmd += ' -d %s' % source |
|
201 | 201 |
(rc, stdout, stderr) = self.module.run_command(cmd) |
202 | 202 |
|
203 | 203 |
if rc != 0: |
204 | 204 |
self.module.fail_json(msg='Failed to remove source: {0}'.format(self.errmsg(stderr))) |
205 | 205 |
|
206 |
- regex = 'Do not have image source "%s", no change' % (source) |
|
206 |
+ regex = 'Do not have image source "%s", no change' % source |
|
207 | 207 |
if re.match(regex, stdout): |
208 | 208 |
self.changed = False |
209 | 209 |
|
210 |
- regex = 'Deleted ".*" image source "%s"' % (source) |
|
210 |
+ regex = 'Deleted ".*" image source "%s"' % source |
|
211 | 211 |
if re.match(regex, stdout): |
212 | 212 |
self.changed = True |
213 | 213 |
|
... | ... |
@@ -53,7 +53,6 @@ RETURN = ''' |
53 | 53 |
''' |
54 | 54 |
|
55 | 55 |
import json |
56 |
- |
|
57 | 56 |
from ansible.module_utils.basic import AnsibleModule |
58 | 57 |
|
59 | 58 |
|
... | ... |
@@ -101,11 +100,9 @@ def main(): |
101 | 101 |
|
102 | 102 |
image_facts = ImageFacts(module) |
103 | 103 |
|
104 |
- data = {} |
|
105 |
- data['smartos_images'] = image_facts.return_all_installed_images() |
|
104 |
+ data = dict(smartos_images=image_facts.return_all_installed_images()) |
|
106 | 105 |
|
107 | 106 |
module.exit_json(ansible_facts=data) |
108 | 107 |
|
109 |
- |
|
110 | 108 |
if __name__ == '__main__': |
111 | 109 |
main() |
... | ... |
@@ -366,7 +366,7 @@ def get_vm_prop(module, uuid, prop): |
366 | 366 |
stdout_json = json.loads(stdout) |
367 | 367 |
except Exception as e: |
368 | 368 |
module.fail_json( |
369 |
- msg='Invalid JSON returned by vmadm for uuid lookup of {0}'.format(uuid), |
|
369 |
+ msg='Invalid JSON returned by vmadm for uuid lookup of {0}'.format(prop), |
|
370 | 370 |
details=to_native(e), exception=traceback.format_exc()) |
371 | 371 |
|
372 | 372 |
if len(stdout_json) > 0 and prop in stdout_json[0]: |
... | ... |
@@ -524,15 +524,15 @@ def create_payload(module, uuid): |
524 | 524 |
# drop the mkstemp call and rely on ANSIBLE_KEEP_REMOTE_FILES to retain |
525 | 525 |
# the payload (thus removing the `save_payload` option). |
526 | 526 |
fname = tempfile.mkstemp()[1] |
527 |
- fh = open(fname, 'w') |
|
528 | 527 |
os.chmod(fname, 0o400) |
529 |
- fh.write(vmdef_json) |
|
530 |
- fh.close() |
|
528 |
+ with open(fname, 'w') as fh: |
|
529 |
+ fh.write(vmdef_json) |
|
531 | 530 |
except Exception as e: |
532 | 531 |
module.fail_json(msg='Could not save JSON payload: %s' % to_native(e), exception=traceback.format_exc()) |
533 | 532 |
|
534 | 533 |
return fname |
535 | 534 |
|
535 |
+ |
|
536 | 536 |
def vm_state_transition(module, uuid, vm_state): |
537 | 537 |
ret = set_vm_state(module, uuid, vm_state) |
538 | 538 |
|
... | ... |
@@ -641,7 +641,7 @@ def main(): |
641 | 641 |
cpu_type=dict( |
642 | 642 |
default='qemu64', |
643 | 643 |
type='str', |
644 |
- choices=['host','qemu64'] |
|
644 |
+ choices=['host', 'qemu64'] |
|
645 | 645 |
), |
646 | 646 |
# Regular strings, however these require additional options. |
647 | 647 |
spice_password=dict(type='str', no_log=True), |
... | ... |
@@ -162,7 +162,6 @@ lib/ansible/modules/cloud/rackspace/rax_mon_check.py |
162 | 162 |
lib/ansible/modules/cloud/rackspace/rax_mon_entity.py |
163 | 163 |
lib/ansible/modules/cloud/rackspace/rax_mon_notification.py |
164 | 164 |
lib/ansible/modules/cloud/rackspace/rax_mon_notification_plan.py |
165 |
-lib/ansible/modules/cloud/smartos/vmadm.py |
|
166 | 165 |
lib/ansible/modules/cloud/softlayer/sl_vm.py |
167 | 166 |
lib/ansible/modules/cloud/univention/udm_dns_record.py |
168 | 167 |
lib/ansible/modules/cloud/univention/udm_dns_zone.py |