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.2624.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2619.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2611.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2606.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2605.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2603.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2597.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2596.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2583.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2579.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2578.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2577.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2576.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2560.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2559.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2549.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2546.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2539.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2537.0 lib/bosh/stemcell/aws/light_stemcell.rb
bosh-stemcell-1.2534.0 lib/bosh/stemcell/aws/light_stemcell.rb