mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-20 19:13:59 -07:00
refactor dict from literal list (#10891)
* refactor dict from literal list * add changelog frag
This commit is contained in:
parent
14a858fd9c
commit
5f471b8e5b
6 changed files with 17 additions and 14 deletions
6
changelogs/fragments/10891-dict-refactor.yml
Normal file
6
changelogs/fragments/10891-dict-refactor.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
minor_changes:
|
||||
- dependent lookup plugin - refactor dict initialization, no impact to users (https://github.com/ansible-collections/community.general/pull/10891).
|
||||
- scaleway module_utils - improve code readability, no impact to users (https://github.com/ansible-collections/community.general/pull/10891).
|
||||
- pacemaker_cluster.py - refactor dict initialization, no impact to users (https://github.com/ansible-collections/community.general/pull/10891).
|
||||
- pacemaker_resource.py - refactor dict initialization, no impact to users (https://github.com/ansible-collections/community.general/pull/10891).
|
||||
- pacemaker_stonith.py - refactor dict initialization, no impact to users (https://github.com/ansible-collections/community.general/pull/10891).
|
|
@ -180,7 +180,7 @@ class LookupModule(LookupBase):
|
|||
|
||||
if isinstance(values, Mapping):
|
||||
for idx, val in sorted(values.items()):
|
||||
current[key] = dict([('key', idx), ('value', val)])
|
||||
current[key] = dict(key=idx, value=val)
|
||||
self.__process(result, terms, index + 1, current, templar, variables)
|
||||
elif isinstance(values, Sequence):
|
||||
for elt in values:
|
||||
|
|
|
@ -109,10 +109,7 @@ class SecretVariables(object):
|
|||
|
||||
@staticmethod
|
||||
def dict_to_list(source_dict):
|
||||
return [
|
||||
dict(key=var[0], value=var[1])
|
||||
for var in source_dict.items()
|
||||
]
|
||||
return [dict(key=k, value=v) for k, v in source_dict.items()]
|
||||
|
||||
@staticmethod
|
||||
def list_to_dict(source_list, hashed=False):
|
||||
|
|
|
@ -87,7 +87,7 @@ class PacemakerCluster(StateModuleHelper):
|
|||
def __init_module__(self):
|
||||
self.runner = pacemaker_runner(self.module)
|
||||
self.vars.set('apply_all', True if not self.module.params['name'] else False)
|
||||
get_args = dict([('cli_action', 'cluster'), ('state', 'status'), ('name', None), ('apply_all', self.vars.apply_all)])
|
||||
get_args = dict(cli_action='cluster', state='status', name=None, apply_all=self.vars.apply_all)
|
||||
if self.module.params['state'] == "maintenance":
|
||||
get_args['cli_action'] = "property"
|
||||
get_args['state'] = "config"
|
||||
|
@ -121,9 +121,9 @@ class PacemakerCluster(StateModuleHelper):
|
|||
def _get(self):
|
||||
with self.runner('cli_action state name') as ctx:
|
||||
result = ctx.run(cli_action=self.vars.get_args['cli_action'], state=self.vars.get_args['state'], name=self.vars.get_args['name'])
|
||||
return dict([('rc', result[0]),
|
||||
('out', result[1] if result[1] != "" else None),
|
||||
('err', result[2])])
|
||||
return dict(rc=result[0],
|
||||
out=(result[1] if result[1] != "" else None),
|
||||
err=result[2])
|
||||
|
||||
def state_cleanup(self):
|
||||
with self.runner('cli_action state name', output_process=self._process_command_output(True, "Fail"), check_mode_skip=True) as ctx:
|
||||
|
|
|
@ -205,9 +205,9 @@ class PacemakerResource(StateModuleHelper):
|
|||
def _get(self):
|
||||
with self.runner('cli_action state name') as ctx:
|
||||
result = ctx.run(cli_action="resource", state='status')
|
||||
return dict([('rc', result[0]),
|
||||
('out', result[1] if result[1] != "" else None),
|
||||
('err', result[2])])
|
||||
return dict(rc=result[0],
|
||||
out=(result[1] if result[1] != "" else None),
|
||||
err=result[2])
|
||||
|
||||
def fmt_as_stack_argument(self, value, arg):
|
||||
if value is not None:
|
||||
|
|
|
@ -183,8 +183,8 @@ class PacemakerStonith(StateModuleHelper):
|
|||
def fmt_stonith_operations(self):
|
||||
modified_stonith_operations = []
|
||||
for stonith_operation in self.vars.stonith_operations:
|
||||
modified_stonith_operations.append(dict([("operation_action", stonith_operation.get('operation_action')),
|
||||
("operation_option", stonith_operation.get('operation_options'))]))
|
||||
modified_stonith_operations.append(dict(operation_action=stonith_operation.get('operation_action'),
|
||||
operation_option=stonith_operation.get('operation_options')))
|
||||
return modified_stonith_operations
|
||||
|
||||
def state_absent(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue