コード例 #1
0
ファイル: snapshots.go プロジェクト: ankoh/vmlcm
// getRunningVMPaths returns the paths of running VMs
func getTemplateSnapshots(
	vmrun vmware.VmrunWrapper,
	config *util.LCMConfiguration) ([]string, error) {
	list, err := vmrun.ListSnapshots(config.TemplatePath)
	if err != nil {
		return nil, err
	}
	lines := strings.Split(list, "\n")

	// Check if at least one line is there
	if len(lines) < 1 {
		return nil, fmt.Errorf("Failed to parse the listSnapshots command")
	}
	// Then remove the first line
	lines = lines[1:]
	var result []string

	// Now remove empty lines
	for _, line := range lines {
		if len(line) == 0 {
			continue
		}
		result = append(result, line)
	}
	return result, nil
}