Commit 6cb51f21 authored by Salvador Girones's avatar Salvador Girones

Make ResourcePool optional

parent f41429b6
...@@ -72,7 +72,6 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -72,7 +72,6 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
"diskmode": &p.config.DiskMode, "diskmode": &p.config.DiskMode,
"host": &p.config.Host, "host": &p.config.Host,
"password": &p.config.Password, "password": &p.config.Password,
"resource_pool": &p.config.ResourcePool,
"username": &p.config.Username, "username": &p.config.Username,
"vm_name": &p.config.VMName, "vm_name": &p.config.VMName,
} }
...@@ -107,6 +106,17 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac ...@@ -107,6 +106,17 @@ 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")
} }
ovftool_uri := fmt.Sprintf("vi://%s:%s@%s/%s/host/%s",
url.QueryEscape(p.config.Username),
url.QueryEscape(p.config.Password),
p.config.Host,
p.config.Datacenter,
p.config.Cluster)
if p.config.ResourcePool != "" {
ovftool_uri += "/Resources/" + p.config.ResourcePool
}
args := []string{ args := []string{
fmt.Sprintf("--noSSLVerify=%t", p.config.Insecure), fmt.Sprintf("--noSSLVerify=%t", p.config.Insecure),
"--acceptAllEulas", "--acceptAllEulas",
...@@ -116,13 +126,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac ...@@ -116,13 +126,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
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),
fmt.Sprintf("vi://%s:%s@%s/%s/host/%s/Resources/%s/", fmt.Sprintf("%s", ovftool_uri),
url.QueryEscape(p.config.Username),
url.QueryEscape(p.config.Password),
p.config.Host,
p.config.Datacenter,
p.config.Cluster,
p.config.ResourcePool),
} }
ui.Message(fmt.Sprintf("Uploading %s to vSphere", vmx)) ui.Message(fmt.Sprintf("Uploading %s to vSphere", vmx))
......
...@@ -35,7 +35,7 @@ Required: ...@@ -35,7 +35,7 @@ Required:
endpoint. endpoint.
* `resource_pool` (string) - The resource pool to upload the VM to. * `resource_pool` (string) - The resource pool to upload the VM to.
This is _not required_ if `datastore` is specified. This is _not required_.
* `username` (string) - The username to use to authenticate to the vSphere * `username` (string) - The username to use to authenticate to the vSphere
endpoint. endpoint.
......
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