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.
167 168 169 170 171 172 173 174 175 |
# File 'lib/osctld/container/recovery.rb', line 167 def initialize(ip_v) @index = {} JSON.parse(syscmd("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.
184 185 186 |
# File 'lib/osctld/container/recovery.rb', line 184 def index @index end |
Instance Method Details
#key(route) ⇒ Object (protected)
186 187 188 189 190 191 192 193 |
# File 'lib/osctld/container/recovery.rb', line 186 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
178 179 180 |
# File 'lib/osctld/container/recovery.rb', line 178 def veth_of(route) index[key(route)] end |