Class: SimpleStack::Storage

Inherits:
Entity
  • Object
show all
Defined in:
lib/simple_stack/storage.rb

Instance Attribute Summary

Attributes inherited from Entity

#hypervisor, #parent, #url

Instance Method Summary collapse

Methods inherited from Entity

#connection, #delete, #info, #initialize, #inspect, #method_missing, #update

Methods included from Cacheable

#cacheable?, #cached_attributes, #reload

Constructor Details

This class inherits a constructor from SimpleStack::Entity

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SimpleStack::Entity

Instance Method Details

#import(opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/simple_stack/storage.rb', line 3

def import(opts={})
  file = File.open(opts[:from], "rb")

  response = hypervisor.post_stream("#{url}/guests", file)
  entity_path = response["location"].sub(/^\//, "").sub(/\/$/, "")
  entity_url = "#{connection.url}/#{entity_path}"
  SimpleStack::Guest.new hypervisor, hypervisor.guests.reload, entity_url
ensure
  file.close rescue nil
end