NAME

iControl - A Perl interface to the F5 iControl API

SYNOPSIS

        use iControl;

        my $ic = iControl->new(
                                server		=> 'bigip.company.com',
                                username	=> 'api_user',
                                password	=> 'my_password',
                                port		=> 443,
                                proto		=> 'https'
                        );

	my $virtual	= ($ic->get_vs_list())[0];

	my %stats	= $ic->get_vs_statistics_stringified($virtual);;

	print '*'x50,"\nVirtual: $virtual\n",'*'x50,"\nTimestamp: $stats{timestamp}\n";

	foreach my $s (sort keys %{$stats{stats}}) {
		print "$s\t$stats{stats}{$s}\n"
	}

DESCRIPTION

This package provides a Perl interface to the F5 iControl API.

The F5 iControl API is an open SOAP/XML for communicating with supported F5 BIGIP products.

The primary aim of this package is to provide a simplified interface to an already simple and intutive API and to allow the user to do more with less code. By reducing the API invocations to methods returning simple types, it is hoped that this module will provide a simple alternative for common tasks.

The secondary aim for this package is to provide a simple interface for accessing statistical data from the iControl API for monitoring, recording, archival and display in other systems. This objective has largely been obsoleted in v11 with the introduction of new statistical monitoring and display features in the web UI.

This package generally provides two methods for each each task; a raw method typically returning the response as received from iControl, and a "stringified" method returning a parsed response.

In general, the stringified methods will typically fufill most requirements and should usually be easier to use.

METHODS

new (%args)

my $ic = iControl->new(
			server		=> 'bigip.company.com',
			username	=> 'api_user',
			password	=> 'my_password',
			port		=> 443,
			proto		=> 'https'
		);

Constructor method. Creates a new iControl object representing a single interface into the iControl API of the target system.

Required parameters are:

server

The target F5 BIGIP device. The supplied value may be either an IP address, FQDN or resolvable hostname.

username

The username with which to connect to the iControl API.

password

The password with which to connect to the iControl API.

port

The port on which to connect to the iControl API.

proto

The protocol with to use for communications with the iControl API (should be either http or https).

get_system_information

Return a SystemInformation struct containing the identifying attributes of the operating system. The struct information is described below;

Member					Type		Description
----------				----------	----------
system_name				String		The name of the operating system implementation.
host_name				String		The host name of the system.
os_release				String		The release level of the operating system.
os_machine				String		The hardware platform CPU type.
os_version				String		The version string for the release of the operating system.
platform				String		The platform of the device.
product_category			String 		The product category of the device.
chassis_serial				String		The chassis serial number.
switch_board_serial			String 		The serial number of the switch board.
switch_board_part_revision		String 		The part revision number of the switch board.
host_board_serial			String 		The serial number of the host motherboard.
host_board_part_revision		String 		The part revision number of the host board.
annunciator_board_serial		String 		The serial number of the annuciator board.
annunciator_board_part_revision		String 		The part revision number of the annunciator board. 

get_cluster_list ()

Gets a list of the cluster names.

get_failover_mode ()

Gets the current fail-over mode that the device is running in.

get_failover_state ()

Gets the current fail-over state that the device is running in.

get_cluster_enabled_state ()

Gets the cluster enabled states.

save_configuration ($filename)

$ic->save_configuration('backup.ucs');

# is equivalent to

$ic->save_configuration('backup');

# Not specifying a filename will use today's date in the
# format YYYYMMDD as the filename.

$ic->save_configuration();

# is equivalent to

$ic->save_configuration('today');

Saves the current configurations on the target device.

This method takes a single optional parameter; the filename to which the configuration should be saved. The file extension .ucs will be suffixed to the filename if missing from the supplied filename.

Specifying no optional filename parameter or using the filename today will use the current date as the filename of the saved configuration file in the format YYYYMMDD.

get_interface_list ()

my @interfaces = $ic->get_interface_list();

Retuns an ordered list of all interfaces on the target device.

get_interface_statistics ($interface)

Returns all statistics for the specified interface as a InterfaceStatistics object. Unless you specifically require access to the raw object, consider using get_interface_statistics_stringified for a pre-parsed hash in an easy-to-digest format.

get_interface_statistics_stringified ($interface)

my $inet	= ($ic->get_interface_list())[0];
my %stats       = $ic->get_interface_statistics_stringified($inet);

