Class: VFabric::AgentImage
- Inherits:
-
Shared::Resource
- Object
- Shared::Resource
- VFabric::AgentImage
- Defined in:
- lib/vas/vfabric/agent_image.rb
Overview
Provides access to the installation image for the vFabric Administration Agent
Instance Attribute Summary
Attributes inherited from Shared::Resource
Instance Method Summary collapse
-
#content {|chunk| ... } ⇒ void
Retrieves the content of the agent installation image (a zip file) from the server.
-
#extract_to(location = '.') ⇒ void
Downloads and extracts the agent installation image.
-
#initialize(location, client) ⇒ AgentImage
constructor
A new instance of AgentImage.
Constructor Details
#initialize(location, client) ⇒ AgentImage
Returns a new instance of AgentImage.
23 24 25 26 |
# File 'lib/vas/vfabric/agent_image.rb', line 23 def initialize(location, client) super(location, client) @content_location = Util::LinkUtils.get_link_href(details, "content") end |
Instance Method Details
#content {|chunk| ... } ⇒ void
This method returns an undefined value.
Retrieves the content of the agent installation image (a zip file) from the server
33 34 35 |
# File 'lib/vas/vfabric/agent_image.rb', line 33 def content(&block) client.get_stream(@content_location, &block) end |
#extract_to(location = '.') ⇒ void
This method returns an undefined value.
Downloads and extracts the agent installation image
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vas/vfabric/agent_image.rb', line 42 def extract_to(location = '.') 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 |