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

metal_virtual_circuit #70

Closed t0mk closed 3 months ago

t0mk commented 1 year ago

Create module for metal_virtual_circuit.

Analogical to resource equinix_metal_virtual_circuit in terraform-provider-equinix:

Module should

See the newest added module to get an idea how to do implement this.

t0mk commented 8 months ago

@antoninrykalsky this is how I think the API routes for metal_circuit should look:

(GETTER and DELETER is straightforwar)

LISTER:

        ('metal_virtual_circuit', action.LIST): spec_types.ListerSpecs(
            equinix_metal.InterconnectionsApi(mpc).list_interconnection_virtual_circuits,
            {'connection_id': 'connection_id'},
        ),
        ('metal_port_virtual_circuit', action.LIST): spec_types.ListerSpecs(
            equinix_metal.InterconnectionsApi(mpc).list_interconnection_port_virtual_circuits,
            {'connection_id': 'connection_id', 'port_id': 'port_id'},
        ),

CREATOR:
        ('metal_virtual_circuit', action.CREATE): spec_types.Specs(
            equinix_metal.InterconnectionsApi(mpc).create_interconnection_port_virtual_circuit,
            {'connection_id': 'organization_id', 'port_id': 'port_id'},
            equinix_metal.VirtualCircuitCreateInput,
        ),

UPDATER:

        ('metal_virtual_circuit', action.UPDATE): spec_types.Specs(
            equinix_metal.InterconnectionsApi(mpc).update_virtual_circuit,
            {},
            equinix_metali.VirtualCircuitUpdateInput,
        ),

I think you will need to make an optional port_id argument in metal_virtual_circuit_info and based on that you'll need to use either of the resource types. See metal_device_info for how it's done with devices:

https://github.com/equinix-labs/ansible-collection-equinix/blob/main/plugins/modules/metal_device_info.py

antoninrykalsky commented 4 months ago

Guys, do you know where to get vnid for the parameter to create a virtual cicruit?

 TASK [metal_virtual_circuit : create first virtual circuit for test] ***********
2024-03-08T12:22:47.0412364Z An exception occurred during task execution. To see the full traceback, use -vvv. The error was: HTTP response body: {"code":422,"errors":["param is missing or the value is empty: vnid"]}
2024-03-08T12:22:47.0417621Z fatal: [testhost]: FAILED! => {"changed": false, "msg": "Error in metal_virtual_circuit: (422)\nReason: Unprocessable Entity\nHTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=utf-8', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Download-Options': 'noopen', 'X-Permitted-Cross-Domain-Policies': 'none', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Cache-Control': 'no-cache', 'X-Request-Id': '76b97dbd1a8e04182ac8e91ca3c0e41e', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains', 'Akamai-Internal-G2G-Failure-Sources': '_ORIGIN-3=422.e1', 'Content-Length': '70', 'Date': 'Fri, 08 Mar 2024 12:22:46 GMT', 'Connection': 'close'})\nHTTP response body: {\"code\":422,\"errors\":[\"param is missing or the value is empty: vnid\"]}\n"}

According to the API, this should not be a mandatory parameter. https://developer.equinix.com/catalog/metalv1#operation/createConnectionPortVirtualCircuit

thx

ctreatma commented 4 months ago

@antoninrykalsky the vnid can be set to either the id or the vxlan of a Virtual Network; it's required for a VLAN Virtual Circuit (the spec is incorrect on that), and it's not used for a VRF Virtual Circuit.

github-actions[bot] commented 3 months ago

This issue has been resolved in version 0.6.0 :tada: