BigIP-iControl
view release on metacpan or search on metacpan
lib/BigIP/iControl.pm view on Meta::CPAN
=head3 is_redundant ()
Returns a boolean indicating the redundancy state of the device.
=cut
sub is_redundant {
return $_[0]->_request(module => 'System', interface => 'Failover', method => 'is_redundant');
}
=head3 get_cluster_enabled_state ()
Gets the cluster enabled states.
=cut
sub get_cluster_enabled_state {
return $_[0]->_request(module => 'System', interface => 'Cluster', method => 'get_cluster_enabled_state');
}
=head3 get_service_list ()
Returns a list of all supported services on this host.
=cut
sub get_service_list {
return @{$_[0]->_request(module => 'System', interface => 'Services', method => 'get_list')}
}
=head3 get_service_status ()
Returns the status of the specified service.
=cut
sub get_service_status {
my($self,$service)= shift;
return $self->_request(module => 'System', interface => 'Services', method => 'get_service_status', data => { services => $service });
}
=head3 get_all_service_statuses ()
Returns the status of all services.
=cut
sub get_all_service_statuses {
my $self = shift;
my %res;
foreach my $service (@{$self->_request(module => 'System', interface => 'Services', method => 'get_all_service_statuses')}) {
$res{$service->{service}} = $service->{status}
}
return %res
}
=head3 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 B<.ucs> will be suffixed to the filename if missing from the supplied filename.
Specifying no optional filename parameter or using the filename B<today> will use the current date as the filename
of the saved configuration file in the format B<YYYYMMDD>.
=cut
sub __save_configuration {
my ($self,$filename,$flag) = @_;
if (($filename eq 'today') or ($filename eq '')) {
$filename = __get_timestamp();
}
$flag or $flag = 'SAVE_FULL';
$self->_request(module => 'System', interface => 'ConfigSync', method => 'save_configuration', data => { filename => $filename, save_flag => $flag});
return 1
}
sub save_configuration {
my ($self,$filename) = @_;
return ($self->__save_configuration($filename,'SAVE_FULL'));
}
=head3 save_base_configuration ()
$ic->save_base_configuration();
Saves only the base configuration (VLANs, self IPs...). The filename specified when used with this mode will
be ignored, since configuration will be saved to /config/bigip_base.conf by default.
=cut
sub save_base_configuration {
return ($_[0]->__save_configuration('ignore','SAVE_BASE_LEVEL_CONFIG'))
}
=head3 save_high_level_configuration ()
$ic->save_high_level_configuration();
Saves only the high-level configuration (virtual servers, pools, members, monitors...). The filename specified
when used with this mode will be ignored, since configuration will be saved to /config/bigip.conf by default.
lib/BigIP/iControl.pm view on Meta::CPAN
Where B<Day> is the three-letter common abbreviation of the day name, B<Mon> is the three letter common
abbreviation of the month name and B<D> has the value range 1-31 with no leading zeros.
=cut
sub get_configuration_list {
my $self = shift;
my %res;
foreach (@{$self->_request(module => 'System', interface => 'ConfigSync', method => 'get_configuration_list')}) {
$res{$_->{file_name}} = $_->{file_datetime}
}
return %res;
}
=head3 delete_configuration ()
$ic->delete_configuration('file.ucs');
Deletes the specified configuration archive from the system.
=cut
sub delete_configuration {
my ($self,$filename) = @_;
$filename or croak 'No filename specified';
return $self->_request(module => 'System', interface => 'ConfigSync', method => 'delete_configuration', data => { filename => $filename });
}
sub _download_file {
my ($self,$config_name,$local_file) = @_;
my $chunk = 65536;
my $offset = 0;
my $data;
$config_name or croak 'No configuration file specified';
open my $fh, '+>', $local_file or croak "Unable to open local file: $local_file";
binmode($fh);
while (1) {
$data = $self->_request(module => 'System', interface => 'ConfigSync', method => 'download_configuration', data => {config_name => $config_name, chunk_size => $chunk, file_offset => $offset});
print $fh $data->{file_data};
last if (($data->{chain_type} eq 'FILE_LAST') or ($data->{chain_type} eq 'FILE_FIRST_AND_LAST'));
$offset+=(length($data->{file_data}));
}
close $fh;
return 1
}
=head3 download_file ( $FILE )
# Print the bigip.conf file to the terminal
print $ic->download_file('/config/bigip.conf');
This method provides direct access to files on the target system. The method returns a scalar containing
the contents of the file.
This method may be useful for downloading configuration files for versioning or backups.
=cut
sub download_file {
my ($self,$file_name) = @_;
my $chunk = 65536;
my $offset = 0;
my ($data, $output);
$file_name or croak 'No file name specified';
while (1) {
$data = $self->_request(module => 'System', interface => 'ConfigSync', method => 'download_file', data => {file_name => $file_name, chunk_size => $chunk, file_offset => $offset});
$output .=$data->{file_data};
last if (($data->{chain_type} eq 'FILE_LAST') or ($data->{chain_type} eq 'FILE_FIRST_AND_LAST'));
$offset+=(length($data->{file_data}));
}
return $output
}
=head3 get_interface_list ()
my @interfaces = $ic->get_interface_list();
Retuns an ordered list of all interfaces on the target device.
=cut
sub get_interface_list {
return sort @{$_[0]->_request(module => 'Networking', interface => 'Interfaces', method => 'get_list')};
}
=head3 get_interface_enabled_state ($interface)
Returns the enabled state of the specific interface.
=cut
sub get_interface_enabled_state {
my ($self, $inet)=@_;
return @{$self->_request(module => 'Networking', interface => 'Interfaces', method => 'get_enabled_state', data => { interfaces => [$inet] })}[0]
}
=head3 get_interface_media_status ($interface)
Returns the media status of the specific interface.
=cut
sub get_interface_media_status {
my ($self, $inet)=@_;
return @{$self->_request(module => 'Networking', interface => 'Interfaces', method => 'get_media_status', data => { interfaces => [$inet] })}[0]
}
=head3 get_interface_media_speed ($interface)
Returns the media speed of the specific interface in Mbps.
=cut
( run in 1.126 second using v1.01-cache-2.11-cpan-df04353d9ac )