class Havox::ModifiedPolicy

Attributes

path[R]

Public Class Methods

new(topology_file_path, policy_file_path) click to toggle source
# File lib/havox/classes/modified_policy.rb, line 5
def initialize(topology_file_path, policy_file_path)
  @topology_file_path = topology_file_path
  @original_policy_file_path = policy_file_path
  @hosts = parsed_hosts
  @path = nil
  append_basic_policies
end

Private Instance Methods

append_basic_policies() click to toggle source
# File lib/havox/classes/modified_policy.rb, line 29
def append_basic_policies
  policy_file_string = File.read(@original_policy_file_path)
  basename = File.basename(@original_policy_file_path, '.mln')
  Tempfile.open([basename, '.mln']) do |tmp|
    tmp.puts "#{policy_file_string}\n"
    tmp.puts policies.join("\n")
    @path = tmp.path
  end
end
arp_policy() click to toggle source
# File lib/havox/classes/modified_policy.rb, line 15
def arp_policy
  Havox::DSL::Directive.new(nil, nil, ethernet_type: 2054).
    to_block(@hosts, @hosts, 'min(100 Mbps)')
end
icmp_policy() click to toggle source
# File lib/havox/classes/modified_policy.rb, line 20
def icmp_policy
  Havox::DSL::Directive.new(nil, nil, ethernet_type: 2048, ip_protocol: 1).
    to_block(@hosts, @hosts, 'min(100 Mbps)')
end
parsed_hosts() click to toggle source
# File lib/havox/classes/modified_policy.rb, line 39
def parsed_hosts
  topology = Havox::Topology.new(@topology_file_path)
  topology.host_names
end
policies() click to toggle source
# File lib/havox/classes/modified_policy.rb, line 25
def policies
  [icmp_policy, arp_policy]
end