equinixmetal-archive / packngo

[Deprecated] A Golang client for the Equinix Metal API. (Packet is now Equinix Metal)
https://deploy.equinix.com/labs/equinix-sdk-go/
Other
79 stars 60 forks source link

With client.DevicePorts deprecated, how does one set a network type to hybrid-bonded? #341

Closed gidoBOSSftw5731 closed 1 year ago

gidoBOSSftw5731 commented 2 years ago

With the old (apparently deprecated) syntax, creating a bonded network can be done like so: metalClient.DevicePorts.DeviceToNetworkType(dev.ID, "hybrid-bonded")

Now, with the new metalClient.Ports object, you can ConvertToLayerTwo() and ConvertToLayerThree() but not ConvertToHybrid() (unless the docs are just very unclear?)

gidoBOSSftw5731 commented 2 years ago

I should clarify, metalClient is the variable name used for a *Client object.

displague commented 1 year ago

@gidoBOSSftw5731 sorry for the ridiculous delay.

ConvertToHybrid, which sets Hybrid Unbonded mode, is achieved by breaking the bond and setting the first device to Layer3 and the second device to Layer2. For example, DevicePortServiceOp.ConvertDevice does the following: https://github.com/packethost/packngo/blob/9693ea74e17ce69b8b5c969a9873566a18ba9804/device_ports.go#L232-L257

Hybrid Bonded mode is another mode to consider which does not require breaking the bond. VLANs can be assigned to a bond device in Layer3 mode, which will automatically convert that device to Hybrid Bonded mode.

displague commented 1 year ago

There's more to learn about these modes, including the raw API calls needed to achieve them in the docs:

gidoBOSSftw5731 commented 1 year ago

Ah, thanks for the clarification. The documentation did not make it clear that the hybrid bonding would be done automatically when required, especially when it doesn't look like it was done automatically before (or else why have an option to force it?)