fix: pep8

This commit is contained in:
Samori Gorse 2024-06-11 15:53:50 +02:00
commit 8e38b9f03c

View file

@ -9,7 +9,7 @@ __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = '''
name: xen_orchestra name: xen_orchestra
short_description: Management of instances on Xen Orchestra short_description: Management of instances on Xen Orchestra
version_added: 4.1.0 version_added: 9.0.1
author: author:
- Samori Gorse (@shinuza) <samorigorse@gmail.com> - Samori Gorse (@shinuza) <samorigorse@gmail.com>
requirements: requirements:
@ -116,7 +116,7 @@ try:
import websocket import websocket
from websocket import create_connection from websocket import create_connection
if LooseVersion(websocket.__version__) <= LooseVersion('1.0.0'): if LooseVersion(websocket.__version__) < LooseVersion('1.0.0'):
raise ImportError raise ImportError
except ImportError as e: except ImportError as e:
HAS_WEBSOCKET = False HAS_WEBSOCKET = False
@ -132,7 +132,6 @@ class XenOrchestra(object):
CALL_TIMEOUT = 100 CALL_TIMEOUT = 100
'''Number of 1/10ths of a second to wait before method call times out.''' '''Number of 1/10ths of a second to wait before method call times out.'''
def __init__(self, module): def __init__(self, module):
# from config # from config
self.counter = -1 self.counter = -1
@ -209,7 +208,7 @@ class XenOrchestra(object):
return answer['result'] return answer['result']
def restart_vm(self, vm_uid): def restart_vm(self, vm_uid):
answer = self.call('vm.restart', {'id': vm_uid, 'force': True }) answer = self.call('vm.restart', {'id': vm_uid, 'force': True})
if 'error' in answer: if 'error' in answer:
raise self.module.fail_json( raise self.module.fail_json(
@ -252,10 +251,11 @@ class XenOrchestra(object):
return answer['result'] return answer['result']
def main(): def main():
if not HAS_WEBSOCKET: if not HAS_WEBSOCKET:
raise AnsibleError('This module requires websocket-client 1.0.0 or higher: ' raise AnsibleError('This module requires websocket-client 1.0.0 or higher: '
'https://github.com/websocket-client/websocket-client.') 'https://github.com/websocket-client/websocket-client.')
module_args = dict( module_args = dict(
api_host=dict(type='str', required=True), api_host=dict(type='str', required=True),
@ -269,10 +269,8 @@ def main():
description=dict(type='str'), description=dict(type='str'),
boot_after_create=dict(type='bool', default=False), boot_after_create=dict(type='bool', default=False),
state=dict(default='present', choices=['present', 'absent', 'stopped', 'started', 'restarted']), state=dict(default='present', choices=['present', 'absent', 'stopped', 'started', 'restarted']),
) )
module = AnsibleModule( module = AnsibleModule(
argument_spec=module_args, argument_spec=module_args,
required_if=[ required_if=[
@ -308,5 +306,6 @@ def main():
result = xen_orchestra.create_vm() result = xen_orchestra.create_vm()
module.exit_json(changed=True, vm_uid=result) module.exit_json(changed=True, vm_uid=result)
if __name__ == '__main__': if __name__ == '__main__':
main() main()