File Coverage

blib/lib/Device/WWN/Hitachi/HDS.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Device::WWN::Hitachi::HDS;
2 1     1   110421 use strict; use warnings;
  1     1   2  
  1         35  
  1         7  
  1         2  
  1         48  
3             our $VERSION = '1.01';
4 1     1   617 use Moose;
  0            
  0            
5             extends 'Device::WWN';
6             use Device::WWN::Carp qw( croak );
7              
8             # http://brionetka.com/linux/?p=38
9             #
10             sub accept_wwn {
11             my ( $self, $wwn ) = @_;
12             return $wwn =~ /^50060e8/;
13             }
14              
15             has '+wwn' => (
16             lazy => 1,
17             default => sub {
18             my $self = shift;
19             my %ports = qw(
20             A 0 B 1 C 2 D 3 E 4 F 5 G 6 H 7
21             J 8 K 9 L A M B N C O D P E Q F
22             );
23             $self->port =~ /^([01])(\w)$/ or croak "Invalid port";
24             my $port = ( $1 - 1 ) . $ports{ $2 };
25             my $oui = $self->oui->normalized;
26             $oui =~ s/[^a-f0-9]//ig;
27             my $fid = sprintf( '%02d', $self->family_id );
28             my $serial = sprintf( '%X', $self->serial_number );
29             return join( '', $self->naa, $oui, '0', $fid, $serial, $port );
30             },
31             );
32              
33             sub _build_naa { return 5 }
34             sub _build_oui { return Device::OUI->new( '0060E8' ) }
35              
36             # HDS seems to ignore the first character of the vendor_id, as far as I can
37             # tell it is always 0
38             has 'family_id' => ( is => 'rw', isa => 'Str', lazy_build => 1 );
39             sub _build_family_id { return substr( shift->vendor_id, 1, 2 ) }
40              
41             has 'serial_number' => ( is => 'rw', isa => 'Str', lazy_build => 1 );
42             sub _build_serial_number { return hex( substr( shift->vendor_id, 3, 4 ) ) }
43              
44             has 'port' => ( is => 'rw', isa => 'Str', lazy_build => 1 );
45             sub _build_port {
46             my $self = shift;
47             my $cluster = substr( $self->vendor_id, 7, 1 ) + 1;
48             my @ports = qw( A B C D E F G H J K L M N O P Q );
49             return $cluster.$ports[ hex( substr( $self->vendor_id, 8, 1 ) ) ];
50             }
51              
52             no Moose;
53             __PACKAGE__->meta->make_immutable;
54             1;
55             __END__
56              
57             =head1 NAME
58              
59             Device::WWN::Hitachi::HDS - Device::WWN subclass for Hitachi HDS WWNs
60              
61             =head1 DESCRIPTION
62              
63             This module is a subclass of L<Device::WWN|Device::WWN> which provides
64             additional information about Hitachi HDS arrays. These arrays are also
65             resold by various vendors under other names, including:
66              
67             Sun StorEdge
68             HP XP series
69              
70             See L<Device::WWN|Device::WWN> for more information.
71              
72             =head1 METHODS
73              
74             =head2 accept_wwn( $wwn )
75              
76             This is called as a class method by L<Device::WWN> and returns a true value
77             if the WWN provided can be handled by this subclass.
78              
79             =head2 family_id
80              
81             Returns the family ID part of the WWN.
82              
83             =head2 port
84              
85             Returns the port the WWN is associated with.
86              
87             =head2 serial_number
88              
89             Returns the serial number of the array the WWN is associated with.
90              
91             =head1 MODULE HOME PAGE
92              
93             The home page of this module is
94             L<http://www.jasonkohles.com/software/device-wwn>. This is where you can
95             always find the latest version, development versions, and bug reports. You
96             will also find a link there to report bugs.
97              
98             =head1 SEE ALSO
99              
100             L<Device::WWN|Device::WWN>
101              
102             L<Device::WWN::Sun::StorEdge|Device::WWN::Sun::StorEdge>
103              
104             L<Device::WWN::HP::XP|Device::WWN::HP::XP>
105              
106             =head1 AUTHOR
107              
108             Jason Kohles C<< <email@jasonkohles.com> >>
109              
110             L<http://www.jasonkohles.com>
111              
112             =head1 COPYRIGHT AND LICENSE
113              
114             Copyright 2008, 2009 Jason Kohles
115              
116             This program is free software; you can redistribute it and/or modify it
117             under the same terms as Perl itself.
118              
119             =cut
120