Class: OsCtld::Commands::NetInterface::IpList
- Defined in:
- lib/osctld/commands/net_interface/ip_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)
| 54 55 56 57 58 59 60 61 62 | # File 'lib/osctld/commands/net_interface/ip_list.rb', line 54 def add_netif(ct, netif) { :pool => ct.pool.name, :ctid => ct.id, :netif => netif.name, 4 => netif.ips(4).map(&:to_string), 6 => netif.ips(6).map(&:to_string) } end | 
#execute ⇒ Object
| 7 8 9 10 11 | # File 'lib/osctld/commands/net_interface/ip_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 | # File 'lib/osctld/commands/net_interface/ip_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[opts[:name]] netif || error!('network interface not found') ret << [ct, netif] else ct.netifs.each { |netif| ret << [ct, netif] } end end elsif opts[:pool] DB::Container.get.each do |ct| next if ct.pool.name != opts[:pool] ct.inclusively do ct.netifs.each { |netif| ret << [ct, netif] } end end else DB::Containers.get.map do |ct| ct.inclusively do ct.netifs.each { |netif| ret << [ct, netif] } end end end ret end |