Beispiel #1
0
 public void PowerOff()
 {
     ConsoleOutput.WriteLine(" Powering off 'Remote:{0}'", _name);
     if (!_simulationOnly)
     {
         _vm.PowerOff();
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override bool Execute()
        {
            using (VMWareVirtualHost host = GetConnectedHost())
            {
                using (VMWareVirtualMachine virtualMachine = OpenVirtualMachine(host))
                {
                    Log.LogMessage(string.Format("Powering off {0}", Filename));
                    virtualMachine.PowerOff(0, PowerOffTimeout);
                }
            }

            return(true);
        }
Beispiel #3
0
 public void GettingStartedWorkstation()
 {
     #region Example: Getting Started (Workstation)
     // declare a virtual host
     using (VMWareVirtualHost virtualHost = new VMWareVirtualHost())
     {
         // connect to a local VMWare Workstation virtual host
         virtualHost.ConnectToVMWareWorkstation();
         // open an existing virtual machine
         using (VMWareVirtualMachine virtualMachine = virtualHost.Open(@"C:\Virtual Machines\xp\xp.vmx"))
         {
             // power on this virtual machine
             virtualMachine.PowerOn();
             // wait for VMWare Tools
             virtualMachine.WaitForToolsInGuest();
             // login to the virtual machine
             virtualMachine.LoginInGuest("Administrator", "password");
             // run notepad
             virtualMachine.RunProgramInGuest("notepad.exe", string.Empty);
             // create a new snapshot
             string name = "New Snapshot";
             // take a snapshot at the current state
             VMWareSnapshot createdSnapshot = virtualMachine.Snapshots.CreateSnapshot(name, "test snapshot");
             createdSnapshot.Dispose();
             // power off
             virtualMachine.PowerOff();
             // find the newly created snapshot
             using (VMWareSnapshot foundSnapshot = virtualMachine.Snapshots.GetNamedSnapshot(name))
             {
                 // revert to the new snapshot
                 foundSnapshot.RevertToSnapshot();
                 // delete snapshot
                 foundSnapshot.RemoveSnapshot();
             }
         }
     }
     #endregion
 }
Beispiel #4
0
 public void GettingStartedVI()
 {
     #region Example: Getting Started (VI)
     // declare a virtual host
     using (VMWareVirtualHost virtualHost = new VMWareVirtualHost())
     {
         // connect to a remove (VMWare ESX) virtual machine
         virtualHost.ConnectToVMWareVIServer("esx.mycompany.com", "vmuser", "password");
         // open an existing virtual machine
         using (VMWareVirtualMachine virtualMachine = virtualHost.Open("[storage] testvm/testvm.vmx"))
         {
             // power on this virtual machine
             virtualMachine.PowerOn();
             // wait for VMWare Tools
             virtualMachine.WaitForToolsInGuest();
             // login to the virtual machine
             virtualMachine.LoginInGuest("Administrator", "password");
             // run notepad
             virtualMachine.RunProgramInGuest("notepad.exe", string.Empty);
             // create a new snapshot
             string name = "New Snapshot";
             // take a snapshot at the current state
             virtualMachine.Snapshots.CreateSnapshot(name, "test snapshot");
             // power off
             virtualMachine.PowerOff();
             // find the newly created snapshot
             using (VMWareSnapshot snapshot = virtualMachine.Snapshots.GetNamedSnapshot(name))
             {
                 // revert to the new snapshot
                 snapshot.RevertToSnapshot();
                 // delete snapshot
                 snapshot.RemoveSnapshot();
             }
         }
     }
     #endregion
 }