Hi..
how to get cluster affinity rule spec prorperties using VI SDK
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