print "Interface: $inet - Bytes in: $stats{stats}{STATISTIC_BYTES_IN} - Bytes out: STATISTIC_BYTES_OUT";

Returns all statistics for the specified interface as a hash having the following structure;

{
timestamp	=> 'YYYY-MM-DD-hh-mm-ss',
stats		=> 	{
			statistic_1	=> value
			...
			statistic_n	=> value
			}
}

Where the keys of the stats hash are the names of the statistic types defined in a InterfaceStatistics object. Refer to the official API documentation for the exact structure of the InterfaceStatistics object.

get_vs_list ()

my @virtuals	= $ic->get_vs_list();

Returns an array of all defined virtual servers.

get_vs_destination ($virtual_server)

my $destination	= $ic->get_vs_destination($vs);

Returns the destination of the specified virtual server in the form ipv4_address%route_domain:port.

get_vs_enabled_state ($virtual_server)

print "Virtual server $vs is in state ",$ic->get_vs_enabled_state($vs),"\n";

Return the enabled state of the specified virtual virtual server.

get_vs_all_statistics ()

Returns the traffic statistics for all configured virtual servers. The statistics are returned as VirtualServerStatistics struct hence this method is useful where access to raw statistical data is required.

For parsed statistic data, see get_vs_statistics_stringified.

For specific information regarding data and units of measurement for statistics methods, please see the Notes section.

get_vs_statistics ($virtual_server)

my $statistics = $ic->get_vs_statistics($vs);

Returns all statistics for the specified virtual server as a VirtualServerStatistics object. Consider using get_vs_statistics_stringified for accessing virtual server statistics in a pre-parsed hash structure.

For specific information regarding data and units of measurement for statistics methods, please see the Notes section.

get_vs_statistics_stringified ($virtual_server)

my $statistics = $ic->get_vs_statistics_stringified($vs);

foreach (sort keys %{$stats{stats}}) {
	print "$_: $stats{stats}{$_}\n";
}

Returns all statistics for the specified virtual server as a multidimensional hash (hash of hashes). The hash has the following structure:

{
	timestamp	=> 'yyyy-mm-dd-hh-mm-ss',
	stats		=> {
				statistic_1	=> value,
				statistic_2	=> value,
				...
				statistic_n	=> value
			}
}

This function accepts a single parameter; the virtual server for which the statistics are to be returned.

For specific information regarding data and units of measurement for statistics methods, please see the Notes section.

get_default_pool_name ($virtual_server)

print "Virtual Server: $virtual_server\nDefault Pool: ", 
	$ic->get_default_pool_name($virtual_server), "\n";

Returns the default pool names for the specified virtual server.

get_pool_list ()

print join " ", ($ic->get_pool_list());

Returns a list of all pools in the target system.

get_pool_members ($pool)

foreach my $pool ($ic->get_pool_list()) {
	print "\n\n$pool:\n";

	foreach my $member ($ic->get_pool_members($pool)) {
		print "\t$member\n";
	}
}

Returns a list of the pool members for the specified pool. This method takes one mandatory parameter; the name of the pool.

Pool member are returned in the format IP_address:service_port.

get_pool_statistics ($pool)

my %stats = $ic->get_pool_statistics($pool);

Returns the statistics for the specified pool as a PoolStatistics object. For pre-parsed pool statistics consider using the get_pool_statistics_stringified method.

get_pool_statistics_stringified ($pool)

my %stats = $ic->get_pool_statistics_stringified($pool);
print "Pool $pool bytes in: $stats{stat}{STATISTIC_SERVER_SIDE_BYTES_OUT}";

Returns a hash containing all pool statistics for the specified pool in a delicious, easily digestable and improved formula.

get_pool_member_statistics ($pool)

Returns all pool member statistics for the specified pool as an array of MemberStatistics objects. Unless you feel like playing with Data::Dumper on a rainy Sunday afternoon, consider using get_pool_member_statistics_stringified method.

get_pool_member_statistics_stringified ($pool)

my %stats = $ic->get_pool_member_statistics_stringified($pool);

print "Member\t\t\t\tRequests\n",'-'x5,"\t\t\t\t",'-'x5,"\n";

foreach my $member (sort keys %stats) {
	print "$member\t\t$stats{$member}{stats}{STATISTIC_TOTAL_REQUESTS}\n";
}

# Prints a list of requests per pool member

Returns a hash containing all pool member statistics for the specified pool. The hash has the following structure;

