Sha256: e19af0edee83860728b968415af7451e7384897669788313f3909a24f5d97800

Contents?: true

Size: 1.03 KB

Versions: 176

Compression:

Stored size: 1.03 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
  class LightStemcell
    def initialize(stemcell)
      @stemcell = stemcell
    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
      File.join(File.dirname(stemcell.path), "light-#{File.basename(stemcell.path)}")
    end

    private

    attr_reader :stemcell

    def manifest
      region = Region.new
      ami = Ami.new(stemcell, region)
      ami_id = ami.publish
      manifest = Bosh::Common::DeepCopy.copy(stemcell.manifest)
      manifest['cloud_properties']['ami'] = { region.name => ami_id }
      manifest
    end
  end
end

Version data entries

176 entries across 176 versions & 1 rubygems

Version Path
bosh-stemcell-1.2690.4.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2732.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2719.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2717.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2710.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2707.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2682.1.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2697.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2693.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2690.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2686.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2685.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2682.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2681.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2671.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2669.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2657.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2652.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2641.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2640.0 lib/bosh/stemcell/aws/light_stemcell.rb