equinix-labs / ansible-collection-equinix

Ansible content to help automate the management of Equinix resources
https://deploy.equinix.com/labs/ansible-collection-equinix/
GNU General Public License v3.0
2 stars 8 forks source link

feat: Add new module for checking Equinix Metal metro capacity #194

Open paolacernada opened 3 weeks ago

paolacernada commented 3 weeks ago

Added a new Ansible module named metal_capacity_metro_info to gather capacity information for Equinix Metal metros.

paolacernada commented 3 weeks ago

I encountered an issue while using the CapacityApi.find_capacity_for_metro endpoint from the Equinix Python SDK. The error indicated that a NoneType object was being iterated over, suggesting that the API call might be returning None or an empty list instead of the expected data. Here is the specific error message:

'NoneType' object is not iterable

Any insights or directions are appreciated.

dcallao commented 3 weeks ago

@paolacernada Quick note on the commits. Use git squash to squash all the feat commits into a single commit.

paolacernada commented 1 week ago

The code is failing with the following error due to a bug in the SDK:

File "/tmp/ansible_equinix.cloud.metal_metro_capacity_info_payload_csk2ijq1/ansible_equinix.cloud.metal_metro_capacity_info_payload.zip/ansible_collections/equinix/cloud/plugins/module_utils/metal/metal_api.py", line 447, in populate_ids_from_hrefs return_dict = response.to_dict() File "/home/pcernada/.local/lib/python3.10/site-packages/equinix_metal/models/capacity_list.py", line 79, in to_dict _field_dict[_key] = self.capacity[_key].to_dict() AttributeError: 'dict' object has no attribute 'to_dict'

This error occurs because the to_dict method is being called on a dictionary object, which does not have this method. The capacity field in the capacity_list model is expected to contain objects with a to_dict method, but it currently contains plain dictionaries instead.