StorageSystem/FileSystem.pm

filter: Statementstmt 66.6% 42 / 63 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 61.5% 8 / 13 Podpod 0.0% 0 / 1 totaltotal 57.4% 50 / 87 CC 7 SCAR 16.9
CC
7
Cov
58%
__ANON__
12.0
new
12.0
__ANON__
6.0
CRAP 5.4
« StorageSystem/VDisk.pm ↑ Summary StorageSystem/Enclosure/Canister.pm »
1 package IBM::StorageSystem::FileSystem;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use IBM::StorageSystem::FileSystem::FileSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use IBM::StorageSystem::Snapshot;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our $VERSION = '0.01';
12 2 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 2 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 2 foreach my $obj ( keys %{ $OBJ } ) {
35 {
36 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 4 my $m = 'get_'.$obj.'s';
39  
40 4 *{ __PACKAGE__ ."::$obj" } =
41 0 ▶ sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
42 0 my( $self, $id ) = @_;
43 0 ▶ defined $id or return;
Branch: 1 branch
BranchTrueFalseTotal
defined $id or return 0 0 0
44  
45 0 ▶ return ( $self->{$obj}->{$id} ? $self->{$obj}->{$id}
Branch: 1 branch
BranchTrueFalseTotal
$self->{$obj}{$id} ? : 0 0 0
46 : $self->$m( $id )
47 )
48 4 };
49  
50 4 *{ __PACKAGE__ .'::get_'. $obj } =
51 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 0 my ( $self, $id ) = @_;
53 0 return $self->$m( $id )
54 4 };
55  
56 4 *{ __PACKAGE__ . "::$m" } =
57 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
58 0 my ( $self, $id ) = @_;
59 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 0 );
64 0 my @res = map { $_->device_name( $self->{device_name} ); $_
65 0 } $self->{__ibm}->__get_sl_objects( %args );
66  
67 0 ▶ return ( defined $id ? $self->{ $OBJ->{$obj}->{type} }->{$id}
Branch: 1 branch
BranchTrueFalseTotal
defined $id ? : 0 0 0
68 : @res
69 )
70 }
71 4 }
72 }
73  
74 2 foreach my $attr ( map lc, @ATTR ) {
75 {
76 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
77 52 ▶ *{ __PACKAGE__ .'::'. $attr } = sub {
Subroutine __ANON__: not called CC=2 SCAR=14.6
78 0 my( $self, $val ) = @_;
79 0 ▶ $self->{$attr} = $val if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 0 0 0
80 0 return $self->{$attr}
81 }
82 52 }
83 }
84  
85 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
86 0 my( $class, $ibm, %args ) = @_;
87 0 my $self = bless {}, $class;
88 0 ▶ defined $args{'Device_name'}
Branch: 1 branch
BranchTrueFalseTotal
defined $args{"Device_name"} or croak("IBM::StorageSystem::FileSystem constructor failed: mandatory Device_name argument not supplied") 0 0 0
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 2 1;
100  
101 __END__
« StorageSystem/VDisk.pm ↑ Summary StorageSystem/Enclosure/Canister.pm »