simple_stack 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,17 @@ module SimpleStack
24
24
  hypervisor.put "#{url}/reboot", :force => opts[:force]
25
25
  end
26
26
 
27
+ def export(opts={})
28
+ opts = {:to => "/tmp/export_file"}.merge(opts)
29
+ file = File.open(opts[:to], "wb")
30
+
31
+ hypervisor.get_stream("#{url}/export", file)
32
+
33
+ options[:to]
34
+ ensure
35
+ file.close rescue nil
36
+ end
37
+
27
38
  def revert_to(snapshot)
28
39
  snapshot.revert
29
40
  end
@@ -50,6 +50,20 @@ module SimpleStack
50
50
  http_call { HTTParty.get(url, http_options) }
51
51
  end
52
52
 
53
+ def get_stream(url, io)
54
+ uri = URI.parse url
55
+ http = Net::HTTP.new(uri.host, uri.port)
56
+ request = Net::HTTP::Get.new(uri.path)
57
+
58
+ headers.each_pair do |k, v|
59
+ request.add_field(k, v)
60
+ end
61
+
62
+ http.request(request) do |res|
63
+ res.read_body {|chunk| io.write chunk }
64
+ end
65
+ end
66
+
53
67
  def post(url, body)
54
68
  http_call { HTTParty.post(url, http_options.merge(:body => JSON.dump(body))) }
55
69
  end
@@ -58,6 +72,20 @@ module SimpleStack
58
72
  http_call { HTTParty.put(url, http_options.merge(:body => JSON.dump(body))) }
59
73
  end
60
74
 
75
+ def put_stream(url, io)
76
+ uri = URI.parse url
77
+ http = Net::HTTP.new(uri.host, uri.port)
78
+ request = Net::HTTP::Put.new(uri.path, {})
79
+
80
+ headers.each_pair do |k, v|
81
+ request.add_field(k, v)
82
+ end
83
+
84
+ request.body_stream = io
85
+ request.content_length = io.size
86
+ http.request(request)
87
+ end
88
+
61
89
  def delete(url)
62
90
  http_call { HTTParty.delete(url, http_options) }
63
91
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleStack
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
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.11
4
+ version: 0.0.12
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-04 00:00:00.000000000 Z
12
+ date: 2012-07-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2153412580 !ruby/object:Gem::Requirement
16
+ requirement: &2153952260 !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: *2153412580
24
+ version_requirements: *2153952260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &2153412160 !ruby/object:Gem::Requirement
27
+ requirement: &2153951840 !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: *2153412160
35
+ version_requirements: *2153951840
36
36
  description: A Simple Stack gem
37
37
  email:
38
38
  - thiago.morello@locaweb.com.br