@@ -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,10 @@ 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 "Install" in supported_operations or "install" in supported_operations :
623+ desired_states .add ("installed" )
624+ if "rename" in supported_operations :
625+ desired_states .add ("renamed" )
604626 if "apply" in supported_operations :
605627 desired_states .add ("applied" )
606628 return desired_states
0 commit comments