mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-18 18:01:31 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -111,15 +111,20 @@ result:
|
|||
|
||||
import traceback
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.remote_management.lxca.common import LXCA_COMMON_ARGS, has_pylxca, connection_object
|
||||
from ansible_collections.community.general.plugins.module_utils.remote_management.lxca.common import (
|
||||
LXCA_COMMON_ARGS,
|
||||
has_pylxca,
|
||||
connection_object,
|
||||
)
|
||||
|
||||
try:
|
||||
from pylxca import nodes
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
UUID_REQUIRED = 'UUID of device is required for nodes_by_uuid command.'
|
||||
CHASSIS_UUID_REQUIRED = 'UUID of chassis is required for nodes_by_chassis_uuid command.'
|
||||
UUID_REQUIRED = "UUID of device is required for nodes_by_uuid command."
|
||||
CHASSIS_UUID_REQUIRED = "UUID of chassis is required for nodes_by_chassis_uuid command."
|
||||
SUCCESS_MSG = "Success %s result"
|
||||
|
||||
|
||||
|
|
@ -128,23 +133,23 @@ def _nodes(module, lxca_con):
|
|||
|
||||
|
||||
def _nodes_by_uuid(module, lxca_con):
|
||||
if not module.params['uuid']:
|
||||
if not module.params["uuid"]:
|
||||
module.fail_json(msg=UUID_REQUIRED)
|
||||
return nodes(lxca_con, module.params['uuid'])
|
||||
return nodes(lxca_con, module.params["uuid"])
|
||||
|
||||
|
||||
def _nodes_by_chassis_uuid(module, lxca_con):
|
||||
if not module.params['chassis']:
|
||||
if not module.params["chassis"]:
|
||||
module.fail_json(msg=CHASSIS_UUID_REQUIRED)
|
||||
return nodes(lxca_con, chassis=module.params['chassis'])
|
||||
return nodes(lxca_con, chassis=module.params["chassis"])
|
||||
|
||||
|
||||
def _nodes_status_managed(module, lxca_con):
|
||||
return nodes(lxca_con, status='managed')
|
||||
return nodes(lxca_con, status="managed")
|
||||
|
||||
|
||||
def _nodes_status_unmanaged(module, lxca_con):
|
||||
return nodes(lxca_con, status='unmanaged')
|
||||
return nodes(lxca_con, status="unmanaged")
|
||||
|
||||
|
||||
def setup_module_object():
|
||||
|
|
@ -160,20 +165,21 @@ def setup_module_object():
|
|||
|
||||
|
||||
FUNC_DICT = {
|
||||
'nodes': _nodes,
|
||||
'nodes_by_uuid': _nodes_by_uuid,
|
||||
'nodes_by_chassis_uuid': _nodes_by_chassis_uuid,
|
||||
'nodes_status_managed': _nodes_status_managed,
|
||||
'nodes_status_unmanaged': _nodes_status_unmanaged,
|
||||
"nodes": _nodes,
|
||||
"nodes_by_uuid": _nodes_by_uuid,
|
||||
"nodes_by_chassis_uuid": _nodes_by_chassis_uuid,
|
||||
"nodes_status_managed": _nodes_status_managed,
|
||||
"nodes_status_unmanaged": _nodes_status_unmanaged,
|
||||
}
|
||||
|
||||
|
||||
INPUT_ARG_SPEC = dict(
|
||||
command_options=dict(default='nodes', choices=['nodes', 'nodes_by_uuid',
|
||||
'nodes_by_chassis_uuid',
|
||||
'nodes_status_managed',
|
||||
'nodes_status_unmanaged']),
|
||||
uuid=dict(), chassis=dict()
|
||||
command_options=dict(
|
||||
default="nodes",
|
||||
choices=["nodes", "nodes_by_uuid", "nodes_by_chassis_uuid", "nodes_status_managed", "nodes_status_unmanaged"],
|
||||
),
|
||||
uuid=dict(),
|
||||
chassis=dict(),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -184,12 +190,10 @@ def execute_module(module):
|
|||
"""
|
||||
try:
|
||||
with connection_object(module) as lxca_con:
|
||||
result = FUNC_DICT[module.params['command_options']](module, lxca_con)
|
||||
module.exit_json(changed=False,
|
||||
msg=SUCCESS_MSG % module.params['command_options'],
|
||||
result=result)
|
||||
result = FUNC_DICT[module.params["command_options"]](module, lxca_con)
|
||||
module.exit_json(changed=False, msg=SUCCESS_MSG % module.params["command_options"], result=result)
|
||||
except Exception as exception:
|
||||
error_msg = '; '.join(exception.args)
|
||||
error_msg = "; ".join(exception.args)
|
||||
module.fail_json(msg=error_msg, exception=traceback.format_exc())
|
||||
|
||||
|
||||
|
|
@ -199,5 +203,5 @@ def main():
|
|||
execute_module(module)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue