From fce2fc526f2015f487fe5e17a11574883e484bf6 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Wed, 30 Apr 2014 16:02:09 +0400 Subject: [PATCH] Optional parameters in vSphere post-processor. datastore, vm_folder, and vm_network options can be omitted. --- post-processor/vsphere/post-processor.go | 9 ++++++--- .../docs/post-processors/vsphere.html.markdown | 14 +++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index 29d0f32bc..f9f9ee102 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -64,14 +64,11 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { templates := map[string]*string{ "cluster": &p.config.Cluster, "datacenter": &p.config.Datacenter, - "datastore": &p.config.Datastore, "diskmode": &p.config.DiskMode, "host": &p.config.Host, - "vm_network": &p.config.VMNetwork, "password": &p.config.Password, "resource_pool": &p.config.ResourcePool, "username": &p.config.Username, - "vm_folder": &p.config.VMFolder, "vm_name": &p.config.VMName, } @@ -80,7 +77,13 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { errs = packer.MultiErrorAppend( errs, fmt.Errorf("%s must be set", key)) } + } + templates ["datastore"] = &p.config.Datastore + templates ["vm_network"] = &p.config.VMNetwork + templates ["vm_folder"] = &p.config.VMFolder + + for key, ptr := range templates { *ptr, err = p.config.tpl.Process(*ptr, nil) if err != nil { errs = packer.MultiErrorAppend( diff --git a/website/source/docs/post-processors/vsphere.html.markdown b/website/source/docs/post-processors/vsphere.html.markdown index 742568dbe..8dde0e8fb 100644 --- a/website/source/docs/post-processors/vsphere.html.markdown +++ b/website/source/docs/post-processors/vsphere.html.markdown @@ -23,8 +23,6 @@ Required: * `datacenter` (string) - The name of the datacenter within vSphere to add the VM to. -* `datastore` (string) - The name of the datastore to store this VM. - * `host` (string) - The vSphere host that will be contacted to perform the VM upload. @@ -36,17 +34,19 @@ Required: * `username` (string) - The username to use to authenticate to the vSphere endpoint. -* `vm_folder` (string) - The folder within the datastore to store the VM. - * `vm_name` (string) - The name of the VM once it is uploaded. -* `vm_network` (string) - The name of the VM network this VM will be - added to. - Optional: +* `datastore` (string) - The name of the datastore to store this VM. + * `disk_mode` (string) - Target disk format. See `ovftool` manual for available options. By default, "thick" will be used. * `insecure` (bool) - Whether or not the connection to vSphere can be done over an insecure connection. By default this is false. + +* `vm_folder` (string) - The folder within the datastore to store the VM. + +* `vm_network` (string) - The name of the VM network this VM will be + added to.