GuestProcessManager c#

Hi, I tried WebService SDK 5.1.0 but it did not work.

The code is below.   I think GuestProcessManager TYPE and its VALUE is false.

I don't know the TYPE and the VALUE of character string in any resource.

(The string in the code below is copied from JAVA code).

In JAVA, the CLASS of GuestProcessManager exists, but in c#, I wouldn't find out who.

Please teach me the TYPE and the STRING of characters or any other cause.

public void displayNewProperties() {}
_Service = ecb.getServiceConnectionV25 (). Service;
_Sic = ecb.getServiceConnectionV25 (). ServiceContent;
String vmName = ecb.get_option ("vmname");
ManagedObjectReference vmmor = ecb.getServiceUtilV25 (). GetDecendentMoRef (null,
'VirtualMachine', vmName);

If (_sic.guestOperationsManager! = null & & vmmor.type == 'VirtualMachine')
{

Nicolas NamePasswordAuthentication = new NamePasswordAuthentication();
nAuth.username = "ad\\administrator";
nAuth.password = "passwordxxxxx;
nAuth.interactiveSession = false;

ManagedObjectReference prRef = new ManagedObjectReference();
prRef.type = "GuestProcessManager";
prRef.Value = "guestOperationsProcessManager";

[long] PID is new long [] {};.

GuestProcessInfo [] intervals
= ecb.getServiceConnectionV25 ._service (). ListProcessesInGuest (prRef, vmmor, Nicolas, null);

{foreach (GuestProcessInfo gpi intermittently)
Console.WriteLine (gpi.owner.ToString () + ',' + gpi.pid.ToString () + ', ' + gpi.cmdLine.ToString ());
}


}
If (vmmor! = null)
{
ArrayList supportedVersions = VersionUtil.getSupportedVersions (ecb.get_option ('url'));

Object [] vmProps is getProperties (vmmor, new String() {"name"});.
String serverName = (String) vmProps [0];
Console.WriteLine ("Name VM" + serverName);

vmProps = getProperties (vmmor, new String() {"config.uuid"});
String uuid = (String) vmProps [0];
Console::WriteLine ("Config UUID" uuid);

vmProps = getProperties (vmmor, new String() {"config.guestId"});
String ID = (String) vmProps [0];
Console.WriteLine ("Comments Id" + ID);

If (VersionUtil.isApiVersionSupported (supportedVersions, "2.5"))
{
vmProps = getProperties (vmmor, new String() {"name"});

Boolean BootOptionsSupported = (Boolean) getObjectProperty (vmmor, "capability.bootOptionsSupported");
Console.WriteLine ("Boot Options supported" + bootOptionsSupported);

Boolean DiskSharesSupported = (Boolean) getObjectProperty (vmmor, "capability.diskSharesSupported");
Console.WriteLine ("Disk actions Supported" + diskSharesSupported);

Boolean flag = VersionUtil.isApiVersionSupported (supportedVersions, "4.0");
Console.WriteLine ("API is supported" + flag);
If (flag)
{
Console.WriteLine ("\nProperties added in vSphere API 4.0\n");
Boolean ChangeTrackingSupported = (Boolean) getObjectProperty (vmmor, "capability.changeTrackingSupported");
Console.WriteLine ("Change of track taken in charge" + changeTrackingSupported);

Boolean RecordReplaySupported = (Boolean) getObjectProperty (vmmor, "capability.recordReplaySupported");
Console.WriteLine ("Record Replay Supported" + recordReplaySupported);

VirtualMachineFaultToleranceState faultToleranceState
= (VirtualMachineFaultToleranceState) getObjectProperty (vmmor, "runtime.faultToleranceState");
Console.WriteLine ("State of fault tolerance" + faultToleranceState);
}
}
}
on the other
{
Console.WriteLine ("Virtal Machine not found");
}
}

Here's the result message.

[2013/06/05 16:29:51] Start the journal.
Has begun
There are one or more problems with the server certificate:

* A chain processed correctly, but terminated by a certificate certification root
e that is not approved by the trust provider.

* The certificate CN name does not match the passed value.


Failed: The object has already been disposed or was not completely created

Press ENTER to exit.

Hello.

I got this moref as:

ManagedObjectReference _guestOpManger = _ecb.getServiceConnectionV25 (). ServiceContent.guestOperationsManager;

ManagedObjectReference _processManagerRef = (ManagedObjectReference) _ecb.getServiceUtilV25 (). GetDynamicProperty (_guestOpManger, "processManager");

Best regards

Alexey Barabash

Tags: VMware

