add some missing template validation (copied from iso builder) and revert to current use of displayName for parsing vm ssh IP; using VMName was breaking chained builds that hadn't updated the display name from the previous build.
This commit is contained in:
parent
c3d6d45696
commit
c3144c2d0a
|
@ -456,10 +456,18 @@ func (d *ESX5Driver) CommHost(state multistep.StateBag) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
|
||||
spacesToUnderscores := func(string string) string {
|
||||
return strings.Replace(string, " ", "_", -1)
|
||||
// The value in the Name field returned by 'esxcli network vm list'
|
||||
// corresponds directly to the value of displayName set in the VMX file
|
||||
var displayName string
|
||||
if v, ok := state.GetOk("display_name"); ok {
|
||||
displayName = v.(string)
|
||||
} else {
|
||||
displayName = strings.Replace(d.VMName, " ", "_", -1)
|
||||
log.Printf("No display_name set; falling back to using VMName %s "+
|
||||
"to look for SSH IP", displayName)
|
||||
}
|
||||
record, err := r.find("Name", spacesToUnderscores(d.VMName))
|
||||
|
||||
record, err := r.find("Name", displayName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|||
errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
|
||||
errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...)
|
||||
|
||||
if c.DriverConfig.RemoteType == "" {
|
||||
if c.RemoteType == "" {
|
||||
if c.SourcePath == "" {
|
||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is blank, but is required"))
|
||||
} else {
|
||||
|
@ -80,6 +80,26 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|||
fmt.Errorf("source_path is invalid: %s", err))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Remote configuration validation
|
||||
if c.RemoteHost == "" {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("remote_host must be specified"))
|
||||
}
|
||||
|
||||
if c.RemoteType != "esx5" {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("Only 'esx5' value is accepted for remote_type"))
|
||||
}
|
||||
}
|
||||
|
||||
if c.Format == "" {
|
||||
c.Format = "ovf"
|
||||
}
|
||||
|
||||
if !(c.Format == "ova" || c.Format == "ovf" || c.Format == "vmx") {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("format must be one of ova, ovf, or vmx"))
|
||||
}
|
||||
|
||||
// Warnings
|
||||
|
|
Loading…
Reference in New Issue