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 {
"diskmode": &p.config.DiskMode,
"host": &p.config.Host,
"password": &p.config.Password,
"resource_pool": &p.config.ResourcePool,
"username": &p.config.Username,
"vm_name": &p.config.VMName,
}
......@@ -107,6 +106,17 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
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{
fmt.Sprintf("--noSSLVerify=%t", p.config.Insecure),
"--acceptAllEulas",
......@@ -116,13 +126,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
fmt.Sprintf("--network=%s", p.config.VMNetwork),
fmt.Sprintf("--vmFolder=%s", p.config.VMFolder),
fmt.Sprintf("%s", vmx),
fmt.Sprintf("vi://%s:%s@%s/%s/host/%s/Resources/%s/",
url.QueryEscape(p.config.Username),
url.QueryEscape(p.config.Password),
p.config.Host,
p.config.Datacenter,
p.config.Cluster,
p.config.ResourcePool),
fmt.Sprintf("%s", ovftool_uri),
}
ui.Message(fmt.Sprintf("Uploading %s to vSphere", vmx))
......
......@@ -35,7 +35,7 @@ Required:
endpoint.
* `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
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