VMware {code} Community
netlib
Enthusiast
Enthusiast
Jump to solution

Which server to connect to with Web Services SDK?

Is there a way to know which server to connect to when using Web Services SDK? I assumed it needs to be the ESX server that the VM is on. But a customer claims that we are connecting to his vCenter Server, which I did not think was possible. I tried calling one of the sample SDKs and connecting to my vCenter server but it could not connect. I had to connect to my ESX or vSphere server.

We both are using vSphere 4.0

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

The vSphere APIs are exposed on both ESX(i) and vCenter, certain things will only be available on one or the other, for example, cloning is a feature of vCenter and there will be APIs that are only available when connecting to vCenter. Depending on what you're trying to perform, you may be able to get the information using both systems, such as searching for a VM. If you only manage one host, it's pretty trivial but if you manage more than 20+ hosts and you have vCenter, then you probably want to use vCenter.

I don't think you clearly understand how the vSphere APIs work and what is worrisome is you're having your clients run an unknown script in which they nor you understand. I believe I've responding to some of your questions in the past, to re-iterate if you're new to the VMware API/SDKs, I would recommend you thoroughly go through the following document -

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

William Lam

VMware vExpert 2009,2010

VMware VCP3,4

VMware VCAP4-DCA

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

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".

View solution in original post

0 Kudos
6 Replies
lamw
Community Manager
Community Manager
Jump to solution

The vSphere APIs are exposed on both ESX(i) and vCenter, certain things will only be available on one or the other, for example, cloning is a feature of vCenter and there will be APIs that are only available when connecting to vCenter. Depending on what you're trying to perform, you may be able to get the information using both systems, such as searching for a VM. If you only manage one host, it's pretty trivial but if you manage more than 20+ hosts and you have vCenter, then you probably want to use vCenter.

I don't think you clearly understand how the vSphere APIs work and what is worrisome is you're having your clients run an unknown script in which they nor you understand. I believe I've responding to some of your questions in the past, to re-iterate if you're new to the VMware API/SDKs, I would recommend you thoroughly go through the following document -

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

William Lam

VMware vExpert 2009,2010

VMware VCP3,4

VMware VCAP4-DCA

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

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
netlib
Enthusiast
Enthusiast
Jump to solution

They will be limited to query-only APIs.

We were able to do it by connecting to the vCenter server. The

question is, why did it fail to connect to the ESX server the VM is

on?

Do they need to do something special to install the API server on the ESX box?

My inhouse test is the exact opposite: I can run the APIs by

connecting to the ESX box but not to vCenter.

Thanks.

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

It might be helpful to provide some details on the script you're trying to run, perhaps even the source. There are no special setup that you need to have, as long as the system that is running the script has access to the management network that your vCenter OR ESX(i) host and you have the correct permissions, you'll be able to access the system. It sounds like the permissions used to connect to your ESX(i) host may be incorrect, again this is a guess because you're being too generic with your statements.

Please provide the exact error you're getting when trying to connect to your ESX(i) host, are you getting connection denied or permission denied? The more details you can provide, the easier someone can help.

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

William Lam

VMware vExpert 2009,2010

VMware VCP3,4

VMware VCAP4-DCA

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

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
netlib
Enthusiast
Enthusiast
Jump to solution

Basically just adapting the GetVirtualDiskFiles and GetVMInfo C-Sharp samples from the SDK.

Ok, I see I was using the wrong credentials. On the vCenter server I added apitest as a Windows login and then added it to the ReadOnly role in vCenter. Now I can make the query to the vCenter server or the ESX server. I'm assuming that vCenter permissions do not propagate down to the ESX machines?

0 Kudos
netlib
Enthusiast
Enthusiast
Jump to solution

I notice that in vCenter there is not an Add User feature like there is in vSphere. I assume I have to add a Windows User first?

0 Kudos
yanivamrami
Enthusiast
Enthusiast
Jump to solution

Hi,

I guess this is what you are looking for:

System.out.println(siContent.getAbout().getFullName());

System.out.println("Server type is " + siContent.getAbout().getApiType());

System.out.println("API version is " + siContent.getAbout().getApiVersion());

in Java, but easily can be tranformed to c#. the siContent is actually the ServiceContent.

To get the full code, check out , page 27.

Yaniv

Please rate helpful / correct answers. Thank you

Please rate helpful / correct answers. Thank you
0 Kudos