Find local IP automatically
This commit is contained in:
parent
d619e751e3
commit
27819cd51f
@ -37,8 +37,6 @@ type CommonConfig struct {
|
|||||||
HTTPPortMin uint `mapstructure:"http_port_min"`
|
HTTPPortMin uint `mapstructure:"http_port_min"`
|
||||||
HTTPPortMax uint `mapstructure:"http_port_max"`
|
HTTPPortMax uint `mapstructure:"http_port_max"`
|
||||||
|
|
||||||
LocalIp string `mapstructure:"local_ip"`
|
|
||||||
|
|
||||||
// SSHHostPortMin uint `mapstructure:"ssh_host_port_min"`
|
// SSHHostPortMin uint `mapstructure:"ssh_host_port_min"`
|
||||||
// SSHHostPortMax uint `mapstructure:"ssh_host_port_max"`
|
// SSHHostPortMax uint `mapstructure:"ssh_host_port_max"`
|
||||||
SSHKeyPath string `mapstructure:"ssh_key_path"`
|
SSHKeyPath string `mapstructure:"ssh_key_path"`
|
||||||
@ -136,7 +134,6 @@ func (c *CommonConfig) Prepare(t *packer.ConfigTemplate, pc *common.PackerConfig
|
|||||||
"boot_wait": &c.RawBootWait,
|
"boot_wait": &c.RawBootWait,
|
||||||
"tools_iso_name": &c.ToolsIsoName,
|
"tools_iso_name": &c.ToolsIsoName,
|
||||||
"http_directory": &c.HTTPDir,
|
"http_directory": &c.HTTPDir,
|
||||||
"local_ip": &c.LocalIp,
|
|
||||||
"ssh_key_path": &c.SSHKeyPath,
|
"ssh_key_path": &c.SSHKeyPath,
|
||||||
"ssh_password": &c.SSHPassword,
|
"ssh_password": &c.SSHPassword,
|
||||||
"ssh_username": &c.SSHUser,
|
"ssh_username": &c.SSHUser,
|
||||||
@ -227,12 +224,6 @@ func (c *CommonConfig) Prepare(t *packer.ConfigTemplate, pc *common.PackerConfig
|
|||||||
errs = append(errs, errors.New("keep_vm must be one of 'always', 'never', 'on_success'"))
|
errs = append(errs, errors.New("keep_vm must be one of 'always', 'never', 'on_success'"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if c.LocalIp == "" {
|
|
||||||
errs = append(errs, errors.New("A local IP visible to XenServer's mangement interface is required to serve files."))
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,10 +60,22 @@ func (self *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAct
|
|||||||
|
|
||||||
log.Printf("Connected to the VNC console: %s", c.DesktopName)
|
log.Printf("Connected to the VNC console: %s", c.DesktopName)
|
||||||
|
|
||||||
// @todo - include http port/ip so kickstarter files can be grabbed
|
// find local ip
|
||||||
|
envVar, err := execute_ssh_cmd("echo $SSH_CLIENT", config.HostIp, "22", config.Username, config.Password)
|
||||||
|
if err != nil {
|
||||||
|
ui.Error(fmt.Sprintf("Error detecting local IP: %s", err))
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
|
if envVar == "" {
|
||||||
|
ui.Error("Error detecting local IP: $SSH_CLIENT was empty")
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
|
localIp := strings.Split(envVar, " ")[0]
|
||||||
|
ui.Message(fmt.Sprintf("Found local IP: %s", localIp))
|
||||||
|
|
||||||
tplData := &bootCommandTemplateData{
|
tplData := &bootCommandTemplateData{
|
||||||
config.VMName,
|
config.VMName,
|
||||||
config.LocalIp,
|
localIp,
|
||||||
http_port,
|
http_port,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user