Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: metal virtual circuit #141

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

antoninrykalsky
Copy link
Contributor

@antoninrykalsky antoninrykalsky commented Nov 24, 2023

Fixes #70
Fixes #33

@t0mk
Copy link
Contributor

t0mk commented Nov 27, 2023

@antoninrykalsky Thanks for the PR. We will wait for an Interconnection to test this properly.

@displague
Copy link
Member

displague commented Feb 21, 2024

Heads up that there is an upcoming requirement for VLAN in the requests: https://feedback.equinixmetal.com/changelog/virtual-circuits-will-require-vlans-on-feb-29-2024

Since this PR allows for vlan to be defined (as nni_vlan, vlan_id, also vrf_id), it is fine that the user will receive a 422 from the API server prompting them to add vlan in their Ansible configuration.

@displague
Copy link
Member

displague commented Feb 21, 2024

The e2e tests would be possible, reusing the same dedicated connection used by Terraform e2e testing. We are a little worried about racing between the two tests. This may not be problematic if Terraform created VCs on the dedicated connection have no impact on Ansible created VCs (resources are swept accordingly by name prefixes, and VC quantity is not impacted by parallel test runners). We can probably run with this and approach and keep an eye out for test failures as described.

@ctreatma suggested that we could make this test conditional based on a dedicated connection environment variable being defined, ANSIBLE_ACC_METAL_DEDICATED_CONNECTION_ID, perhaps. I've defined this variable as a GitHub Action Repository secret. This project's E2E runner should be able to access it.

Alternatively, dedicated connection mocks would be helpful here because dedicated connections have harder setup requirements and we don't want to accidentally delete them or misconfigure them.

@displague
Copy link
Member

I'd like to be able to include this in the v0.4.0 release in the next few weeks.

@displague
Copy link
Member

displague commented Feb 27, 2024

Error in metal_virtual_circuit: No match found when deserializing the JSON string into VirtualCircuitCreateInput with oneOf schemas: VlanVirtualCircuitCreateInput, VrfVirtualCircuitCreateInput.

Details:

  • 1 validation error for VlanVirtualCircuitCreateInput

    • nni_vlan value is not a valid integer (type=type_error.integer)
  • 4 validation errors for VrfVirtualCircuitCreateInput

    • nni_vlan value is not a valid integer (type=type_error.integer)
    • peer_asn none is not an allowed value (type=type_error.none.not_allowed)
    • subnet none is not an allowed value (type=type_error.none.not_allowed)
    • vrf none is not an allowed value (type=type_error.none.not_allowed)

https://github.com/equinix-labs/ansible-collection-equinix/pull/141/files#diff-f66d1a8381458f8e62c2cb40b979f693ae7697846f1b6cbe0edd4fcbc33c3421R71-R79

ansible-test integration metal_virtual_circuit
Running metal_virtual_circuit integration test role

PLAY [testhost] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [testhost]

TASK [metal_virtual_circuit : set_fact] ****************************************
ok: [testhost]

TASK [metal_virtual_circuit : set_fact] ****************************************
ok: [testhost]

TASK [metal_virtual_circuit : set_fact] ****************************************
ok: [testhost]

TASK [metal_virtual_circuit : set_fact] ****************************************
ok: [testhost]

TASK [metal_virtual_circuit : set_fact] ****************************************
ok: [testhost]

TASK [metal_virtual_circuit : create first project for test] *******************
changed: [testhost]

TASK [metal_virtual_circuit : create connection for test] **********************
changed: [testhost]

TASK [metal_virtual_circuit : Display test_connection] *************************
ok: [testhost] => {
    "test_connection": {
        "changed": true,
        "contact_email": "[email protected]",
        "description": "My new VLAN",
        "failed": false,
        "id": "8a2e639f-7efa-43b7-a8d4-26b2b99e61f4",
        "metro": {
            "code": "am",
            "country": "NL",
            "id": "108b2cfb-246b-45e3-885a-bf3e82fce1a0",
            "name": "Amsterdam"
        },
        "mode": "standard",
        "name": "ansible-integration-test-project-ar-denfnszy-TestConn",
        "ports": [
            {
                "href": "/metal/v1/connections/8a2e639f-7efa-43b7-a8d4-26b2b99e61f4/ports/7cb170a3-c254-4b5d-8abd-508e7dc87562",
                "id": "7cb170a3-c254-4b5d-8abd-508e7dc87562",
                "link_status": "unknown",
                "name": "ansible-integration-test-project-ar-denfnszy-TestConn-primary",
                "organization": {
                    "href": "/metal/v1/organizations/e965d662-e182-4f84-a43b-ff16c5d320bd"
                },
                "role": "primary",
                "speed": 50000000,
                "status": "requested",
                "virtual_circuits": []
            }
        ],
        "redundancy": "primary",
        "requested_by": {
            "href": "/metal/v1/users/72fe6383-b41f-4373-9f67-4bd5ec9a74a7",
            "id": "72fe6383-b41f-4373-9f67-4bd5ec9a74a7"
        },
        "status": "pending",
        "tags": [],
        "type": "dedicated"
    }
}

TASK [metal_virtual_circuit : Display test_metro_id] ***************************
ok: [testhost] => {
    "test_metro_id": "VARIABLE IS NOT DEFINED!"
}

TASK [metal_virtual_circuit : create VLAN resource no.1] ***********************
changed: [testhost]

