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: VRF support #377

Merged
merged 2 commits into from
Nov 16, 2023
Merged

feat: VRF support #377

merged 2 commits into from
Nov 16, 2023

Conversation

codinja1188
Copy link
Contributor

@codinja1188 codinja1188 commented Nov 2, 2023

Fixes #268

Implements the following:

Method HTTP request Description
DeleteVrf Delete /vrfs/{id} Delete the VRF
FindVrfById Get /vrfs/{id} Retrieve a VRF
FindVrfs Get /projects/{id}/vrfs Retrieve all VRFs in the project
UpdateVrf Put /vrfs/{id} Update the VRF

.DS_Store Outdated Show resolved Hide resolved
internal/vrf/delete.go Outdated Show resolved Hide resolved
internal/vrf/vrf.go Outdated Show resolved Hide resolved
docs/metal.md Outdated Show resolved Hide resolved
"strconv"
"strings"

metal "github.com/equinix-labs/metal-go/metal/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

goimports format sequence we can follow - 1st block go runtime imports, 2nd block 3rd party imports, 3rd block local packages import

Copy link
Member

@displague displague Nov 16, 2023

Choose a reason for hiding this comment

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

In other words: goimports -l "github.com/equinix-labs/metal-go" -w .

internal/vrf/create.go Outdated Show resolved Hide resolved
internal/vrf/create.go Outdated Show resolved Hide resolved
internal/vrf/create.go Show resolved Hide resolved
internal/vrf/delete.go Show resolved Hide resolved
internal/vrf/retrieve.go Outdated Show resolved Hide resolved
var vrfs []metal.Vrf
var err error
if vrfID != "" {
vrf, _, err = c.Service.FindVrfById(context.Background(), vrfID).Include(c.Servicer.Includes(inc)).Exclude(c.Servicer.Excludes(exc)).Execute()
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets refactor these cases into individual functions - retrieveVrfByID() and retrieveVrfByProject()

internal/vrf/retrieve.go Outdated Show resolved Hide resolved
internal/vrf/retrieve.go Outdated Show resolved Hide resolved
@codinja1188
Copy link
Contributor Author

Test Results:

Vasubabus-MacBook-Pro:metal-cli vasubabu$ make build
go build -ldflags "-X github.com/equinix/metal-cli/cmd.Version=40cf06b -X github.com/equinix/metal-cli/cmd.Build=40cf06b" -o bin/metal ./cmd/metal
Vasubabus-MacBook-Pro:metal-cli vasubabu$ cd bin/
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal vrf create -p b4673e33-0f48-4948-961a-c31d6edf64f8 -d "cli-vrf-test3" -m da -n "cli-vrf-test3" -a 3456 -r "89.89.1.0/24"
+---------------+---------------+----------+--------------+-------------------------------+
|     NAME      |  DESCRIPTION  | LOCALASN |   IPRANGE    |            CREATED            |
+---------------+---------------+----------+--------------+-------------------------------+
| cli-vrf-test3 | cli-vrf-test3 | 3456     | 89.89.1.0/24 | 2023-11-09 16:08:40 +0000 UTC |
+---------------+---------------+----------+--------------+-------------------------------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal vrf get -p b4673e33-0f48-4948-961a-c31d6edf64f8
+--------------------------------------+---------------+--------------+----------+-------------------------------+
|                  ID                  |  DESCRIPTION  |   IPRANGES   | LOCALASN |            CREATED            |
+--------------------------------------+---------------+--------------+----------+-------------------------------+
| 166fc922-114d-4af9-840c-7239572d5152 | cli-vrf-test1 | 100.0.1.0/24 | 5678     | 2023-11-09 14:49:21 +0000 UTC |
| 522c895f-0bf8-40b1-a152-bbc7668573c8 | test-vrf      | 10.0.1.0/24  | 1245     | 2023-11-08 15:06:07 +0000 UTC |
| ee2269f7-bcc5-419b-b3d1-0d2372cf3962 | cli-vrf-test  | 13.0.1.0/24  | 3456     | 2023-11-08 16:22:02 +0000 UTC |
| 7798dd73-65da-4d0a-970d-b42fbbc6603a | cli-vrf-test3 | 89.89.1.0/24 | 3456     | 2023-11-09 16:08:40 +0000 UTC |
+--------------------------------------+---------------+--------------+----------+-------------------------------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal vrf delete -i 7798dd73-65da-4d0a-970d-b42fbbc6603a
Are you sure you want to delete VRF 7798dd73-65da-4d0a-970d-b42fbbc6603a: : y
VRF 7798dd73-65da-4d0a-970d-b42fbbc6603a successfully deleted.
Device deletion initiated. Please check 'metal vrf get -i 7798dd73-65da-4d0a-970d-b42fbbc6603a ' for status
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal vrf get -p b4673e33-0f48-4948-961a-c31d6edf64f8
+--------------------------------------+---------------+--------------+----------+-------------------------------+
|                  ID                  |  DESCRIPTION  |   IPRANGES   | LOCALASN |            CREATED            |
+--------------------------------------+---------------+--------------+----------+-------------------------------+
| 166fc922-114d-4af9-840c-7239572d5152 | cli-vrf-test1 | 100.0.1.0/24 | 5678     | 2023-11-09 14:49:21 +0000 UTC |
| 522c895f-0bf8-40b1-a152-bbc7668573c8 | test-vrf      | 10.0.1.0/24  | 1245     | 2023-11-08 15:06:07 +0000 UTC |
| ee2269f7-bcc5-419b-b3d1-0d2372cf3962 | cli-vrf-test  | 13.0.1.0/24  | 3456     | 2023-11-08 16:22:02 +0000 UTC |
+--------------------------------------+---------------+--------------+----------+-------------------------------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal vrf create -p b4673e33-0f48-4948-961a-c31d6edf64f8 -d "cli-vrf-test3" -m da -n "cli-vrf-test3" -a 3456 -r "89.89.1.0/24"
+---------------+---------------+----------+--------------+-------------------------------+
|     NAME      |  DESCRIPTION  | LOCALASN |   IPRANGE    |            CREATED            |
+---------------+---------------+----------+--------------+-------------------------------+
| cli-vrf-test3 | cli-vrf-test3 | 3456     | 89.89.1.0/24 | 2023-11-09 16:09:32 +0000 UTC |
+---------------+---------------+----------+--------------+-------------------------------+
Vasubabus-MacBook-Pro:bin vasubabu$ ./metal vrf get -p b4673e33-0f48-4948-961a-c31d6edf64f8
+--------------------------------------+---------------+--------------+----------+-------------------------------+
|                  ID                  |  DESCRIPTION  |   IPRANGES   | LOCALASN |            CREATED            |
+--------------------------------------+---------------+--------------+----------+-------------------------------+
| 166fc922-114d-4af9-840c-7239572d5152 | cli-vrf-test1 | 100.0.1.0/24 | 5678     | 2023-11-09 14:49:21 +0000 UTC |
| 22cdd487-1c8c-41d1-9c1a-9b9a31f83a38 | cli-vrf-test3 | 89.89.1.0/24 | 3456     | 2023-11-09 16:09:32 +0000 UTC |
| 522c895f-0bf8-40b1-a152-bbc7668573c8 | test-vrf      | 10.0.1.0/24  | 1245     | 2023-11-08 15:06:07 +0000 UTC |
| ee2269f7-bcc5-419b-b3d1-0d2372cf3962 | cli-vrf-test  | 13.0.1.0/24  | 3456     | 2023-11-08 16:22:02 +0000 UTC |
+--------------------------------------+---------------+--------------+----------+-------------------------------+

@codinja1188 codinja1188 marked this pull request as ready for review November 9, 2023 16:10
internal/vrf/create.go Outdated Show resolved Hide resolved
internal/vrf/create.go Outdated Show resolved Hide resolved
internal/vrf/retrieve.go Outdated Show resolved Hide resolved
@displague displague merged commit 3a48a02 into equinix:main Nov 16, 2023
7 of 8 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.

Add support for VRF features
4 participants