Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 176561

Get VirtualMachine for Reboot using Vim

$
0
0

I'm working with VMware.Vim library in C# and am having a bit of trouble intermittently when using the VirtualMachine.Reboot functionality.  It seems that when I call for a vm with VimClient.FindEntityView()  at times that vm will have a vm.Guest.ToolsStatus != VirtualMachineToolsStatus.toolsOk.  If I attempt to reboot the vm by calling Reboot off of the VirtualMachine object when its in this state, I get the error listed below.

 

VMware.Vim.VimException: Cannot complete operation because VMware Tools is not running in this virtual machine.

 

In some cases, for some guests i can just reload the VM from an additional call to FindEntityView.  But not for all, in all cases the tools are running, the vm is on and working - I can verify this via https://vc.example.com/mob/?moid=vm-12345&doPath=guest

 

It almost seems like its getting some cached version of the VM or that I should be calling something else before checking the tools status.  Is there a property that i should be passing to the FindEntityView?  Something to tell it to load the correct tools status?

 

Here's how i'm loading it.

 

        private VirtualMachine GetVirtualMachine(Guid vmUuid, VimClient client)

        {

            //ServiceContent content = client.Connect(VMWareConfiguration.Settings.vCenterServerUrl);

            UserSession userSession = client.Login(VMWareConfiguration.Settings.vCenterServerUrl, VMWareConfiguration.Settings.Username, VMWareConfiguration.Settings.Password);

            NameValueCollection filter = new NameValueCollection();

            filter.Add("config.uuid", vmUuid.ToString());

 

 

            var virtualMachine = (VirtualMachine)client.FindEntityView(typeof(VirtualMachine), null, filter, null);

            return virtualMachine;

        }

 

Any help would be greatly appreciated!

 

Scott


Viewing all articles
Browse latest Browse all 176561

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>