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

chore: Migrate ports command from packngo to metal-go client #355

Merged
merged 4 commits into from
Nov 9, 2023

Conversation

aayushrangwala
Copy link
Contributor

@aayushrangwala aayushrangwala commented Sep 27, 2023

Issue Task as part of migrating metal-cli from packngo to metal-go client, added the support of ports subcommand to use metal-go
Part of: #333

Discussion:
As of metal-go 0.22.2 there is 1 issue which needs api support

  • All the APIs such as FindPortById, BondPort, DisbondPort, CreatePortVlanAssignmentBatch etc needs to support Exclude([]string) parameter as well. It only supports Includes([]string)

@aayushrangwala aayushrangwala temporarily deployed to external September 27, 2023 15:34 — with GitHub Actions Inactive
@aayushrangwala aayushrangwala marked this pull request as draft September 27, 2023 15:34
@aayushrangwala aayushrangwala changed the title Migrate ports command from packngo to metal-go client fix: Migrate ports command from packngo to metal-go client Sep 27, 2023
@aayushrangwala aayushrangwala marked this pull request as ready for review October 5, 2023 15:12
internal/ports/convert.go Outdated Show resolved Hide resolved
Copy link
Member

@displague displague left a comment

Choose a reason for hiding this comment

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

Let's add a test to ensure that the convert/layer-3, convert/layer-2, disbond, and bond, endpoints are reached when the associated arguments are supplied.

internal/ports/convert.go Outdated Show resolved Hide resolved
internal/ports/port.go Show resolved Hide resolved
@ctreatma
Copy link
Contributor

@aayushrangwala There are a few error logs and test failures related to these changes in the most recent E2E run:

...
=== RUN   TestPorts_Convert/convert_port_layer-3_bonded_true
2023/10/23 12:37:55 Converting port a6f37738-6cb9-4c8b-80ad-f88874f33ba8 to layer-3 with addresses [{0xc0002b750c 0xc0002b7520 map[]}]
Error when calling `DevicesApi.FindDeviceById`: 404 Not Found
...

=== RUN   TestPorts_Retrieve/retrieve_port
Error when calling `DevicesApi.FindDeviceById`: 404 Not Found
--- PASS: TestPorts_Retrieve (146.11s)
    --- PASS: TestPorts_Retrieve/retrieve_port (0.18s)
=== RUN   TestPorts_VLANs
Error when calling `VLANsApi.CreateVirtualNetwork`: 404 Not Found
    vlans_test.go:29: 404 Not Found
=== RUN   TestPorts_VLANs/vlan_assignment_port
Error: Could not update port VLAN assignments: 422 Unprocessable Entity
    vlans_test.go:67: Could not update port VLAN assignments: 422 Unprocessable Entity
    vlans_test.go:75: Timeout exceeded for vlan assignment with port ID: e0f3e6f8-5bbf-4d24-ae9d-567647c5167c
=== CONT  TestPorts_VLANs
    vlans_test.go:34: 422 Unprocessable Entity
...

@aayushrangwala aayushrangwala temporarily deployed to external October 25, 2023 16:01 — with GitHub Actions Inactive
@aayushrangwala aayushrangwala requested a deployment to external October 26, 2023 00:45 — with GitHub Actions Abandoned
@displague
Copy link
Member

Rerunning since the failed test (createdevice) could be a flake. If the helper hasn't been modified I would definitely assume this was a flake.

@aayushrangwala
Copy link
Contributor Author

Rerunning since the failed test (createdevice) could be a flake. If the helper hasn't been modified I would definitely assume this was a flake.

@displague Yes it was flaky test. Tests passed in this run

@ctreatma
Copy link
Contributor

ctreatma commented Oct 27, 2023

@aayushrangwala Re: this note in the PR description:

All the APIs such as FindPortById, BondPort, DisbondPort, CreatePortVlanAssignmentBatch etc needs to support Exclude([]string) parameter as well. It only supports Includes([]string)

@sbhatnagar-equinix did some focused work earlier this year to align include/exclude parameter declarations in the spec with actual parameter support in the API. Surbhit can confirm whether these missing methods are expected to be missing.

