[pve-devel] [PATCH storage 1/5] remove unused method
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Sep 14 16:08:48 CEST 2016
only used by test case, which should use what the rest of
the codebase uses as well
---
PVE/Storage.pm | 21 ---------------------
test/run_test_zfspoolplugin.pl | 21 +++++++++++++++------
2 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 4fcda5a..273d17d 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -341,27 +341,6 @@ sub parse_volume_id {
return PVE::Storage::Plugin::parse_volume_id($volid, $noerr);
}
-sub volume_is_base {
- my ($cfg, $volid) = @_;
-
- my ($sid, $volname) = parse_volume_id($volid, 1);
- return 0 if !$sid;
-
- if (my $scfg = $cfg->{ids}->{$sid}) {
- my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
- my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
- $plugin->parse_volname($volname);
- return $isBase ? 1 : 0;
- } else {
- # stale volid with undefined storage - so we can just guess
- if ($volid =~ m/base-/) {
- return 1;
- }
- }
-
- return 0;
-}
-
# try to map a filesystem path to a volume identifier
sub path_to_volume_id {
my ($cfg, $path) = @_;
diff --git a/test/run_test_zfspoolplugin.pl b/test/run_test_zfspoolplugin.pl
index 2512db9..53d4a15 100755
--- a/test/run_test_zfspoolplugin.pl
+++ b/test/run_test_zfspoolplugin.pl
@@ -818,7 +818,7 @@ my $test10 =sub {
print "\nrun test10 \"volume_is_base\"\n";
eval {
- if (1 == PVE::Storage::volume_is_base($cfg, "$storagename:$vmdisk")) {
+ if (1 == volume_is_base($cfg, "$storagename:$vmdisk")) {
$count++;
warn "Test10 a: is no base";
}
@@ -830,7 +830,7 @@ my $test10 =sub {
}
eval {
- if (0 == PVE::Storage::volume_is_base($cfg, "$storagename:$vmbase")) {
+ if (0 == volume_is_base($cfg, "$storagename:$vmbase")) {
$count++;
warn "Test10 b: is base";
}
@@ -842,7 +842,7 @@ my $test10 =sub {
}
eval {
- if (1 == PVE::Storage::volume_is_base($cfg, "$storagename:$vmbase\/$vmlinked")) {
+ if (1 == volume_is_base($cfg, "$storagename:$vmbase\/$vmlinked")) {
$count++;
warn "Test10 c: is no base";
}
@@ -854,7 +854,7 @@ my $test10 =sub {
}
eval {
- if (1 == PVE::Storage::volume_is_base($cfg, "$storagename:$ctdisk")) {
+ if (1 == volume_is_base($cfg, "$storagename:$ctdisk")) {
$count++;
warn "Test10 d: is no base";
}
@@ -866,7 +866,7 @@ my $test10 =sub {
}
eval {
- if (0 == PVE::Storage::volume_is_base($cfg, "$storagename:$ctbase")) {
+ if (0 == volume_is_base($cfg, "$storagename:$ctbase")) {
$count++;
warn "Test10 e: is base";
}
@@ -878,7 +878,7 @@ my $test10 =sub {
}
eval {
- if (1 == PVE::Storage::volume_is_base($cfg, "$storagename:$ctbase\/$ctlinked")) {
+ if (1 == volume_is_base($cfg, "$storagename:$ctbase\/$ctlinked")) {
$count++;
warn "Test10 f: is no base";
}
@@ -2640,6 +2640,15 @@ sub clean_up_zpool {
unlink 'zpool.img';
}
+sub volume_is_base {
+ my ($cfg, $volid) = @_;
+
+ my (undef, undef, undef, undef, undef, $isBase, undef) = PVE::Storage::parse_volname($cfg, $volid);
+
+ return $isBase;
+}
+
+
setup_zpool();
my $time = time;
--
2.1.4
More information about the pve-devel
mailing list