VMware {code} Community
kbr5678
Contributor
Contributor

Cluster Affinity rule spec.....

Hi..

how to get cluster affinity rule spec prorperties using VI SDK

0 Kudos
2 Replies
oreeh
Immortal
Immortal

FYI: this thread has been moved to the Management APIs (VI Perl, VI SDK, CIM SDK) forum.

Oliver Reeh[/i]

[VMware Communities User Moderator|http://communities.vmware.com/docs/DOC-2444][/i]

0 Kudos
lamw
Community Manager
Community Manager

Using the Cluster View you can get the affinity information by the following:

my $rules = $local_cluster->configurationEx->rule;
if($rules) {
	foreach (@$rules) {
		my $rule = $_;
        my $is_enabled = $rule->enabled;
        my $rule_name = $rule->name;
		my $rule_type;
		if(ref($rule) eq 'ClusterAffinityRuleSpec') {
			$rule_type = "AFFINITY";
		}
		elsif (ref($rule) eq 'ClusterAntiAffinityRuleSpec') {
			$rule_type = "ANTI-AFFINITY";
		}
			print $rule_name,"\n",$rule_type,"\n",($is_enabled) ? "YES" : "NO","\n";
        }
        print REPORT_OUTPUT "</table>\n";
}

This is a snippet of a VMware Health Check script that I wrote that extracts information about your vCenter, ESX/ESXi hosts and VM(s): http://communities.vmware.com/docs/DOC-9420

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

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

0 Kudos