Class: OsCtld::Commands::Container::Restart

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

Instance Attribute Summary

Attributes inherited from Base

#client, #client_handler, #id, #opts

Instance Method Summary collapse

Methods included from Utils::SwitchUser

#ct_attach, #ct_syscmd

Methods inherited from Logged

#base_execute

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

#execute(ct) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/osctld/commands/container/restart.rb', line 16

def execute(ct)
  manipulate(ct) do
    if opts[:reboot]
      begin
        ContainerControl::Commands::Reboot.run!(ct)
        ok
      rescue ContainerControl::Error => e
        error!(e.message)
      end

    else
      call_cmd!(
        Commands::Container::Stop,
        pool: ct.pool.name,
        id: ct.id,
        timeout: opts[:stop_timeout],
        method: opts[:stop_method],
        message: opts[:message]
      )
      call_cmd!(
        Commands::Container::Start,
        pool: ct.pool.name,
        id: ct.id,
        force: true,
        wait: opts[:wait]
      )
    end
  end
end

#findObject



11
12
13
14
# File 'lib/osctld/commands/container/restart.rb', line 11

def find
  ct = DB::Containers.find(opts[:id], opts[:pool])
  ct || error!('container not found')
end