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) ⇒ Ami

Returns a new instance of Ami.



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

def initialize(stemcell, region)
  @stemcell = stemcell
  @region = region
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



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

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|
    ami_id = cloud.create_stemcell("#{tmp_dir}/image", stemcell_manifest['cloud_properties'])
    cloud.ec2.images[ami_id].public = true
    ami_id
  end
end