vmware-iso: Update VNCAddressFinder interface to return errors from VNCAddress()
This commit is contained in:
parent
6acbc91ff7
commit
2c41d59e21
@ -148,7 +148,7 @@ func (d *ESX5Driver) HostIP() (string, error) {
|
|||||||
return host, err
|
return host, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint) {
|
func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint, error) {
|
||||||
var vncPort uint
|
var vncPort uint
|
||||||
// TODO(dougm) use esxcli network ip connection list
|
// TODO(dougm) use esxcli network ip connection list
|
||||||
for port := portMin; port <= portMax; port++ {
|
for port := portMin; port <= portMax; port++ {
|
||||||
@ -170,7 +170,13 @@ func (d *ESX5Driver) VNCAddress(portMin, portMax uint) (string, uint) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.Host, vncPort
|
if vncPort == 0 {
|
||||||
|
err := fmt.Errorf("Unable to find available VNC port between %d and %d",
|
||||||
|
portMin, portMax)
|
||||||
|
return d.Host, vncPort, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return d.Host, vncPort, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) SSHAddress(state multistep.StateBag) (string, error) {
|
func (d *ESX5Driver) SSHAddress(state multistep.StateBag) (string, error) {
|
||||||
|
@ -24,10 +24,10 @@ import (
|
|||||||
type stepConfigureVNC struct{}
|
type stepConfigureVNC struct{}
|
||||||
|
|
||||||
type VNCAddressFinder interface {
|
type VNCAddressFinder interface {
|
||||||
VNCAddress(uint, uint) (string, uint)
|
VNCAddress(uint, uint) (string, uint, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stepConfigureVNC) VNCAddress(portMin, portMax uint) (string, uint) {
|
func (stepConfigureVNC) VNCAddress(portMin, portMax uint) (string, uint, error) {
|
||||||
// Find an open VNC port. Note that this can still fail later on
|
// Find an open VNC port. Note that this can still fail later on
|
||||||
// because we have to release the port at some point. But this does its
|
// because we have to release the port at some point. But this does its
|
||||||
// best.
|
// best.
|
||||||
@ -47,7 +47,7 @@ func (stepConfigureVNC) VNCAddress(portMin, portMax uint) (string, uint) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "127.0.0.1", vncPort
|
return "127.0.0.1", vncPort, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepConfigureVNC) Run(state multistep.StateBag) multistep.StepAction {
|
func (s *stepConfigureVNC) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
@ -79,10 +79,8 @@ func (s *stepConfigureVNC) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
vncFinder = s
|
vncFinder = s
|
||||||
}
|
}
|
||||||
log.Printf("Looking for available port between %d and %d", config.VNCPortMin, config.VNCPortMax)
|
log.Printf("Looking for available port between %d and %d", config.VNCPortMin, config.VNCPortMax)
|
||||||
vncIp, vncPort := vncFinder.VNCAddress(config.VNCPortMin, config.VNCPortMax)
|
vncIp, vncPort, err := vncFinder.VNCAddress(config.VNCPortMin, config.VNCPortMax)
|
||||||
if vncPort == 0 {
|
if err != nil {
|
||||||
err := fmt.Errorf("Unable to find available VNC port between %d and %d",
|
|
||||||
config.VNCPortMin, config.VNCPortMax)
|
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user