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); }
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(); }
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(); }
public void SetVm(DbVirtualMachine vm) { Update(vm, x => x.Uuid); }