Esempio n. 1
0
File: vms.go Progetto: ankoh/vmlcm
// getRunningVMPaths returns the paths of running VMs
func getRunningVMPaths(
	vmrun vmware.VmrunWrapper) ([]string, error) {
	list, err := vmrun.List()
	if err != nil {
		return nil, err
	}
	matches := listVMPaths.FindAllString(list, -1)
	return matches, nil
}
Esempio n. 2
0
// getRunningVMNumber returns the number of running vms
func getRunningVMNumber(
	vmrun vmware.VmrunWrapper) (int, error) {
	list, err := vmrun.List()
	if err != nil {
		return 0, err
	}

	matches := listVMNumber.FindStringSubmatch(list)
	if len(matches) < 2 {
		return 0, fmt.Errorf("Could not parse vm number information")
	}
	number, err := strconv.Atoi(matches[1])
	if err != nil {
		return 0, fmt.Errorf("Could not parse regex match as integer")
	}

	return number, nil
}