Skip to content

Commit 6113dce

Browse files
Merge pull request #494 from netscaler/rename
Supporting operation rename
2 parents 71829ee + 9afa8bb commit 6113dce

76 files changed

Lines changed: 460 additions & 53 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

plugins/module_utils/common.py

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -190,29 +190,47 @@ def _check_create_resource_params(resource_name, resource_module_params, action=
190190
]
191191
except KeyError:
192192
resource_action_keys = []
193-
194-
# TODO: Should we allow non-add keys for the resource? OR should we error out if any non-add key is passed?
195-
for key in resource_module_params.keys():
196-
if not action:
197-
if key in resource_add_keys:
198-
post_data[key] = resource_module_params[key]
199-
elif resource_name == "service" and key == "ipaddress":
200-
post_data["ip"] = resource_module_params[key]
201-
else:
202-
log(
203-
"WARNING: Key `{}` is not allowed for the resource `{}` for CREATE operation. Skipping the key for the operation".format(
204-
key, resource_name
205-
)
206-
)
193+
if action == "rename":
194+
oldnamekey = NITRO_RESOURCE_MAP[resource_name]["primary_key"]
195+
if oldnamekey in resource_module_params:
196+
post_data[oldnamekey] = resource_module_params[oldnamekey]
197+
else:
198+
msg = "ERROR: Key `{}` is required for the resource `{}` for RENAME operation".format(
199+
oldnamekey, resource_name
200+
)
201+
log(msg)
202+
return False, msg, None
203+
if "newname" in resource_module_params:
204+
post_data["newname"] = resource_module_params["newname"]
207205
else:
208-
if key in resource_action_keys:
209-
post_data[key] = resource_module_params[key]
206+
msg = "ERROR: Key `newname` is required for the resource `{}` for RENAME operation".format(
207+
resource_name
208+
)
209+
log(msg)
210+
return False, msg, None
211+
else:
212+
# TODO: Should we allow non-add keys for the resource? OR should we error out if any non-add key is passed?
213+
for key in resource_module_params.keys():
214+
if not action:
215+
if key in resource_add_keys:
216+
post_data[key] = resource_module_params[key]
217+
elif resource_name == "service" and key == "ipaddress":
218+
post_data["ip"] = resource_module_params[key]
219+
else:
220+
log(
221+
"WARNING: Key `{}` is not allowed for the resource `{}` for CREATE operation. Skipping the key for the operation".format(
222+
key, resource_name
223+
)
224+
)
210225
else:
211-
log(
212-
"WARNING: Key `{}` is not allowed for the resource `{}` for `{}` action. Skipping the key for the operation".format(
213-
key, resource_name, action.upper()
226+
if key in resource_action_keys:
227+
post_data[key] = resource_module_params[key]
228+
else:
229+
log(
230+
"WARNING: Key `{}` is not allowed for the resource `{}` for `{}` action. Skipping the key for the operation".format(
231+
key, resource_name, action.upper()
232+
)
214233
)
215-
)
216234

217235
return True, None, post_data
218236

@@ -601,6 +619,8 @@ def get_valid_desired_states(resource_name):
601619
desired_states.add("switched")
602620
if "unset" in supported_operations:
603621
desired_states.add("unset")
622+
if "rename" in supported_operations:
623+
desired_states.add("renamed")
604624
if "apply" in supported_operations:
605625
desired_states.add("applied")
606626
return desired_states

plugins/module_utils/module_executor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ def main(self):
963963
"flushed",
964964
"switched",
965965
"unset",
966+
"renamed",
966967
"applied",
967968
}:
968969
state_action_map = {
@@ -971,6 +972,7 @@ def main(self):
971972
"flushed": "flush",
972973
"switched": "switch",
973974
"unset": "unset",
975+
"renamed": "rename",
974976
"applied": "apply",
975977
}
976978
self.act_on_resource(

plugins/modules/appflowaction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- present
3232
- absent
3333
- unset
34+
- renamed
3435
default: present
3536
description:
3637
- The state of the resource being configured by the module on the NetScaler
@@ -39,6 +40,7 @@
3940
the module's parameters.
4041
- When C(absent), the resource will be deleted from the NetScaler ADC node.
4142
- When C(unset), the resource will be unset on the NetScaler ADC node.
43+
- When C(renamed), the resource will be renamed on the NetScaler ADC node.
4244
type: str
4345
botinsight:
4446
type: str

plugins/modules/appflowcollector.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- present
3232
- absent
3333
- unset
34+
- renamed
3435
default: present
3536
description:
3637
- The state of the resource being configured by the module on the NetScaler
@@ -39,6 +40,7 @@
3940
the module's parameters.
4041
- When C(absent), the resource will be deleted from the NetScaler ADC node.
4142
- When C(unset), the resource will be unset on the NetScaler ADC node.
43+
- When C(renamed), the resource will be renamed on the NetScaler ADC node.
4244
type: str
4345
ipaddress:
4446
type: str

plugins/modules/appflowpolicy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- present
3232
- absent
3333
- unset
34+
- renamed
3435
default: present
3536
description:
3637
- The state of the resource being configured by the module on the NetScaler
@@ -39,6 +40,7 @@
3940
the module's parameters.
4041
- When C(absent), the resource will be deleted from the NetScaler ADC node.
4142
- When C(unset), the resource will be unset on the NetScaler ADC node.
43+
- When C(renamed), the resource will be renamed on the NetScaler ADC node.
4244
type: str
4345
action:
4446
type: str

plugins/modules/appflowpolicylabel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
choices:
3131
- present
3232
- absent
33+
- renamed
3334
default: present
3435
description:
3536
- The state of the resource being configured by the module on the NetScaler
3637
ADC node.
3738
- When C(present), the resource will be added/updated configured according to
3839
the module's parameters.
3940
- When C(absent), the resource will be deleted from the NetScaler ADC node.
41+
- When C(renamed), the resource will be renamed on the NetScaler ADC node.
4042
type: str
4143
labelname:
4244
type: str

plugins/modules/appfwpolicy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- present
3232
- absent
3333
- unset
34+
- renamed
3435
default: present
3536
description:
3637
- The state of the resource being configured by the module on the NetScaler
@@ -39,6 +40,7 @@
3940
the module's parameters.
4041
- When C(absent), the resource will be deleted from the NetScaler ADC node.
4142
- When C(unset), the resource will be unset on the NetScaler ADC node.
43+
- When C(renamed), the resource will be renamed on the NetScaler ADC node.
4244
type: str
4345
comment:
4446
type: str

plugins/modules/appfwpolicylabel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
choices:
3131
- present
3232
- absent
33+
- renamed
3334
default: present
3435
description:
3536
- The state of the resource being configured by the module on the NetScaler
3637
ADC node.
3738
- When C(present), the resource will be added/updated configured according to
3839
the module's parameters.
3940
- When C(absent), the resource will be deleted from the NetScaler ADC node.
41+
- When C(renamed), the resource will be renamed on the NetScaler ADC node.
4042
type: str
4143
labelname:
4244
type: str

plugins/modules/authenticationloginschemapolicy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- present
3232
- absent
3333
- unset
34+
- renamed
3435
default: present
3536
description:
3637
- The state of the resource being configured by the module on the NetScaler
@@ -39,6 +40,7 @@
3940
the module's parameters.
4041
- When C(absent), the resource will be deleted from the NetScaler ADC node.
4142
- When C(unset), the resource will be unset on the NetScaler ADC node.
43+
- When C(renamed), the resource will be renamed on the NetScaler ADC node.
4244
type: str
4345
action:
4446
type: str

plugins/modules/authenticationoauthidppolicy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- present
3232
- absent
3333
- unset
34+
- renamed
3435
default: present
3536
description:
3637
- The state of the resource being configured by the module on the NetScaler
@@ -39,6 +40,7 @@
3940
the module's parameters.
4041
- When C(absent), the resource will be deleted from the NetScaler ADC node.
4142
- When C(unset), the resource will be unset on the NetScaler ADC node.
43+
- When C(renamed), the resource will be renamed on the NetScaler ADC node.
4244
type: str
4345
action:
4446
type: str

0 commit comments

Comments
 (0)