Skip to content

Commit

Permalink
update error messages for device tools
Browse files Browse the repository at this point in the history
  • Loading branch information
noredistribution committed Nov 17, 2023
1 parent e67066c commit b62f3cc
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions ansible_collections/arista/cvp/plugins/module_utils/device_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,10 +1936,9 @@ def apply_configlets(self, user_inventory: DeviceInventory):
msg="Error applying configlets to device"
)
except CvpRequestError:
MODULE_LOGGER.error("Error applying configlets to device. User is unauthorized!")
self.__ansible.fail_json(
msg="Error applying configlets to device. User is unauthorized!"
)
message = "Failed to apply configlets to device. User is unauthorized!"
MODULE_LOGGER.error(message)
self.__ansible.fail_json(msg=message)
else:
if resp["data"]["status"] == "success":
result_data.changed = True
Expand Down Expand Up @@ -2235,10 +2234,9 @@ def delete_device(self, user_inventory: DeviceInventory):
msg="Error removing device from provisioning"
)
except CvpRequestError:
MODULE_LOGGER.error("Removing device from provisioning failed. User is unauthorized!")
self.__ansible.fail_json(
msg="Removing device from provisioning failed. User is unauthorized!"
)
message = "Failed to remove device from provisioning. User is unauthorized!"
MODULE_LOGGER.error(message)
self.__ansible.fail_json(msg=message)
else:
if resp["result"] == "success":
result_data.changed = True
Expand Down Expand Up @@ -2279,7 +2277,7 @@ def decommission_device(self, user_inventory: DeviceInventory):
self.__ansible.fail_json(msg="Error decommissioning device")
except CvpRequestError as e:
if "403 Forbidden" in e.msg:
request_err_msg = f"User is unauthorized to decommission device {device_id}"
request_err_msg = f"Failed to decommission device {device_id}. User is unauthorized!"
else:
request_err_msg = f"Device with {device_id} does not exist or is not registered to decommission"
MODULE_LOGGER.error(request_err_msg)
Expand Down Expand Up @@ -2345,8 +2343,9 @@ def reset_device(self, user_inventory: DeviceInventory):
MODULE_LOGGER.error("Error resetting device")
self.__ansible.fail_json(msg="Error resetting device")
except CvpRequestError:
MODULE_LOGGER.error("Error resetting device. Users is unauthorized!")
self.__ansible.fail_json(msg="Error resetting device. Users is unauthorized!")
message = "Failed to reset device. Users is unauthorized!"
MODULE_LOGGER.error(message)
self.__ansible.fail_json(msg=message)
else:
if resp and resp["data"]["status"] == "success":
result_data.changed = True
Expand Down

0 comments on commit b62f3cc

Please sign in to comment.