Sha256: ad38b187eedf50456eb5f190e11908a1aab067f7738bc3c1a85b281b2ad0dbe5
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
require 'rake/file_utils_ext' require 'yaml' require 'bosh/stemcell/aws/region' module Bosh::Stemcell class Archive attr_reader :path def initialize(path = '') @path = path validate_stemcell end def manifest @manifest ||= Psych.load(`tar -Oxzf #{path} stemcell.MF`) end def name manifest.fetch('name') end def infrastructure cloud_properties.fetch('infrastructure') end def version cloud_properties.fetch('version') end def light? infrastructure == 'aws' && ami_id end def ami_id(region = Aws::Region::DEFAULT) cloud_properties.fetch('ami', {}).fetch(region, nil) end def extract(tar_options = {}, &block) Dir.mktmpdir do |tmp_dir| tar_cmd = "tar xzf #{path} --directory #{tmp_dir}" tar_cmd << " --exclude=#{tar_options[:exclude]}" if tar_options.has_key?(:exclude) Rake::FileUtilsExt.sh(tar_cmd) block.call(tmp_dir, manifest) end end private def cloud_properties manifest.fetch('cloud_properties') end def validate_stemcell raise "Cannot find file `#{path}'" unless File.exists?(path) end end end
Version data entries
4 entries across 4 versions & 1 rubygems