AIX-LVM
view release on metacpan or search on metacpan
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: AIX-LVM
version: 1.1
version_from: lib/AIX/LVM.pm
installdirs: site
requires:
IO::Handle: 1.0
IO::Select: 1.0
IPC::Open3: 1.0
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.30
lib/AIX/LVM.pm view on Meta::CPAN
my $class = shift;
my $self = {};
bless $self, $class;
return $self->init(@_);
}
sub init
{
my $self = shift;
my ($result, %lslv, %lspv, %lsvg, @lslv, @lsvg, @lspv);
my ($lsvg, $lsvg_error) = $self->_exec_open3("lsvg -o");
croak "Error found during execution of lsvg -o: $lsvg_error\n" if $lsvg_error;
@lsvg = $self->_splitter($lsvg, qr'\n+');
foreach my $lvg (@lsvg) {
$self->{$lvg}= $self->_get_lv_pv_props($lvg); #Hierarchy is lsvg -> lslv and lspv
}
return $self;
}
lib/AIX/LVM.pm view on Meta::CPAN
}
}
return \%prop;
}
# This subroutine is used to execute the commands using open3 to capture Error stream.
sub _exec_open3
{
my $self = shift;
my ($result, $error);
my $writer_h = new IO::Handle;
my $reader_h = new IO::Handle;
my $error_h = new IO::Handle;
my $pid = open3($writer_h, $reader_h, $error_h, @_) or croak "Not able to open3: $! \n";
$reader_h->autoflush();
$error_h->autoflush();
my $selector = IO::Select->new();
$selector->add($reader_h, $error_h); ## Add the handlers to select call ##
while( my @ready = $selector->can_read ){
foreach my $fh ( @ready ){
if( fileno($fh) == fileno($reader_h) ){
my $ret = $reader_h->sysread($_, 1024);
$result .= $_;
$selector->remove($fh) unless $ret;
}
if( fileno($fh) == fileno($error_h) ){
my $ret = $error_h->sysread($_, 1024);
$error .= $_;
$selector->remove($fh) unless $ret;
}
}
}
$reader_h->autoflush();
$error_h->autoflush();
waitpid $pid, 0;
my $rc = $? >> 8;
carp "Error in executing the command\n" if ($rc);
return $result, $error;
}
# Splitter based on pattern
sub _splitter
{
my $self = shift;
my ($string, $pat) = (shift, shift);
return split /$pat/, $string;
}
lib/AIX/LVM.pm view on Meta::CPAN
=head1 NAME
AIX::LVM - Perl extension to handle AIX LVM Structure.
=head1 SYNOPSIS
use AIX::LVM;
my $lvm = AIX::LVM->new;
my @volume_group = $lvm->get_logical_volume_group(); #List all the Volume groups present.
my @pvs = $lvm->get_physical_volumes(); #List all the Physical volumes present.
my @lvs = $lvm->get_logical_volumes(); #List all the Physical volumes present.
#%vg_props consist of all the volume group properties in key=>value format.
my %vg_props = $lvm->get_volume_group_properties("rootvg");
#%lv_props consist of all the properties for logical volume "x" under volume group "rootvg";
my %lv_props = $lvm->get_logical_volume_properties("rootvg","x");
my $lslv_l_cmd = $lvm->get_LV_logical_command("rootvg","x") #Equivalent to lslv -l x
my $lslv_m_cmd = $lvm->get_LV_M_command("rootvg","x") #Equivalent to lslv -m x
lib/AIX/LVM.pm view on Meta::CPAN
This Module is a Perl wrapper for AIX LVM and provides access to the properties
of Volume groups, Logial Volumes, Physical Volumes, Physical Partitions. This provides
access to LVM command equivalents.
=head1 METHODS
=over 4
=item get_logical_volume_group();
Returns an array of volume groups present.
=item get_physical_volumes();
Returns an array of Physical volumes present.
=item get_logical_volumes();
Returns an array of Logical volumes present.
=item get_volume_group_properties("rootvg")
Returns a hash of properties for volume group "rootvg"
=item get_logical_volume_properties("rootvg","hd5")
Returns a hash of properties for logical volume "hd5" present under volume group "rootvg"
=item get_physical_volume_properties("rootvg","hdisk0")
Returns a hash of properties for physical volume "hdisk0" present under volume group "rootvg"
=item get_LV_logical_command("rootvg","hd5")
Returns output as scalar for command equivalent of lslv -l hd5
=item get_LV_ M_command("rootvg","hd5")
Returns output as scalar for command equivalent of lslv -m hd5
=item get_PV_PP_command("rootvg","hdisk0")
t/AIX-LVM.t view on Meta::CPAN
skip "Environment is not AIX", 6 if $^O!~/aix/i;
eval {
$lvm = new AIX::LVM;
};
isa_ok($lvm,"AIX::LVM");
ok(!$@,"Loaded Module AIX::LVM") or diag("Error is $@") ;
isa_ok( $lvm, "AIX::LVM" );
SKIP: {
skip "Module itself have errors", 3 if $@;
ok(grep(/rootvg/,$lvm->get_logical_volume_group),"Get Volume Groups");
ok(scalar($lvm->get_physical_volumes), "Physical Volume Presence");
ok(scalar($lvm->get_logical_volumes), "Logical Volume Presence");
}
}
( run in 1.354 second using v1.01-cache-2.11-cpan-49f99fa48dc )