Class: Phut::Configuration
- Inherits:
-
Object
- Object
- Phut::Configuration
- Defined in:
- lib/phut/configuration.rb
Overview
Parsed DSL data.
Instance Method Summary collapse
-
#fetch(key) ⇒ Object
rubocop:disable MethodLength.
-
#initialize(&block) ⇒ Configuration
constructor
A new instance of Configuration.
- #run ⇒ Object
- #stop ⇒ Object
-
#update_connections ⇒ Object
rubocop:enable MethodLength.
Constructor Details
#initialize(&block) ⇒ Configuration
7 8 9 10 11 12 13 |
# File 'lib/phut/configuration.rb', line 7 def initialize(&block) OpenVswitch.all.clear Vhost.all.clear Netns.all.clear VirtualLink.all.clear block.call self end |
Instance Method Details
#fetch(key) ⇒ Object
rubocop:disable MethodLength
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/phut/configuration.rb', line 16 def fetch(key) case key when String [OpenVswitch, Vhost, Netns].each do |each| found = each.find_by(name: key) return found if found end fail "Invalid key: #{key.inspect}" when Array VirtualLink.each do |each| return each if [each.name_a, each.name_b].sort == key.sort end fail "link #{key.join ' '} not found." else fail "Invalid key: #{key.inspect}" end end |
#run ⇒ Object
42 43 44 45 46 |
# File 'lib/phut/configuration.rb', line 42 def run [VirtualLink, Vhost, Netns, OpenVswitch].each do |klass| klass.each(&:run) end end |
#stop ⇒ Object
48 49 50 51 52 |
# File 'lib/phut/configuration.rb', line 48 def stop [OpenVswitch, Vhost, Netns, VirtualLink].each do |klass| klass.each(&:stop) end end |
#update_connections ⇒ Object
rubocop:enable MethodLength
35 36 37 38 39 40 |
# File 'lib/phut/configuration.rb', line 35 def update_connections update_vswitch_ports update_vhost_interfaces update_netns_interfaces self end |