Module: Havox::Network

Defined in:
lib/havox/exceptions.rb,
lib/havox/dsl/network.rb

Defined Under Namespace

Classes: InvalidTopology

Class Method Summary collapse

Class Method Details

.define(&block) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/havox/dsl/network.rb', line 14

def self.define(&block)
  reset!
  directive_proxy = Havox::DSL::DirectiveProxy.new
  directive_proxy.instance_eval(&block)
  @rib = Havox::RIB.new
  infer_associations_by_ospf
end

.devicesObject



10
# File 'lib/havox/dsl/network.rb', line 10

def self.devices; @devices end

.directivesObject



8
# File 'lib/havox/dsl/network.rb', line 8

def self.directives; @directives end

.reachable(protocol = :bgp) ⇒ Object



30
31
32
# File 'lib/havox/dsl/network.rb', line 30

def self.reachable(protocol = :bgp)
  @rib.nil? ? [] : @rib.network_list(protocol)
end

.reset!Object



34
35
36
37
38
39
# File 'lib/havox/dsl/network.rb', line 34

def self.reset!
  @directives = []
  @devices    = {}
  @rib        = nil
  @topology   = nil
end

.ribObject



9
# File 'lib/havox/dsl/network.rb', line 9

def self.rib; @rib end

.topologyObject



11
# File 'lib/havox/dsl/network.rb', line 11

def self.topology; @topology end

.topology=(topo) ⇒ Object



12
# File 'lib/havox/dsl/network.rb', line 12

def self.topology=(topo); @topology = topo end

.transcompile(opts = {}) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/havox/dsl/network.rb', line 22

def self.transcompile(opts = {})
  @directives.map do |d|
    src_hosts = @topology.host_names - @topology.switch_hosts[d.switch.to_s]
    dst_hosts = @topology.switch_hosts[d.switch.to_s]
    d.to_block(src_hosts, dst_hosts, opts[:qos])
  end
end