rename 'vcenter_host' to 'vcenter_server'

This commit is contained in:
Michael Kuzmin 2017-07-01 18:54:10 +03:00
parent 84af7f5583
commit d12fbcb700
5 changed files with 17 additions and 22 deletions

View File

@ -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`}}",

View File

@ -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
}

View File

@ -17,7 +17,7 @@ const testBuilderAccBasic = `
"builders": [{
"type": "test",
"vcenter_host": "vcenter.vsphere5.test",
"vcenter_server": "vcenter.vsphere5.test",
"username": "root",
"password": "jetbrains",

View File

@ -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"))

View File

@ -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",