Class: OsCtld::Commands::NetInterface::RouteDel

Inherits:
Logged
  • Object
show all
Includes:
OsCtl::Lib::Utils::Log, OsCtl::Lib::Utils::System, Utils::SwitchUser
Defined in:
lib/osctld/commands/net_interface/route_del.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_control, #ct_exec, #ct_runscript, #ct_syscmd, #init_script, #unlink_file

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(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
# File 'lib/osctld/commands/net_interface/route_del.rb', line 16

def execute(ct)
  netif = ct.netifs[opts[:name]]
  netif || error!('network interface not found')
  netif.type == :routed || error!('not a routed interface')

  manipulate(ct) do
    if opts[:addr] == 'all'
      netif.del_all_routes(opts[:version] && opts[:version].to_i)

    else
      addr = IPAddress.parse(opts[:addr])

      error!('route not found') unless netif.has_route?(addr)
      netif.del_route(addr)
    end

    ct.save_config
    ct.lxc_config.configure_network

    DistConfig.run(ct, :network) if ct.can_dist_configure_network?
  end

  ok
end

#findObject



11
12
13
14
# File 'lib/osctld/commands/net_interface/route_del.rb', line 11

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