From d12fbcb700534b4dd82c92dee80acc0df3ae6f01 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Sat, 1 Jul 2017 18:54:10 +0300 Subject: [PATCH] rename 'vcenter_host' to 'vcenter_server' --- README.md | 6 +++--- builder.go | 2 +- builder_acc_test.go | 2 +- config.go | 27 +++++++++++---------------- config_test.go | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index cbf11f0c0..c09acf77d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This builder uses native vSphere API, and creates virtual machines remotely. { "type": "vsphere", - "vcenter_host": "vcenter.domain.com", + "vcenter_server": "vcenter.domain.com", "username": "root", "password": "secret", @@ -41,7 +41,7 @@ This builder uses native vSphere API, and creates virtual machines remotely. ## Parameters ### Required -* `vcenter_host` - vCenter hostname. +* `vcenter_server` - vCenter server hostname. * `username` - vSphere username. * `password` - vSphere password. * `template` - name of source VM. @@ -80,7 +80,7 @@ Post-processing: { "type": "vsphere", - "vcenter_host": "vcenter.domain.com", + "vcenter_server": "vcenter.domain.com", "datacenter": "dc1", "username": "root", "password": "{{user `vsphere_password`}}", diff --git a/builder.go b/builder.go index 8d98ee03d..1e28a47a5 100644 --- a/builder.go +++ b/builder.go @@ -40,7 +40,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ctx := context.TODO() state.Put("ctx", ctx) - vcenter_url, err := url.Parse(fmt.Sprintf("https://%v/sdk", b.config.VCenterHost)) + vcenter_url, err := url.Parse(fmt.Sprintf("https://%v/sdk", b.config.VCenterServer)) if err != nil { return nil, err } diff --git a/builder_acc_test.go b/builder_acc_test.go index 6bc29bebe..a0759bd49 100644 --- a/builder_acc_test.go +++ b/builder_acc_test.go @@ -17,7 +17,7 @@ const testBuilderAccBasic = ` "builders": [{ "type": "test", - "vcenter_host": "vcenter.vsphere5.test", + "vcenter_server": "vcenter.vsphere5.test", "username": "root", "password": "jetbrains", diff --git a/config.go b/config.go index fc07447f8..1efcf71b8 100644 --- a/config.go +++ b/config.go @@ -16,10 +16,10 @@ type Config struct { common.PackerConfig `mapstructure:",squash"` // Connection - VCenterHost string `mapstructure:"vcenter_host"` - Datacenter string `mapstructure:"datacenter"` - Username string `mapstructure:"username"` - Password string `mapstructure:"password"` + VCenterServer string `mapstructure:"vcenter_server"` + Datacenter string `mapstructure:"datacenter"` + Username string `mapstructure:"username"` + Password string `mapstructure:"password"` // Location Template string `mapstructure:"template"` @@ -59,34 +59,29 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { } } - // Accumulate any errors errs := new(packer.MultiError) var warnings []string - - // Prepare config(s) errs = packer.MultiErrorAppend(errs, c.Config.Prepare(&c.ctx)...) - // Check the required params - if c.VCenterHost == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("vCenter host required")) + if c.VCenterServer == "" { + errs = packer.MultiErrorAppend(errs, fmt.Errorf("vCenter hostname is required")) } if c.Username == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Username required")) + errs = packer.MultiErrorAppend(errs, fmt.Errorf("Username is required")) } if c.Password == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Password required")) + errs = packer.MultiErrorAppend(errs, fmt.Errorf("Password is required")) } if c.Template == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Template VM name required")) + errs = packer.MultiErrorAppend(errs, fmt.Errorf("Template name is required")) } if c.VMName == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target VM name required")) + errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target VM name is required")) } if c.Host == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target host required")) + errs = packer.MultiErrorAppend(errs, fmt.Errorf("vSphere host is required")) } - // Verify numeric parameters if present if c.CPUs != "" { if _, err := strconv.Atoi(c.CPUs); err != nil { errs = packer.MultiErrorAppend(errs, fmt.Errorf("Invalid number of CPU sockets")) diff --git a/config_test.go b/config_test.go index 63ff36b82..3188dfadf 100644 --- a/config_test.go +++ b/config_test.go @@ -37,7 +37,7 @@ func TestTimeout(t *testing.T) { func minimalConfig() map[string]interface{} { return map[string]interface{}{ - "vcenter_host": "vcenter.domain.local", + "vcenter_server": "vcenter.domain.local", "username": "root", "password": "vmware", "template": "ubuntu",