Skip to content

Commit

Permalink
vm: make sshkey argument optional
Browse files Browse the repository at this point in the history
An image can well be setup without a key.
Just password-less root login.
  • Loading branch information
dvyukov committed Apr 16, 2018
1 parent f032e92 commit 1bf59f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
4 changes: 0 additions & 4 deletions vm/isolated/isolated.go
Expand Up @@ -55,10 +55,6 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if cfg.Target_Dir == "" {
return nil, fmt.Errorf("config param target_dir is empty")
}
// sshkey is optional
if env.SSHKey != "" && !osutil.IsExist(env.SSHKey) {
return nil, fmt.Errorf("ssh key '%v' does not exist", env.SSHKey)
}
for _, target := range cfg.Targets {
if _, _, err := splitTargetPort(target); err != nil {
return nil, fmt.Errorf("bad target %q: %v", target, err)
Expand Down
7 changes: 3 additions & 4 deletions vm/odroid/odroid.go
Expand Up @@ -76,9 +76,6 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if cfg.Hub_Port == 0 {
return nil, fmt.Errorf("config param hub_port is empty")
}
if !osutil.IsExist(env.Sshkey) {
return nil, fmt.Errorf("ssh key '%v' does not exist", env.Sshkey)
}
if !osutil.IxExist(cfg.Console) {
return nil, fmt.Errorf("console file '%v' does not exist", cfg.Console)
}
Expand Down Expand Up @@ -398,7 +395,6 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin

func (inst *instance) sshArgs(portArg string) []string {
args := []string{
"-i", inst.sshkey,
portArg, "22",
"-F", "/dev/null",
"-o", "ConnectionAttempts=10",
Expand All @@ -409,6 +405,9 @@ func (inst *instance) sshArgs(portArg string) []string {
"-o", "StrictHostKeyChecking=no",
"-o", "LogLevel=error",
}
if inst.sshkey != "" {
args = append(args, "-i", inst.sshkey)
}
if inst.debug {
args = append(args, "-v")
}
Expand Down
7 changes: 3 additions & 4 deletions vm/qemu/qemu.go
Expand Up @@ -127,9 +127,6 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
if !osutil.IsExist(env.Image) {
return nil, fmt.Errorf("image file '%v' does not exist", env.Image)
}
if !osutil.IsExist(env.SSHKey) {
return nil, fmt.Errorf("ssh key '%v' does not exist", env.SSHKey)
}
}
if cfg.CPU <= 0 || cfg.CPU > 1024 {
return nil, fmt.Errorf("bad qemu cpu: %v, want [1-1024]", cfg.CPU)
Expand Down Expand Up @@ -485,7 +482,6 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin

func (inst *instance) sshArgs(portArg string) []string {
args := []string{
"-i", inst.sshkey,
portArg, strconv.Itoa(inst.port),
"-F", "/dev/null",
"-o", "ConnectionAttempts=10",
Expand All @@ -496,6 +492,9 @@ func (inst *instance) sshArgs(portArg string) []string {
"-o", "StrictHostKeyChecking=no",
"-o", "LogLevel=error",
}
if inst.sshkey != "" {
args = append(args, "-i", inst.sshkey)
}
if inst.debug {
args = append(args, "-v")
}
Expand Down

0 comments on commit 1bf59f0

Please sign in to comment.