Class: LinuxBridge

Inherits:
BridgeDetection show all
Defined in:
lib/resources/bridge.rb

Overview

Linux Bridge If /sys/class/net/interface/bridge exists then it must be a bridge /sys/class/net/interface/brif contains the network interfaces

Instance Attribute Summary

Attributes inherited from BridgeDetection

#inspec

Instance Method Summary collapse

Methods inherited from BridgeDetection

#initialize

Constructor Details

This class inherits a constructor from BridgeDetection

Instance Method Details

#bridge_info(bridge_name) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/resources/bridge.rb', line 65

def bridge_info(bridge_name)
  # read bridge information
  bridge = inspec.file("/sys/class/net/#{bridge_name}/bridge").directory?
  return nil unless bridge

  # load interface names
  interfaces = inspec.command("ls -1 /sys/class/net/#{bridge_name}/brif/")
  interfaces = interfaces.stdout.chomp.split("\n")
  {
    name: bridge_name,
    interfaces: interfaces,
  }
end