IBM-StorageSystem

 view release on metacpan or  search on metacpan

lib/IBM/StorageSystem.pm  view on Meta::CPAN

# in our and pushed onto the return array.
#
# Things to note in this sub include the hack required to handle non-unique column names.
# For example; an 'lsfabric' output may include multiple 'WWPN' columns, so it is 
# neccesary to identify duplicate column names and treat the corresponding hash values
# as anonymous arrays rather than scalars.

sub __get_ml_objects {
	my ( $self, %args ) = @_;
	my @res;
	
	foreach my $object ( @{ $args{ objects } } ) {
		my ( %a, %dkeys );
		my @output = split /\n/, ( split /\n\n/, $self->__cmd( "$args{ cmd } $object" ) )[0];
		%dkeys = map { $_ => $dkeys{ $_ }++ } 
			 map { ( split /\s/, $_ )[0] } @output;

		for ( @output ) {
			last if /^\s*$/;
			s/$/ -/;
			my ( $var, $val ) = ( split /\s/ )[0,1];

			if ( $dkeys{ $var } >= 1 ) { 
				push @{ $a{ $var } }, $val 
			}
			else { 
				$a{ $var } = $val 
			}
		}

		my $obj = $args{ class }->new( $self, %a );
		$self->{ $args{ type } }->{ $a{ $args{ id } } } = $args{ class }->new( $self, %a ) unless ( $args{ nocache } );
		push @res, $obj
	}

	return @res
}

1;

__END__

=head1 NAME

IBM::StorageSystem - Perl API to IBM StorageSystem CLI

=head1 VERSION

Version 0.01

=head1 SYNOPSIS

IBM::StorageSystem is a Perl module that provides a simple API to the IBM StorageSystem CLI.

	use IBM::StorageSystem;

	# Create a IBM::StorageSystem object
	my $ibm = IBM::StorageSystem->new(	
					user		=> 'admin',
					host		=> 'my-StorageSystem',
					key_path	=> '/path/to/my/.ssh/private_key'
			) or die "Couldn't create object! $!\n";

	# Get a list of our enclosures as IBM::StorageSystem::Enclosure objects
	my @enclosures = $ibm->get_enclosures;

	# Print the status of each enclosure
	map { printf( "Enclosure %s status: %10s\n", $_->id, $_->status ) } @enclosures;

	# Get the status of each PSU in each enclosure as IBM::StorageSystem::Enclsoure::PSU objects
	map { printf( "\tPSU %s status: %s", $_->id, $_->status ) }
		map { print "--- Enclosure $_->id ---\n"; $ $_->get_psus } @enclosures;

	# Prints something like:
	# --- Enclosure 1 ---
	#     PSU 1 status: online
	#     PSU 2 status: online
	# --- Enclosure 2 ---
	#     PSU 1 status: online
	#     PSU 2 status: online
	# ...

	# Get a list of canisters in the first enclosure as IBM::StorageSystem::Enclosure::Canister objects
	my @canisters = $enclosures[0]->get_canisters;

	# Get the temperature of just the first canister in the second enclosure
	print "Temperature: ", $ibm->enclosure(2)->canister(1)->temperature, "\n";

	# Prints - Temperature: 39
    ...

=head1 METHODS

=head3 new 

	my $ibm = IBM::StorageSystem->new(	
					user		=> 'admin',
					host		=> 'my-StorageSystem',
					key_path	=> '/path/to/my/.ssh/private_key'
			) or die "Couldn't create object! $!\n";

Constructor - creates a new IBM::StorageSystem object.  This method accepts three mandatory parameters
and one optional parameter, the three mandatory parameters are:

=over 3

=item user

The username of the user with which to connect to the device.

=item host

The hostname or IP address of the device to which we are connecting.

=item key_path

Either a relative or fully qualified path to the private ssh key valid for the
user name and device to which we are connecting.  Please note that the executing user
must have read permission to this key.

=back

The optional parameter is:

=over 3

=item stats_threshold

The period in seconds for which retrieved system statistics will be considered fresh,
after which they will be re-retrieved.  If not set, the default value of this parameter
is zero meaning that the statistics are not refreshed unless done explicitly via the 
B<refresh> method of an L<IBM:StorageSystem::Statistic> object.

=back

=head3 auth_service_cert_set

Specifies if the authentication service certificate has been set.

=head3 auth_service_configured

True if the auth_service_type is configured and either one of the following is true:     

=over 3

