packer-cn/builder/vmware/common/vmx_config.go

39 lines
855 B
Go
Raw Normal View History

2013-12-26 17:14:19 -05:00
package common
import (
"fmt"
"strconv"
"github.com/mitchellh/packer/common"
2015-05-27 17:16:28 -04:00
"github.com/mitchellh/packer/template/interpolate"
2013-12-26 17:14:19 -05:00
)
type VMXConfig struct {
2014-05-10 13:19:35 -04:00
VMXData map[string]string `mapstructure:"vmx_data"`
VMXDataPost map[string]string `mapstructure:"vmx_data_post"`
2013-12-26 17:14:19 -05:00
}
func (c *VMXConfig) Prepare(ctx *interpolate.Context, remoteType string) []error {
var errs []error
var err error
var desiredMem uint64
// Validate memory resources, only on local hosts
if remoteType == "" {
for k, v := range c.VMXData {
if k == "memsize" {
desiredMem, err = strconv.ParseUint(v, 10, 64)
if err != nil {
errs = append(errs, fmt.Errorf("Error parsing string: %s", err))
}
}
}
}
if err = common.AvailableMem(desiredMem); err != nil {
errs = append(errs, fmt.Errorf("Unavailable Resources: %s", err))
}
return errs
2013-12-26 17:14:19 -05:00
}