Class: OsCtld::Commands::NetInterface::RouteList
- Defined in:
- lib/osctld/commands/net_interface/route_list.rb
Instance Attribute Summary
Attributes inherited from Base
#client, #client_handler, #id, #opts
Instance Method Summary collapse
- #add_netif(ct, netif) ⇒ Object protected
- #execute ⇒ Object
- #netifs ⇒ Object protected
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
#add_netif(ct, netif) ⇒ Object (protected)
67 68 69 70 71 72 73 |
# File 'lib/osctld/commands/net_interface/route_list.rb', line 67 def add_netif(ct, netif) netif.routes.export.merge( pool: ct.pool.name, ctid: ct.id, netif: netif.name ) end |
#execute ⇒ Object
7 8 9 10 11 |
# File 'lib/osctld/commands/net_interface/route_list.rb', line 7 def execute ok(netifs.map do |ct, netif| add_netif(ct, netif) end) end |
#netifs ⇒ Object (protected)
15 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/osctld/commands/net_interface/route_list.rb', line 15 def netifs ret = [] if opts[:id] ct = DB::Containers.find(opts[:id], opts[:pool]) ct || error!('container not found') ct.inclusively do if opts[:name] netif = ct.netifs.detect { |n| n.name == opts[:name] } netif || error!('network interface not found') netif.type == :routed || error!('not a routed interface') ret << [ct, netif] else ct.netifs.each do |netif| next if netif.type != :routed ret << [ct, netif] end end end elsif opts[:pool] DB::Container.get.each do |ct| next if ct.pool.name != opts[:pool] ct.inclusively do ct.netifs.each do |netif| next if netif.type != :routed ret << [ct, netif] end end end else DB::Containers.get.map do |ct| ct.inclusively do ct.netifs.each do |netif| next if netif.type != :routed ret << [ct, netif] end end end end ret end |