class Wire::Resource::OVSBridge

Open vSwitch Bridge resource

Attributes

executables[RW]

type of bridge (here: ovs) executables [Hash] of binaries needed to control the resource

type[RW]

type of bridge (here: ovs) executables [Hash] of binaries needed to control the resource

Public Class Methods

new(name) click to toggle source

initialize the bridge object with given name and type params:

  • name bridge name, i.e. “br0”

Calls superclass method
# File lib/wire/resource/bridge.rb, line 24
def initialize(name)
  super(name)

  # TODO: make configurable
  @executables = {
    :vsctl => '/usr/bin/ovs-vsctl'
  }
end

Public Instance Methods

down() click to toggle source

deletes the bridge (ovs-vsctl del-br)

# File lib/wire/resource/bridge.rb, line 64
def down
  LocalExecution.with(@executables[:vsctl],
                      ['del-br', @name]) do |down_exec_obj|
    down_exec_obj.run
    return (down_exec_obj.exitstatus == 0)
  end
end
down?() click to toggle source

checks if the bridge is down

# File lib/wire/resource/bridge.rb, line 59
def down?
  !(up?)
end
exist?() click to toggle source

TODO: move to generic execution method codeclimate.com/github/de-wiring/wire/Wire::Resource::OVSBridge checks if the bridge exists

# File lib/wire/resource/bridge.rb, line 36
def exist?
  LocalExecution.with(@executables[:vsctl],
                      ['br-exists', @name]) do |exec_obj|
    exec_obj.run
    return (exec_obj.exitstatus != 2)
  end
end
to_s() click to toggle source

Returns a string representation

# File lib/wire/resource/bridge.rb, line 73
def to_s
  "Bridge:[#{name},type=#{type}]"
end
up() click to toggle source

adds the bridge (ovs-vsctl add-br)

# File lib/wire/resource/bridge.rb, line 50
def up
  LocalExecution.with(@executables[:vsctl],
                      ['add-br', @name]) do |up_exec_obj|
    up_exec_obj.run
    return (up_exec_obj.exitstatus == 0)
  end
end
up?() click to toggle source

checks if the bridge exists

# File lib/wire/resource/bridge.rb, line 45
def up?
  exist?
end