Skip to content

Commit 4216c17

Browse files
committed
Remove the connection checker, use SSH instead
Also update "config", to output ssh parameters
1 parent 4a5c295 commit 4216c17

File tree

4 files changed

+28
-146
lines changed

4 files changed

+28
-146
lines changed

commands/config.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ package commands
33
import (
44
"fmt"
55
"os"
6-
"path/filepath"
76

8-
"github.com/boot2podman/machine/commands/mcndirs"
97
"github.com/boot2podman/machine/libmachine"
10-
"github.com/boot2podman/machine/libmachine/check"
118
"github.com/boot2podman/machine/libmachine/log"
129
)
1310

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

29-
podmanHost, _, err := check.DefaultConnChecker.Check(host)
26+
if host.Driver == nil {
27+
return err
28+
}
29+
30+
user := host.Driver.GetSSHUsername()
31+
32+
addr, err := host.Driver.GetSSHHostname()
33+
if err != nil {
34+
return err
35+
}
36+
37+
port, err := host.Driver.GetSSHPort()
3038
if err != nil {
31-
return fmt.Errorf("Error running connection boilerplate: %s", err)
39+
return err
3240
}
3341

34-
log.Debug(podmanHost)
42+
key := host.Driver.GetSSHKeyPath()
3543

36-
tlsCACert := filepath.Join(mcndirs.GetMachineDir(), host.Name, "ca.pem")
37-
tlsCert := filepath.Join(mcndirs.GetMachineDir(), host.Name, "cert.pem")
38-
tlsKey := filepath.Join(mcndirs.GetMachineDir(), host.Name, "key.pem")
44+
if addr != "" {
45+
// always use root@ for socket
46+
user = "root"
47+
}
3948

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

4552
return nil
4653
}

libmachine/check/check.go

Lines changed: 0 additions & 70 deletions
This file was deleted.

libmachine/check/check_test.go

Lines changed: 0 additions & 60 deletions
This file was deleted.

libmachine/libmachine.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/boot2podman/machine/drivers/errdriver"
1010
"github.com/boot2podman/machine/libmachine/auth"
1111
"github.com/boot2podman/machine/libmachine/cert"
12-
"github.com/boot2podman/machine/libmachine/check"
1312
"github.com/boot2podman/machine/libmachine/drivers"
1413
"github.com/boot2podman/machine/libmachine/drivers/plugin/localbinary"
1514
"github.com/boot2podman/machine/libmachine/drivers/rpc"
@@ -169,9 +168,15 @@ func (api *Client) performCreate(h *host.Host) error {
169168

170169
// We should check the connection to podman here
171170
log.Info("Checking connection to Podman...")
172-
if _, _, err = check.DefaultConnChecker.Check(h); err != nil {
173-
return fmt.Errorf("Error checking the host: %s", err)
171+
client, err := h.CreateSSHClient()
172+
if err != nil {
173+
return fmt.Errorf("Error creating SSH client: %s", err)
174+
}
175+
version, err := client.Output("podman --version")
176+
if err != nil {
177+
return fmt.Errorf("Error getting podman version: %s", err)
174178
}
179+
log.Debugf("%s", version)
175180

176181
log.Info("Podman is up and running!")
177182
return nil

0 commit comments

Comments
 (0)