=item * The auth_service_type is LDAP-only (if at least one LDAP server is configured)    

=item * The auth_service_type is TIP-only:                  

=over 5

=item * The name, password, and URL are established

=item * An SSL certificate is created (if an HTTPS URL is available)

=back

=back

lib/IBM/StorageSystem.pm  view on Meta::CPAN

        
        # Print the node description
        print "Description: " . $node->description . "\n";

        # Prints something like: "Description: active management node"
        # Or alternately;
        print "Description: " . $ibm->node( mgmt001st001 )->description . "\n";


Returns the node identified by the value of the node parameter as a L<IBM::StorageSystem::Node> object.

B<Note> that this method implements caching and that a cached object will be returned if one is available.
If you require a non-cached object, then please use the non-caching B<get_node> method.

=head3 get_node( $node )

This is a functionally equivalent non-caching implementation of the B<node> method.

=head3 get_nodes

        # Print the GPFS and CTDB stati of all nodes
        foreach my $node ( $ibm->get_nodes ) {
                print "GPFS status: " . $node->GPFS_status . " - CTDB status: " . $node->CTDB_status . "\n"
        }

Returns an array of L<IBM::StorageSystem::Node> objects representing all configured nodes on the target system.

=head3 pool( $pool )

Returns the pool identified by the value of the node parameter as a L<IBM::StorageSystem::Pool> object.

B<Note> that this method implements caching and that a cached object will be returned if one is available.
If you require a non-cached object, then please use the non-caching B<get_pool> method.

=head3 get_pool( $pool )

This is a functionally equivalent non-caching implementation of the B<pool> method.

=head3 get_pools( $pool )

Returns an array of L<IBM::StorageSystem::Pool> objects representing all configured pools on the target system.

=head3 replication( $eventlog_id )

Returns the replication event identified by the eventlog_id parameter as an L<IBM::StorageSystem::Replication> object.

B<Note> that this method implements caching and that a cached object will be returned if one is available.
If you require a non-cached object, then please use the non-caching B<get_node> method.

=head3 get_replication( $eventlog_id )

This is a functionally equivalent non-caching implementation of the B<replication> method.

=head3 get_replications

        use Date::Calc qw(date_to_Time Today_and_Now);

        my $ibm = IBM::StorageSystem->new(      
                                        user            => 'admin',
                                        host            => 'my-v7000',
                                        key_path        => '/path/to/my/.ssh/private_key'
                                ) or die "Couldn't create object! $!\n";

        # Generate an alert for any replication errors in the last six hours

        foreach my $task ( $ibm->get_replications ) {

                if ( $task->status eq 'ERROR' and ( Date_to_Time( Today_and_Now ) 
                        - ( Date_to_Time( split /-| |\./, $task->time ) ) ) < 21_600 ) {
                        alert( "Replication failure for filesystem " . $task->filesystem . 
                                " - log ID: " . $task->log_id . )
                }

        }

Returns all asynchornous replication tasks as an array of L<IBM::StorageSystem::Replication> objects.

=head3 service( $service )

        # Print the enabled status of the NFS service
        print $ibm->service(NFS)->enabled;

        # Print the configured and enabled status of all services
        printf( "%-20s%-20s%-20s\n", 'Service', 'Configured', 'Active' );
        map { printf( "%-20s%-20s%-20s\n", $_->name, $_->configured, $_->active ) } $ibm->get_services;

Returns a L<IBM::StorageSystem::Service> object representing the service identified by the value of the
service parameter.

B<Note> that this method implements caching and that a cached object will be returned if one is available.
If you require a non-cached object, then please use the non-caching B<get_node> method.

=head3 get_service( $service )

This is a functionally equivalent non-caching implementation of the B<service> method.

=head3 get_services

Returns an array of L<IBM::StorageSystem::Service> objects representing all configured services on the target
system.

=head3 task( $task )

	# Print the status of the SNAPSHOTS task
	my $snapshots = $ibm->task(SNAPSHOTS);
	print "Status: " . $snapshots->status . "\n";

	# Alternately
	print "Status: " . $ibm->task(SNAPSHOTS)->status . "\n";

Return the task identified by the value of the task parameter as an L<IBM::StorageSystem::Task> object.

B<Note> that this method implements caching and that a cached object will be returned if one is available.
If you require a non-cached object, then please use the non-caching B<get_node> method.

=head3 get_task( $task )

This is a functionally equivalent non-caching implementation of the B<task> method.

=head3 get_tasks



( run in 0.457 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )