diff --git a/README.md b/README.md index 523384c53..d31f55c0d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This builder uses native vSphere API, and creates virtual machines remotely. { "type": "vsphere", - "url": "https://vcenter.domain.com/sdk", + "vcenter_host": "vcenter.domain.com", "username": "root", "password": "secret", @@ -41,7 +41,7 @@ This builder uses native vSphere API, and creates virtual machines remotely. ## Parameters ### Required -* `url` - URL of vCenter API enpoint. +* `vcenter_host` - vCenter hostname. * `username` - vSphere username. * `password` - vSphere password. * `template` - name of source VM. @@ -79,7 +79,7 @@ Post-processing: { "type": "vsphere", - "url": "https://vcenter.domain.com/sdk", + "vcenter_host": "vcenter.domain.com", "dc_name": "dc1", "username": "root", "password": "{{user `vsphere_password`}}", diff --git a/builder.go b/builder.go index 97f9b1167..14f601a30 100644 --- a/builder.go +++ b/builder.go @@ -15,6 +15,7 @@ import ( "net/url" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/object" + "fmt" ) type Builder struct { @@ -39,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(b.config.Url) + vcenter_url, err := url.Parse(fmt.Sprintf("https://%v/sdk", b.config.VCenterHost)) if err != nil { return nil, err } diff --git a/builder_acc_test.go b/builder_acc_test.go index fc24f92bc..6bc29bebe 100644 --- a/builder_acc_test.go +++ b/builder_acc_test.go @@ -17,7 +17,7 @@ const testBuilderAccBasic = ` "builders": [{ "type": "test", - "url": "https://vcenter.vsphere5.test/sdk", + "vcenter_host": "vcenter.vsphere5.test", "username": "root", "password": "jetbrains", diff --git a/config.go b/config.go index 9d11afa80..fa7b91143 100644 --- a/config.go +++ b/config.go @@ -16,9 +16,9 @@ type Config struct { common.PackerConfig `mapstructure:",squash"` communicator.Config `mapstructure:",squash"` - Url string `mapstructure:"url"` - Username string `mapstructure:"username"` - Password string `mapstructure:"password"` + VCenterHost string `mapstructure:"vcenter_host"` + Username string `mapstructure:"username"` + Password string `mapstructure:"password"` // Location Template string `mapstructure:"template"` @@ -33,7 +33,7 @@ type Config struct { LinkedClone bool `mapstructure:"linked_clone"` ConvertToTemplate bool `mapstructure:"convert_to_template"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"` - ShutdownTimeout time.Duration `` + ShutdownTimeout time.Duration // Customization Cpus string `mapstructure:"cpus"` @@ -63,8 +63,8 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { errs = packer.MultiErrorAppend(errs, c.Config.Prepare(&c.ctx)...) // Check the required params - if c.Url == "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("URL required")) + if c.VCenterHost == "" { + errs = packer.MultiErrorAppend(errs, fmt.Errorf("vCenter host required")) } if c.Username == "" { errs = packer.MultiErrorAppend(errs, fmt.Errorf("Username required")) diff --git a/config_test.go b/config_test.go index f6bed1613..0e2de650c 100644 --- a/config_test.go +++ b/config_test.go @@ -31,13 +31,13 @@ func TestTimeout(t *testing.T) { conf, warns, err := NewConfig(raw) testConfigOk(t, warns, err) if conf.ShutdownTimeout != 3 * time.Minute { - t.Fatalf("shutdown_timeout sourld equal 3 minutes") + t.Fatalf("shutdown_timeout sould be equal 3 minutes") } } func minimalConfig() map[string]interface{} { return map[string]interface{}{ - "url": "https://vcenter.domain.local/sdk", + "vcenter_host": "vcenter.domain.local", "username": "root", "password": "vmware", "template": "ubuntu",