Skip to content

Commit

Permalink
Remove the connection checker, use SSH instead
Browse files Browse the repository at this point in the history
Also update "config", to output ssh parameters
  • Loading branch information
afbjorklund committed Jan 9, 2019
1 parent 4a5c295 commit 4216c17
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 146 deletions.
33 changes: 20 additions & 13 deletions commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ package commands
import (
"fmt"
"os"
"path/filepath"

"github.com/boot2podman/machine/commands/mcndirs"
"github.com/boot2podman/machine/libmachine"
"github.com/boot2podman/machine/libmachine/check"
"github.com/boot2podman/machine/libmachine/log"
)

Expand All @@ -26,21 +23,31 @@ func cmdConfig(c CommandLine, api libmachine.API) error {
return err
}

podmanHost, _, err := check.DefaultConnChecker.Check(host)
if host.Driver == nil {
return err
}

user := host.Driver.GetSSHUsername()

addr, err := host.Driver.GetSSHHostname()
if err != nil {
return err
}

port, err := host.Driver.GetSSHPort()
if err != nil {
return fmt.Errorf("Error running connection boilerplate: %s", err)
return err
}

log.Debug(podmanHost)
key := host.Driver.GetSSHKeyPath()

tlsCACert := filepath.Join(mcndirs.GetMachineDir(), host.Name, "ca.pem")
tlsCert := filepath.Join(mcndirs.GetMachineDir(), host.Name, "cert.pem")
tlsKey := filepath.Join(mcndirs.GetMachineDir(), host.Name, "key.pem")
if addr != "" {
// always use root@ for socket
user = "root"
}

// TODO(nathanleclaire): These magic strings for the certificate file
// names should be cross-package constants.
fmt.Printf("--tlsverify\n--tlscacert=%q\n--tlscert=%q\n--tlskey=%q\n-H=%s\n",
tlsCACert, tlsCert, tlsKey, podmanHost)
fmt.Printf("--username=%s\n--host=%s\n--port=%d\n--identity-file=%s\n",
user, addr, port, key)

return nil
}
70 changes: 0 additions & 70 deletions libmachine/check/check.go

This file was deleted.

60 changes: 0 additions & 60 deletions libmachine/check/check_test.go

This file was deleted.

11 changes: 8 additions & 3 deletions libmachine/libmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/boot2podman/machine/drivers/errdriver"
"github.com/boot2podman/machine/libmachine/auth"
"github.com/boot2podman/machine/libmachine/cert"
"github.com/boot2podman/machine/libmachine/check"
"github.com/boot2podman/machine/libmachine/drivers"
"github.com/boot2podman/machine/libmachine/drivers/plugin/localbinary"
"github.com/boot2podman/machine/libmachine/drivers/rpc"
Expand Down Expand Up @@ -169,9 +168,15 @@ func (api *Client) performCreate(h *host.Host) error {

// We should check the connection to podman here
log.Info("Checking connection to Podman...")
if _, _, err = check.DefaultConnChecker.Check(h); err != nil {
return fmt.Errorf("Error checking the host: %s", err)
client, err := h.CreateSSHClient()
if err != nil {
return fmt.Errorf("Error creating SSH client: %s", err)
}
version, err := client.Output("podman --version")
if err != nil {
return fmt.Errorf("Error getting podman version: %s", err)
}
log.Debugf("%s", version)

log.Info("Podman is up and running!")
return nil
Expand Down

0 comments on commit 4216c17

Please sign in to comment.