VMware {code} Community
login007
Contributor
Contributor

Help me! How to login GuestOS using vSphere Web Services SDK?

Hi, guys. I'm a newer to vSphere Web Services SDK. I want to control vms through vCenter .

Now, I can power on a vm using PowerOnVM_Task(...) api, but I don't konw how to login the guestOS with password .Could anyone guide me how to do it ? Thanks in advance.

Tags (2)
0 Kudos
11 Replies
lamw
Community Manager
Community Manager

The vSphere API is primarily used to manage your virtual infrastructure (hosts/VMs/etc), it's not meant to manage the actual guestOS themselves or have any capabilities to login to the guest to perform operations.

Depending on what you're trying to accomplish, other APIs maybe more suitable for your task. VMware does have an API to perform some guest specific operations including running programs/scripts within the guestOS through VMware Tools, take a look at VMware VIX

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
login007
Contributor
Contributor

You do me a great favor. Thank you very much .

0 Kudos
nikhilxp64
Enthusiast
Enthusiast

So there is absolutely no way I can work with the guest via ListProcessesInGuest and StartProgramInGuest without using VIX? Because when my Guest is at the Login screen (Win XP) those methods don't work but as soon as I login on the guest they operate fine. There is no web service SDK method to do a login?

0 Kudos
stumpr
Virtuoso
Virtuoso

If using vSphere 5, the VIX functionality was moved into the core SDK.  So that is an option for vSphere 5 environments.

In terms of VIX and running programs without an active interactive session in the Guest...I've used the VIX on several projects to execute programs in the GuestOS without first logging into the OS.  I haven't validated this with the vSphere 5 API additions.

Is that the environment you're using?  vSphere 5.0 API GuestOperations against WindowsXP?  I may validate it if I get some time tonight.

Reuben Stump | http://www.virtuin.com | @ReubenStump
0 Kudos
nikhilxp64
Enthusiast
Enthusiast

Hi,

I am using a vSphere 5 host with primarily Windows XP and Ubuntu Guests and I am programming against the web services API. I did not find a mention of LoginInGuest in the vSphere API reference. Or were you saying there is an equivalent method?

0 Kudos
stumpr
Virtuoso
Virtuoso

Yes, look at GuestAuthManager in the vSphere 5.0 API Reference.  You'll probably want to use NamePasswordAuthentication as the requestedAuth parameter.  I usually set interactiveSession to false.

You'll get a GuestAuthentication object as a return from AcquireCredentialsInGuest.

Then you'll use that GuestAuthentication object as your auth parameter for StartProgramInGuest.

I haven't validated this personally, but it should work.  I've done this pattern before through the standard VIX libraries on several projects.

Reuben Stump | http://www.virtuin.com | @ReubenStump
0 Kudos
nikhilxp64
Enthusiast
Enthusiast

All I did was set interactiveSession to false in my NamedPasswordAuthentication as per your suggestion and it worked without having to first login to the guest OS! Thanks! Smiley Happy

Now what is the explanation for this? How does the interactive session make a difference to the way the StartProgramInGuest method works?

0 Kudos
stumpr
Virtuoso
Virtuoso

interactiveSession will not create a new session to interact with.  The assumption is you want to interact with an existing, open environment.

When you set interactiveSession = false, you're running your Program with the specified credentials as a new background process.

If you need a desktop application to open for the existing user, you would use interactiveSession = true but you'll need an existing desktop session to call your program.

I think that's what you're looking for clarification on, right?

Reuben Stump | http://www.virtuin.com | @ReubenStump
0 Kudos
lamw
Community Manager
Community Manager

Just to clarify, you do need to have "valid" guest credentials to perform any operation using VIX API whether it's the standalone or intergrated within vSphere. You're right that it does not need to be an interactive session, but the credentials are needed to perform the operation assuming the account you're using has the proper permission. I think you already knew that but I just wanted to make sure that was the case

0 Kudos
nikhilxp64
Enthusiast
Enthusiast

Yup that explains what interactive session does. Thank you!

0 Kudos
ToolsDev
Contributor
Contributor

If you're coding in .Net, this is excellent:

http://vmwaretasks.codeplex.com/

0 Kudos