Пример #1
0
func (action *actConfigNetworkIFacesVM) Run() (e error) {
	vm, e := vbox.LoadVM(action.Name)
	if e != nil {
		return e
	}

	if action.Id >= 8 {
		return fmt.Errorf("Only 8 nics supported!")
	}

	var nic *vbox.VNet
	for i := range vm.Nics {
		if vm.Nics[i].Id == action.Id {
			nic = vm.Nics[i]
		}
	}

	if nic == nil {
		nic = &vbox.VNet{Id: action.Id}
		vm.Nics = append(vm.Nics, nic)
	}

	nic.NType = action.NType
	if action.NType == "hostonly" {
		if action.Network == "" {
			return fmt.Errorf("No name for the hostonly network specified!")
		}
		nic.Name = action.Network
	}

	return vm.Save()
}
Пример #2
0
func (action *actConfigMemVM) Run() (e error) {
	vm, e := vbox.LoadVM(action.Name)
	if e != nil {
		return e
	}

	vm.Memory = action.Memory
	return vm.Save()
}
Пример #3
0
func (action *actConfigCPUsVM) Run() (e error) {
	vm, e := vbox.LoadVM(action.Name)
	if e != nil {
		return e
	}

	vm.Cpus = action.CPUs

	return vm.Save()
}
Пример #4
0
func showVMInfo(name string) (e error) {
	vm, e := vbox.LoadVM(name)
	if e != nil {
		return e
	}

	log.Printf("%s", vm)

	return nil
}
Пример #5
0
func (action *actConfigBootOrderVM) Run() (e error) {
	vm, e := vbox.LoadVM(action.Name)
	if e != nil {
		return e
	}

	for i := 0; i < 4; i++ {
		if i < len(action.Devices) {
			vm.BootOrder[i] = action.Devices[i]
		} else {
			vm.BootOrder[i] = "none"
		}
	}

	return vm.Save()
}