fix post-processor vsphere
This commit is contained in:
parent
30ba7307b6
commit
2aaec946b3
|
@ -17,11 +17,13 @@ type Config struct {
|
|||
common.PackerConfig `mapstructure:",squash"`
|
||||
|
||||
Insecure bool `mapstructure:"insecure"`
|
||||
Cluster string `mapstructure:"cluster"`
|
||||
Datacenter string `mapstructure:"datacenter"`
|
||||
Datastore string `mapstructure:"datastore"`
|
||||
Debug bool `mapstructure:"debug"`
|
||||
Host string `mapstructure:"host"`
|
||||
Password string `mapstructure:"password"`
|
||||
PathToResourcePool string `mapstructure:"path_to_resource_pool"`
|
||||
ResourcePool string `mapstructure:"resource_pool"`
|
||||
Username string `mapstructure:"username"`
|
||||
VMFolder string `mapstructure:"vm_folder"`
|
||||
VMName string `mapstructure:"vm_name"`
|
||||
|
@ -47,18 +49,24 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
|
|||
// Accumulate any errors
|
||||
errs := new(packer.MultiError)
|
||||
|
||||
if err := tpl.Validate(p.config.VMName); err != nil {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, fmt.Errorf("Error parsing output template: %s", err))
|
||||
}
|
||||
|
||||
if _, err := exec.LookPath("ovftool"); err != nil {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, fmt.Errorf("ovftool not found: %s", err))
|
||||
}
|
||||
|
||||
validates := map[string]*string{
|
||||
"cluster": &p.config.Cluster,
|
||||
"datacenter": &p.config.Datacenter,
|
||||
"datastore": &p.config.Datastore,
|
||||
"host": &p.config.Host,
|
||||
"vm_network": &p.config.VMNetwork,
|
||||
"password": &p.config.Password,
|
||||
"path_to_resource_pool": &p.config.PathToResourcePool,
|
||||
"resource_pool": &p.config.ResourcePool,
|
||||
"username": &p.config.Username,
|
||||
"vm_folder": &p.config.VMFolder,
|
||||
"vm_name": &p.config.VMName,
|
||||
|
@ -104,12 +112,18 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
|||
fmt.Sprintf("--datastore=%s", p.config.Datastore),
|
||||
fmt.Sprintf("--network=%s", p.config.VMNetwork),
|
||||
fmt.Sprintf("--vmFolder=%s", p.config.VMFolder),
|
||||
fmt.Sprintf("vi://%s:%s@%s/%s/%s",
|
||||
fmt.Sprintf("%s", vmx),
|
||||
fmt.Sprintf("vi://%s:%s@%s/%s/host/%s/Resources/%s",
|
||||
p.config.Username,
|
||||
p.config.Password,
|
||||
p.config.Host,
|
||||
p.config.Datacenter,
|
||||
p.config.PathToResourcePool),
|
||||
p.config.Cluster,
|
||||
p.config.ResourcePool),
|
||||
}
|
||||
|
||||
if p.config.Debug {
|
||||
ui.Message(fmt.Sprintf("DEBUG: %s", args))
|
||||
}
|
||||
|
||||
var out bytes.Buffer
|
||||
|
|
Loading…
Reference in New Issue