If we'd like to validate the API behavior ourselves, one thing to try is to make a curl request to the affected endpoints, then try the request again with an excludes parameter, to see if the response changes:

# Run commands like the following and see if the request changes due to the addition of exclude param
$ curl -v -H 'X-Auth-Token: <some_token>' https://api.equinix.com/metal/v1/<path_to_endpoint>
$ curl -v -H 'X-Auth-Token: <some_token>' https://api.equinix.com/metal/v1/<path_to_endpoint>?excludes=<something>

If we do find differences we can put those details in a ticket for the API team.

@displague
Copy link
Member

displague commented Oct 27, 2023

I can't seem to use this command to convert a port to Layer 3.

PACKNGO_DEBUG=1 go run ./cmd/metal ports convert -i d5acf76f-329b-4534-96f4-b28d9cfa6173 --bonded -4 -6

^
If I omit -b, the CLI only attempts a GET request and doesn't attempt any conversion.
When I include -b, the CLI only attempts to bond the port.

Fortunately, for this PR, I can't seem to do that with the existing 1.16 binary either 😬

While looking at the --help docs, I noticed:

  • there is no option or instruction on how to --disbond (and -b false does not do this either, not sure which I would prefer) https://github.com/equinix-labs/metal-go/blob/main/docs/PortsApi.md#disbondport
  • the notes on adding a public ipv4/ipv6 address say "Layer-2" when they mean "Layer-3"
  • there should be an option to convert to layer3, this would imply only a private ipv4 address. -3 | --layer3. adding -4 and -6 would add the optional ipv4 and ipv6 addresses to the request.
  • -2 should not assume layer-2 unbonded, that should depend on the -b true|false argument

@aayushrangwala
Copy link
Contributor Author

aayushrangwala commented Oct 30, 2023

@aayushrangwala Re: this note in the PR description:

All the APIs such as FindPortById, BondPort, DisbondPort, CreatePortVlanAssignmentBatch etc needs to support Exclude([]string) parameter as well. It only supports Includes([]string)

@sbhatnagar-equinix did some focused work earlier this year to align include/exclude parameter declarations in the spec with actual parameter support in the API. Surbhit can confirm whether these missing methods are expected to be missing.

If we'd like to validate the API behavior ourselves, one thing to try is to make a curl request to the affected endpoints, then try the request again with an excludes parameter, to see if the response changes:

# Run commands like the following and see if the request changes due to the addition of exclude param
$ curl -v -H 'X-Auth-Token: <some_token>' https://api.equinix.com/metal/v1/<path_to_endpoint>
$ curl -v -H 'X-Auth-Token: <some_token>' https://api.equinix.com/metal/v1/<path_to_endpoint>?excludes=<something>

If we do find differences we can put those details in a ticket for the API team.

@ctreatma I remember we discussing this and as you correctly pointed out, there was some work on this but still after that only include was supported.
Checked the Developer API doc for the support and even the HTTP API doesnt seem to support the exclude
https://deploy.equinix.com/developers/api/metal/#tag/Ports

After checking, exclude doesnot work via curl as well hence the spec and API doc is correct

curl -v -H 'X-Auth-Token: API_TOKEN' https://api.equinix.com/metal/v1/ports/1d7b102b-a955-4aea-9662-c4ab742fae9b\?exclude\='virtual_networks' | grep virtual_networks

Response:

{"id":"1d7b102b-a955-4aea-9662-c4ab742fae9b","type":"NetworkBondPort","name":"bond0","data":{"bonded":true},"network_type":"layer2-bonded","native_virtual_network":null,"virtual_networks":[{"href":"/metal/v1/virtual-networks/561319f2-1ba2-43ea-9337-12cb409c24c9"}],"disbond_operation_supported":true,"href":"/metal/v1/ports/1d7b102b-a955-4aea-9662-c4ab742fae9b"}
curl -v -H 'X-Auth-Token: API_TOKEN' https://api.equinix.com/metal/v1/ports/1d7b102b-a955-4aea-9662-c4ab742fae9b\?include\='virtual_networks' | grep virtual_networks

Response:

