Class: Bosh::Stemcell::Aws::Ami

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/stemcell/aws/ami.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stemcell, region, virtualization_type) ⇒ Ami

Returns a new instance of Ami.



12
13
14
15
16
# File 'lib/bosh/stemcell/aws/ami.rb', line 12

def initialize(stemcell, region, virtualization_type)
  @stemcell = stemcell
  @region = region
  @virtualization_type = virtualization_type || 'paravirtual'
end

Instance Attribute Details

#stemcellObject (readonly)

Returns the value of attribute stemcell.



10
11
12
# File 'lib/bosh/stemcell/aws/ami.rb', line 10

def stemcell
  @stemcell
end

Instance Method Details

#publishObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bosh/stemcell/aws/ami.rb', line 18

def publish
  cloud_config = OpenStruct.new(logger: Logger.new('ami.log'), task_checkpoint: nil)
  Bosh::Clouds::Config.configure(cloud_config)

  cloud = Bosh::Clouds::Provider.create(options, 'fake-director-uuid')

  stemcell.extract do |tmp_dir, stemcell_manifest|
    cloud_properties = stemcell_manifest['cloud_properties'].merge(
      'virtualization_type' => virtualization_type
    )
    ami_id = cloud.create_stemcell("#{tmp_dir}/image", cloud_properties)
    cloud.ec2.images[ami_id].public = true
    ami_id
  end
end