diff --git a/plugins/modules/inventory_intent.py b/plugins/modules/inventory_intent.py index c7102c9221..e9542a01f0 100644 --- a/plugins/modules/inventory_intent.py +++ b/plugins/modules/inventory_intent.py @@ -1924,11 +1924,12 @@ def get_udf_id(self, field_name): return udf_id - def mandatory_parameter(self): + def mandatory_parameter(self, device_to_add_in_ccc): """ Check for and validate mandatory parameters for adding network devices in Cisco Catalyst Center. Parameters: self (object): An instance of a class used for interacting with Cisco Cisco Catalyst Center. + device_to_add_in_ccc(list): List to device ip addresses to be added in Cisco Catalyst Center. Returns: dict: The input `config` dictionary if all mandatory parameters are present. Description: @@ -1953,12 +1954,12 @@ def mandatory_parameter(self): if mandatory_params_absent: self.status = "failed" - self.msg = "Required parameters {0} for adding devices are not present".format(str(mandatory_params_absent)) + self.msg = "Required parameters {0} for adding devices '{1}' are not present".format(str(mandatory_params_absent), str(device_to_add_in_ccc)) self.result['msg'] = self.msg self.log(self.msg, "ERROR") else: self.status = "success" - self.msg = "Required parameter for Adding the devices in Inventory are present." + self.msg = "Required parameters for adding the devices '{0}' to inventory are present.".format(str(device_to_add_in_ccc)) self.log(self.msg, "INFO") return self @@ -2569,6 +2570,7 @@ def update_interface_detail_of_device(self, device_to_update): # Call the Get interface details by device IP API and fetch the interface Id is_update_occurred = False + response_list = [] for device_ip in device_to_update: interface_params = self.config[0].get('update_interface_details') interface_names_list = interface_params.get('interface_name') @@ -2597,7 +2599,7 @@ def update_interface_detail_of_device(self, device_to_update): if response.get('role').upper() != "ACCESS": self.msg = "The action to clear the MAC Address table is only supported for devices with the ACCESS role." self.log(self.msg, "WARNING") - self.result['response'] = self.msg + response_list.append(self.msg) self.result['changed'] = False else: deploy_mode = interface_params.get('deployment_mode', 'Deploy') @@ -2663,7 +2665,7 @@ def update_interface_detail_of_device(self, device_to_update): self.status = "success" is_update_occurred = True self.msg = "Successfully updated the Interface Details for device '{0}'.".format(device_ip) - self.result['response'] = self.msg + response_list.append(self.msg) self.log(self.msg, "INFO") break elif execution_details.get("isError"): @@ -2683,9 +2685,10 @@ def update_interface_detail_of_device(self, device_to_update): self.result['changed'] = False self.msg = "Port actions are only supported on user facing/access ports as it's not allowed or No Updation required" self.log(self.msg, "INFO") - self.result['response'] = self.msg + response_list.append(self.msg) self.result['changed'] = is_update_occurred + self.result['response'] = response_list return self @@ -2977,7 +2980,8 @@ def get_diff_merged(self, config): device_params.pop('snmpPrivPassphrase', None) device_params.pop('snmpPrivProtocol', None) - self.mandatory_parameter().check_return_status() + device_to_add_in_ccc = device_params['ipAddress'] + self.mandatory_parameter(device_to_add_in_ccc).check_return_status() try: response = self.dnac._exec( family="devices", diff --git a/plugins/modules/inventory_workflow_manager.py b/plugins/modules/inventory_workflow_manager.py index 3d4c6dc18d..5ec69bb447 100644 --- a/plugins/modules/inventory_workflow_manager.py +++ b/plugins/modules/inventory_workflow_manager.py @@ -1916,11 +1916,12 @@ def get_udf_id(self, field_name): return udf_id - def mandatory_parameter(self): + def mandatory_parameter(self, device_to_add_in_ccc): """ Check for and validate mandatory parameters for adding network devices in Cisco Catalyst Center. Parameters: self (object): An instance of a class used for interacting with Cisco Cisco Catalyst Center. + device_to_add_in_ccc(list): List to device ip addresses to be added in Cisco Catalyst Center. Returns: dict: The input `config` dictionary if all mandatory parameters are present. Description: @@ -1945,12 +1946,12 @@ def mandatory_parameter(self): if mandatory_params_absent: self.status = "failed" - self.msg = "Required parameters {0} for adding devices are not present".format(str(mandatory_params_absent)) + self.msg = "Required parameters {0} for adding devices '{1}' are not present".format(str(mandatory_params_absent), str(device_to_add_in_ccc)) self.result['msg'] = self.msg self.log(self.msg, "ERROR") else: self.status = "success" - self.msg = "Required parameter for Adding the devices in Inventory are present." + self.msg = "Required parameters for adding the devices '{0}' to inventory are present.".format(str(device_to_add_in_ccc)) self.log(self.msg, "INFO") return self @@ -2561,6 +2562,7 @@ def update_interface_detail_of_device(self, device_to_update): # Call the Get interface details by device IP API and fetch the interface Id is_update_occurred = False + response_list = [] for device_ip in device_to_update: interface_params = self.config[0].get('update_interface_details') interface_names_list = interface_params.get('interface_name') @@ -2589,7 +2591,7 @@ def update_interface_detail_of_device(self, device_to_update): if response.get('role').upper() != "ACCESS": self.msg = "The action to clear the MAC Address table is only supported for devices with the ACCESS role." self.log(self.msg, "WARNING") - self.result['response'] = self.msg + response_list.append(self.msg) self.result['changed'] = False else: deploy_mode = interface_params.get('deployment_mode', 'Deploy') @@ -2622,7 +2624,7 @@ def update_interface_detail_of_device(self, device_to_update): self.msg = """Interface details for the given interface '{0}' are already updated in the Cisco Catalyst Center for the device '{1}'.""".format(interface_name, device_ip) self.log(self.msg, "INFO") - self.result['response'] = self.msg + response_list.append(self.msg) continue update_interface_params = { @@ -2655,7 +2657,7 @@ def update_interface_detail_of_device(self, device_to_update): self.status = "success" is_update_occurred = True self.msg = "Successfully updated the Interface Details for device '{0}'.".format(device_ip) - self.result['response'] = self.msg + response_list.append(self.msg) self.log(self.msg, "INFO") break elif execution_details.get("isError"): @@ -2675,9 +2677,10 @@ def update_interface_detail_of_device(self, device_to_update): self.result['changed'] = False self.msg = "Port actions are only supported on user facing/access ports as it's not allowed or No Updation required" self.log(self.msg, "INFO") - self.result['response'] = self.msg + response_list.append(self.msg) self.result['changed'] = is_update_occurred + self.result['response'] = response_list return self @@ -2968,7 +2971,8 @@ def get_diff_merged(self, config): device_params.pop('snmpPrivPassphrase', None) device_params.pop('snmpPrivProtocol', None) - self.mandatory_parameter().check_return_status() + device_to_add_in_ccc = device_params['ipAddress'] + self.mandatory_parameter(device_to_add_in_ccc).check_return_status() try: response = self.dnac._exec( family="devices",