{"id":"1d7b102b-a955-4aea-9662-c4ab742fae9b","type":"NetworkBondPort","name":"bond0","data":{"bonded":true},"network_type":"layer2-bonded","native_virtual_network":null,"virtual_networks":[{"id":"561319f2-1ba2-43ea-9337-12cb409c24c9","description":"","vxlan":1000,"created_at":"2023-10-30T14:13:43Z","tags":[],"metro":{"href":"/metal/v1/locations/metros/b1ac82b2-616c-4405-9424-457ef6edf9ae"},"metal_gateways":[],"facility":null,"instances":[{"href":"/metal/v1/devices/d6a80ef5-8c92-4502-a22b-482bc89ea5b1"}],"assigned_to":{"href":"/metal/v1/projects/ad7bb41a-810e-4a06-b12b-97697bf9e2cd"},"facility_code":null,"assigned_to_virtual_circuit":false,"metro_code":"fr","href":"/metal/v1/virtual-networks/561319f2-1ba2-43ea-9337-12cb409c24c9"}],"disbond_operation_supported":true,"href":"/metal/v1/ports/1d7b102b-a955-4aea-9662-c4ab742fae9b"}
curl -v -H 'X-Auth-Token: API_TOKEN' https://api.equinix.com/metal/v1/ports/1d7b102b-a955-4aea-9662-c4ab742fae9b

{"id":"1d7b102b-a955-4aea-9662-c4ab742fae9b","type":"NetworkBondPort","name":"bond0","data":{"bonded":true},"network_type":"layer2-bonded","native_virtual_network":null,"virtual_networks":[{"href":"/metal/v1/virtual-networks/561319f2-1ba2-43ea-9337-12cb409c24c9"}],"disbond_operation_supported":true,"href":"/metal/v1/ports/1d7b102b-a955-4aea-9662-c4ab742fae9b"}

@aayushrangwala
Copy link
Contributor Author

I can't seem to use this command to convert a port to Layer 3.

PACKNGO_DEBUG=1 go run ./cmd/metal ports convert -i d5acf76f-329b-4534-96f4-b28d9cfa6173 --bonded -4 -6

^ If I omit -b, the CLI only attempts a GET request and doesn't attempt any conversion. When I include -b, the CLI only attempts to bond the port.

Fortunately, for this PR, I can't seem to do that with the existing 1.16 binary either 😬

While looking at the --help docs, I noticed:

  • there is no option or instruction on how to --disbond (and -b false does not do this either, not sure which I would prefer) https://github.com/equinix-labs/metal-go/blob/main/docs/PortsApi.md#disbondport
  • the notes on adding a public ipv4/ipv6 address say "Layer-2" when they mean "Layer-3"
  • there should be an option to convert to layer3, this would imply only a private ipv4 address. -3 | --layer3. adding -4 and -6 would add the optional ipv4 and ipv6 addresses to the request.
  • -2 should not assume layer-2 unbonded, that should depend on the -b true|false argument

@displague #374 Created this issue

Signed-off-by: Ayush Rangwala <[email protected]>
@displague displague changed the title fix: Migrate ports command from packngo to metal-go client chrore: Migrate ports command from packngo to metal-go client Nov 7, 2023
@aayushrangwala aayushrangwala changed the title chrore: Migrate ports command from packngo to metal-go client chore: Migrate ports command from packngo to metal-go client Nov 7, 2023
@aayushrangwala
Copy link
Contributor Author

@displague Can you please re-trigger the E2E tests. I think was a flaky scenario

@codinja1188
Copy link
Contributor

Vasubabus-MacBook-Pro:metal-cli vasubabu$ make test
go test -v ./... -timeout 1000s
=== RUN   TestCli_RegisterCommands
=== RUN   TestCli_RegisterCommands/test
--- PASS: TestCli_RegisterCommands (0.00s)
    --- PASS: TestCli_RegisterCommands/test (0.00s)
