From 55ed5ffdeca85c6647625f2a4bba15b64505da18 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 6 Oct 2016 10:18:29 -0700 Subject: [PATCH] Update hosts to new API --- cmd/host.go | 33 +-------------------------------- cmd/host_create.go | 8 ++++---- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/cmd/host.go b/cmd/host.go index 38fb897fb..44c633f50 100644 --- a/cmd/host.go +++ b/cmd/host.go @@ -87,42 +87,11 @@ func hostLs(ctx *cli.Context) error { return err } - opts := defaultListOpts(ctx) - delete(opts.Filters, "state_ne") - collection, err := c.Host.List(opts) + collection, err := c.Host.List(defaultListOpts(ctx)) if err != nil { return err } - knownMachines := map[string]bool{} - for _, host := range collection.Data { - knownMachines[host.PhysicalHostId] = true - } - - machineCollection, err := c.Machine.List(nil) - if err != nil { - return err - } - - for _, machine := range machineCollection.Data { - if knownMachines[machine.Id] { - continue - } - host := client.Host{ - Resource: client.Resource{ - Id: machine.Id, - }, - Hostname: machine.Name, - State: machine.State, - TransitioningMessage: machine.TransitioningMessage, - } - if machine.State == "active" { - host.State = "waiting" - host.TransitioningMessage = "Almost there... Waiting for agent connection" - } - collection.Data = append(collection.Data, host) - } - writer := NewTableWriter([][]string{ {"ID", "Host.Id"}, {"HOSTNAME", "Host.Hostname"}, diff --git a/cmd/host_create.go b/cmd/host_create.go index 6ded57a4a..fb7be9921 100644 --- a/cmd/host_create.go +++ b/cmd/host_create.go @@ -117,11 +117,11 @@ func hostCreate(ctx *cli.Context) error { return err } - machineSchema := c.GetSchemas().Schema("machine") - flags := buildFlags("", machineSchema, c.GetSchemas()) + hostSchema := c.GetSchemas().Schema("host") + flags := buildFlags("", hostSchema, c.GetSchemas()) drivers := []string{} - for name := range machineSchema.ResourceFields { + for name := range hostSchema.ResourceFields { if strings.HasSuffix(name, "Config") { drivers = append(drivers, strings.TrimSuffix(name, "Config")) } @@ -137,7 +137,7 @@ func hostCreate(ctx *cli.Context) error { EnvVar: "MACHINE_DRIVER", }) hostCommand.Subcommands[i].Action = func(ctx *cli.Context) error { - return hostCreateRun(ctx, c, machineSchema, c.GetSchemas()) + return hostCreateRun(ctx, c, hostSchema, c.GetSchemas()) } hostCommand.Subcommands[i].SkipFlagParsing = false }