Sha256: 66b15d9cda2ba646123075b60000db3405a7ffae1f25c57daf8e8b77d0a1dde0

Contents?: true

Size: 1.82 KB

Versions: 30

Compression:

Stored size: 1.82 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 ==(other)
        name == other.name &&
          hypervisor == other.hypervisor &&
          default_disk_size == other.default_disk_size
      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: 3072)
      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

30 entries across 30 versions & 1 rubygems

Version Path
bosh-stemcell-1.2824.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2820.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2818.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2811.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2810.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2809.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2807.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2801.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2798.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2797.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2792.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2789.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2788.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2787.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2786.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2785.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2781.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2780.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2778.0 lib/bosh/stemcell/infrastructure.rb
bosh-stemcell-1.2776.0 lib/bosh/stemcell/infrastructure.rb