VMware {code} Community
Umby
VMware Employee
VMware Employee

Determining Primary Host vs. Shadow Host in FT VM

Hello All,

I am trying to determine what the name of my primary host (vs. my shadow or secondary host) is during Fault Tolerant operations from within an FT Ubuntu VM using the Perl SDK. Here is what I am running right now:

#!/usr/bin/perl -w

use strict;

use warnings;

use VMware::VIRuntime;

use VMware::VILib;

my %opts = (

vmname => {

type => "=s",

help => "Name of VM to locate",

required => 1,

},

);

Opts::add_options(%opts);

Opts::parse();

Opts::validate();

Util::connect();

  1. Obtain all inventory objects for the VM

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

my $entity_views = Vim::find_entity_views(

view_type => 'VirtualMachine', filter => {

'config.name' => $vmname });

  1. Process the findings and output to the console

foreach my $entity_view (@$entity_views) {

my $entity_name = $entity_view->name;

my $entity_host = $entity_view->runtime->host;

my $vmhostname = Vim::get_view(mo_ref => $entity_host)->name;

Util::trace(0, "$entity_name is running on $vmhostname\n");

}

  1. Disconnect from the server

Util::disconnect();

The problem is, it returns two host hames, the primary and the secondary, but it does not define which is which. Are there additional parameters I can work with using the Perl SDK for the FT Ubuntu VM? Thanks for any help.

Reply
0 Kudos
4 Replies
lamw
Community Manager
Community Manager

Yes, you'll want to look at the FaultToleranceConfigInfo role value which is set to either 0 or 1

1 = Primary

0 = Secondary

This information along with details about your vSphere infrastructure is captured in this vSphere Health Check Script - if you're interested in capturing other details

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

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

Reply
0 Kudos
Umby
VMware Employee
VMware Employee

Thanks William,

Will this work for a Linux VM (Ubuntu) or just Windows VM's?

Reply
0 Kudos
lamw
Community Manager
Community Manager

umby,

It does not matter, this is a VMware property within the vSphere API with regards to VM's that are configured for Fault Tolerance. The OS has nothing to do with this value, if you're able to successfully enable FT on a VM, you will have a primary and secondary VM MoRef. When querying for a given FT VM, you'll get back 2 entries as you've noted. To distinguish between the two, you'll look at the FT property role to figure out whether it's the primary or secondary VM

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

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

Reply
0 Kudos
Umby
VMware Employee
VMware Employee

Thank you William!

Reply
0 Kudos