delete trailing white-space

This commit is contained in:
Dietmar Maurer
2013-08-12 11:56:41 +02:00
parent f4648aef06
commit 1a3459ac78
3 changed files with 49 additions and 49 deletions

View File

@ -61,7 +61,7 @@ sub storage_config {
my ($cfg, $storeid, $noerr) = @_; my ($cfg, $storeid, $noerr) = @_;
die "no storage id specified\n" if !$storeid; die "no storage id specified\n" if !$storeid;
my $scfg = $cfg->{ids}->{$storeid}; my $scfg = $cfg->{ids}->{$storeid};
die "storage '$storeid' does not exists\n" if (!$noerr && !$scfg); die "storage '$storeid' does not exists\n" if (!$noerr && !$scfg);
@ -273,7 +273,7 @@ sub volume_is_base {
if (my $scfg = $cfg->{ids}->{$sid}) { if (my $scfg = $cfg->{ids}->{$sid}) {
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) = my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
$plugin->parse_volname($volname); $plugin->parse_volname($volname);
return $isBase ? 1 : 0; return $isBase ? 1 : 0;
} else { } else {
@ -304,7 +304,7 @@ sub path_to_volume_id {
return (''); return ('');
} }
# Note: abs_path() return undef if $path doesn not exist # Note: abs_path() return undef if $path doesn not exist
# for example when nfs storage is not mounted # for example when nfs storage is not mounted
$path = abs_path($path) || $path; $path = abs_path($path) || $path;
@ -332,7 +332,7 @@ sub path_to_volume_id {
} }
} elsif ($path =~ m!^$isodir/([^/]+\.[Ii][Ss][Oo])$!) { } elsif ($path =~ m!^$isodir/([^/]+\.[Ii][Ss][Oo])$!) {
my $name = $1; my $name = $1;
return ('iso', "$sid:iso/$name"); return ('iso', "$sid:iso/$name");
} elsif ($path =~ m!^$tmpldir/([^/]+\.tar\.gz)$!) { } elsif ($path =~ m!^$tmpldir/([^/]+\.tar\.gz)$!) {
my $name = $1; my $name = $1;
return ('vztmpl', "$sid:vztmpl/$name"); return ('vztmpl', "$sid:vztmpl/$name");
@ -341,7 +341,7 @@ sub path_to_volume_id {
return ('rootdir', "$sid:rootdir/$vmid"); return ('rootdir', "$sid:rootdir/$vmid");
} elsif ($path =~ m!^$backupdir/([^/]+\.(tar|tar\.gz|tar\.lzo|tgz|vma|vma\.gz|vma\.lzo))$!) { } elsif ($path =~ m!^$backupdir/([^/]+\.(tar|tar\.gz|tar\.lzo|tgz|vma|vma\.gz|vma\.lzo))$!) {
my $name = $1; my $name = $1;
return ('iso', "$sid:backup/$name"); return ('iso', "$sid:backup/$name");
} }
} }
@ -395,14 +395,14 @@ sub storage_migrate {
my $dirname = dirname($dst); my $dirname = dirname($dst);
if ($tcfg->{shared}) { # we can do a local copy if ($tcfg->{shared}) { # we can do a local copy
run_command(['/bin/mkdir', '-p', $dirname]); run_command(['/bin/mkdir', '-p', $dirname]);
run_command(['/bin/cp', $src, $dst]); run_command(['/bin/cp', $src, $dst]);
} else { } else {
run_command(['/usr/bin/ssh', "root\@${target_host}", run_command(['/usr/bin/ssh', "root\@${target_host}",
'/bin/mkdir', '-p', $dirname]); '/bin/mkdir', '-p', $dirname]);
# we use rsync with --sparse, so we can't use --inplace, # we use rsync with --sparse, so we can't use --inplace,
@ -410,12 +410,12 @@ sub storage_migrate {
# save space # save space
my ($size, $format) = PVE::Storage::Plugin::file_size_info($src); my ($size, $format) = PVE::Storage::Plugin::file_size_info($src);
if ($format && ($format eq 'raw') && $size) { if ($format && ($format eq 'raw') && $size) {
run_command(['/usr/bin/ssh', "root\@${target_host}", run_command(['/usr/bin/ssh', "root\@${target_host}",
'rm', '-f', $dst], 'rm', '-f', $dst],
outfunc => sub {}); outfunc => sub {});
} }
my $cmd = ['/usr/bin/rsync', '--progress', '--sparse', '--whole-file', my $cmd = ['/usr/bin/rsync', '--progress', '--sparse', '--whole-file',
$src, "root\@${target_host}:$dst"]; $src, "root\@${target_host}:$dst"];
my $percent = -1; my $percent = -1;
@ -445,13 +445,13 @@ sub storage_migrate {
sub vdisk_clone { sub vdisk_clone {
my ($cfg, $volid, $vmid) = @_; my ($cfg, $volid, $vmid) = @_;
my ($storeid, $volname) = parse_volume_id($volid); my ($storeid, $volname) = parse_volume_id($volid);
my $scfg = storage_config($cfg, $storeid); my $scfg = storage_config($cfg, $storeid);
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
activate_storage($cfg, $storeid); activate_storage($cfg, $storeid);
# lock shared storage # lock shared storage
@ -469,7 +469,7 @@ sub vdisk_create_base {
my $scfg = storage_config($cfg, $storeid); my $scfg = storage_config($cfg, $storeid);
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
activate_storage($cfg, $storeid); activate_storage($cfg, $storeid);
# lock shared storage # lock shared storage
@ -515,7 +515,7 @@ sub vdisk_free {
my $scfg = storage_config($cfg, $storeid); my $scfg = storage_config($cfg, $storeid);
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
activate_storage($cfg, $storeid); activate_storage($cfg, $storeid);
my $cleanup_worker; my $cleanup_worker;
@ -523,7 +523,7 @@ sub vdisk_free {
# lock shared storage # lock shared storage
$plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub { $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
my ($vtype, $name, $vmid, undef, undef, $isBase) = my ($vtype, $name, $vmid, undef, undef, $isBase) =
$plugin->parse_volname($volname); $plugin->parse_volname($volname);
if ($isBase) { if ($isBase) {
my $vollist = $plugin->list_images($storeid, $scfg); my $vollist = $plugin->list_images($storeid, $scfg);
@ -533,7 +533,7 @@ sub vdisk_free {
my $basevmid = undef; my $basevmid = undef;
eval{ eval{
(undef, undef, undef, $basename, $basevmid) = (undef, undef, undef, $basename, $basevmid) =
$plugin->parse_volname($tmpvolname); $plugin->parse_volname($tmpvolname);
}; };
@ -558,8 +558,8 @@ sub vdisk_free {
sub template_list { sub template_list {
my ($cfg, $storeid, $tt) = @_; my ($cfg, $storeid, $tt) = @_;
die "unknown template type '$tt'\n" die "unknown template type '$tt'\n"
if !($tt eq 'iso' || $tt eq 'vztmpl' || $tt eq 'backup'); if !($tt eq 'iso' || $tt eq 'vztmpl' || $tt eq 'backup');
my $ids = $cfg->{ids}; my $ids = $cfg->{ids};
@ -604,7 +604,7 @@ sub template_list {
} elsif ($tt eq 'backup') { } elsif ($tt eq 'backup') {
next if $fn !~ m!/([^/]+\.(tar|tar\.gz|tar\.lzo|tgz|vma|vma\.gz|vma\.lzo))$!; next if $fn !~ m!/([^/]+\.(tar|tar\.gz|tar\.lzo|tgz|vma|vma\.gz|vma\.lzo))$!;
$info = { volid => "$sid:backup/$1", format => $2 }; $info = { volid => "$sid:backup/$1", format => $2 };
} }
@ -773,7 +773,7 @@ sub deactivate_volumes {
my $scfg = storage_config($cfg, $storeid); my $scfg = storage_config($cfg, $storeid);
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
eval { eval {
$plugin->deactivate_volume($storeid, $scfg, $volname, $cache); $plugin->deactivate_volume($storeid, $scfg, $volname, $cache);
}; };
@ -787,7 +787,7 @@ sub deactivate_volumes {
if scalar(@errlist); if scalar(@errlist);
} }
sub storage_info { sub storage_info {
my ($cfg, $content) = @_; my ($cfg, $content) = @_;
my $ids = $cfg->{ids}; my $ids = $cfg->{ids};
@ -803,11 +803,11 @@ sub storage_info {
my $type = $ids->{$storeid}->{type}; my $type = $ids->{$storeid}->{type};
$info->{$storeid} = { $info->{$storeid} = {
type => $type, type => $type,
total => 0, total => 0,
avail => 0, avail => 0,
used => 0, used => 0,
shared => $ids->{$storeid}->{shared} ? 1 : 0, shared => $ids->{$storeid}->{shared} ? 1 : 0,
content => PVE::Storage::Plugin::content_hash_to_string($ids->{$storeid}->{content}), content => PVE::Storage::Plugin::content_hash_to_string($ids->{$storeid}->{content}),
active => 0, active => 0,
@ -833,9 +833,9 @@ sub storage_info {
eval { ($total, $avail, $used, $active) = $plugin->status($storeid, $scfg, $cache); }; eval { ($total, $avail, $used, $active) = $plugin->status($storeid, $scfg, $cache); };
warn $@ if $@; warn $@ if $@;
next if !$active; next if !$active;
$info->{$storeid}->{total} = $total; $info->{$storeid}->{total} = $total;
$info->{$storeid}->{avail} = $avail; $info->{$storeid}->{avail} = $avail;
$info->{$storeid}->{used} = $used; $info->{$storeid}->{used} = $used;
$info->{$storeid}->{active} = $active; $info->{$storeid}->{active} = $active;
} }
@ -844,7 +844,7 @@ sub storage_info {
sub resolv_server { sub resolv_server {
my ($server) = @_; my ($server) = @_;
my $packed_ip = gethostbyname($server); my $packed_ip = gethostbyname($server);
if (defined $packed_ip) { if (defined $packed_ip) {
return inet_ntoa($packed_ip); return inet_ntoa($packed_ip);
@ -922,7 +922,7 @@ sub __scan_usb_device {
my $product = file_read_firstline("$devpath/product"); my $product = file_read_firstline("$devpath/product");
$d->{product} = $product if $product; $d->{product} = $product if $product;
my $manu = file_read_firstline("$devpath/manufacturer"); my $manu = file_read_firstline("$devpath/manufacturer");
$d->{manufacturer} = $manu if $manu; $d->{manufacturer} = $manu if $manu;

View File

@ -14,9 +14,9 @@ use base qw(PVE::Storage::Plugin);
# Glusterfs helper functions # Glusterfs helper functions
sub read_proc_mounts { sub read_proc_mounts {
local $/; # enable slurp mode local $/; # enable slurp mode
my $data = ""; my $data = "";
if (my $fd = IO::File->new("/proc/mounts", "r")) { if (my $fd = IO::File->new("/proc/mounts", "r")) {
$data = <$fd>; $data = <$fd>;
@ -35,7 +35,7 @@ sub glusterfs_is_mounted {
if ($mountdata =~ m|^$source/?\s$mountpoint\sfuse.glusterfs|m) { if ($mountdata =~ m|^$source/?\s$mountpoint\sfuse.glusterfs|m) {
return $mountpoint; return $mountpoint;
} }
return undef; return undef;
} }
@ -62,7 +62,7 @@ sub plugindata {
{ images => 1 }], { images => 1 }],
format => [ { raw => 1, qcow2 => 1, vmdk => 1 } , 'raw' ], format => [ { raw => 1, qcow2 => 1, vmdk => 1 } , 'raw' ],
}; };
} }
sub properties { sub properties {
return { return {
@ -127,7 +127,7 @@ sub status {
my $volume = $scfg->{volume}; my $volume = $scfg->{volume};
return undef if !glusterfs_is_mounted($server, $volume, $path, $cache->{mountdata}); return undef if !glusterfs_is_mounted($server, $volume, $path, $cache->{mountdata});
return $class->SUPER::status($storeid, $scfg, $cache); return $class->SUPER::status($storeid, $scfg, $cache);
} }
@ -141,8 +141,8 @@ sub activate_storage {
my $server = $scfg->{server} ? $scfg->{server} : 'localhost'; my $server = $scfg->{server} ? $scfg->{server} : 'localhost';
my $volume = $scfg->{volume}; my $volume = $scfg->{volume};
if (!glusterfs_is_mounted($server, $volume, $path, $cache->{mountdata})) { if (!glusterfs_is_mounted($server, $volume, $path, $cache->{mountdata})) {
mkpath $path; mkpath $path;
die "unable to activate storage '$storeid' - " . die "unable to activate storage '$storeid' - " .
@ -163,9 +163,9 @@ sub deactivate_storage {
my $server = $scfg->{server} ? $scfg->{server} : 'localhost'; my $server = $scfg->{server} ? $scfg->{server} : 'localhost';
my $volume = $scfg->{volume}; my $volume = $scfg->{volume};
if (glusterfs_is_mounted($server, $volume, $path, $cache->{mountdata})) { if (glusterfs_is_mounted($server, $volume, $path, $cache->{mountdata})) {
my $cmd = ['/bin/umount', $path]; my $cmd = ['/bin/umount', $path];
run_command($cmd, errmsg => 'umount error'); run_command($cmd, errmsg => 'umount error');
} }
} }

View File

@ -421,7 +421,7 @@ sub create_base {
# this only works for file based storage types # this only works for file based storage types
die "storage definintion has no path\n" if !$scfg->{path}; die "storage definintion has no path\n" if !$scfg->{path};
my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) = my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
$class->parse_volname($volname); $class->parse_volname($volname);
die "create_base on wrong vtype '$vtype'\n" if $vtype ne 'images'; die "create_base on wrong vtype '$vtype'\n" if $vtype ne 'images';
@ -446,7 +446,7 @@ sub create_base {
die "file '$newpath' already exists\n" if -f $newpath; die "file '$newpath' already exists\n" if -f $newpath;
rename($path, $newpath) || rename($path, $newpath) ||
die "rename '$path' to '$newpath' failed - $!\n"; die "rename '$path' to '$newpath' failed - $!\n";
# We try to protect base volume # We try to protect base volume
@ -456,7 +456,7 @@ sub create_base {
# also try to set immutable flag # also try to set immutable flag
eval { run_command(['/usr/bin/chattr', '+i', $newpath]); }; eval { run_command(['/usr/bin/chattr', '+i', $newpath]); };
warn $@ if $@; warn $@ if $@;
return $newvolname; return $newvolname;
} }
@ -464,10 +464,10 @@ my $find_free_diskname = sub {
my ($imgdir, $vmid, $fmt) = @_; my ($imgdir, $vmid, $fmt) = @_;
my $disk_ids = {}; my $disk_ids = {};
PVE::Tools::dir_glob_foreach($imgdir, PVE::Tools::dir_glob_foreach($imgdir,
qr!(vm|base)-$vmid-disk-(\d+)\..*!, qr!(vm|base)-$vmid-disk-(\d+)\..*!,
sub { sub {
my ($fn, $type, $disk) = @_; my ($fn, $type, $disk) = @_;
$disk_ids->{$disk} = 1; $disk_ids->{$disk} = 1;
}); });
@ -486,7 +486,7 @@ sub clone_image {
# this only works for file based storage types # this only works for file based storage types
die "storage definintion has no path\n" if !$scfg->{path}; die "storage definintion has no path\n" if !$scfg->{path};
my ($vtype, $basename, $basevmid, undef, undef, $isBase) = my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
$class->parse_volname($volname); $class->parse_volname($volname);
die "clone_image on wrong vtype '$vtype'\n" if $vtype ne 'images'; die "clone_image on wrong vtype '$vtype'\n" if $vtype ne 'images';
@ -506,13 +506,13 @@ sub clone_image {
my $path = $class->path($scfg, $newvol); my $path = $class->path($scfg, $newvol);
# Note: we use relative paths, so we need to call chdir before qemu-img # Note: we use relative paths, so we need to call chdir before qemu-img
eval { eval {
local $CWD = $imagedir; local $CWD = $imagedir;
my $cmd = ['/usr/bin/qemu-img', 'create', '-b', "../$basevmid/$basename", my $cmd = ['/usr/bin/qemu-img', 'create', '-b', "../$basevmid/$basename",
'-f', 'qcow2', $path]; '-f', 'qcow2', $path];
run_command($cmd); run_command($cmd);
}; };
my $err = $@; my $err = $@;
@ -531,7 +531,7 @@ sub alloc_image {
mkpath $imagedir; mkpath $imagedir;
$name = &$find_free_diskname($imagedir, $vmid, $fmt) if !$name; $name = &$find_free_diskname($imagedir, $vmid, $fmt) if !$name;
my (undef, $tmpfmt) = parse_name_dir($name); my (undef, $tmpfmt) = parse_name_dir($name);
die "illegal name '$name' - wrong extension for format ('$tmpfmt != '$fmt')\n" die "illegal name '$name' - wrong extension for format ('$tmpfmt != '$fmt')\n"
@ -745,7 +745,7 @@ sub list_images {
push @$res, { push @$res, {
volid => $volid, format => $format, volid => $volid, format => $format,
size => $size, vmid => $owner, used => $used, parent => $parent size => $size, vmid => $owner, used => $used, parent => $parent
}; };
} }