<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Hi,</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">AFAIK having a setting to control wether auto-import of pool is desirable would be a plus. As in some situations the import/export of the pool is controlled by any other means, and an accidental pool of the pool may be a destructive action (ie. when the pool maybe from a shared medium like iscsi, and thus should not be mounted by two nodes at the same time).</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Regards</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 12, 2015 at 8:27 PM, Adrian Costin <span dir="ltr"><<a href="mailto:adrian@goat.fish" target="_blank">adrian@goat.fish</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">- Moved the zpool_import method of zfs_request() to it's own pool_request function<br>
- activate_storage() is now using "zfs list" to check if the zpool is imported<br>
- pool import only the configured pool, not all the accessible pools<br>
<br>
Signed-off-by: Adrian Costin <adrian@goat.fish><br>
---<br>
 PVE/Storage/ZFSPoolPlugin.pm | 39 +++++++++++++++++++++++++++------------<br>
 1 file changed, 27 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm<br>
index 5cbd1b2..3fc2978 100644<br>
--- a/PVE/Storage/ZFSPoolPlugin.pm<br>
+++ b/PVE/Storage/ZFSPoolPlugin.pm<br>
@@ -149,16 +149,27 @@ sub zfs_request {<br>
<br>
     $timeout = 5 if !$timeout;<br>
<br>
-    my $cmd = [];<br>
+    my $cmd = ['zfs', $method, @params];<br>
<br>
-    if ($method eq 'zpool_list') {<br>
-       push @$cmd, 'zpool', 'list';<br>
-    } else {<br>
-       push @$cmd, 'zfs', $method;<br>
-    }<br>
+    my $msg = '';<br>
+<br>
+    my $output = sub {<br>
+        my $line = shift;<br>
+        $msg .= "$line\n";<br>
+    };<br>
+<br>
+    run_command($cmd, outfunc => $output, timeout => $timeout);<br>
+<br>
+    return $msg;<br>
+}<br>
+<br>
+sub zpool_request {<br>
+    my ($class, $scfg, $timeout, $method, @params) = @_;<br>
+<br>
+    $timeout = 5 if !$timeout;<br>
+<br>
+    my $cmd = ['zpool', $method, @params];<br>
<br>
-    push @$cmd, @params;<br>
-<br>
     my $msg = '';<br>
<br>
     my $output = sub {<br>
@@ -428,12 +439,16 @@ sub volume_rollback_is_possible {<br>
 sub activate_storage {<br>
     my ($class, $storeid, $scfg, $cache) = @_;<br>
<br>
-    my @param = ('-o', 'name', '-H');<br>
+    my @param = ('-o', 'name', '-H', $scfg->{'pool'});<br>
+<br>
+    my $text = zfs_request($class, $scfg, undef, 'list', @param);<br>
<br>
-    my $text = zfs_request($class, $scfg, undef, 'zpool_list', @param);<br>
-<br>
     if ($text !~ $scfg->{pool}) {<br>
-       run_command("zpool import -d /dev/disk/by-id/ -a");<br>
+       my ($pool_name) = $scfg->{pool} =~ /([^\/]+)/;<br>
+<br>
+       my @import_params = ('-d', '/dev/disk/by-id/', $pool_name);<br>
+<br>
+       zpool_request($class, $scfg, undef, 'import', @import_params);<br>
     }<br>
     return 1;<br>
 }<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.3 (Apple Git-50)<br>
<br>
_______________________________________________<br>
pve-devel mailing list<br>
<a href="mailto:pve-devel@pve.proxmox.com">pve-devel@pve.proxmox.com</a><br>
<a href="http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel" target="_blank">http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel</a><br>
</font></span></blockquote></div><br></div>