Commit 9df6b8f0 authored by mheidenr's avatar mheidenr

post-processor-vsphere: user variables for datastore

parent 129749a2
...@@ -100,6 +100,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac ...@@ -100,6 +100,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
return nil, false, fmt.Errorf("VMX file not found") return nil, false, fmt.Errorf("VMX file not found")
} }
// Get user variables from template
vm_name, err := p.config.tpl.Process(p.config.VMName, p.config.PackerUserVars) vm_name, err := p.config.tpl.Process(p.config.VMName, p.config.PackerUserVars)
if err != nil { if err != nil {
return nil, false, fmt.Errorf("Failed: %s", err) return nil, false, fmt.Errorf("Failed: %s", err)
...@@ -115,13 +116,18 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac ...@@ -115,13 +116,18 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
return nil, false, fmt.Errorf("Failed: %s", err) return nil, false, fmt.Errorf("Failed: %s", err)
} }
datastore, err := p.config.tpl.Process(p.config.Datastore, p.config.PackerUserVars)
if err != nil {
return nil, false, fmt.Errorf("Failed: %s", err)
}
ui.Message(fmt.Sprintf("Uploading %s to vSphere", vmx)) ui.Message(fmt.Sprintf("Uploading %s to vSphere", vmx))
args := []string{ args := []string{
fmt.Sprintf("--noSSLVerify=%t", p.config.Insecure), fmt.Sprintf("--noSSLVerify=%t", p.config.Insecure),
"--acceptAllEulas", "--acceptAllEulas",
fmt.Sprintf("--name=%s", vm_name), fmt.Sprintf("--name=%s", vm_name),
fmt.Sprintf("--datastore=%s", p.config.Datastore), fmt.Sprintf("--datastore=%s", datastore),
fmt.Sprintf("--network=%s", p.config.VMNetwork), fmt.Sprintf("--network=%s", p.config.VMNetwork),
fmt.Sprintf("--vmFolder=%s", p.config.VMFolder), fmt.Sprintf("--vmFolder=%s", p.config.VMFolder),
fmt.Sprintf("%s", vmx), fmt.Sprintf("%s", vmx),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment