Class: Bosh::Stemcell::Archive
- Inherits:
-
Object
- Object
- Bosh::Stemcell::Archive
- Defined in:
- lib/bosh/stemcell/archive.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #extract(tar_options = {}, &block) ⇒ Object
- #infrastructure ⇒ Object
-
#initialize(path = '') ⇒ Archive
constructor
A new instance of Archive.
- #light? ⇒ Boolean
- #manifest ⇒ Object
- #name ⇒ Object
- #sha1 ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(path = '') ⇒ Archive
Returns a new instance of Archive.
9 10 11 12 |
# File 'lib/bosh/stemcell/archive.rb', line 9 def initialize(path = '') @path = path validate_stemcell end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/bosh/stemcell/archive.rb', line 7 def path @path end |
Instance Method Details
#extract(tar_options = {}, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bosh/stemcell/archive.rb', line 40 def extract( = {}, &block) Dir.mktmpdir do |tmp_dir| tar_cmd = "tar xzf #{path} --directory #{tmp_dir}" tar_cmd << " --exclude=#{[:exclude]}" if .has_key?(:exclude) Rake::FileUtilsExt.sh(tar_cmd) block.call(tmp_dir, manifest) end end |
#infrastructure ⇒ Object
22 23 24 |
# File 'lib/bosh/stemcell/archive.rb', line 22 def infrastructure cloud_properties.fetch('infrastructure') end |
#light? ⇒ Boolean
36 37 38 |
# File 'lib/bosh/stemcell/archive.rb', line 36 def light? infrastructure == 'aws' && has_ami? end |
#manifest ⇒ Object
14 15 16 |
# File 'lib/bosh/stemcell/archive.rb', line 14 def manifest @manifest ||= Psych.load(`tar -Oxzf #{path} stemcell.MF`) end |
#name ⇒ Object
18 19 20 |
# File 'lib/bosh/stemcell/archive.rb', line 18 def name manifest.fetch('name') end |
#sha1 ⇒ Object
30 31 32 33 34 |
# File 'lib/bosh/stemcell/archive.rb', line 30 def sha1 sha1 = manifest.fetch('sha1') raise 'sha1 must not be nil' unless sha1 sha1.to_s end |
#version ⇒ Object
26 27 28 |
# File 'lib/bosh/stemcell/archive.rb', line 26 def version cloud_properties.fetch('version') end |