#!/usr/local/bin/perl # index.cgi # Display a table of all volumne groups and their physical and logical volumes. require './lvm-lib.pl'; if (!&has_command("vgdisplay")) { &lvm_header(); print "
",&text('index_ecommands', "vgdisplay"),"
\n"; &ui_print_footer("/", $text{'index'}); exit; } ($lvm_version, $out) = &get_lvm_version(); if ($lvm_version && $lvm_version < 2) { # /proc/lvm doesn't exist in LVM 2 if (!-d $lvm_proc) { system("modprobe lvm-mod >/dev/null 2>&1"); } if (!-d $lvm_proc) { &lvm_header(); print "
",&text('index_emodule', "$lvm_proc", "lvm-mod"),"
\n"; &ui_print_footer("/", $text{'index'}); exit; } } if (!$lvm_version) { &lvm_header(); print "
",&text('index_eversion', "vgdisplay --version", "
$out"),"
\n"; &ui_print_footer("/", $text{'index'}); exit; } &lvm_header(); # Show table of volume groups @vgs = &list_volume_groups(); if (@vgs) { print "
| $text{'index_vgs'} | ", "$text{'index_pvs'} | ", "$text{'index_lvs'} |
| \n";
&icons_table( [ "edit_vg.cgi?vg=".&urlize($v->{'name'}) ],
[ &html_escape($v->{'name'}).
" ".&nice_size($v->{'size'}*1024) ], [ "images/vg.gif" ], 1); print &ui_links_row([ "$text{'index_add'}" ]); print " | \n";
# Show physical volume icons
local @pvs = sort { $a->{'number'} <=> $b->{'number'} }
&list_physical_volumes($v->{'name'});
if (@pvs) {
local (@icons, @titles, @links);
@icons = map { "images/pv.gif" } @pvs;
@titles = map { &html_escape($_->{'device'}).
" ".&nice_size($_->{'size'}*1024) } @pvs; @links = map { "edit_pv.cgi?vg=".&urlize($v->{'name'}). "&pv=".&urlize($_->{'name'}) } @pvs; &icons_table(\@links, \@titles, \@icons, 3); } else { print "$text{'index_nopvs'} \n"; } print &ui_links_row([ "$text{'index_addpv'}" ]); # Show logical volume icons print " | \n";
local @lvs = sort { $a->{'number'} <=> $b->{'number'} }
&list_logical_volumes($v->{'name'});
if (@lvs) {
@icons = map { $_->{'is_snap'} ? "images/snap.gif"
: "images/lv.gif" } @lvs;
@titles = map { &html_escape($_->{'name'}).
" ".&nice_size($_->{'size'}*1024) } @lvs; @links = map { "edit_lv.cgi?vg=".&urlize($v->{'name'}). "&lv=".&urlize($_->{'name'}) } @lvs; &icons_table(\@links, \@titles, \@icons, 3); } else { print "$text{'index_nolvs'} \n"; } print &ui_links_row([ "$text{'index_addlv'}", @lvs ? ( "$text{'index_addsnap'}" ) : ( ) ]); print " |
\n"; } else { print "$text{'index_none'}
\n"; @tab = &list_lvmtab(); if (@tab) { # Maybe LVM needs to be re-started print &text('index_init', "init.cgi"),"
\n"; } print &ui_links_row([ "$text{'index_add'}" ]); } &ui_print_footer("/", $text{'index'}); sub lvm_header { &ui_print_header(undef, $text{'index_title'}, "", undef, 0, 1, 0, &help_search_link("lvm", "man", "doc", "google"), undef, undef, $lvm_version ? &text('index_version', $lvm_version) : undef); }