PASS
ok  	github.com/equinix/metal-cli/cmd	2.155s
?   	github.com/equinix/metal-cli/cmd/metal	[no test files]
?   	github.com/equinix/metal-cli/internal/capacity	[no test files]
?   	github.com/equinix/metal-cli/internal/cli	[no test files]
?   	github.com/equinix/metal-cli/internal/completion	[no test files]
?   	github.com/equinix/metal-cli/internal/devices	[no test files]
?   	github.com/equinix/metal-cli/internal/docs	[no test files]
?   	github.com/equinix/metal-cli/internal/emdocs	[no test files]
?   	github.com/equinix/metal-cli/internal/env	[no test files]
?   	github.com/equinix/metal-cli/internal/events	[no test files]
?   	github.com/equinix/metal-cli/internal/facilities	[no test files]
?   	github.com/equinix/metal-cli/internal/gateway	[no test files]
?   	github.com/equinix/metal-cli/internal/hardware	[no test files]
?   	github.com/equinix/metal-cli/internal/init	[no test files]
?   	github.com/equinix/metal-cli/internal/ips	[no test files]
?   	github.com/equinix/metal-cli/internal/metros	[no test files]
?   	github.com/equinix/metal-cli/internal/organizations	[no test files]
?   	github.com/equinix/metal-cli/internal/os	[no test files]
?   	github.com/equinix/metal-cli/internal/outputs	[no test files]
?   	github.com/equinix/metal-cli/internal/pagination	[no test files]
?   	github.com/equinix/metal-cli/internal/plans	[no test files]
?   	github.com/equinix/metal-cli/internal/ports	[no test files]
?   	github.com/equinix/metal-cli/internal/projects	[no test files]
?   	github.com/equinix/metal-cli/internal/ssh	[no test files]
?   	github.com/equinix/metal-cli/internal/twofa	[no test files]
?   	github.com/equinix/metal-cli/internal/users	[no test files]
?   	github.com/equinix/metal-cli/internal/vlan	[no test files]
=== RUN   TestCli_Capacity
=== RUN   TestCli_Capacity/get
=== RUN   TestCli_Capacity/get_by_plan_1
=== RUN   TestCli_Capacity/get_by_plan_2
=== RUN   TestCli_Capacity/check_by_multi_metro
=== RUN   TestCli_Capacity/check_by_multi_plan
=== RUN   TestCli_Capacity/check_by_multi_metro_and_plan
--- PASS: TestCli_Capacity (7.51s)
    --- PASS: TestCli_Capacity/get (2.33s)
    --- PASS: TestCli_Capacity/get_by_plan_1 (2.78s)
    --- PASS: TestCli_Capacity/get_by_plan_2 (0.72s)
    --- PASS: TestCli_Capacity/check_by_multi_metro (0.53s)
    --- PASS: TestCli_Capacity/check_by_multi_plan (0.50s)
    --- PASS: TestCli_Capacity/check_by_multi_metro_and_plan (0.64s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/capacitytest	7.825s
=== RUN   TestCli_Devices_Create_Flags
=== RUN   TestCli_Devices_Create_Flags/create_device
--- PASS: TestCli_Devices_Create_Flags (100.43s)
    --- PASS: TestCli_Devices_Create_Flags/create_device (100.43s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/devices/devicecreateflagstest	101.038s
=== RUN   TestCli_Devices_Create
=== RUN   TestCli_Devices_Create/create_device
--- PASS: TestCli_Devices_Create (152.59s)
    --- PASS: TestCli_Devices_Create/create_device (152.59s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/devices/devicecreatetest	154.131s
=== RUN   TestCli_Devices_Get
=== RUN   TestCli_Devices_Get/get_by_device_id
--- PASS: TestCli_Devices_Get (185.83s)
    --- PASS: TestCli_Devices_Get/get_by_device_id (185.83s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/devices/devicegettest	186.731s
=== RUN   TestCli_Devices_Update
=== RUN   TestCli_Devices_Update/reinstall_device
--- PASS: TestCli_Devices_Update (713.88s)
    --- PASS: TestCli_Devices_Update/reinstall_device (713.88s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/devices/devicereinstalltest	715.713s
=== RUN   TestCli_Devices_Update
=== RUN   TestCli_Devices_Update/start_device
--- PASS: TestCli_Devices_Update (182.09s)
    --- PASS: TestCli_Devices_Update/start_device (182.09s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/devices/devicestarttest	183.307s
=== RUN   TestCli_Devices_Update
=== RUN   TestCli_Devices_Update/stop_device
--- PASS: TestCli_Devices_Update (174.67s)
    --- PASS: TestCli_Devices_Update/stop_device (174.67s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/devices/devicestoptest	177.103s
=== RUN   TestCli_Devices_Update
=== RUN   TestCli_Devices_Update/update_device
--- PASS: TestCli_Devices_Update (157.30s)
    --- PASS: TestCli_Devices_Update/update_device (157.30s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/devices/deviceupdatetest	159.860s
=== RUN   TestCli_Events_Get
=== RUN   TestCli_Events_Get/get_events_by_dev_id
--- PASS: TestCli_Events_Get (164.59s)
    --- PASS: TestCli_Events_Get/get_events_by_dev_id (164.59s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/events/deviceeventstest	167.536s
=== RUN   TestCli_Events_Get
=== RUN   TestCli_Events_Get/get_events_by_proj_id
--- PASS: TestCli_Events_Get (1.72s)
    --- PASS: TestCli_Events_Get/get_events_by_proj_id (1.72s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/events/projecteventstest	3.031s
=== RUN   TestCli_Ips_Get
=== RUN   TestCli_Ips_Get/get_ip_reservations
    ips_get_test.go:43: Skipping this test because someCondition is true
--- PASS: TestCli_Ips_Get (0.00s)
    --- SKIP: TestCli_Ips_Get/get_ip_reservations (0.00s)
=== RUN   TestCli_Vlan_Create
=== RUN   TestCli_Vlan_Create/Request_NewIP
    ips_request_test.go:44: Skipping temporarily for now
--- PASS: TestCli_Vlan_Create (0.00s)
    --- SKIP: TestCli_Vlan_Create/Request_NewIP (0.00s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/ipstest	0.331s
=== RUN   TestCli_Metros
=== RUN   TestCli_Metros/get
--- PASS: TestCli_Metros (0.52s)
    --- PASS: TestCli_Metros/get (0.52s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/metrotest	0.851s
=== RUN   TestCli_Organization
=== RUN   TestCli_Organization/get
+--------------------------------------+---------------------------------+-------------------------------+
|                  ID                  |              NAME               |            CREATED            |
+--------------------------------------+---------------------------------+-------------------------------+
| 4d12f460-8c5e-43ea-986d-529d328815ee | DevRel Engineering (Playground) | 2023-08-03 20:50:33 +0000 UTC |
+--------------------------------------+---------------------------------+-------------------------------+
--- PASS: TestCli_Organization (0.63s)
    --- PASS: TestCli_Organization/get (0.63s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/organizationtest	0.980s
=== RUN   TestCli_OperatingSystem
=== RUN   TestCli_OperatingSystem/get
--- PASS: TestCli_OperatingSystem (0.97s)
    --- PASS: TestCli_OperatingSystem/get (0.97s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/ostest	1.320s
=== RUN   TestCli_Plans
=== RUN   TestCli_Plans/get
=== RUN   TestCli_Plans/get_by_slug
=== RUN   TestCli_Plans/get_by_type
--- PASS: TestCli_Plans (2.87s)
    --- PASS: TestCli_Plans/get (1.77s)
    --- PASS: TestCli_Plans/get_by_slug (0.33s)
    --- PASS: TestCli_Plans/get_by_type (0.77s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/plantest	3.219s
=== RUN   TestPorts_Convert
=== RUN   TestPorts_Convert/convert_port_layer-2_bonded_false
=== RUN   TestPorts_Convert/convert_port_layer-2_bonded_true
=== RUN   TestPorts_Convert/convert_port_layer-3_bonded_true
2023/11/07 22:48:16 Converting port 7c34b179-358d-48b3-b269-72853c9737c1 to layer-3 with addresses [{0x14000315c5c 0x14000315c90 map[]}]
--- PASS: TestPorts_Convert (214.35s)
    --- PASS: TestPorts_Convert/convert_port_layer-2_bonded_false (21.01s)
    --- PASS: TestPorts_Convert/convert_port_layer-2_bonded_true (8.48s)
    --- PASS: TestPorts_Convert/convert_port_layer-3_bonded_true (10.41s)
=== RUN   TestPorts_Retrieve
=== RUN   TestPorts_Retrieve/retrieve_port
--- PASS: TestPorts_Retrieve (189.94s)
    --- PASS: TestPorts_Retrieve/retrieve_port (0.42s)
=== RUN   TestPorts_VLANs
=== RUN   TestPorts_VLANs/vlan_assignment_port
--- PASS: TestPorts_VLANs (198.76s)
    --- PASS: TestPorts_VLANs/vlan_assignment_port (11.06s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/ports	603.381s
=== RUN   TestCli_SshKey
=== RUN   TestCli_SshKey/get
--- PASS: TestCli_SshKey (0.49s)
    --- PASS: TestCli_SshKey/get (0.49s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/sshtest	0.899s
=== RUN   TestCli_Users
=== RUN   TestCli_Users/get
--- PASS: TestCli_Users (0.56s)
    --- PASS: TestCli_Users/get (0.56s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/usertest	0.894s
=== RUN   TestCli_Vlan_Create
=== RUN   TestCli_Vlan_Create/create_virtual_network
--- PASS: TestCli_Vlan_Create (2.12s)
    --- PASS: TestCli_Vlan_Create/create_virtual_network (2.12s)
=== RUN   TestCli_Vlan_Clean
=== RUN   TestCli_Vlan_Clean/delete_virtual_network
--- PASS: TestCli_Vlan_Clean (2.26s)
    --- PASS: TestCli_Vlan_Clean/delete_virtual_network (2.26s)
=== RUN   TestCli_Vlan_Get
=== RUN   TestCli_Vlan_Get/get_virtual_network
--- PASS: TestCli_Vlan_Get (2.43s)
    --- PASS: TestCli_Vlan_Get/get_virtual_network (2.43s)
PASS
ok  	github.com/equinix/metal-cli/test/e2e/vlan	7.157s
?   	github.com/equinix/metal-cli/test/helper	[no test files]
Vasubabus-MacBook-Pro:metal-cli vasubabu$




Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i 3995686b-715a-4aae-8a16-19346b7b7015
+--------------------------------------+------+-------------+--------------+-------------------+--------+
|                  ID                  | NAME |    TYPE     | NETWORK TYPE |        MAC        | BONDED |
+--------------------------------------+------+-------------+--------------+-------------------+--------+
| 3995686b-715a-4aae-8a16-19346b7b7015 | eth0 | NetworkPort |              | f8:f2:1e:80:74:00 | true   |
+--------------------------------------+------+-------------+--------------+-------------------+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i e1b645f9-458d-45c6-b165-4a73103c3660
+--------------------------------------+------+-------------+--------------+-------------------+--------+
|                  ID                  | NAME |    TYPE     | NETWORK TYPE |        MAC        | BONDED |
+--------------------------------------+------+-------------+--------------+-------------------+--------+
| e1b645f9-458d-45c6-b165-4a73103c3660 | eth1 | NetworkPort |              | f8:f2:1e:80:74:01 | true   |
+--------------------------------------+------+-------------+--------------+-------------------+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i d414a2ca-2e91-4e2d-a598-42180c354e9d
+--------------------------------------+-------+-----------------+--------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE | MAC | BONDED |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer3       |     | true   |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port convert -i d414a2ca-2e91-4e2d-a598-42180c354e9d --layer2 --bonded=false
Are you sure you want to convert Port d414a2ca-2e91-4e2d-a598-42180c354e9d to Layer2 and remove assigned IP addresses: : y
+--------------------------------------+-------+-----------------+-------------------+-----+--------+
|                  ID                  | NAME  |      TYPE       |   NETWORK TYPE    | MAC | BONDED |
+--------------------------------------+-------+-----------------+-------------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer2-individual |     | false  |
+--------------------------------------+-------+-----------------+-------------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i d414a2ca-2e91-4e2d-a598-42180c354e9d
+--------------------------------------+-------+-----------------+-------------------+-----+--------+
|                  ID                  | NAME  |      TYPE       |   NETWORK TYPE    | MAC | BONDED |
+--------------------------------------+-------+-----------------+-------------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer2-individual |     | false  |
+--------------------------------------+-------+-----------------+-------------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port convert -i d414a2ca-2e91-4e2d-a598-42180c354e9d -2=false -b -4 -6
2023/11/07 23:25:31 Converting port d414a2ca-2e91-4e2d-a598-42180c354e9d to layer-3 with addresses [{0x140002c2540 0x140002c2544 map[]} {0x140002c2540 0x140002c2544 map[]} {0x140002c2540 0x140002c2544 map[]}]

+--------------------------------------+-------+-----------------+--------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE | MAC | BONDED |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer3       |     | true   |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port convert -i d414a2ca-2e91-4e2d-a598-42180c354e9d --layer2 --bonded
Are you sure you want to convert Port d414a2ca-2e91-4e2d-a598-42180c354e9d to Layer2 and remove assigned IP addresses: : y
+--------------------------------------+-------+-----------------+---------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE  | MAC | BONDED |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer2-bonded |     | true   |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port convert -i d414a2ca-2e91-4e2d-a598-42180c354e9d -2=false -b -4 -6
2023/11/07 23:27:16 Converting port d414a2ca-2e91-4e2d-a598-42180c354e9d to layer-3 with addresses [{0x140002c0520 0x140002c0524 map[]} {0x140002c0520 0x140002c0524 map[]} {0x140002c0520 0x140002c0524 map[]}]
+--------------------------------------+-------+-----------------+--------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE | MAC | BONDED |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer3       |     | true   |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port convert -i d414a2ca-2e91-4e2d-a598-42180c354e9d --layer2 --bonded
Are you sure you want to convert Port d414a2ca-2e91-4e2d-a598-42180c354e9d to Layer2 and remove assigned IP addresses: : y
+--------------------------------------+-------+-----------------+---------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE  | MAC | BONDED |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer2-bonded |     | true   |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i d414a2ca-2e91-4e2d-a598-42180c354e9d
+--------------------------------------+-------+-----------------+---------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE  | MAC | BONDED |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer2-bonded |     | true   |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port convert -i d414a2ca-2e91-4e2d-a598-42180c354e9d -2=false -b -4 -6
2023/11/07 23:29:57 Converting port d414a2ca-2e91-4e2d-a598-42180c354e9d to layer-3 with addresses [{0x140002c2540 0x140002c2544 map[]} {0x140002c2540 0x140002c2544 map[]} {0x140002c2540 0x140002c2544 map[]}]
+--------------------------------------+-------+-----------------+--------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE | MAC | BONDED |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer3       |     | true   |
+--------------------------------------+-------+-----------------+--------------+-----+--------+

VLANS Assign and Un-assign

Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port vlan -i d414a2ca-2e91-4e2d-a598-42180c354e9d -a 1010
+--------------------------------------+-------+-----------------+--------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE | MAC | BONDED |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer3       |     | true   |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i d414a2ca-2e91-4e2d-a598-42180c354e9d
+--------------------------------------+-------+-----------------+---------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE  | MAC | BONDED |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | hybrid-bonded |     | true   |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i d414a2ca-2e91-4e2d-a598-42180c354e9d -o yml
2023/11/07 23:33:41 unknown format: "yml". Using default.
+--------------------------------------+-------+-----------------+---------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE  | MAC | BONDED |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | hybrid-bonded |     | true   |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i d414a2ca-2e91-4e2d-a598-42180c354e9d -o yaml
data:
  bonded: true
disbond_operation_supported: true
href: /metal/v1/ports/d414a2ca-2e91-4e2d-a598-42180c354e9d
id: d414a2ca-2e91-4e2d-a598-42180c354e9d
name: bond0
network_type: hybrid-bonded
type: NetworkBondPort
virtual_networks:
- href: /metal/v1/virtual-networks/15315810-2fda-48b8-b8cd-441ebab684b5

Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port vlan -i d414a2ca-2e91-4e2d-a598-42180c354e9d -u 1010
+--------------------------------------+-------+-----------------+---------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE  | MAC | BONDED |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | hybrid-bonded |     | true   |
+--------------------------------------+-------+-----------------+---------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port get -i d414a2ca-2e91-4e2d-a598-42180c354e9d -o yaml
data:
  bonded: true
disbond_operation_supported: true
href: /metal/v1/ports/d414a2ca-2e91-4e2d-a598-42180c354e9d
id: d414a2ca-2e91-4e2d-a598-42180c354e9d
name: bond0
network_type: hybrid-bonded
type: NetworkBondPort
virtual_networks:
- href: /metal/v1/virtual-networks/15315810-2fda-48b8-b8cd-441ebab684b5

Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port vlan -i d414a2ca-2e91-4e2d-a598-42180c354e9d -u 1010
+--------------------------------------+-------+-----------------+--------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE | MAC | BONDED |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer3       |     | true   |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port vlan -i d414a2ca-2e91-4e2d-a598-42180c354e9d -a 1010
+--------------------------------------+-------+-----------------+--------------+-----+--------+
|                  ID                  | NAME  |      TYPE       | NETWORK TYPE | MAC | BONDED |
+--------------------------------------+-------+-----------------+--------------+-----+--------+
| d414a2ca-2e91-4e2d-a598-42180c354e9d | bond0 | NetworkBondPort | layer3       |     | true   |
+--------------------------------------+-------+-----------------+--------------+-----+--------+

image

Copy link
Contributor

@codinja1188 codinja1188 left a comment

Choose a reason for hiding this comment

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

why port convert from layer2 to layer3 bond with IPV4 and IPV6 shows some Junk data

Vasubabus-MacBook-Pro:bin vasubabu$ ./metal port convert -i d414a2ca-2e91-4e2d-a598-42180c354e9d -2=false -b -4 -6
2023/11/07 23:29:57 Converting port d414a2ca-2e91-4e2d-a598-42180c354e9d to layer-3 with addresses [{0x140002c2540 0x140002c2544 map[]} {0x140002c2540 0x140002c2544 map[]} {0x140002c2540 0x140002c2544 map[]}]

@aayushrangwala
Copy link
Contributor Author

Converting port

Its returning the pointers for IP addresses objects. Will fix it

@displague
Copy link
Member

One E2E test failed:

=== RUN   TestPorts_VLANs
Error when calling `DevicesApi.FindDeviceById`: 403 Forbidden
    helper.go:302: 403 Forbidden
    helper.go:305: Timeout while waiting for device: 467ae367-bb48-469d-b910-8e71533cf42f to be active
Error when calling `DevicesApi.FindDeviceById`: 403 Forbidden
    helper.go:310: 403 Forbidden
--- FAIL: TestPorts_VLANs (65.85s)
panic: runtime error: index out of range [2] with length 0 [recovered]
	panic: runtime error: index out of range [2] with length 0

goroutine 36 [running]:
testing.tRunner.func1.2({0xca9f80, 0xc0001cb338})
	/opt/hostedtoolcache/go/1.19.13/x64/src/testing/testing.go:1396 +0x24e
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.19.13/x64/src/testing/testing.go:1399 +0x39f
panic({0xca9f80, 0xc0001cb338})
	/opt/hostedtoolcache/go/1.19.13/x64/src/runtime/panic.go:884 +0x212
github.com/equinix/metal-cli/test/e2e/ports.TestPorts_VLANs(0xc0004f4000)
	/home/runner/work/metal-cli/metal-cli/test/e2e/ports/vlans_test.go:28 +0x4dc
testing.tRunner(0xc0004f4000, 0xd6b4f0)
	/opt/hostedtoolcache/go/1.19.13/x64/src/testing/testing.go:1446 +0x10b
created by testing.(*T).Run
	/opt/hostedtoolcache/go/1.19.13/x64/src/testing/testing.go:1493 +0x35f
FAIL	github.com/equinix/metal-cli/test/e2e/ports	596.680s

@displague
Copy link
Member

Going to merge this to unblock other work. Ahead of the next release (ahead of merging any feat or fix PRs) we should address these two issues.

@displague displague merged commit dc66c2d into equinix:main Nov 9, 2023
8 of 10 checks passed
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.

5 participants