rename 'url' to 'vcenter_host'
This commit is contained in:
parent
de58c87878
commit
b9cac9d681
|
@ -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`}}",
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ const testBuilderAccBasic = `
|
|||
"builders": [{
|
||||
"type": "test",
|
||||
|
||||
"url": "https://vcenter.vsphere5.test/sdk",
|
||||
"vcenter_host": "vcenter.vsphere5.test",
|
||||
"username": "root",
|
||||
"password": "jetbrains",
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ type Config struct {
|
|||
common.PackerConfig `mapstructure:",squash"`
|
||||
communicator.Config `mapstructure:",squash"`
|
||||
|
||||
Url string `mapstructure:"url"`
|
||||
VCenterHost string `mapstructure:"vcenter_host"`
|
||||
Username string `mapstructure:"username"`
|
||||
Password string `mapstructure:"password"`
|
||||
|
||||
|
@ -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"))
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue