Class: VCloudCloud::Steps::StemcellInfo

Inherits:
VCloudCloud::Step show all
Defined in:
lib/cloud/vcloud/steps/stemcell_info.rb

Instance Attribute Summary

Attributes inherited from VCloudCloud::Step

#client, #state

Instance Method Summary collapse

Methods inherited from VCloudCloud::Step

#initialize, #rollback

Constructor Details

This class inherits a constructor from VCloudCloud::Step

Instance Method Details

#cleanupObject



15
16
17
# File 'lib/cloud/vcloud/steps/stemcell_info.rb', line 15

def cleanup
  FileUtils.remove_entry_secure state[:stemcell_dir] if state[:stemcell_dir]
end

#perform(image, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/cloud/vcloud/steps/stemcell_info.rb', line 4

def perform(image, &block)
  tmpdir = state[:stemcell_dir] = Dir.mktmpdir
  # examine files in the tarball
  `tar -C #{tmpdir} -xzf #{File.absolute_path(image)}`
  raise 'Invalid stemcell image' unless $?.success?
  files = Dir.glob File.join(tmpdir, '*.ovf')
  # stemcell should only include one .ovf file
  raise "Invalid stemcell image: having #{files.length} .ovf files" if files.length != 1
  state[:stemcell_ovf] = File.basename files[0]
end