class Bosh::Stemcell::Aws::LightStemcell

Public Class Methods

new(stemcell, virtualization_type, regions=Region::REGIONS) click to toggle source
# File lib/bosh/stemcell/aws/light_stemcell.rb, line 11
def initialize(stemcell, virtualization_type, regions=Region::REGIONS)
  @stemcell = stemcell
  @virtualization_type = virtualization_type
  @regions = regions
end

Public Instance Methods

path() click to toggle source
# File lib/bosh/stemcell/aws/light_stemcell.rb, line 27
def path
  stemcell_name = adjust_hvm_name(File.basename(@stemcell.path))
  File.join(File.dirname(@stemcell.path), "light-#{stemcell_name}")
end
write_archive() click to toggle source
# File lib/bosh/stemcell/aws/light_stemcell.rb, line 17
def write_archive
  @stemcell.extract(exclude: 'image') do |extracted_stemcell_dir|
    Dir.chdir(extracted_stemcell_dir) do
      FileUtils.touch('image', verbose: true)
      File.write('stemcell.MF', Psych.dump(manifest))
      Rake::FileUtilsExt.sh("sudo tar cvzf #{path} *")
    end
  end
end

Private Instance Methods

adjust_hvm_name(name) click to toggle source
# File lib/bosh/stemcell/aws/light_stemcell.rb, line 48
def adjust_hvm_name(name)
  @virtualization_type == HVM_VIRTUALIZATION ? name.gsub("xen", "xen-hvm") : name
end
manifest() click to toggle source

this method has heavy side effects

# File lib/bosh/stemcell/aws/light_stemcell.rb, line 35
def manifest
  manifest = Bosh::Common::DeepCopy.copy(@stemcell.manifest)
  manifest['name'] = adjust_hvm_name(manifest['name'])
  manifest['cloud_properties']['name'] = adjust_hvm_name(manifest['cloud_properties']['name'])

  ami_collection = AmiCollection.new(@stemcell, @regions, @virtualization_type)

  # Light stemcell contains AMIs for all regions
  # so that CPI can pick one based on its configuration
  manifest['cloud_properties']['ami'] = ami_collection.publish
  manifest
end