Example #1
0
func (c *VBoxManageConfig) Prepare(ctx *interpolate.Context) []error {
	if c.VBoxManage == nil {
		c.VBoxManage = make([][]string, 0)
		return nil
	}

	var errs []error
	var err error
	var desiredMem uint64

	for _, cmd := range c.VBoxManage {
		if cmd[2] == "--memory" {
			desiredMem, err = strconv.ParseUint(cmd[3], 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
}
Example #2
0
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
}