Sha256: bb715855cb733fcbb3d6715890c1c85ca89a7f1b9f18e7b07593a7bf3b472f70
Contents?: true
Size: 959 Bytes
Versions: 2
Compression:
Stored size: 959 Bytes
Contents
require 'oscar' require 'ipaddress' class Oscar::Networking def initialize(yaml_config) range = yaml_config["pool"] @domainname = yaml_config["domainname"] @network = IPAddress.parse(range) @pool = [] @nodes = {} @network.each_host { |h| @pool << h } @iterator = @pool.each end def register(node) next_addr = @iterator.next.to_s node.networking = self node.address = next_addr @nodes[next_addr] = node end def hosts_for(node) arr = [] arr << ['127.0.0.1', ['localhost']] arr << ['127.0.1.1', [node.name, "#{node.name}.#{@domainname}"]] arr << ['::1', %w{ip6-localhost ip6-loopback}] arr << ['fe00::0', ['ip6-localnet']] arr << ['ff00::0', ['ip6-mcastprefix']] arr << ['ff02::1', ['ip6-allnodes']] arr << ['ff02::2', ['ip6-allrouters']] @nodes.each_pair { |address, n| arr << [address, [n.name, "#{n.name}.#{@domainname}"]] } arr end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
oscar-0.2.0alpha2 | lib/oscar/networking.rb |
oscar-0.2.0alpha1 | lib/oscar/networking.rb |