Sha256: 77b648ab424c7ad38833f34b20d9370011cd423d3b39b5e14d2470b0899073b8

Contents?: true

Size: 1.73 KB

Versions: 21

Compression:

Stored size: 1.73 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 '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
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
bosh-stemcell-1.2479.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2448.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2446.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2427.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2416.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2411.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2409.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2398.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2384.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2375.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2372.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2366.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2361.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2355.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2354.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2347.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2341.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2334.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2311.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2291.0 lib/bosh/stemcell/infrastructure.rb