|
|
@ -10,8 +10,11 @@ open STDERR, '>/dev/null'; |
|
|
|
my $json; |
|
|
|
my $json; |
|
|
|
@{$json->{data}} = (); |
|
|
|
@{$json->{data}} = (); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my @vg = eval { get_volume_group_list() }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unless ($@){ |
|
|
|
if ($what eq "volumes"){ |
|
|
|
if ($what eq "volumes"){ |
|
|
|
foreach my $group (get_volume_group_list()){ |
|
|
|
foreach my $group (@vg){ |
|
|
|
my %lvs = get_logical_volume_information($group); |
|
|
|
my %lvs = get_logical_volume_information($group); |
|
|
|
foreach my $lv (keys %lvs){ |
|
|
|
foreach my $lv (keys %lvs){ |
|
|
|
$lv = ($lv =~ m!^/dev/$group!) ? $lv : "/dev/$group/$lv"; |
|
|
|
$lv = ($lv =~ m!^/dev/$group!) ? $lv : "/dev/$group/$lv"; |
|
|
@ -20,7 +23,7 @@ if ($what eq "volumes"){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
elsif ($what eq "snapshots"){ |
|
|
|
elsif ($what eq "snapshots"){ |
|
|
|
foreach my $group (get_volume_group_list()){ |
|
|
|
foreach my $group (@vg){ |
|
|
|
my %lvs = get_logical_volume_information($group); |
|
|
|
my %lvs = get_logical_volume_information($group); |
|
|
|
foreach my $lv (keys %lvs){ |
|
|
|
foreach my $lv (keys %lvs){ |
|
|
|
if (defined $lvs{$lv}->{allocated_to_snapshot}){ |
|
|
|
if (defined $lvs{$lv}->{allocated_to_snapshot}){ |
|
|
@ -31,7 +34,7 @@ elsif ($what eq "snapshots"){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
elsif ($what eq "thin_pools"){ |
|
|
|
elsif ($what eq "thin_pools"){ |
|
|
|
foreach my $group (get_volume_group_list()){ |
|
|
|
foreach my $group (@vg){ |
|
|
|
my %lvs = get_logical_volume_information($group); |
|
|
|
my %lvs = get_logical_volume_information($group); |
|
|
|
foreach my $lv (keys %lvs){ |
|
|
|
foreach my $lv (keys %lvs){ |
|
|
|
if (defined $lvs{$lv}->{allocated_pool_data}){ |
|
|
|
if (defined $lvs{$lv}->{allocated_pool_data}){ |
|
|
@ -42,17 +45,17 @@ elsif ($what eq "thin_pools"){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
elsif ($what eq "groups"){ |
|
|
|
elsif ($what eq "groups"){ |
|
|
|
foreach my $group (get_volume_group_list()){ |
|
|
|
foreach my $group (@vg){ |
|
|
|
push @{$json->{data}}, { "{#LVMGRP}" => $group }; |
|
|
|
push @{$json->{data}}, { "{#LVMGRP}" => $group }; } |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
print <<"EOF"; |
|
|
|
print <<"EOF"; |
|
|
|
|
|
|
|
|
|
|
|
Usage: $0 [volumes|snapshots|groups] |
|
|
|
Usage: $0 [volumes|snapshots|thin_pools|groups] |
|
|
|
|
|
|
|
|
|
|
|
EOF |
|
|
|
EOF |
|
|
|
|
|
|
|
exit 1; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
print to_json($json); |
|
|
|
print to_json($json); |
|
|
|
exit(0); |
|
|
|
exit(0); |
|
|
|