ZXTM Control API Overview and Reference
Version 4.0
method tries to add a node to a pool that did not exist, a SOAP fault
will be raised. Perl's on_fault handler will be called if this happens.
The example illustrates Perl's hash slice technique to quickly build an
associative array, mapping pool name to a list of nodes:
my $res = $conn >getPoolNames();
my @names = @{$res >result};
$res = $conn >getNodes( \@names );
my %nodes;
@nodes{@names} = @{$res >result};
This is a very easy way to take advantage of the fact that the ZXTM
Control API methods are all bulk enabled, i.e., they are designed to
process lists of objects efficiently.
The listVS example could also use a hash slice, as follows:
my $res = $conn >getVirtualServerNames();
my @names = @{$res >result};
$res = $conn >getEnabled( \@names );
my %enabled;
@enabled{@names} = @{$res >result};
A ZXTM Control API application could update the configuration by
modifying the hash:
# Turn everything off...
foreach my $name( keys %enabled ) {
$enabled{ $name } = 0;
}
It could then bulk commit the new configuration with a single method
call:
$res = $conn >setEnabled(
[ keys %enabled ], [ values %enabled ] );
38
New Page 1