Class: Bosh::Director::CompiledPackage::CompiledPackagesExport
- Defined in:
- lib/bosh/director/compiled_package/compiled_packages_export.rb
Instance Method Summary collapse
- #extract(tempdir = nil) {|manifest, packages| ... } ⇒ Object
-
#initialize(options = {}) ⇒ CompiledPackagesExport
constructor
A new instance of CompiledPackagesExport.
Constructor Details
#initialize(options = {}) ⇒ CompiledPackagesExport
Returns a new instance of CompiledPackagesExport.
6 7 8 9 |
# File 'lib/bosh/director/compiled_package/compiled_packages_export.rb', line 6 def initialize(={}) @file = .fetch(:file) @exec = .fetch(:exec, Bosh::Exec) end |
Instance Method Details
#extract(tempdir = nil) {|manifest, packages| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bosh/director/compiled_package/compiled_packages_export.rb', line 11 def extract(tempdir=nil) tempdir ||= Dir.mktmpdir exec.sh("tar -C #{tempdir} -xf #{file}") manifest = YAML.load_file("#{tempdir}/compiled_packages.MF") packages = [] manifest['compiled_packages'].each do |p| packages << CompiledPackage.new( package_name: p['package_name'], package_fingerprint: p['package_fingerprint'], sha1: p['compiled_package_sha1'], stemcell_sha1: p['stemcell_sha1'], blobstore_id: p['blobstore_id'], blob_path: File.join(tempdir, 'compiled_packages', 'blobs', p['blobstore_id'])) end yield manifest, packages FileUtils.rm_rf(tempdir) end |