lamw
Community Manager
Community Manager

You can get the vCenter instance name by using that advanced key VirtualCenter.InstanceName as you mentioned, but this is not guaranteed to match the actual hostname of your vCenter.

If I understand you correctly and you're using vSphere SDK for Perl and you're already connected to vCenter server since you're querying for the advanced VPX configurations, you can actually get the IP or Hostname by doing the following:

my $server = Opts::get_option('server');

VMware has already created a few modules that helps creating new vSphere SDK for Perl scripts and handles most of the authentication and by default you can access the username, password and server among other variables. So if you're already connecting to vCenter using IP or FQDN, you can just extract that variable out. Now if you want the full FQDN and you're connecting via IP, then just use Perl to do a reverse lookup, assuming DNS is fully functional in your environment as it should be.

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

William Lam

VMware vExpert 2009,2010

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

Reply
0 Kudos