Class: VFabric::AgentImage

Inherits:
Shared::Resource show all
Defined in:
lib/vas/vfabric/agent_image.rb

Instance Attribute Summary

Attributes inherited from Shared::Resource

#location, #security

Instance Method Summary collapse

Constructor Details

#initialize(location, client) ⇒ AgentImage

:nodoc:



22
23
24
25
# File 'lib/vas/vfabric/agent_image.rb', line 22

def initialize(location, client) #:nodoc:
  super(location, client)
  @content_location = Util::LinkUtils.get_link_href(details, "content")
end

Instance Method Details

#content(&block) ⇒ Object



27
28
29
# File 'lib/vas/vfabric/agent_image.rb', line 27

def content(&block)
  client.get_stream(@content_location, &block)
end

#extract_to(location = '.') ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vas/vfabric/agent_image.rb', line 31

def extract_to(location = '.')
  agent_image = Tempfile.open('agent-image.zip') { |temp_file|
    content { |chunk| temp_file << chunk }
    temp_file.rewind
    Zip::ZipFile.foreach(temp_file.path) { |entry|
      FileUtils.mkdir_p(File.dirname(entry.name))
      entry.extract
    }
    temp_file.rewind
    Zip::ZipFile.foreach(temp_file.path) { |entry|
      File.chmod(entry.unix_perms, entry.name)
    }
    temp_file.delete
  }

  File.join(location, 'vfabric-administration-agent')
end