Only validate vmware resources on local hosts
Disable resource validation when `remote_type` is specified
This commit is contained in:
parent
eda84cb2d3
commit
f01578c91e
|
@ -13,11 +13,13 @@ type VMXConfig struct {
|
||||||
VMXDataPost map[string]string `mapstructure:"vmx_data_post"`
|
VMXDataPost map[string]string `mapstructure:"vmx_data_post"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *VMXConfig) Prepare(ctx *interpolate.Context) []error {
|
func (c *VMXConfig) Prepare(ctx *interpolate.Context, remoteType string) []error {
|
||||||
var errs []error
|
var errs []error
|
||||||
var err error
|
var err error
|
||||||
var desiredMem uint64
|
var desiredMem uint64
|
||||||
|
|
||||||
|
// Validate memory resources, only on local hosts
|
||||||
|
if remoteType == "" {
|
||||||
for k, v := range c.VMXData {
|
for k, v := range c.VMXData {
|
||||||
if k == "memsize" {
|
if k == "memsize" {
|
||||||
desiredMem, err = strconv.ParseUint(v, 10, 64)
|
desiredMem, err = strconv.ParseUint(v, 10, 64)
|
||||||
|
@ -26,6 +28,7 @@ func (c *VMXConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err = common.AvailableMem(desiredMem); err != nil {
|
if err = common.AvailableMem(desiredMem); err != nil {
|
||||||
errs = append(errs, fmt.Errorf("Unavailable Resources: %s", err))
|
errs = append(errs, fmt.Errorf("Unavailable Resources: %s", err))
|
||||||
|
|
|
@ -93,7 +93,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
||||||
errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs, b.config.VMXConfig.Prepare(&b.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, b.config.VMXConfig.Prepare(&b.config.ctx, b.config.RemoteType)...)
|
||||||
|
|
||||||
if b.config.DiskName == "" {
|
if b.config.DiskName == "" {
|
||||||
b.config.DiskName = "disk"
|
b.config.DiskName = "disk"
|
||||||
|
@ -171,11 +171,13 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if DiskSize is able to be allocated
|
// Determine if DiskSize is able to be allocated, only when running locally
|
||||||
|
if b.config.RemoteType == "" {
|
||||||
if err = common.AvailableDisk(uint64(b.config.DiskSize)); err != nil {
|
if err = common.AvailableDisk(uint64(b.config.DiskSize)); err != nil {
|
||||||
errs = packer.MultiErrorAppend(errs,
|
errs = packer.MultiErrorAppend(errs,
|
||||||
fmt.Errorf("Unavailable Resources: %s", err))
|
fmt.Errorf("Unavailable Resources: %s", err))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Warnings
|
// Warnings
|
||||||
if b.config.ShutdownCommand == "" {
|
if b.config.ShutdownCommand == "" {
|
||||||
|
|
|
@ -63,7 +63,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||||
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
|
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
|
errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)
|
errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs, c.VMXConfig.Prepare(&c.ctx)...)
|
errs = packer.MultiErrorAppend(errs, c.VMXConfig.Prepare(&c.ctx, c.RemoteType)...)
|
||||||
|
|
||||||
if c.SourcePath == "" {
|
if c.SourcePath == "" {
|
||||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is blank, but is required"))
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is blank, but is required"))
|
||||||
|
|
Loading…
Reference in New Issue