Assorted pylint fixes

This commit is contained in:
Dag Wieers 2019-02-14 21:02:27 +01:00 committed by Matt Clay
commit f9ab9b4d68
65 changed files with 343 additions and 473 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2016, Abdoul Bah (@helldorado) <bahabdoul at gmail.com>
# Copyright: (c) 2016, Abdoul Bah (@helldorado) <bahabdoul at gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -675,7 +675,7 @@ def create_vm(module, proxmox, vmid, newid, node, name, memory, cpu, cores, sock
valid_clone_params = ['format', 'full', 'pool', 'snapname', 'storage', 'target']
clone_params = {}
# Default args for vm. Note: -args option is for experts only. It allows you to pass arbitrary arguments to kvm.
vm_args = "-serial unix:/var/run/qemu-server/{}.serial,server,nowait".format(vmid)
vm_args = "-serial unix:/var/run/qemu-server/{0}.serial,server,nowait".format(vmid)
proxmox_node = proxmox.nodes(node)
@ -909,7 +909,7 @@ def main():
try:
vmid = get_nextvmid(module, proxmox)
except Exception as e:
module.fail_json(msg="Can't get the next vmid for VM {} automatically. Ensure your cluster state is good".format(name))
module.fail_json(msg="Can't get the next vmid for VM {0} automatically. Ensure your cluster state is good".format(name))
else:
try:
if not clone:
@ -918,9 +918,9 @@ def main():
vmid = get_vmid(proxmox, clone)[0]
except Exception as e:
if not clone:
module.fail_json(msg="VM {} does not exist in cluster.".format(name))
module.fail_json(msg="VM {0} does not exist in cluster.".format(name))
else:
module.fail_json(msg="VM {} does not exist in cluster.".format(clone))
module.fail_json(msg="VM {0} does not exist in cluster.".format(clone))
if clone is not None:
if get_vmid(proxmox, name):
@ -933,7 +933,7 @@ def main():
try:
newid = get_nextvmid(module, proxmox)
except Exception as e:
module.fail_json(msg="Can't get the next vmid for VM {} automatically. Ensure your cluster state is good".format(name))
module.fail_json(msg="Can't get the next vmid for VM {0} automatically. Ensure your cluster state is good".format(name))
else:
vm = get_vm(proxmox, newid)
if vm:
@ -942,15 +942,15 @@ def main():
if delete is not None:
try:
settings(module, proxmox, vmid, node, name, timeout, delete=delete)
module.exit_json(changed=True, msg="Settings has deleted on VM {} with vmid {}".format(name, vmid))
module.exit_json(changed=True, msg="Settings has deleted on VM {0} with vmid {1}".format(name, vmid))
except Exception as e:
module.fail_json(msg='Unable to delete settings on VM {} with vmid {}: '.format(name, vmid) + str(e))
module.fail_json(msg='Unable to delete settings on VM {0} with vmid {1}: '.format(name, vmid) + str(e))
elif revert is not None:
try:
settings(module, proxmox, vmid, node, name, timeout, revert=revert)
module.exit_json(changed=True, msg="Settings has reverted on VM {} with vmid {}".format(name, vmid))
module.exit_json(changed=True, msg="Settings has reverted on VM {0} with vmid {1}".format(name, vmid))
except Exception as e:
module.fail_json(msg='Unable to revert settings on VM {} with vmid {}: Maybe is not a pending task... '.format(name, vmid) + str(e))
module.fail_json(msg='Unable to revert settings on VM {0} with vmid {1}: Maybe is not a pending task... '.format(name, vmid) + str(e))
if state == 'present':
try:
@ -1031,9 +1031,9 @@ def main():
module.exit_json(changed=True, msg="VM %s with vmid %s deployed" % (name, vmid), **results)
except Exception as e:
if update:
module.fail_json(msg="Unable to update vm {} with vmid {}=".format(name, vmid) + str(e))
module.fail_json(msg="Unable to update vm {0} with vmid {1}=".format(name, vmid) + str(e))
elif clone is not None:
module.fail_json(msg="Unable to clone vm {} from vmid {}=".format(name, vmid) + str(e))
module.fail_json(msg="Unable to clone vm {0} from vmid {1}=".format(name, vmid) + str(e))
else:
module.fail_json(msg="creation of %s VM %s with vmid %s failed with exception=%s" % (VZ_TYPE, name, vmid, e))
@ -1111,7 +1111,7 @@ def main():
if status:
module.exit_json(changed=False, msg="VM %s with vmid = %s is %s" % (name, vmid, current), **status)
except Exception as e:
module.fail_json(msg="Unable to get vm {} with vmid = {} status: ".format(name, vmid) + str(e))
module.fail_json(msg="Unable to get vm {0} with vmid = {1} status: ".format(name, vmid) + str(e))
if __name__ == '__main__':

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2016, Ryan Scott Brown <ryansb@redhat.com>
# Copyright: (c) 2016, Ryan Scott Brown <ryansb@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -147,9 +147,9 @@ def read_serverless_config(module):
config = yaml.safe_load(sls_config.read())
return config
except IOError as e:
module.fail_json(msg="Could not open serverless.yml in {}. err: {}".format(path, str(e)), exception=traceback.format_exc())
module.fail_json(msg="Could not open serverless.yml in {0}. err: {1}".format(path, str(e)), exception=traceback.format_exc())
module.fail_json(msg="Failed to open serverless config at {}".format(
module.fail_json(msg="Failed to open serverless config at {0}".format(
os.path.join(path, 'serverless.yml')))
@ -159,9 +159,9 @@ def get_service_name(module, stage):
module.fail_json(msg="Could not read `service` key from serverless.yml file")
if stage:
return "{}-{}".format(config['service'], stage)
return "{0}-{1}".format(config['service'], stage)
return "{}-{}".format(config['service'], config.get('stage', 'dev'))
return "{0}-{1}".format(config['service'], config.get('stage', 'dev'))
def main():
@ -202,7 +202,7 @@ def main():
elif state == 'absent':
command += 'remove '
else:
module.fail_json(msg="State must either be 'present' or 'absent'. Received: {}".format(state))
module.fail_json(msg="State must either be 'present' or 'absent'. Received: {0}".format(state))
if state == 'present':
if not deploy:
@ -211,19 +211,19 @@ def main():
command += '--force '
if region:
command += '--region {} '.format(region)
command += '--region {0} '.format(region)
if stage:
command += '--stage {} '.format(stage)
command += '--stage {0} '.format(stage)
if verbose:
command += '--verbose '
rc, out, err = module.run_command(command, cwd=service_path)
if rc != 0:
if state == 'absent' and "-{}' does not exist".format(stage) in out:
if state == 'absent' and "-{0}' does not exist".format(stage) in out:
module.exit_json(changed=False, state='absent', command=command,
out=out, service_name=get_service_name(module, stage))
module.fail_json(msg="Failure when executing Serverless command. Exited {}.\nstdout: {}\nstderr: {}".format(rc, out, err))
module.fail_json(msg="Failure when executing Serverless command. Exited {0}.\nstdout: {1}\nstderr: {2}".format(rc, out, err))
# gather some facts about the deployment
module.exit_json(changed=True, state='present', out=out, command=command,