Skip to content

Commit b0babde

Browse files
author
Bradley A. Thornton
authored
Merge pull request #11 from trishnaguha/_state_methods
Do not hardcode arguments for _state_{{ operation }} methods
2 parents ff779ac + 2e39511 commit b0babde

File tree

1 file changed

+12
-25
lines changed
  • roles/resource_module/templates/module_utils/network_os/config/resource

1 file changed

+12
-25
lines changed

roles/resource_module/templates/module_utils/network_os/config/resource/resource.py.j2

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,72 +91,59 @@ class {{ resource|capitalize }}(ConfigBase, {{ resource|capitalize }}Args):
9191
"""
9292
state = self._module.params['state']
9393
if state == 'overridden':
94-
commands = self._state_overridden(want, have)
94+
kwargs = {}
95+
commands = self._state_overridden(**kwargs)
9596
elif state == 'deleted':
96-
commands = self._state_deleted(want, have)
97+
kwargs = {}
98+
commands = self._state_deleted(**kwargs)
9799
elif state == 'merged':
98-
commands = self._state_merged(want, have)
100+
kwargs = {}
101+
commands = self._state_merged(**kwargs)
99102
elif state == 'replaced':
100-
commands = self._state_replaced(want, have)
103+
kwargs = {}
104+
commands = self._state_replaced(**kwargs)
101105
return commands
102106

103107
@staticmethod
104-
def _state_replaced(want, have):
108+
def _state_replaced(self, **kwargs):
105109
""" The command generator when state is replaced
106110
107-
:param want: the desired configuration as a dictionary
108-
:param have: the current configuration as a dictionary
109111
:rtype: A list
110112
:returns: the commands necessary to migrate the current configuration
111113
to the deisred configuration
112114
"""
113-
if want != have:
114-
# compare and generate command set
115-
pass
116115
commands = []
117116
return commands
118117

119118
@staticmethod
120-
def _state_overridden(want, have):
119+
def _state_overridden(self, **kwargs):
121120
""" The command generator when state is overridden
122121
123-
:param want: the desired configuration as a dictionary
124-
:param have: the current configuration as a dictionary
125122
:rtype: A list
126123
:returns: the commands necessary to migrate the current configuration
127124
to the deisred configuration
128125
"""
129-
if want != have:
130-
pass
131126
commands = []
132127
return commands
133128

134129
@staticmethod
135-
def _state_merged(want, have):
130+
def _state_merged(self, **kwargs):
136131
""" The command generator when state is merged
137132
138-
:param want: the additive configuration as a dictionary
139-
:param have: the current configuration as a dictionary
140133
:rtype: A list
141134
:returns: the commands necessary to merge the provided into
142135
the current configuration
143136
"""
144-
if want != have:
145-
pass
146137
commands = []
147138
return commands
148139

149140
@staticmethod
150-
def _state_deleted(want, have):
141+
def _state_deleted(self, **kwargs):
151142
""" The command generator when state is deleted
152143
153-
:param want: the objects from which the configuration should be removed
154-
:param have: the current configuration as a dictionary
155144
:rtype: A list
156145
:returns: the commands necessary to remove the current configuration
157146
of the provided objects
158147
"""
159-
if want != have:
160-
pass
161148
commands = []
162149
return commands

0 commit comments

Comments
 (0)