Removed commented (obsolete) code from builder\virtualbox\common\driver_4_2.go
This commit is contained in:
parent
5e00253450
commit
fd5a2db58f
|
@ -325,92 +325,3 @@ func (d *VBox42Driver) DeleteSnapshot(vmname string, sn *VBoxSnapshot) error {
|
|||
log.Printf("Executing DeleteSnapshot: VM: %s, SnapshotName %s", vmname, sn.UUID)
|
||||
return d.VBoxManage("snapshot", vmname, "delete", sn.UUID)
|
||||
}
|
||||
|
||||
/*
|
||||
func (d *VBox42Driver) SnapshotExists(vmname string, snapshotName string) (bool, error) {
|
||||
log.Printf("Executing SnapshotExists: VM %s, SnapshotName %s", vmname, snapshotName)
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
cmd := exec.Command(d.VBoxManagePath, "snapshot", vmname, "list", "--machinereadable")
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
err := cmd.Run()
|
||||
|
||||
if _, ok := err.(*exec.ExitError); ok {
|
||||
stderrString := strings.TrimSpace(stderr.String())
|
||||
return false, (fmt.Errorf("VBoxManage error: %s", stderrString))
|
||||
}
|
||||
|
||||
SnapshotNameRe := regexp.MustCompile(fmt.Sprintf("SnapshotName[^=]*=[^\"]*\"%s\"", snapshotName))
|
||||
|
||||
for _, line := range strings.Split(stdout.String(), "\n") {
|
||||
if SnapshotNameRe.MatchString(line) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (d *VBox42Driver) GetParentSnapshot(vmname string, snapshotName string) (string, error) {
|
||||
log.Printf("Executing GetParentSnapshot: VM %s, SnapshotName %s", vmname, snapshotName)
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
cmd := exec.Command(d.VBoxManagePath, "snapshot", vmname, "list", "--machinereadable")
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
err := cmd.Run()
|
||||
|
||||
if _, ok := err.(*exec.ExitError); ok {
|
||||
stderrString := strings.TrimSpace(stderr.String())
|
||||
return "", (fmt.Errorf("VBoxManage error: %s", stderrString))
|
||||
}
|
||||
|
||||
SnapshotNameRe := regexp.MustCompile(fmt.Sprintf("SnapshotName[^=]*=[^\"]*\"%s\"", snapshotName))
|
||||
|
||||
var snapshot string
|
||||
for _, line := range strings.Split(stdout.String(), "\n") {
|
||||
if SnapshotNameRe.MatchString(line) {
|
||||
snapshot = line
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if snapshot == "" {
|
||||
return "", (fmt.Errorf("Snapshot %s does not exist", snapshotName))
|
||||
}
|
||||
|
||||
SnapshotNamePartsRe := regexp.MustCompile("SnapshotName(?P<Path>(-[1-9]+)*)")
|
||||
matches := SnapshotNamePartsRe.FindStringSubmatch(snapshot)
|
||||
log.Printf("************ Snapshot %s name parts", snapshot)
|
||||
log.Printf("Matches %#v\n", matches)
|
||||
log.Printf("Node %s\n", matches[0])
|
||||
log.Printf("Path %s\n", matches[1])
|
||||
log.Printf("Leaf %s\n", matches[2])
|
||||
leaf := matches[2]
|
||||
node := matches[0]
|
||||
if node == "" {
|
||||
return "", (fmt.Errorf("Unsupported format for snapshot %s", snapshot))
|
||||
}
|
||||
if leaf != "" && node != "" {
|
||||
SnapshotNodeRe := regexp.MustCompile("^(?P<Node>SnapshotName[^=]*)=[^\"]*\"(?P<Name>[^\"]+)\"")
|
||||
parentNode := node[:len(node)-len(leaf)]
|
||||
log.Printf("Parent node %s\n", parentNode)
|
||||
var parentName string
|
||||
for _, line := range strings.Split(stdout.String(), "\n") {
|
||||
if matches := SnapshotNodeRe.FindStringSubmatch(line); len(matches) > 1 && parentNode == matches[1] {
|
||||
parentName = matches[2]
|
||||
log.Printf("Parent Snapshot name %s\n", parentName)
|
||||
break
|
||||
}
|
||||
}
|
||||
if parentName == "" {
|
||||
return "", (fmt.Errorf("Internal error: Unable to find name for snapshot node %s", parentNode))
|
||||
}
|
||||
return parentName, nil
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue