Class: Bifrossht::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/bifrossht/connection.rb,
lib/bifrossht/connection/base.rb,
lib/bifrossht/connection/exec.rb

Defined Under Namespace

Classes: Base, Exec

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connectionsObject (readonly)

Returns the value of attribute connections.



9
10
11
# File 'lib/bifrossht/connection.rb', line 9

def connections
  @connections
end

Class Method Details

.connection(hop) ⇒ Object



44
45
46
# File 'lib/bifrossht/connection.rb', line 44

def connection(hop)
  @connections[hop]
end

.find(target) ⇒ Object



22
23
24
25
26
27
# File 'lib/bifrossht/connection.rb', line 22

def find(target)
  c = match(target)
  return c unless c.nil?

  probe(target)
end

.match(target) ⇒ Object



29
30
31
32
33
# File 'lib/bifrossht/connection.rb', line 29

def match(target)
  connections.values.select do |c|
    c.match(target)
  end.first
end

.probe(target) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/bifrossht/connection.rb', line 35

def probe(target)
  connections.values.reject(&:skip_probe).each do |c|
    Logger.debug("probing #{c.name}...")
    return c if c.probe(target)
  end

  nil
end

.register_connection(config) ⇒ Object



15
16
17
18
19
20
# File 'lib/bifrossht/connection.rb', line 15

def register_connection(config)
  @connections ||= {}

  klass = build_class_name(config.type)
  @connections[config.name] = klass.new(config)
end

.register_connections(connections = []) ⇒ Object



11
12
13
# File 'lib/bifrossht/connection.rb', line 11

def register_connections(connections = [])
  connections.each { |c| register_connection(c) }
end