Class: OsCtld::Commands::User::Delete

Inherits:
Logged
  • Object
show all
Includes:
OsCtl::Lib::Utils::Log, OsCtl::Lib::Utils::System
Defined in:
lib/osctld/commands/user/delete.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #client_handler, #id, #opts

Instance Method Summary collapse

Methods inherited from Logged

#base_execute

Methods inherited from Base

#base_execute, #call_cmd, #call_cmd!, 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

#execute(u) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/osctld/commands/user/delete.rb', line 15

def execute(u)
  error!('user has container(s)') if u.has_containers?

  manipulate(u) do
    UserControl::Supervisor.stop_server(u)

    # Double-check user's containers, for only within the lock
    # can we be sure
    error!('user has container(s)') if u.has_containers?

    call_cmd!(Commands::User::Unregister, name: u.name, pool: u.pool.name)

    zfs(:destroy, nil, u.dataset)
    File.unlink(u.config_path)

    DB::Users.remove(u)
    call_cmd(Commands::User::SubUGIds)
  end

  ok
end

#findObject



10
11
12
13
# File 'lib/osctld/commands/user/delete.rb', line 10

def find
  u = DB::Users.find(opts[:name], opts[:pool])
  u || error!('user not found')
end