Sha256: a00270da10b7c97a70f0cc2e196b75943b4a92765d3cfc9e83b0df39ba82ba3c

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module Clusterfuck
  module LeafSpineDSL
    def cluster(name, &block)
      @cluster = Cluster.create(name)
      yield(@cluster)
    end

    def spine(name, **args, &block)
      vip_subnet = args[:vip_subnet] || IPAddr.new("192.168.99.1/24")
      priv_subnet = args[:priv_subnet] || IPAddr.new("10.0.0.0/16")
      args = { announced: [vip_subnet, priv_subnet] }.merge(args)

      driver = args[:driver] || QuaggaBGPRouter

      @spine = driver.new(name, args)
      yield(@spine)
    end

    def leaf(name, **args, &block)
      driver = args[:driver] || QuaggaBGPRouter
      leaf_spine_subnet = args[:spine_subnet] || SubnetFactory.next

      @leaf = driver.new(name, **args)
      @cluster.connect(leaf_spine_subnet, @leaf, @spine)

      yield(@leaf)
    end

    def host(name, **args)
      driver = args[:driver] || Machine
      leaf_subnet = args[:leaf_subnet] || SubnetFactory.next

      args = {
        gateway: @leaf,
        routes:  @spine.bgp_announced,
      }.merge(args)

      machine = driver.new(name, args)

      # TODO this sucks
      @leaf.bgp_announced = @leaf.bgp_announced.push(leaf_subnet.subnet)
      @cluster.connect(leaf_subnet, @leaf, machine)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-clusterfuck-0.0.1 lib/clusterfuck/leaf_spine_dsl.rb