TASK [metal_virtual_circuit : Display test_vlan] *******************************
ok: [testhost] => {
    "test_vlan": {
        "changed": true,
        "description": "This is my new VLAN 1.",
        "failed": false,
        "id": "9573b1af-97c3-493b-a674-9bd026db01ed",
        "metro": {
            "href": "/metal/v1/locations/metros/108b2cfb-246b-45e3-885a-bf3e82fce1a0",
            "id": "108b2cfb-246b-45e3-885a-bf3e82fce1a0"
        },
        "vxlan": 1234
    }
}

TASK [metal_virtual_circuit : create first virtual circuit for test] ***********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was:   none is not an allowed value (type=type_error.none.not_allowed)
fatal: [testhost]: FAILED! => {"changed": false, "msg": "Error in metal_virtual_circuit: No match found when deserializing the JSON string into VirtualCircuitCreateInput with oneOf schemas: VlanVirtualCircuitCreateInput, VrfVirtualCircuitCreateInput. Details: 1 validation error for VlanVirtualCircuitCreateInput\nnni_vlan\n  value is not a valid integer (type=type_error.integer), 4 validation errors for VrfVirtualCircuitCreateInput\nnni_vlan\n  value is not a valid integer (type=type_error.integer)\npeer_asn\n  none is not an allowed value (type=type_error.none.not_allowed)\nsubnet\n  none is not an allowed value (type=type_error.none.not_allowed)\nvrf\n  none is not an allowed value (type=type_error.none.not_allowed)"}

TASK [metal_virtual_circuit : Announce teardown start] *************************
ok: [testhost] => {
    "msg": "***** TESTING COMPLETE. COMMENCE TEARDOWN *****"
}

TASK [metal_virtual_circuit : list test projects] ******************************
ok: [testhost]

TASK [metal_virtual_circuit : delete test projects] ****************************
changed: [testhost] => (item={'backend_transfer_enabled': True, 'customdata': {}, 'description': '', 'id': '08f99f1a-ed09-4149-a16e-87f37665a423', 'name': 'ansible-integration-test-project-ar-denfnszy-project1', 'organization_id': 'e965d662-e182-4f84-a43b-ff16c5d320bd', 'payment_method_id': ''})

PLAY RECAP *********************************************************************
testhost                   : ok=15   changed=4    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

@displague
Copy link
Member

It should be possible to test reading in the virtual circuit returned by a shared interconnection.

('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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unfamiliar with the patterns in this project.
Is L279 correct?

Is L280 expected to work with the single CreateInput type or perhaps does this resource need to be split up like metal_connection_project_* to accommodate the multiple input types: VlanVirtualCircuitCreateInput,VrfVirtualCircuitCreateInput?

@t0mk
Copy link
Contributor

t0mk commented Mar 1, 2024

@displague Can you please check that ANSIBLE_ACC_METAL_DEDICATED_CONNECTION_ID was indeed set? Is it in the same "namespace" as the access token? We need to read it as envvar and it seems empty.

ctreatma added a commit that referenced this pull request Mar 6, 2024
This PR adds secret ANSIBLE_ACC_METAL_DEDICATED_CONNECTION_ID to
integration test pr as an env var so that we can use it in #141
@displague
Copy link
Member

displague commented Mar 6, 2024

https://github.com/equinix-labs/ansible-collection-equinix/actions/runs/8112585936/job/22174149489?pr=141#step:9:1974

TASK [metal_virtual_circuit : create first project for test] *******************
changed: [testhost]

TASK [metal_virtual_circuit : Display test_connection] *************************
ok: [testhost] => {
    "test_connection": "VARIABLE IS NOT DEFINED!"
}

TASK [metal_virtual_circuit : create VLAN resource no.1] ***********************
changed: [testhost]

TASK [metal_virtual_circuit : Display test_vlan] *******************************
ok: [testhost] => {
    "test_vlan": {
        "changed": true,
        "description": "This is my new VLAN 1.",
        "failed": false,
        "id": "6fbb33c1-bc30-45da-a04e-06f64c1ee388",
        "metro": {
            "href": "/metal/v1/locations/metros/108b2cfb-246b-45e3-885a-bf3e82fce1a0",
            "id": "108b2cfb-246b-45e3-885a-bf3e82fce1a0"
        },
        "vxlan": 1234
    }
}

TASK [metal_virtual_circuit : create first virtual circuit for test] ***********
fatal: [testhost]: FAILED! => {"changed": false, "msg": "Invalid UUID for connection_id: "}

@displague
Copy link
Member

Needs a rebase @antoninrykalsky

@ctreatma
Copy link
Contributor

@antoninrykalsky the metal-python SDK was recently upgraded and this will need a rebase to pull in those changes. The upgraded SDK is able to differentiate between VLAN and VRF virtual circuits.

plugins/modules/metal_virtual_circuit_info.py Outdated Show resolved Hide resolved
plugins/modules/metal_virtual_circuit_info.py Outdated Show resolved Hide resolved
plugins/modules/metal_virtual_circuit_info.py Outdated Show resolved Hide resolved
plugins/modules/metal_virtual_circuit_info.py Show resolved Hide resolved
plugins/modules/metal_virtual_circuit.py Outdated Show resolved Hide resolved
plugins/modules/metal_virtual_circuit.py Outdated Show resolved Hide resolved
plugins/modules/metal_virtual_circuit.py Show resolved Hide resolved
plugins/modules/metal_virtual_circuit.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ctreatma ctreatma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antoninrykalsky lgtm but needs a rebase.

@t0mk t0mk merged commit 26fffc6 into equinix:main Mar 20, 2024
4 checks passed
Copy link

This PR is included in version 0.6.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

metal_virtual_circuit metal_virtual_circuit_info
4 participants