示例#1
0
        public void SetVmType(DbVirtualMachine vm, VirtualMachineType type)
        {
            vm.VmType = (int)type;
            // !! It is important to normalize thngs with ToUpper()
            var node = Directory[vm.Host].Children.Find(x => x.Type == NodeType.VirtualMachines && x.Uuid.ToUpper() == vm.Uuid.ToString().ToUpper());

            node.VmType = new NodeVirtualMachineType(type);
            Update(vm, x => x.Uuid);
        }
示例#2
0
 private void SetBase(MasterTreeNode node)
 {
     if (node.Type != NodeType.VirtualMachines || node.VmType?.Value != VirtualMachineType.NONE)
     {
         return;
     }
     try
     {
         HyperV.CheckpointVm(node.Host, node.Name, "Base Checkpoint DNR");
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Exception", MessageBoxButtons.OK);
     }
     databaseManager.SetVmType(DbVirtualMachine.FromTreeNode(node), VirtualMachineType.BASE);
     RefreshUI();
 }
示例#3
0
 private void UnsetBase(MasterTreeNode node)
 {
     if (node.Type != NodeType.VirtualMachines || node.VmType?.Value != VirtualMachineType.BASE)
     {
         return;
     }
     if (MessageBox.Show(
             "This action may corrupt all existing templates of this base VM. Data loss may occur. Are you sure you want to continue?",
             "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.No)
     {
         return;
     }
     try
     {
         HyperV.RestoreVmSnapshot(node.Host, node.Name, "Base Checkpoint DNR");
         HyperV.RemoveVmSnapshot(node.Host, node.Name, "Base Checkpoint DNR");
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Exception", MessageBoxButtons.OK);
     }
     databaseManager.SetVmType(DbVirtualMachine.FromTreeNode(node), VirtualMachineType.NONE);
     RefreshUI();
 }
示例#4
0
 public void SetVm(DbVirtualMachine vm)
 {
     Update(vm, x => x.Uuid);
 }