Class: Phut::Configuration

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/phut/configuration.rb

Overview

Parsed DSL data.

Instance Method Summary collapse

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

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


25
26
27
# File 'lib/phut/configuration.rb', line 25

def links
  @all.values.select { |each| each.is_a? VirtualLink }
end

#runObject



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

#stopObject



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

#vhostsObject



21
22
23
# File 'lib/phut/configuration.rb', line 21

def vhosts
  @all.values.select { |each| each.is_a? Vhost }
end

#vswitchesObject



17
18
19
# File 'lib/phut/configuration.rb', line 17

def vswitches
  @all.values.select { |each| each.is_a? OpenVswitch }
end