Exemplo n.º 1
0
 public VmNameId CloneVm(VmNameId original)
 {
     var guid = Guid.NewGuid().ToString(); return(CloneVm(original, new VmNameId()
     {
         Name = $"Clone of {original.Name} {guid}", Guid = guid
     }));
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public VmNameId TryCloneVm(VmId original, VmNameId clone)
 {
     try { return(CloneVm(original, clone)); } catch (VmManagementException) { return(default(VmNameId)); }
 }
Exemplo n.º 4
0
 public VmId(VmNameId id)
 {
     Id = id.Guid ?? id.Name;
 }