Пример #1
0
        private void BindSelectedNode()
        {
            TreeNode node = SnapshotsTree.SelectedNode;

            btnApply.Enabled                             =
                btnRename.Enabled                        =
                    btnDelete.Enabled                    =
                        btnDeleteSubtree.Enabled         =
                            SnapshotDetailsPanel.Visible = (node != null);

            NoSnapshotsPanel.Visible = (SnapshotsTree.Nodes.Count == 0);

            if (node != null)
            {
                // set name
                txtSnapshotName.Text = node.Text;

                // load snapshot details
                VirtualMachineSnapshot snapshot = ES.Services.VPS2012.GetSnapshot(PanelRequest.ItemID, node.Value);
                if (snapshot != null)
                {
                    litCreated.Text = snapshot.Created.ToString();
                }

                // set image
                imgThumbnail.ImageUrl =
                    string.Format("~/DesktopModules/SolidCP/VPS2012/VirtualMachineSnapshotImage.ashx?ItemID={0}&SnapshotID={1}&rnd={2}",
                                  PanelRequest.ItemID, HttpUtility.UrlEncode(node.Value), DateTime.Now.Ticks);

                if (snapshot != null && !String.IsNullOrEmpty(snapshot.SnapshotType) && snapshot.SnapshotType.Equals("Recovery"))
                {
                    btnApply.Enabled = btnDelete.Enabled = btnDeleteSubtree.Enabled = false;
                }
            }
        }
Пример #2
0
        private void BindSelectedNode()
        {
            TreeNode node = SnapshotsTree.SelectedNode;

            btnApply.Enabled          =
                btnRename.Enabled     =
                    btnDelete.Enabled =
                        //btnDeleteSubtree.Enabled =
                        SnapshotDetailsPanel.Visible = (node != null);

            NoSnapshotsPanel.Visible = (SnapshotsTree.Nodes.Count == 0);

            if (node != null)
            {
                // set name
                txtSnapshotName.Text = node.Text;

                // load snapshot details
                VirtualMachineSnapshot snapshot = ES.Services.Proxmox.GetSnapshot(PanelRequest.ItemID, node.Value);
                if (snapshot != null)
                {
                    litCreated.Text = snapshot.Created.ToString();
                }

                // set image

                /*
                 * imgThumbnail.ImageUrl =
                 *  string.Format("~/DesktopModules/SolidCP/Proxmox/VirtualMachineSnapshotImage.ashx?ItemID={0}&SnapshotID={1}&rnd={2}",
                 *  PanelRequest.ItemID, HttpUtility.UrlEncode(node.Value), DateTime.Now.Ticks);
                 */
            }
        }
Пример #3
0
        public override void restoreSnapshot()
        {
            VimClientImpl  _vClient = VClient.getConnection();
            VirtualMachine vm       = VClient.getMachine();

            // Find a named snapshot which corresponds to what we're interested in
            VirtualMachineSnapshotTree snapshot = findRecusively(vm.Snapshot.RootSnapshotList, _spec.snapshotFriendlyName);

            // and revert it.
            VirtualMachineSnapshot shot = new VirtualMachineSnapshot(_vClient, snapshot.Snapshot);

            shot.RevertToSnapshot(vm.MoRef, false);
        }
Пример #4
0
 public VirtualMachineSnapshot GetSnapshot(string snapshotId)
 {
     try
     {
         Log.WriteStart("'{0}' GetSnapshot", ProviderSettings.ProviderName);
         VirtualMachineSnapshot result = VirtualizationProvider.GetSnapshot(snapshotId);
         Log.WriteEnd("'{0}' GetSnapshot", ProviderSettings.ProviderName);
         return(result);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' GetSnapshot", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
        private VirtualMachineSnapshot FindSnapshot( string name, IEnumerable<VirtualMachineSnapshotTree> trees )
        {
            VirtualMachineSnapshot snapshot = null;

            foreach ( VirtualMachineSnapshotTree tree in trees )
            {
                if ( tree.Name == name )
                {
                    snapshot = new VirtualMachineSnapshot( _virtualHost, tree.Snapshot );
                    break;
                }

                snapshot = FindSnapshot( name, tree.ChildSnapshotList );

                if ( snapshot != null )
                {
                    break;
                }
            }

            return snapshot;
        }
        public void TakesSnapshotOnPoweredOnVirtualMachineWhenTakeSnapshotIsCalledAndVirtualMachineIsOn()
        {
            IVirtualMachine vm = CreateVirtualMachine();
            vm.Start();

            string snapshotName = Guid.NewGuid().ToString( "N" );

            ManagedObjectReference initialSnapshot = _vmWareVirtualMachine.Snapshot.CurrentSnapshot;

            try
            {
                vm.TakeSnapshot( snapshotName, "Some description" );
                _vmWareVirtualMachine.UpdateViewData();
            }
            finally
            {
                if ( initialSnapshot.ToString() != _vmWareVirtualMachine.Snapshot.CurrentSnapshot.ToString() )
                {
                    VirtualMachineSnapshot snapshot = new VirtualMachineSnapshot( _vmWareVirtualMachine.Client, _vmWareVirtualMachine.Snapshot.CurrentSnapshot );
                    snapshot.UpdateViewData();
                    snapshot.RemoveSnapshot( false, null );
                }
            }
        }
        public void RevertsToPoweredOnVmWhenSnapshotWasDoneOnPoweredOnVirtualMachine()
        {
            IVirtualMachine vm = CreateVirtualMachine();
            vm.Start();

            string snapshotName = Guid.NewGuid().ToString( "N" );

            ManagedObjectReference initialSnapshot = _vmWareVirtualMachine.Snapshot.CurrentSnapshot;

            try
            {
                vm.TakeSnapshot( snapshotName, "Some description" );

                VirtualMachineSnapshot snapshot = new VirtualMachineSnapshot( _vmWareVirtualMachine.Client, initialSnapshot );
                snapshot.RevertToSnapshot( null, false );
                _vmWareVirtualMachine.UpdateViewData();

                Assert.IsFalse( vm.VirtualMachineIsRunning() );

                vm.RevertToSnapshot( snapshotName );

                Assert.IsTrue( vm.VirtualMachineIsRunning() );
            }
            finally
            {
                if ( initialSnapshot.ToString() != _vmWareVirtualMachine.Snapshot.CurrentSnapshot.ToString() )
                {
                    VirtualMachineSnapshot snapshot = new VirtualMachineSnapshot( _vmWareVirtualMachine.Client, _vmWareVirtualMachine.Snapshot.CurrentSnapshot );
                    snapshot.UpdateViewData();
                    snapshot.RemoveSnapshot( false, null );
                }
            }
        }