Sha256: f96ab3084bbd8233df6050ac32d99309b311ec031428bcf054f497fcb9d940f5
Contents?: true
Size: 1.53 KB
Versions: 46
Compression:
Stored size: 1.53 KB
Contents
require 'rake/file_utils' require 'yaml' require 'common/deep_copy' require 'bosh/stemcell/aws/region' require 'bosh/stemcell/aws/ami' module Bosh::Stemcell::Aws HVM_VIRTUALIZATION = 'hvm' class LightStemcell def initialize(stemcell, virtualization_type) @stemcell = stemcell @virtualization_type = virtualization_type end def write_archive stemcell.extract(exclude: 'image') do |extracted_stemcell_dir| Dir.chdir(extracted_stemcell_dir) do FileUtils.touch('image', verbose: true) File.open('stemcell.MF', 'w') do |out| Psych.dump(manifest, out) end Rake::FileUtilsExt.sh("sudo tar cvzf #{path} *") end end end def path stemcell_name = File.basename(stemcell.path) stemcell_name = stemcell_name.gsub("xen", "xen-hvm") if virtualization_type == HVM_VIRTUALIZATION File.join(File.dirname(stemcell.path), "light-#{stemcell_name}") end private attr_reader :stemcell, :virtualization_type def manifest region = Region.new ami = Ami.new(stemcell, region, virtualization_type) ami_id = ami.publish manifest = Bosh::Common::DeepCopy.copy(stemcell.manifest) if virtualization_type == HVM_VIRTUALIZATION manifest['name'] = manifest['name'].gsub("xen", "xen-hvm") manifest['cloud_properties']['name'] = manifest['cloud_properties']['name'].gsub("xen", "xen-hvm") end manifest['cloud_properties']['ami'] = { region.name => ami_id } manifest end end end
Version data entries
46 entries across 46 versions & 1 rubygems