File Coverage

blib/lib/IBM/StorageSystem/FileSystem.pm
Criterion Covered Total %
statement 24 45 53.3
branch 0 10 0.0
condition n/a
subroutine 8 17 47.0
pod 0 1 0.0
total 32 73 43.8


line stmt bran cond sub pod time code
1             package IBM::StorageSystem::FileSystem;
2              
3 1     1   6 use strict;
  1         3  
  1         36  
4 1     1   5 use warnings;
  1         2  
  1         25  
5              
6 1     1   655 use IBM::StorageSystem::FileSystem::FileSet;
  1         3  
  1         32  
7 1     1   835 use IBM::StorageSystem::Snapshot;
  1         2  
  1         300  
8 1     1   8 use Scalar::Util qw(weaken);
  1         2  
  1         58  
9 1     1   7 use Carp qw(croak);
  1         2  
  1         185  
10              
11             our $VERSION = '0.01';
12             our @ATTR = qw(ACLtype Atime Block_allocation_type Block_size Cluster Def_quota
13             Device_name Dmapi Ind_block_size Inode_size Inodes Last_update Locking_type
14             Log_placement Logf_size Max_Inodes Min_frag_size Mount_point Mtime Quota
15             Remote_device Replication Snapdir State Type Version);
16              
17             our $OBJ = {
18             fileset => {
19             cmd => 'lsfset -v -Y',
20             id => 'ID',
21             class => 'IBM::StorageSystem::FileSystem::FileSet',
22             type => 'fset',
23             sl => 1
24             },
25             snapshot => {
26             cmd => 'lssnapshot -Y',
27             id => 'Snapshot_ID',
28             class => 'IBM::StorageSystem::Snapshot',
29             type => 'snapshot',
30             sl => 1
31             }
32             };
33              
34             foreach my $obj ( keys %{ $OBJ } ) {
35             {
36 1     1   6 no strict 'refs';
  1         3  
  1         453  
37              
38             my $m = 'get_'.$obj.'s';
39              
40             *{ __PACKAGE__ ."::$obj" } =
41             sub {
42 0     0     my( $self, $id ) = @_;
        0      
43 0 0         defined $id or return;
44              
45 0 0         return ( $self->{$obj}->{$id} ? $self->{$obj}->{$id}
46             : $self->$m( $id )
47             )
48             };
49              
50             *{ __PACKAGE__ .'::get_'. $obj } =
51             sub {
52 0     0     my ( $self, $id ) = @_;
53 0           return $self->$m( $id )
54             };
55              
56             *{ __PACKAGE__ . "::$m" } =
57             sub {
58 0     0     my ( $self, $id ) = @_;
59 0           my %args = ( cmd => "$OBJ->{$obj}->{cmd} ".$self->device_name,
60             class => $OBJ->{$obj}->{class},
61             type => $OBJ->{$obj}->{type},
62             id => $OBJ->{$obj}->{id}
63             );
64 0           my @res = map { $_->device_name( $self->{device_name} ); $_
  0            
  0            
65             } $self->{__ibm}->__get_sl_objects( %args );
66              
67 0 0         return ( defined $id ? $self->{ $OBJ->{$obj}->{type} }->{$id}
68             : @res
69             )
70             }
71             }
72             }
73              
74             foreach my $attr ( map lc, @ATTR ) {
75             {
76 1     1   7 no strict 'refs';
  1         2  
  1         543  
77             *{ __PACKAGE__ .'::'. $attr } = sub {
78 0     0     my( $self, $val ) = @_;
        0      
        0      
        0      
79 0 0         $self->{$attr} = $val if $val;
80 0           return $self->{$attr}
81             }
82             }
83             }
84              
85             sub new {
86 0     0 0   my( $class, $ibm, %args ) = @_;
87 0           my $self = bless {}, $class;
88 0 0         defined $args{'Device_name'}
89             or croak __PACKAGE__ . ' constructor failed: mandatory Device_name argument not supplied';
90 0           weaken( $self->{__ibm} = $ibm );
91              
92 0           foreach my $attr ( @ATTR ) {
93 0           $self->{lc $attr} = $args{$attr}
94             }
95              
96 0           return $self
97             }
98              
99             1;
100              
101             __END__