Class: Phut::Configuration
- Inherits:
-
Object
- Object
- Phut::Configuration
- Extended by:
- Forwardable
- Defined in:
- lib/phut/configuration.rb
Overview
Parsed DSL data.
Instance Method Summary collapse
-
#add_link(name_a, device_a, name_b, device_b) ⇒ Object
This method smells of :reek:LongParameterList.
- #add_vhost(name, attrs) ⇒ Object
- #add_vswitch(name, attrs) ⇒ Object
-
#initialize(logger = NullLogger.new) ⇒ Configuration
constructor
A new instance of Configuration.
- #links ⇒ Object
- #run ⇒ Object
- #stop ⇒ Object
- #vhosts ⇒ Object
- #vswitches ⇒ Object
Constructor Details
#initialize(logger = NullLogger.new) ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 |
# File 'lib/phut/configuration.rb', line 12 def initialize(logger = NullLogger.new) @all = {} @logger = logger end |
Instance Method Details
#add_link(name_a, device_a, name_b, device_b) ⇒ Object
This method smells of :reek:LongParameterList
52 53 54 55 |
# File 'lib/phut/configuration.rb', line 52 def add_link(name_a, device_a, name_b, device_b) @all[[name_a, name_b]] = VirtualLink.new(name_a, device_a, name_b, device_b, @logger) end |
#add_vhost(name, attrs) ⇒ Object
46 47 48 49 |
# File 'lib/phut/configuration.rb', line 46 def add_vhost(name, attrs) check_name_conflict name @all[name] = Vhost.new(attrs[:ip], attrs[:promisc], name, @logger) end |
#add_vswitch(name, attrs) ⇒ Object
41 42 43 44 |
# File 'lib/phut/configuration.rb', line 41 def add_vswitch(name, attrs) check_name_conflict name @all[name] = OpenVswitch.new(attrs[:dpid], name, @logger) end |
#links ⇒ Object
25 26 27 |
# File 'lib/phut/configuration.rb', line 25 def links @all.values.select { |each| each.is_a? VirtualLink } end |
#run ⇒ Object
29 30 31 32 33 |
# File 'lib/phut/configuration.rb', line 29 def run links.each(&:run) vswitches.each(&:run) vhosts.each { |each| each.run vhosts } end |
#stop ⇒ Object
35 36 37 38 39 |
# File 'lib/phut/configuration.rb', line 35 def stop vswitches.each(&:maybe_stop) vhosts.each(&:maybe_stop) links.each(&:maybe_stop) end |
#vhosts ⇒ Object
21 22 23 |
# File 'lib/phut/configuration.rb', line 21 def vhosts @all.values.select { |each| each.is_a? Vhost } end |
#vswitches ⇒ Object
17 18 19 |
# File 'lib/phut/configuration.rb', line 17 def vswitches @all.values.select { |each| each.is_a? OpenVswitch } end |