]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/API2/Disks/ZFS.pm
rename check_available to assert_sid_unused
[pve-storage.git] / PVE / API2 / Disks / ZFS.pm
index 1690768168684eb74df572411f9ae2f4466ab857..f187eb2dec8f3a018ff2784fbe27031444688f75 100644 (file)
@@ -141,7 +141,65 @@ __PACKAGE__->register_method ({
        },
     },
     returns => {
-       type => 'object'
+       type => 'object',
+       properties => {
+           name => {
+               type => 'string',
+               description => 'The name of the zpool.',
+           },
+           state => {
+               type => 'string',
+               description => 'The state of the zpool.',
+           },
+           status => {
+               optional => 1,
+               type => 'string',
+               description => 'Information about the state of the zpool.',
+           },
+           action => {
+               optional => 1,
+               type => 'string',
+               description => 'Information about the recommended action to fix the state.',
+           },
+           scan => {
+               type => 'string',
+               description => 'Information about the last/current scrub.',
+           },
+           scan => {
+               type => 'string',
+               description => 'Information about the errors on the zpool.',
+           },
+           children => {
+               type => 'array',
+               description => "The tree of the vdevs. Depending on the configuration of the zpool, they can be nested.",
+               items => {
+                   type => 'object',
+                   properties => {
+                       name => {
+                           type => 'string',
+                           description => 'The name of the vdev.',
+                       },
+                       state => {
+                           type => 'string',
+                           description => 'The state of the vdev.',
+                       },
+                       read => {
+                           type => 'number',
+                       },
+                       write => {
+                           type => 'number',
+                       },
+                       cksum => {
+                           type => 'number',
+                       },
+                       msg => {
+                           type => 'string',
+                           description => 'An optional message about the vdev.'
+                       }
+                   },
+               },
+           },
+       },
     },
     code => sub {
        my ($param) = @_;
@@ -283,14 +341,10 @@ __PACKAGE__->register_method ({
 
        foreach my $dev (@$devs) {
            $dev = PVE::Diskmanage::verify_blockdev_path($dev);
-           die "device $dev is already in use\n" if PVE::Diskmanage::disk_is_used($dev);
+           PVE::Diskmanage::check_unused($dev);
        }
 
-       my $cfg = PVE::Storage::config();
-
-       if (my $scfg = PVE::Storage::storage_config($cfg, $name, 1)) {
-           die "storage ID '$name' already defined\n";
-       }
+       PVE::Storage::assert_sid_unused($name) if $param->{add_storage};
 
        my $numdisks = scalar(@$devs);
        my $mindisks = {