Class: Inspec::Resources::LinuxBridge

Inherits:
BridgeDetection show all
Defined in:
lib/inspec/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 Inspec::Resources::BridgeDetection

Instance Method Details

#bridge_info(bridge_name) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/inspec/resources/bridge.rb', line 74

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