Sha256: b840d09012576c5a91a56bf0a08f1c3ba1f59a81051a0d37370f721ffaa9801c

Contents?: true

Size: 1.36 KB

Versions: 11

Compression:

Stored size: 1.36 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
        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 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 Aws < Base
      def initialize
        super(name: 'aws', hypervisor: 'xen', supports_light_stemcell: true, default_disk_size: 2048)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bosh-stemcell-1.2121.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2089.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2086.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2068.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2063.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2005.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.1975.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.1868.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.1858.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.1840.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.1836.0 lib/bosh/stemcell/infrastructure.rb