cloud/shepherd/equinix/cli: Rename servers before deletion
This avoids collisions when redeploying servers
Change-Id: I94c8c5e0b1b601ee6513f7baddb251053ce9430b
Reviewed-on: https://review.monogon.dev/c/monogon/+/1864
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/cloud/shepherd/equinix/wrapngo/wrapn.go b/cloud/shepherd/equinix/wrapngo/wrapn.go
index d193b1a..7bd4522 100644
--- a/cloud/shepherd/equinix/wrapngo/wrapn.go
+++ b/cloud/shepherd/equinix/wrapngo/wrapn.go
@@ -101,6 +101,8 @@
// retry was needed but in the meantime the requested hardware reservation from
// which this machine was requested got lost.
CreateDevice(ctx context.Context, request *packngo.DeviceCreateRequest) (*packngo.Device, error)
+
+ UpdateDevice(ctx context.Context, id string, request *packngo.DeviceUpdateRequest) (*packngo.Device, error)
RebootDevice(ctx context.Context, did string) error
DeleteDevice(ctx context.Context, id string) error
@@ -301,6 +303,13 @@
})
}
+func (e *client) UpdateDevice(ctx context.Context, id string, r *packngo.DeviceUpdateRequest) (*packngo.Device, error) {
+ return wrap(ctx, e, func(cl *packngo.Client) (*packngo.Device, error) {
+ dev, _, err := cl.Devices.Update(id, r)
+ return dev, err
+ })
+}
+
func (e *client) ListDevices(ctx context.Context, pid string) ([]packngo.Device, error) {
return wrap(ctx, e, func(cl *packngo.Client) ([]packngo.Device, error) {
// to increase the chances of a stable pagination, we sort the devices by hostname
@@ -309,16 +318,6 @@
})
}
-func (e *client) UpdateDevice(ctx context.Context, id string, r *packngo.DeviceUpdateRequest) (*packngo.Device, error) {
- return wrap(ctx, e, func(p *packngo.Client) (*packngo.Device, error) {
- d, _, err := p.Devices.Update(id, r)
- if err != nil {
- return nil, fmt.Errorf("Devices.Update: %w", err)
- }
- return d, nil
- })
-}
-
func (e *client) GetDevice(ctx context.Context, pid, did string, opts *packngo.ListOptions) (*packngo.Device, error) {
return wrap(ctx, e, func(cl *packngo.Client) (*packngo.Device, error) {
d, _, err := cl.Devices.Get(did, opts)