public VmNameId CloneVm(VmNameId original) { var guid = Guid.NewGuid().ToString(); return(CloneVm(original, new VmNameId() { Name = $"Clone of {original.Name} {guid}", Guid = guid })); }
public VmNameId CloneVm(VmId original, VmNameId clone) { if (VBoxManagePath == null) { throw new MissingToolException("VBoxManage", VBoxManage_Paths); } // TODO: More streamy stdout parser so we can sanely parse: // 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% // Machine has been successfully cloned as "Name" var exit = Proc.ExecIn(null, VBoxManagePath, $"clonevm {original} --register --uuid {clone.Guid} --name \"{clone.Name}\"", stdout => { }, stderr => { }, ProcessWindowStyle.Hidden); if (exit != 0) { throw new ToolResultSyntaxException("VBoxManage clonevm ...", "Returned nonzero"); } return(clone); }
public VmNameId TryCloneVm(VmId original, VmNameId clone) { try { return(CloneVm(original, clone)); } catch (VmManagementException) { return(default(VmNameId)); } }
public VmId(VmNameId id) { Id = id.Guid ?? id.Name; }