Class: OsCtld::Container::Recovery::RouteList
- Inherits:
-
Object
- Object
- OsCtld::Container::Recovery::RouteList
- Includes:
- OsCtl::Lib::Utils::Log, OsCtl::Lib::Utils::System
- Defined in:
- lib/osctld/container/recovery.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
protected
Returns the value of attribute index.
Instance Method Summary collapse
-
#initialize(ip_v) ⇒ RouteList
constructor
A new instance of RouteList.
- #key(route) ⇒ Object protected
- #veth_of(route) ⇒ Object
Constructor Details
#initialize(ip_v) ⇒ RouteList
Returns a new instance of RouteList.
231 232 233 234 235 236 237 238 239 |
# File 'lib/osctld/container/recovery.rb', line 231 def initialize(ip_v) @index = {} JSON.parse(syscmd_argv(['ip', "-#{ip_v}", '-json', 'route', 'list']).output).each do |route| next unless route['dev'].start_with?('veth') index[route['dst']] = route['dev'] end end |
Instance Attribute Details
#index ⇒ Object (readonly, protected)
Returns the value of attribute index.
248 249 250 |
# File 'lib/osctld/container/recovery.rb', line 248 def index @index end |
Instance Method Details
#key(route) ⇒ Object (protected)
250 251 252 253 254 255 256 257 |
# File 'lib/osctld/container/recovery.rb', line 250 def key(route) if (route.addr.ipv4? && route.addr.prefix == 32) \ || (route.addr.ipv6? && route.addr.prefix == 128) route.addr.to_s else route.addr.to_string end end |
#veth_of(route) ⇒ Object
242 243 244 |
# File 'lib/osctld/container/recovery.rb', line 242 def veth_of(route) index[key(route)] end |