simple_stack 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,10 +26,7 @@ module SimpleStack
26
26
  entity_path = response.headers["location"].sub(/^\//, "").sub(/\/$/, "")
27
27
  entity_url = "#{connection.url}/#{entity_path}"
28
28
  new_item = clazz.new hypervisor, self, entity_url
29
- if cacheable?
30
- cached_attributes[:items] ||= []
31
- cached_attributes[:items] << self
32
- end
29
+ reload if cacheable?
33
30
  new_item
34
31
  end
35
32
 
@@ -20,10 +20,7 @@ module SimpleStack
20
20
 
21
21
  def delete
22
22
  response = hypervisor.delete url
23
- if cacheable?
24
- parent.cached_attributes[:items] ||= []
25
- parent.cached_attributes[:items].delete self
26
- end
23
+ parent.reload if cacheable?
27
24
  response
28
25
  end
29
26
 
@@ -17,15 +17,15 @@ module SimpleStack
17
17
  end
18
18
 
19
19
  def add_tag(tag)
20
- cached_attributes[:tags] ||= []
21
20
  hypervisor.post "#{url}/tags", :name => tag
22
- cached_attributes[:tags] << tag if cached_attributes[:tags]
21
+ reload if cacheable?
22
+ tag
23
23
  end
24
24
 
25
25
  def remove_tag(tag)
26
- cached_attributes[:tags] ||= []
27
26
  hypervisor.delete "#{url}/tags/#{tag}"
28
- cached_attributes[:tags].delete tag if cached_attributes[:tags]
27
+ reload if cacheable?
28
+ tag
29
29
  end
30
30
 
31
31
  def reboot(opts={:force => false})
@@ -53,10 +53,10 @@ module SimpleStack
53
53
  def import(opts={})
54
54
  file = File.open(opts[:from], "rb")
55
55
 
56
- response = put_stream("#{url}/guests", file)
56
+ response = post_stream("#{url}/guests", file)
57
57
  entity_path = response["location"].sub(/^\//, "").sub(/\/$/, "")
58
58
  entity_url = "#{connection.url}/#{entity_path}"
59
- SimpleStack::Guest.new self, guests, entity_url
59
+ SimpleStack::Guest.new self, guests.reload, entity_url
60
60
  ensure
61
61
  file.close rescue nil
62
62
  end
@@ -87,10 +87,10 @@ module SimpleStack
87
87
  http_call { HTTParty.put(url, http_options.merge(:body => JSON.dump(body))) }
88
88
  end
89
89
 
90
- def put_stream(url, io)
90
+ def post_stream(url, io)
91
91
  uri = URI.parse url
92
92
  http = Net::HTTP.new(uri.host, uri.port)
93
- request = Net::HTTP::Put.new(uri.path, {})
93
+ request = Net::HTTP::Post.new(uri.path, {})
94
94
 
95
95
  headers.each_pair do |k, v|
96
96
  request.add_field(k, v)
@@ -1,4 +1,14 @@
1
1
  module SimpleStack
2
2
  class Storage < Entity
3
+ def import(opts={})
4
+ file = File.open(opts[:from], "rb")
5
+
6
+ response = post_stream("#{url}/guests", file)
7
+ entity_path = response["location"].sub(/^\//, "").sub(/\/$/, "")
8
+ entity_url = "#{connection.url}/#{entity_path}"
9
+ SimpleStack::Guest.new hypervisor, hypervisor.guests.reload, entity_url
10
+ ensure
11
+ file.close rescue nil
12
+ end
3
13
  end
4
14
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleStack
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
12
+ date: 2012-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2158814840 !ruby/object:Gem::Requirement
16
+ requirement: &2155160460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2158814840
24
+ version_requirements: *2155160460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &2158814380 !ruby/object:Gem::Requirement
27
+ requirement: &2155160000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2158814380
35
+ version_requirements: *2155160000
36
36
  description: A Simple Stack gem
37
37
  email:
38
38
  - thiago.morello@locaweb.com.br