Similar Questions

  • Run a command in a running virtual machine

    Is it possible to java using the vim.jar command in a virtual machine running?

    Thank you.

    Hi casolorz,

    He has since vSphere 5.0 API managed object GuestOperationsManager , which currently provides three categories of manager API, each represented by its own managed object.

    You want to take a look at the GuestProcessManager of managed objects. You will find the StartProgramInGuest method that should meet your requirement.

    Hope this is what you are looking for.

  • ListProcessesInGuest & StartProgramInGuest

    I'm trying retrieve a list of a Windows host process and also to start a program in the comments using c#. I used the example of Java code in "RunProgram.java" in the SDK samples as a guide.

    The first problem was a reference to the GuestProcessManager. The reference of vSphere API online says:

    Managed object Property of
    GuestProcessManagerGuestOperationsManager
    GuestOperationsManagerServiceContent

    However when I go to my host CROWD ESXi 4.1 the ServiceInstance does not contain a GuestOperationsManager. Given that I had access to the GuestOperationsManager through the VimService object I get a MOR GuestOperationsManager, but is quickly rendered account that I can't really access the properties of the children of a MOR, I can recover only its type and its value and perhaps pass as a parameter in a method call.

    Java sample helped here since she owned the following lines, that I picked up and used in my code as well:

    ManagedObjectReference processManagerRef = new ManagedObjectReference();
             processManagerRef.setType("GuestProcessManager");
             processManagerRef.setValue("ha-guest-operations-process-manager");
    

    So my first problem is this: If we get a MOR to an object that does not appear in the CROWD at the location specified by the API reference, how can we find it? I was lucky to have the sample using the same MOR but if it wasn't then what?

    So now my code for the process in the list in the prompt looks like this (c#):

    public void GetGuestProcesses()
            {
                //ManagedObjectReference guestOpsMgr = _host.ServiceContent.guestOperationsManager;
                
                ManagedObjectReference processMgr = new ManagedObjectReference();
                processMgr.type = "GuestProcessManager";
                processMgr.Value = "ha-guest-operations-process-manager";
                
    
                NamePasswordAuthentication auth = new NamePasswordAuthentication();
                auth.username = "xyz";
                auth.password = "abc";
                auth.interactiveSession = true;
    
                GuestProcessInfo[] processes;
                long[] pids = new long[] { };
                try
                {
                    
                    processes = _host.VimService.ListProcessesInGuest(processMgr, _MOR, auth, pids);
                    Debug.WriteLine(processes.Length);
                }
                catch (System.Web.Services.Protocols.SoapException se)
                {
                    Debug.WriteLine(se.Message);
                    Debug.WriteLine(se.Detail.FirstChild.LocalName);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
    

    Authentication for the guest was also something that I took the example of "RunProgram.java." When I run this code block my error message is:

    An exception of first chance of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll
    type
    InvalidRequestFault

    To test the starting a program in the Windows prompt my code is as follows:

    public void StartInGuest()
            {
                ManagedObjectReference processMgr = new ManagedObjectReference();
                processMgr.type = "GuestProcessManager";
                processMgr.Value = "ha-guest-operations-process-manager";
                NamePasswordAuthentication auth = new NamePasswordAuthentication();
                auth.username = "xyz";
                auth.password = "abc";
                auth.interactiveSession = true;
                GuestProgramSpec progSpec = new GuestProgramSpec();
                progSpec.programPath = "C:\\WINDOWS\\NOTEPAD.EXE";
                progSpec.arguments = "";
    
                
                try
                {
                    long pid = _host.VimService.StartProgramInGuest(processMgr, _MOR, auth, progSpec);
                    
                }
                catch (System.Web.Services.Protocols.SoapException se)
                {
                    Debug.WriteLine(se.Message);
                    Debug.WriteLine(se.Detail.FirstChild.LocalName);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
    

    My error is the same:

    An exception of first chance of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll
    type
    InvalidRequestFault

    I make sure the case of the path of the program string is the same as what the host uses. In both cases, so holds the MOR on the virtual target computer.

    I looked up InvalidRequest reference API under Types of error that says:

    An error of InvalidRequest is launched in response to a query malformed to the server which fails in the transport layer, for example, the XML SOAP request was invalid. Subtypes of this flaw, provides errors of specific transport, such as the use of a reference to a method or an unknown managed object type.

    So could this happen because my MOR to the GuestProcessManager was incorrect? Or the authentication code is incorrect? Both were taken to the Java example and seemed to make sense to me. I even read on NamedPasswordAuthentication and he said that it could be used for any call management comments.

    What could be wrong?

    The guestOperations is a new feature in vSphere 5 (http://www.virtuallyghetto.com/2011/07/automating-new-integrated-vixguest.html), if you are using vSphere 4.1, you will not have access to the managed object.

    As you can see on vSphere 5 QAnywhere - http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.apiref.doc_50/vim.ServiceInstanceContent.html

    guestOps MO was added in 5.0

Maybe you are looking for