Skip navigation
VMware
Up to Discussions in vSphere Web Services SDK

Developer: vSphere Web Services SDK

Develop management applications for VMware vSphereâ„¢
 

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
325 Views 7 Replies Last post: Mar 9, 2012 9:19 PM by Steve Jin RSS
tayky Novice 24 posts since
Feb 9, 2011
Currently Being Moderated

Dec 19, 2011 1:03 AM

Sample to retrieve vm IP address

Hi,

 

I would like to know if there any sample code to retrieve the ip address of the vms on vcenter?

Thanks in advance.

maishsk Expert 570 posts since
Jun 1, 2005
Currently Being Moderated
1. Dec 19, 2011 4:16 AM in response to: tayky
Re: Sample to retrieve vm IP address

Are you looking to use any specific language? PowerCLI perhaps?

 

Maish

rajatscybage Novice 6 posts since
Jan 2, 2012
Currently Being Moderated
3. Jan 6, 2012 1:26 AM in response to: tayky
Re: Sample to retrieve vm IP address

Hi,

 

Yes we can retrieve the IpAddress of a VM using

((Vim25Api.VirtualMachineSummary)(objVM)).guest.ipAddress but this API does not return IP Addresses of all the VM of a particular ESX

lamw Guru 5,959 posts since
Nov 27, 2007
Currently Being Moderated
4. Jan 6, 2012 8:17 AM in response to: rajatscybage
Re: Sample to retrieve vm IP address

The IP Address being returned from the guest is only available if they're running VMware Tools, it could alos be the case that it's installed but not running. That's how that property is being populated.

*Disclaimer: VMware Employee - William Lam | http://www.virtuallyghetto.com | http://blogs.vmware.com/vsphere/automation | @lamw
rajatscybage Novice 6 posts since
Jan 2, 2012
Currently Being Moderated
6. Mar 5, 2012 10:51 PM in response to: tayky
Re: Sample to retrieve vm IP address

Hi,

 

Can you please elaborate on what code exactly do u need. I have retrivied IP address using vpshere sdk only.

 

object objVM = svc.GetDynamicProperty(ocary[i].obj, "summary"); where svc is webservice object

((Vim25Api.VirtualMachineSummary)(objVM)).guest.ipAddress

Steve Jin Expert 542 posts since
Jun 4, 2007
Currently Being Moderated
7. Mar 9, 2012 9:19 PM in response to: rajatscybage
Re: Sample to retrieve vm IP address
Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org

Bookmarked By (0)

Communities