c/s/e/cli: add equinix api cli tooling

This is a fairly simple and hacked together cli but it does its job for basic maintenance tasks

Change-Id: I043c12b930546f9405b9f8190326724122f1c0aa
Reviewed-on: https://review.monogon.dev/c/monogon/+/1704
Tested-by: Jenkins CI
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/cloud/shepherd/equinix/cli/cmd_move.go b/cloud/shepherd/equinix/cli/cmd_move.go
new file mode 100644
index 0000000..fa93501
--- /dev/null
+++ b/cloud/shepherd/equinix/cli/cmd_move.go
@@ -0,0 +1,43 @@
+package main
+
+import (
+	"context"
+
+	"github.com/spf13/cobra"
+	"k8s.io/klog/v2"
+
+	"source.monogon.dev/cloud/shepherd/equinix/wrapngo"
+	clicontext "source.monogon.dev/metropolis/cli/pkg/context"
+)
+
+var moveCmd = &cobra.Command{
+	Use:   "move [source] [target]",
+	Short: "Move all reserved hardware from one to another project",
+	Args:  cobra.ExactArgs(2),
+	Run:   doMove,
+}
+
+func init() {
+	rootCmd.AddCommand(moveCmd)
+}
+
+func doMove(cmd *cobra.Command, args []string) {
+	ctx := clicontext.WithInterrupt(context.Background())
+	api := wrapngo.New(&c)
+
+	klog.Infof("Listing reservations for %q", args[0])
+	reservations, err := api.ListReservations(ctx, args[0])
+	if err != nil {
+		klog.Exitf("failed listing reservations: %v", err)
+	}
+
+	klog.Infof("Got %d reservations. Moving machines", len(reservations))
+	for _, r := range reservations {
+		_, err := api.MoveReservation(ctx, r.ID, args[1])
+		if err != nil {
+			klog.Errorf("failed moving reservation: %v", err)
+			continue
+		}
+		klog.Infof("Moved Device %s", r.ID)
+	}
+}