IBM-StorageSystem
view release on metacpan or search on metacpan
lib/IBM/StorageSystem/Host.pm view on Meta::CPAN
package IBM::StorageSystem::Host;
use strict;
use warnings;
use Carp qw(croak);
our $VERSION = '0.01';
our @ATTR = qw(WWPN id iogrp_count mask name node_logged_in_count port_count
state status type);
foreach my $attr ( @ATTR ) {
{
no strict 'refs';
*{ __PACKAGE__ .'::'. $attr } = sub {
my( $self, $val ) = @_;
$self->{$attr} = $val if $val;
return $self->{$attr}
}
}
}
sub new {
my( $class, $ibm, %args ) = @_;
my $self = bless {}, $class;
defined $args{'id'} or croak __PACKAGE__
. ' constructor failed: mandatory id argument not supplied';
foreach my $attr ( @ATTR ) { $self->{$attr} = $args{$attr} }
return $self
}
1;
__END__
=pod
=head1 NAME
IBM::StorageSystem::Host - Class for operations with a IBM StorageSystem attached hosts
=head1 VERSION
Version 0.01
=head1 SYNOPSIS
IBM::StorageSystem::Host is a utility class for operations with a IBM StorageSystem attached hosts.
use IBM::StorageSystem;
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";
# Print a list of all configured hosts sorted by hostname, their WWPNs,
# port state and login status.
foreach $host ( map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, $_->name ] } $ibm->get_hosts ) {
my $c = 0;
foreach $wwpn ( @{ $host->WWPN } ) {
print ( $c ? "\t" : ('-'x100)."\n".$host->name );
print "\t\t\t$wwpn\t" . @{ $host->state }[$c] . "\t\t" .
( @{$host->node_logged_in_count }[$c] ? '' : 'not ' ) . "logged in\n";
$c++
}
}
# Prints something similar to:
# ----------------------------------------------------------------------------------------------------
# host-3 2101001B32A3D94C active logged in
# 2100001B3283D94C active logged in
# ----------------------------------------------------------------------------------------------------
# host-4 2100001B320786E7 active logged in
# 2101001B322786E7 active logged in
# ----------------------------------------------------------------------------------------------------
# storage-2 210100E08BB40A08 offline not logged in
# 210000E08B940A08 offline not logged in
# ... etc.
=head1 METHODS
=head3 WWPN
Returns an array of the WWPNs configured for this host - the order of the WWPNs in the array preserves the order
in which the WWPNs were returned from the CLI. For example, if two WWPNs would be returned from the CLI
command of lshost <host_id>, then the order in which the WWPNs will be preserved in the array so that the first
WWPN to be returned is the first array item and the second to be returned is the second array item.
See the L<NOTES> section for further detail.
=head3 id
Returns the numerical identifier of the host.
=head3 iogrp_count
Returns the IO group count for the host.
=head3 mask
Returns the LUN masking for the host.
=head3 name
Returns the name of the host - this is the name with which the host was configured with in the CLI or GUI.
=head3 node_logged_in_count
Returns an array of integers representing the node logged in count for the corresponding WWPN. The array
( run in 0.666 second using v1.01-cache-2.11-cpan-39bf76dae61 )