IBM-StorageSystem

 view release on metacpan or  search on metacpan

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

package IBM::StorageSystem::Fabric;

use strict;
use warnings;

use Carp qw(croak);

our @ATTR = qw(local_wwpn:remote_wwpn remote_wwpn remote_nportid id node_name 
local_wwpn local_port local_nportid state name cluster_name 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{'local_wwpn:remote_wwpn'} or croak __PACKAGE__ 
		. ' constructor failed: mandatory local_wwpn:remote_wwpn argument not supplied';

        foreach my $attr ( @ATTR ) { $self->{$attr} = $args{$attr} }

        return $self
}

1;

__END__

=pod

=head1 NAME

IBM::StorageSystem::Fabric - Class for operations with a IBM StorageSystem fabric entity

=head1 VERSION

Version 0.01

=head1 SYNOPSIS

IBM::StorageSystem::Fabric is a utility class for operations with a IBM StorageSystem fabric entity.

        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 our fabrics (sorted by fabric ID) including the fabric ID, node ID, port ID,
	# local WWPN, remote WWPN and fabric status.

	printf( "%-5s%-8s%-8s%-20s%-20s%-10s\n", 'ID', 'Node', 'Port', 'Local WWPN', 'Remote WWPN', 'Status');
	print '-'x80,"\n";

	for my $fabric ( map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [$_, $_->id] } $ibm->get_fabrics ) {
		printf( "%-5s%-8s%-8s%-20s%-20s%-10s\n", $fabric->id, $fabric->node_name, $fabric->local_port,
			$fabric->local_wwpn, $fabric->remote_wwpn, $fabric->state )
	}

	# Prints something like:
	#
	# ID   Node    Port    Local WWPN          Remote WWPN         Status    
	# --------------------------------------------------------------------------------
	# 1    node1   1       5005076802159D73    21000024FF43DE7B    active    
	# 1    node1   2       5005076802259D73    21000024FF35B8FC    active    
	# 2    node2   1       5005076802159D74    21000024FF43DE7A    active    
	# 2    node2   2       5005076802259D74    21000024FF35B8FD    active 


=head1 METHODS

=head3 cluster_name

Returns the cluster name of the fabric (if present).

=head3 id

Returns the fabric ID.

=head3 local_nportid

Returns the local NPort ID.

=head3 local_port

Returns the local port ID.

=head3 local_wwpn

Returns the local port World Wide Port Number (WWPN).

=head3 name

Returns the fabric name (if present).

=head3 node_name

Returns the the fabric node name.

=head3 remote_nportid

Returns the fabric remote NPort ID.

=head3 remote_wwpn

Returns the fabric remote WWPN.



( run in 0.630 second using v1.01-cache-2.11-cpan-39bf76dae61 )