-
Notifications
You must be signed in to change notification settings - Fork 46
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
Adopt metal-go #270
Adopt metal-go #270
Conversation
c.rootCmd = rootCmd | ||
return c.rootCmd | ||
} | ||
|
||
// ListOptions creates a packngo.ListOptions using the includes and excludes persistent | ||
// flags. When not defined, the defaults given will be supplied. | ||
func (c *Client) ListOptions(defaultIncludes, defaultExcludes []string) *packngo.ListOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we will want to preserve ListOptions in some way.
In Metal Go, request types that include Include()
and Exclude()
could be used as the basis for an interface that a new ListOptions
would depend on.
We could take advantage of the generated methods (https://github.com/equinix-labs/metal-go/blob/main/metal/v1/api_devices.go#L831-L841).
type RequestWithOptions interface {
Include([]string)
Exclude([]string)
}
And create a ListOptions function that returns a function that manipulates the Request object:
func (c *Client) ListOptions(defaultIncludes, defaultExcludes []string) func(RequestWithOptions ) {
// essentially the existing code, building `[]string` for
// `includes` and `excludes` rather than stashing it
// into the ListOptions variable.
return func(RequestWithOptions req) {
res.Include(includes)
res.Exclude(excludes)
}
}
The caller would then pass their request into the returned function to update the request object based on the options. This approach would be in an attempt to minimize the code change needed from action to action.
Where this seems to fall apart is that we don't have spec definitions for search
, sort-by
, and sort-dir
. These could be added to the API spec (via patches) case-by-case for the APIs where metal-cli needs them. The returned function then becomes func(interface{})
and we would need type assertions to verify if the Request object implements RequestWithOptions
, RequestWithSearch
, RequestWithSort
, etc. before manipulating the object with the options.
More complex is that In order to apply the filter
(an arbitrary set of key/value pairs: map[string]string
), we would need some function that could append additional query parameters, either well-known (defined in spec, with helper methods) or not (arbitrary query parameters).
Thoughts, @ctreatma?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we rip out the ListOptions
helper and do this by hand for each action until a better pattern emerges. 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generated SDKs are extremely opinionated, which is what makes them so good at providing spec feedback. If we start trying to bolt packngo design patterns on to metal-go, I think we'd be better off killing metal-go and keeping packngo as the supported Go SDK.
In terms of the missing parameters in the spec, we should get those updated upstream; patches are nice but it can be a pain when they're upstreamed, and these parameters are a clear case of something that should be covered in the spec (and by extension, the redoc docs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ctreatma were there examples in your other 'adopt metal-go' PRs that could serve as guidance for these query parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The terraform PR makes use of Include
in some places, such as here: https://github.com/equinix/terraform-provider-equinix/pull/291/files#diff-dd9b87265483ecd6ba13ac77846bf80816e2efc1b654fb84e897155fda5e89dfR224
The request models are chainable, so using both include and exclude parameters could look something like obj, resp, err := req.Include(includes).Exclude(excludes).Execute()
. Once the other parameters are in the spec, the generated code would include similar methods for requests that support those parameters as well, so you'd potentially end up with something like req.Include(includes).Exclude(excludes).Filter(filter).Search(search).SortBy(sortBy).Execute()
(with better formatting, but there's only so much that formatting can do with that). If I had to guess, it would actually look like a bunch of if statements so we only call, e.g. req.Search()
if there is a non-nil value for search
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Filter
is a packngo-ism. It represents arbitrary query string parameters. These happen to be useful for filtering ("metro=sv").
Does metal-go have a way to tack-on query parameters (ideally from a map[string]string parameter) in a request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would actually look like a bunch of if statements so we only call
I believe the API won't complain (or change its response) if empty strings are provided for these parameters. I agree that it would be better to not chance that. I wonder if openapitools-generator's Go will include omitempty
for these string fields based on some OAS3 spec. I see https://swagger.io/docs/specification/describing-parameters/#nullable, but that "allowEmptyValue" is about permitting ?foo&bar
, not omitting those fields from the query string.
d2c8aef
to
d9b5846
Compare
github.com/manifoldco/promptui v0.9.0 | ||
github.com/olekukonko/tablewriter v0.0.5 | ||
github.com/packethost/packngo v0.29.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may have an easier time adopting metal-go if we do it gradually. That would look similar to the metal-go PR for the terraform provider, where we set up both a packngo client and a metal-go client: equinix/terraform-provider-equinix#291
25759f8
to
423dde5
Compare
SpotInstance: spotInstance, | ||
SpotPriceMax: spotPriceMax, | ||
TerminationTime: endDt, | ||
AlwaysPxe: &alwaysPXE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AlwaysPxe is a pointer in metal-go but it's not in packngo. In packngo there was no distinction between unset and zero values, so false
(default value in line 143) was an empty value for omitempty
, but now it is false
. This causes the creation of a device with OS other than ipxe to fail in API since it shouldn't be specified.
I would rather check wether is empty and only include it depending on the operatingSystem
field. Behavior of ipxescripturl, hardwareReservationID, spotInstance, spotPriceMax
may need to be reviewed as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this same issue came up in the cluster-api provider. This is the change we needed over there to only set the hardware reservation if one was specified: https://github.com/kubernetes-sigs/cluster-api-provider-packet/pull/527/files#diff-febb66857beae6d70b0aad1c73c92369afe1fb7d309f699f6047af7912d99e05R187-R189
cf21af8
to
94c745a
Compare
015ce2f
to
7a67ebd
Compare
0067a90
to
1938c38
Compare
Sounds like we've decided to instead break this up into smaller PRs like #282 #284 and #285 . Shall we close this @displague and @ctreatma |
Breakout from #270 What this PR does / why we need it: This PR replaces packngo with metal-go for all interactions with the Equinix Metal API specifically for Device sub commands Test Results: ================ # Retrieve ## Cmd: metal devices get * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` * Metal-Go ``` vasu@vasu-cloud:~/Equinix$ metal devices get +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` ## Cmd: metal devices get -p <Project_ID> * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get -p 65dcd8f4-abd4-4e7a-8b29-da4b030edd96 +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` * Metal-Go ``` vasu@vasu-cloud:~/Equinix/metal-cli/bin$ ./metal devices get -p 65dcd8f4-abd4-4e7a-8b29-da4b030edd96 +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01 08:42:42 +0000 UTC | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25 12:33:17 +0000 UTC | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26 13:09:24 +0000 UTC | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01 08:43:12 +0000 UTC | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03 09:42:52 +0000 UTC | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:01 +0000 UTC | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:05 +0000 UTC | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03 09:47:59 +0000 UTC | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:00 +0000 UTC | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03 09:54:11 +0000 UTC | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24 18:24:15 +0000 UTC | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24 18:24:12 +0000 UTC | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24 18:22:35 +0000 UTC | +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ ``` ## Cmd: metal devices get -i <Device ID> * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get -i 09be98b7-0db6-4fdb-90be-901ab847158d +--------------------------------------+--------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+--------------+------------------+--------+----------------------+ | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | +--------------------------------------+--------------+------------------+--------+----------------------+ ``` *Metal-go: ``` vasu@vasu-cloud:~/Equinix/metal-cli/bin$ ./metal devices get -i 09be98b7-0db6-4fdb-90be-901ab847158d +--------------------------------------+--------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+--------------+------------------+--------+-------------------------------+ | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26 13:09:24 +0000 UTC | +--------------------------------------+--------------+------------------+--------+-------------------------------+ ``` # Create ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d -P m3.small.x86 -m da -O ubuntu_20_04 -H create-device-dev-cdata --customdata '{"testDate":"fromCli"}' +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ | 8dc6920e-cf5a-4852-994d-a53094fe9673 | create-device-dev-cdata | Ubuntu 20.04 LTS | queued | 2023-08-24 10:28:29 +0000 UTC | +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d -P m3.small.x86 -m da -O ubuntu_20_04 -H create-dev-cdata --customdata '{"testDate":""}' +--------------------------------------+------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+------------------+------------------+--------+-------------------------------+ | a45f8746-f3b5-4fc5-8fe6-b4fa6493d365 | create-dev-cdata | Ubuntu 20.04 LTS | queued | 2023-08-24 10:40:50 +0000 UTC | +--------------------------------------+------------------+------------------+--------+-------------------------------+ ``` ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d --hostname netboot-custom-ipxe-1 --plan c3.small.x86 --metro sv --operating-system custom_ipxe --userdata='#!ipxe chain -ar https://boot.netboot.xyz' --always-pxe=true +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ | b149fc32-bcfd-44c8-9c0e-9e5d49d382e0 | netboot-custom-ipxe-1 | Custom iPXE | queued | 2023-08-24 10:48:33 +0000 UTC | +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ <img width="1430" alt="image" src="https://github.com/equinix/metal-cli/assets/3358152/ea4d5a5a-b495-40e7-a7ec-e3a6905ac5c7"> ``` ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d --hostname netboot-custom-ipxe --plan c3.small.x86 --metro sv --operating-system custom_ipxe --userdata='#!ipxe > chain -ar https://boot.netboot.xyz' +--------------------------------------+---------------------+-------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+---------------------+-------------+--------+-------------------------------+ | 4aa8977b-259b-4684-a3b4-9ff49e96db47 | netboot-custom-ipxe | Custom iPXE | queued | 2023-08-24 10:44:02 +0000 UTC | +--------------------------------------+---------------------+-------------+--------+-------------------------------+ <img width="1416" alt="image" src="https://github.com/equinix/metal-cli/assets/3358152/a9ff3f36-4716-4cbd-a9be-cc2dc8e672b7"> ```
Breakout from #270 What this PR does / why we need it: This PR replaces packngo with metal-go for all interactions with the Equinix Metal API specifically for ports sub commands DISCUSSION POINTS: META parameter is missing in IPAddressList https://github.com/vasubabu/metal-go/blob/main/docs/IPReservationList.md
Breakout from #270 What this PR does / why we need it: This PR replaces packngo with metal-go for all interactions with the Equinix Metal API specifically for Device sub commands Test Results: ================ # Retrieve ## Cmd: metal devices get * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` * Metal-Go ``` vasu@vasu-cloud:~/Equinix$ metal devices get +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` ## Cmd: metal devices get -p <Project_ID> * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get -p 65dcd8f4-abd4-4e7a-8b29-da4b030edd96 +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` * Metal-Go ``` vasu@vasu-cloud:~/Equinix/metal-cli/bin$ ./metal devices get -p 65dcd8f4-abd4-4e7a-8b29-da4b030edd96 +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01 08:42:42 +0000 UTC | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25 12:33:17 +0000 UTC | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26 13:09:24 +0000 UTC | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01 08:43:12 +0000 UTC | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03 09:42:52 +0000 UTC | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:01 +0000 UTC | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:05 +0000 UTC | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03 09:47:59 +0000 UTC | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:00 +0000 UTC | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03 09:54:11 +0000 UTC | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24 18:24:15 +0000 UTC | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24 18:24:12 +0000 UTC | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24 18:22:35 +0000 UTC | +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ ``` ## Cmd: metal devices get -i <Device ID> * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get -i 09be98b7-0db6-4fdb-90be-901ab847158d +--------------------------------------+--------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+--------------+------------------+--------+----------------------+ | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | +--------------------------------------+--------------+------------------+--------+----------------------+ ``` *Metal-go: ``` vasu@vasu-cloud:~/Equinix/metal-cli/bin$ ./metal devices get -i 09be98b7-0db6-4fdb-90be-901ab847158d +--------------------------------------+--------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+--------------+------------------+--------+-------------------------------+ | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26 13:09:24 +0000 UTC | +--------------------------------------+--------------+------------------+--------+-------------------------------+ ``` # Create ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d -P m3.small.x86 -m da -O ubuntu_20_04 -H create-device-dev-cdata --customdata '{"testDate":"fromCli"}' +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ | 8dc6920e-cf5a-4852-994d-a53094fe9673 | create-device-dev-cdata | Ubuntu 20.04 LTS | queued | 2023-08-24 10:28:29 +0000 UTC | +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d -P m3.small.x86 -m da -O ubuntu_20_04 -H create-dev-cdata --customdata '{"testDate":""}' +--------------------------------------+------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+------------------+------------------+--------+-------------------------------+ | a45f8746-f3b5-4fc5-8fe6-b4fa6493d365 | create-dev-cdata | Ubuntu 20.04 LTS | queued | 2023-08-24 10:40:50 +0000 UTC | +--------------------------------------+------------------+------------------+--------+-------------------------------+ ``` ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d --hostname netboot-custom-ipxe-1 --plan c3.small.x86 --metro sv --operating-system custom_ipxe --userdata='#!ipxe chain -ar https://boot.netboot.xyz' --always-pxe=true +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ | b149fc32-bcfd-44c8-9c0e-9e5d49d382e0 | netboot-custom-ipxe-1 | Custom iPXE | queued | 2023-08-24 10:48:33 +0000 UTC | +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ <img width="1430" alt="image" src="https://github.com/equinix/metal-cli/assets/3358152/ea4d5a5a-b495-40e7-a7ec-e3a6905ac5c7"> ``` ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d --hostname netboot-custom-ipxe --plan c3.small.x86 --metro sv --operating-system custom_ipxe --userdata='#!ipxe > chain -ar https://boot.netboot.xyz' +--------------------------------------+---------------------+-------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+---------------------+-------------+--------+-------------------------------+ | 4aa8977b-259b-4684-a3b4-9ff49e96db47 | netboot-custom-ipxe | Custom iPXE | queued | 2023-08-24 10:44:02 +0000 UTC | +--------------------------------------+---------------------+-------------+--------+-------------------------------+ <img width="1416" alt="image" src="https://github.com/equinix/metal-cli/assets/3358152/a9ff3f36-4716-4cbd-a9be-cc2dc8e672b7"> ```
Breakout from #270 What this PR does / why we need it: This PR replaces packngo with metal-go for all interactions with the Equinix Metal API specifically for ports sub commands DISCUSSION POINTS: META parameter is missing in IPAddressList https://github.com/vasubabu/metal-go/blob/main/docs/IPReservationList.md
What this PR does / why we need it:
This PR replaces packngo with metal-go for all interactions with the Equinix Metal API. The metal-go SDK is generated from the Equinix Metal API spec, and we will gradually replace all usage of packngo with metal-go to streamline support.
Which issue(s) this PR fixes (optional, in fixes #(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #