Sha256: 567f8ab7f52ea8f3fd08878c2f381a49d1a83220d68fa2f979a601a46e4fa4bf

Contents?: true

Size: 805 Bytes

Versions: 6

Compression:

Stored size: 805 Bytes

Contents

module Clusterfuck
  class BGPPeer < Machine
    attr_accessor :bgp_asn,
      :bgp_router_id,
      :bgp_announce

    def initialize(name, **args)
      super

      @bgp_announce = args[:announce] ? Array(args[:announce]) : []
      @bgp_asn = args[:asn] || ASNFactory.next
      @bgp_router_id = args[:router_id] || RouterIDFactory.next
    end

    def bgp_neighbors
      cluster.bgp_neighbors(self)
    end

    class ASNFactory
      @asn = 64999

      def self.next
        @asn += 1
      end
    end

    # A router ID just an IP to identify the router on BGP. It does not have to
    # be equal to the IP; just has to be an IP. We just pick start somewhere.
    class RouterIDFactory
      @id = IPAddr.new("10.0.20.1")

      def self.next
        @id = @id.succ
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-clusterfuck-0.0.7 lib/clusterfuck/bgp_peer.rb
vagrant-clusterfuck-0.0.6 lib/clusterfuck/bgp_peer.rb
vagrant-clusterfuck-0.0.5 lib/clusterfuck/bgp_peer.rb
vagrant-clusterfuck-0.0.4 lib/clusterfuck/bgp_peer.rb
vagrant-clusterfuck-0.0.3 lib/clusterfuck/bgp_peer.rb
vagrant-clusterfuck-0.0.2 lib/clusterfuck/bgp_peer.rb