member_1 => 	{
		timestamp	=> 'YYYY-MM-DD-hh-mm-ss',
		stats		=>	{
					statistics_1	=> value
					...
					statistic_n	=> value
					}
		}
member_2 =>	{
		...
		}
member_n =>	{
		...
		}

Each pool member is specified in the form ipv4_address%route_domain:port.

get_all_pool_member_statistics ($pool)

Returns all pool member statistics for the specified pool. This method is analogous to the get_pool_member_statistics() method and the two will likely be merged in a future release.

get_node_list ()

print join "\n", ($ic->get_node_list());

Returns a list of all configured nodes in the target system.

Nodes are returned as ipv4 addresses.

get_screen_name ($node)

foreach ($ic->get_node_list()) {
	print "Node: $_ (" . $ic->get_screen_name($_) . ")\n";
}

Retuns the screen name of the specified node.

get_node_status ($node)

$ic->get_node_status(

Returns the status of the specified node as a StatusObject struct.

For formatted node status information, see the get_node_status_as_string() method.

get_node_availability_status ($node)

Retuns the availability status of the node.

get_node_enabled_status ($node)

Retuns the enabled status of the node.

get_node_status_description ($node)

Returns a descriptive status of the specified node.

get_node_status_as_string ($node)

Returns the node status as a descriptive string.

get_node_monitor_status ($node)

Gets the current availability status of the specified node addresses.

get_node_statistics ($node)

Returns all statistics for the specified node.

get_node_statistics_stringified

my %stats = $ltm->get_node_statistics_stringified($node);

foreach (sort keys %{stats{stats}}) {
	print "$_:\t$stats{stats}{$_}{high}\t$stats{stats}{$_}{low}\n";
}

Returns a multidimensional hash containing all current statistics for the specified node. The hash has the following structure:

{
	timestamp	=> 'yyyy-mm-dd-hh-mm-ss',
	stats		=> {
				statistic_1	=> value,
				statistic_2	=> value,
				...
				statistic_n	=> value
			}
}

This function accepts a single parameter; the node for which the statistics are to be returned.

For specific information regarding data and units of measurement for statistics methods, please see the Notes section.

get_event_subscription

Returns all registered event subscriptions.

get_subscription_list

This method is an analog of get_event_subscription

create_subscription_list (%args)

my $subscription = $ic->create_subscription_list (
                                        name                            => 'my_subscription_name',
                                        url                             => 'http://company.com/my/eventnotification/endpoint,
                                        username                        => 'username',
                                        password                        => 'password',
                                        ttl                             => -1,
                                        min_events_per_timeslice        => 10,
                                        max_timeslice                   => 10
                                );   

Creates an event subscription with the target system. This method requires the following parameters:

name

A user-friendly name for the subscription.

url

The target URL endpoint for the event notification interface to send event notifications.

username

The basic authentication username required to access the URL endpoint.

password

The basic authentication password required to access the URL endpoint.

ttl

The time to live (in seconds) for this subscription. After the ttl is reached, the subscription will be removed from the system. A value of -1 indicates an infinite life time.

min_events_per_timeslice

The minimum number of events needed to trigger a notification. If this value is 50, then this means that when 50 events are queued up they will be sent to the notification endpoint no matter what the max_timeslice is set to.

max_timeslice

This maximum time to wait (in seconds) before event notifications are sent to the notification endpoint. If this value is 30, then after 30 seconds a notification will be sent with the events in the subscription queue.

NOTES

Statistic Methods

Within iControl, statistical values are a 64-bit unsigned integer represented as a Common::ULong64 object. The ULong64 object is a stuct of two 32-bit values. This representation is used as there is no native support for the encoding of 64-bit numbers in SOAP.

The ULong object has the following structure;

({
	STATISTIC_NAME	=> {
			high	=> long
			low	=> long
		}
}, bless Common::ULong64)

Where high is the unsigned 32-bit integer value of the high-order portion of the measured value and low is the unsigned 32-bit integer value of the low-order portion of the measured value.

In non-stringified statistic methods, these return values are ULong64 objects as returned by the iControl API. In stringified statistic method calls, the values are processed on the client side into a local 64-bit representation of the value using the following form.

$value = ($high<<32)|$low;

Stringified method calls are guaranteed to return a correct localised 64-bit representation of the value.

It is the callers responsibility to convert the ULong struct for all other non-stringified statistic method calls.

AUTHOR

Luke Poskitt, <ltp@cpan.org>

LICENSE AND COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.