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

implements metal connection, info and integration tests #118

Closed AlexBacho closed 9 months ago

AlexBacho commented 10 months ago

work in progress

Fixes #15 Fixes #54

AlexBacho commented 10 months ago

I get a 500 unhandled exception when creating a shared primary connection, any idea what is causing this?

image

t0mk commented 10 months ago

I get a 500 unhandled exception when creating a shared primary connection, any idea what is causing this?

image

This might be a misconfiguration for connection. Probably an API issue. TF doesn't sanitize this.

AlexBacho commented 10 months ago

should be ready for review

t0mk commented 9 months ago

@AlexBacho we will need to rework this a bit still. With the API update and with new equinix_metal pip package, you can see that InterconnectionCreateInput class is not genreated anymore. Instead it's defined as oneOf[0], and there is for type == "dedicated": https://github.com/equinix-labs/metal-python/blob/main/equinix_metal/docs/DedicatedPortCreateInput.md for type =="shared": https://github.com/equinix-labs/metal-python/blob/main/equinix_metal/docs/VlanFabricVcCreateInput.md

[0] https://github.com/equinix-labs/metal-python/blob/main/oas3.fetched/components/requestBodies/InterconnectionCreateInput.yaml

You will need to update equinix_metal to the latest release to see the new input classes. Please also fix equinix_metal to the newest equinix_metal release in requirements.yml.

t0mk commented 9 months ago

@AlexBacho I looked a bit more on the API[0]. It seems that there's a way to create IC in project[1] or in an org[2]. The module should handle both. The API input to project can be any of the three [3], and input to org can be only DedicatedPort.

We have 4 combinations here which is not good. We need to think how to handle those in the api_router[4], because in the CREATOR routes, we have a combination of APImethod-Input, I think we'll need 4 entries there

metal_connection_project_dedicated metal_connection_project_vlanfabric metal_connection_project_vrf metal_connection_organization_dedicated

.. in form

        ('`metal_connection_organization_vlanfabric', action.CREATE): spec_types.Specs(
            equinix_metal.InterconnectionsApi(mpc).metal_connection_organization_vlanfabric,
            {'organization_id': 'organization_id'},  # see the args of the function in [5] 
            equinix_metal.DedicatedPortCreateInput,
        ),

.. I think you understand what the configuration should be for the other routes.

You will need to distinguish those for the create event in the module. I do sth similar but much simpler in the metal_project, line 245 [6]. As for the GETTER and UPDATER, there's only one of each [7,8]. As for listers there will be 2 [9,10] (you will need them in metal_connection_info, where there should be two exclusive params project_id and organization_id.

You don't need to implement the fetch by name in metal_connection. Just by ID. It's a pretty bad practice anyway, I shouldn't have done in the collection.

I hope this is clear, let's talk tomorrow.

[0] https://deploy.equinix.com/developers/api/metal#tag/Interconnections [1] https://deploy.equinix.com/developers/api/metal#tag/Interconnections/operation/createProjectInterconnection [2] https://deploy.equinix.com/developers/api/metal#tag/Interconnections/operation/createOrganizationInterconnection [3] https://github.com/equinix-labs/metal-python/blob/main/oas3.fetched/components/requestBodies/InterconnectionCreateInput.yaml [4] https://github.com/equinix-labs/ansible-collection-equinix/blob/main/plugins/module_utils/metal/api_routes.py [5] https://github.com/equinix-labs/metal-python/blob/main/equinix_metal/equinix_metal/api/interconnections_api.py#L223 [6] https://github.com/equinix-labs/ansible-collection-equinix/blob/main/plugins/modules/metal_project.py#L245 [7] https://deploy.equinix.com/developers/api/metal#tag/Interconnections/operation/getInterconnection [8] https://deploy.equinix.com/developers/api/metal#tag/Interconnections/operation/updateInterconnection [9] https://deploy.equinix.com/developers/api/metal#tag/Interconnections/operation/organizationListInterconnections [10] https://deploy.equinix.com/developers/api/metal#tag/Interconnections/operation/projectListInterconnections