Sha256: f60eed474cd534e7b3795ccbb5a8e7c8b603885bb3111c283fdefa78ae8d3ca9

Contents?: true

Size: 1.91 KB

Versions: 40

Compression:

Stored size: 1.91 KB

Contents

module Bosh::Stemcell
  module Infrastructure
    def self.for(name)
      case name
        when 'openstack'
          OpenStack.new
        when 'aws'
          Aws.new
        when 'vsphere'
          Vsphere.new
        when 'warden'
          Warden.new
        when 'vcloud'
          Vcloud.new
        when 'null'
          NullInfrastructure.new
        else
          raise ArgumentError.new("invalid infrastructure: #{name}")
      end
    end

    class Base
      attr_reader :name, :hypervisor, :default_disk_size

      def initialize(options = {})
        @name = options.fetch(:name)
        @supports_light_stemcell = options.fetch(:supports_light_stemcell, false)
        @hypervisor = options.fetch(:hypervisor)
        @default_disk_size = options.fetch(:default_disk_size)
      end

      def light?
        @supports_light_stemcell
      end

      def ==(other)
        name == other.name &&
          hypervisor == other.hypervisor &&
          default_disk_size == other.default_disk_size &&
          light? == other.light?
      end
    end

    class NullInfrastructure < Base
      def initialize
        super(name: 'null', hypervisor: 'null', default_disk_size: -1)
      end
    end

    class OpenStack < Base
      def initialize
        super(name: 'openstack', hypervisor: 'kvm', default_disk_size: 10240)
      end
    end

    class Vsphere < Base
      def initialize
        super(name: 'vsphere', hypervisor: 'esxi', default_disk_size: 3072)
      end
    end

    class Vcloud < Base
      def initialize
        super(name: 'vcloud', hypervisor: 'esxi', default_disk_size: 3072)
      end
    end

    class Aws < Base
      def initialize
        super(name: 'aws', hypervisor: 'xen', supports_light_stemcell: true, default_disk_size: 2048)
      end
    end

    class Warden < Base
      def initialize
        super(name: 'warden', hypervisor: 'boshlite', default_disk_size: 2048)
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
bosh-stemcell-1.2690.4.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2710.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2707.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2682.1.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2697.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2693.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2690.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2686.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2685.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2682.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2681.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2671.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2669.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2657.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2652.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2641.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2640.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2624.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2619.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2611.0 lib/bosh/stemcell/infrastructure.rb