Class: OsCtld::Commands::TrashBin::DatasetAdd

Inherits:
Base
  • Object
show all
Defined in:
lib/osctld/commands/trash_bin/dataset_add.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #client_handler, #id, #opts

Instance Method Summary collapse

Methods inherited from Base

#base_execute, #call_cmd, #call_cmd!, #error, #error!, handle, #handled, #indirect?, #initialize, #manipulate, #manipulation_holder, #ok, #progress, #request_stop, run, run!

Constructor Details

This class inherits a constructor from OsCtld::Commands::Base

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/osctld/commands/trash_bin/dataset_add.rb', line 8

def execute
  ds = OsCtl::Lib::Zfs::Dataset.new(opts[:dataset])
  error!("#{ds.name} is a pool, provide a dataset") if ds.is_pool?

  pool = DB::Pools.find(ds.pool)
  error!("pool #{ds.pool} not installed in osctld") if pool.nil?

  begin
    pool.trash_bin.add_dataset(ds)
  rescue SystemCommandFailed => e
    error!("unable to add dataset to the trash-bin: #{e.message}")
  end

  ok
end