Class: Inspec::Resources::Bridge

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/resources/bridge.rb

Instance Method Summary collapse

Constructor Details

#initialize(bridge_name) ⇒ Bridge

Returns a new instance of Bridge.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/inspec/resources/bridge.rb', line 21

def initialize(bridge_name)
  @bridge_name = bridge_name

  @bridge_provider = nil
  if inspec.os.linux?
    @bridge_provider = LinuxBridge.new(inspec)
  elsif inspec.os.windows?
    @bridge_provider = WindowsBridge.new(inspec)
  else
    skip_resource "The `bridge` resource is not supported on your OS yet."
  end
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/inspec/resources/bridge.rb', line 34

def exists?
  !bridge_info.nil? && !bridge_info[:name].nil?
end

#has_interface?(interface) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/inspec/resources/bridge.rb', line 38

def has_interface?(interface)
  return skip_resource "The `bridge` resource does not provide interface detection for Windows yet" if inspec.os.windows?

  bridge_info.nil? ? false : bridge_info[:interfaces].include?(interface)
end

#interfacesObject



44
45
46
# File 'lib/inspec/resources/bridge.rb', line 44

def interfaces
  bridge_info.nil? ? nil : bridge_info[:interfaces]
end

#resource_idObject



48
49
50
# File 'lib/inspec/resources/bridge.rb', line 48

def resource_id
  @bridge_name || "bridge"
end

#to_sObject



52
53
54
# File 'lib/inspec/resources/bridge.rb', line 52

def to_s
  "Bridge #{@bridge_name}"
end