AIX-LVM

 view release on metacpan or  search on metacpan

lib/AIX/LVM.pm  view on Meta::CPAN

    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;
}


sub get_logical_volume_group
{
	my $self = shift;
	return sort keys %{$self};
}


sub get_logical_volumes
{
	my $self = shift;
	return map {keys %{$self->{$_}->{lvol}}}keys %{$self};
}


sub get_physical_volumes
{
	my $self = shift;
	return map {keys %{$self->{$_}->{pvol}}}keys %{$self};

lib/AIX/LVM.pm  view on Meta::CPAN


sub get_volume_group_properties
{
	my $self = shift;
	my $vg   = shift;
	croak "Pass values for Volume Group\n" unless $vg;
	exists $self->{$vg}->{prop}? %{$self->{$vg}->{prop}}:undef;
}


sub get_logical_volume_properties
{
	my $self        = shift;
	my ($vg, $lv)   = (shift, shift);
	croak "Pass values for Volume Group\n" unless $vg;
	croak "Pass values for Logical Volume Group\n" unless $lv;
	exists $self->{$vg}->{lvol}->{$lv}->{prop}? %{$self->{$vg}->{lvol}->{$lv}->{prop}} : undef;
}


sub get_physical_volume_properties

lib/AIX/LVM.pm  view on Meta::CPAN

sub get_PV_LV_command
{
	my $self        = shift;
	my ($vg, $pv)   = (shift, shift);
	croak "Pass values for Volume Group\n" unless $vg;
	croak "Pass values for Physical Volume Group\n" unless $pv;
	exists $self->{$vg}->{pvol}->{$pv}->{PV_LV_CMD_OUT}? $self->{$vg}->{pvol}->{$pv}->{PV_LV_CMD_OUT} : undef;
}


sub get_LV_logical_command
{
	my $self        = shift;
	my ($vg, $lv)   = (shift, shift);
	croak "Pass values for Volume Group\n" unless $vg;
	croak "Pass values for Logical Volume Group\n" unless $lv;
	exists $self->{$vg}->{lvol}->{$lv}->{LV_LOGICAL_CMD_OUT}? $self->{$vg}->{lvol}->{$lv}->{LV_LOGICAL_CMD_OUT} : undef;
}


sub get_LV_M_command

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


=head1 DESCRIPTION

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")

Returns output as scalar for command equivalent of lspv -p hd5

t/AIX-LVM.t  view on Meta::CPAN

# `make test'. After `make install' it should work as `perl AIX-LVM.t'

#########################

use Test::More tests => 17;
BEGIN { use_ok('AIX::LVM') };
use AIX::LVM;
#########################

@methods = (
				"get_logical_volume_group",
				"get_physical_volumes",
				"get_logical_volumes",
				"get_volume_group_properties",
				"get_logical_volume_properties",
				"get_physical_volume_properties",
				"get_PV_PP_command",
				"get_PV_LV_command",
				"get_LV_logical_command",
				"get_LV_M_command"
			);
foreach my $meth (@methods) {
    can_ok('AIX::LVM', $meth);
}

SKIP: {
        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.273 second using v1.01-cache-2.11-cpan-49f99fa48dc )