Class: Wire::Resource::OVSBridge
- Inherits:
-
ResourceBase
- Object
- ResourceBase
- Wire::Resource::OVSBridge
- Defined in:
- lib/wire/resource/bridge.rb
Overview
Open vSwitch Bridge resource
Instance Attribute Summary collapse
-
#executables ⇒ Object
typeof bridge (here: ovs)executables[Hash] of binaries needed to control the resource. -
#type ⇒ Object
typeof bridge (here: ovs)executables[Hash] of binaries needed to control the resource.
Attributes inherited from ResourceBase
Instance Method Summary collapse
-
#down ⇒ Object
deletes the bridge (ovs-vsctl del-br).
-
#down? ⇒ Boolean
checks if the bridge is down.
-
#exist? ⇒ Boolean
TODO: move to generic execution method codeclimate.com/github/de-wiring/wire/Wire::Resource::OVSBridge checks if the bridge exists.
-
#initialize(name) ⇒ OVSBridge
constructor
initialize the bridge object with given
nameand type params: - name bridge name, i.e. -
#to_s ⇒ Object
Returns a string representation.
-
#up ⇒ Object
adds the bridge (ovs-vsctl add-br).
-
#up? ⇒ Boolean
checks if the bridge exists.
Constructor Details
#initialize(name) ⇒ OVSBridge
initialize the bridge object with given name and type params:
-
name bridge name, i.e. “br0”
24 25 26 27 28 29 30 31 |
# File 'lib/wire/resource/bridge.rb', line 24 def initialize(name) super(name) # TODO: make configurable @executables = { :vsctl => '/usr/bin/ovs-vsctl' } end |
Instance Attribute Details
#executables ⇒ Object
type of bridge (here: ovs) executables [Hash] of binaries needed to control the resource
18 19 20 |
# File 'lib/wire/resource/bridge.rb', line 18 def executables @executables end |
#type ⇒ Object
type of bridge (here: ovs) executables [Hash] of binaries needed to control the resource
18 19 20 |
# File 'lib/wire/resource/bridge.rb', line 18 def type @type end |
Instance Method Details
#down ⇒ Object
deletes the bridge (ovs-vsctl del-br)
64 65 66 67 68 69 70 |
# 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? ⇒ Boolean
checks if the bridge is down
59 60 61 |
# File 'lib/wire/resource/bridge.rb', line 59 def down? !(up?) end |
#exist? ⇒ Boolean
TODO: move to generic execution method codeclimate.com/github/de-wiring/wire/Wire::Resource::OVSBridge checks if the bridge exists
36 37 38 39 40 41 42 |
# 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 ⇒ Object
Returns a string representation
73 74 75 |
# File 'lib/wire/resource/bridge.rb', line 73 def to_s "Bridge:[#{name},type=#{type}]" end |
#up ⇒ Object
adds the bridge (ovs-vsctl add-br)
50 51 52 53 54 55 56 |
# 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? ⇒ Boolean
checks if the bridge exists
45 46 47 |
# File 'lib/wire/resource/bridge.rb', line 45 def up? exist? end |