rjiffy 0.1.0 → 0.1.1

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.
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ pkg/*
7
7
  coverage/*
8
8
  .rvmrc
9
9
  *.rbc
10
+ *.rbx
data/Readme.md CHANGED
@@ -25,6 +25,9 @@ Ruby Wrapper for jiffybox.de API
25
25
  ## Create a box
26
26
  Rjiffy::Box.create({:name => "Test", :planid => "1", :distribution => "centos_5_6_32bit"})
27
27
 
28
+ ## Start, shutdown, pullplug, freeze and thaw a box
29
+ `box.start`, `box.shutdown`, `box.pullplug`, `box.freeze`, `box.thaw(PLANID)`
30
+
28
31
  ## List all plans
29
32
  Rjiffy::Plan.all
30
33
 
data/lib/rjiffy/box.rb CHANGED
@@ -27,5 +27,16 @@ module Rjiffy
27
27
  def backups
28
28
  Backup.new(Request.get_data("/backups/#{id}"))
29
29
  end
30
+
31
+ def thaw(planid)
32
+ merge!(Request.put_data("/jiffyBoxes/#{id}", "status=THAW&planid=#{planid}"))
33
+ end
34
+
35
+ [:start, :shutdown, :pullplug, :freeze].each do |method|
36
+ define_method(method) do
37
+ merge!(Request.put_data("/jiffyBoxes/#{id}", "status=#{method.to_s.upcase}"))
38
+ end
39
+ end
40
+
30
41
  end
31
42
  end
@@ -13,6 +13,10 @@ module Rjiffy
13
13
  process_response(Configuration.base_uri[url].delete.deserialize)
14
14
  end
15
15
 
16
+ def put_data(url, params)
17
+ process_response(Configuration.base_uri[url].put(params).deserialize)
18
+ end
19
+
16
20
  private
17
21
 
18
22
  def process_response(response)
@@ -1,3 +1,3 @@
1
1
  module Rjiffy
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,26 @@
1
+ {
2
+ "messages": [],
3
+ "result": {
4
+ "id": 12345,
5
+ "name": "Test",
6
+ "ips": {
7
+ "public": ["188.93.14.211"],
8
+ "private": ["10.93.14.211"]
9
+ },
10
+ "status": "FREEZING",
11
+ "created": 1234567890,
12
+ "recoverymodeActive": false,
13
+ "manualBackupRunning": false,
14
+ "isBeingCopied": false,
15
+ "running": false,
16
+ "host": "vmhost-testsys-2-2-9-2",
17
+ "plan": {
18
+ "id":2 ,
19
+ "name": "CloudLevel 3",
20
+ "diskSizeInMB": 40960,
21
+ "ramInMB": 2048,
22
+ "pricePerHour": 0.08,
23
+ "pricePerHourFrozen": 0.02
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "messages": [],
3
+ "result": {
4
+ "id": 12345,
5
+ "name": "Test",
6
+ "ips": {
7
+ "public": ["188.93.14.211"],
8
+ "private": ["10.93.14.211"]
9
+ },
10
+ "status": "UPDATING",
11
+ "created": 1234567890,
12
+ "recoverymodeActive": false,
13
+ "manualBackupRunning": false,
14
+ "isBeingCopied": false,
15
+ "running": false,
16
+ "host": "vmhost-testsys-2-2-9-2",
17
+ "plan": {
18
+ "id":1 ,
19
+ "name": "CloudLevel 2",
20
+ "diskSizeInMB": 40960,
21
+ "ramInMB": 1024,
22
+ "pricePerHour": 0.04,
23
+ "pricePerHourFrozen": 0.01
24
+ }
25
+ }
26
+ }
@@ -8,6 +8,7 @@ describe Rjiffy::Box do
8
8
  FakeWeb.register_uri(:delete, Rjiffy::Configuration.base_uri["/jiffyBoxes/#{@id}"].to_s, :body => fixture_file("deleted_box.json"), :content_type => "application/json")
9
9
  FakeWeb.register_uri(:get, Rjiffy::Configuration.base_uri["/backups/#{@id}"].to_s, :body => fixture_file("backup_from_box.json"), :content_type => "application/json")
10
10
  FakeWeb.register_uri(:post, Rjiffy::Configuration.base_uri["/jiffyBoxes"].to_s, :body => fixture_file("created_box.json"), :content_type => "application/json")
11
+ FakeWeb.register_uri(:put, Rjiffy::Configuration.base_uri["/jiffyBoxes/#{@id}"].to_s, :body => fixture_file("updated_box.json"), :content_type => "application/json")
11
12
  @box = Rjiffy::Box.find(@id)
12
13
  end
13
14
 
@@ -53,4 +54,21 @@ describe Rjiffy::Box do
53
54
  box.id.should == id_from_created_box
54
55
  end
55
56
 
57
+ it "start, shutdown, pullplug and freeze the box", :box_status => true do
58
+ [:start, :shutdown, :pullplug, :freeze].each do |method|
59
+ box = Rjiffy::Box.create({:name => "Test", :planid => "1", :distribution => "centos_5_6_32bit"})
60
+ box.send(method)
61
+ box.status.should == "UPDATING"
62
+ end
63
+ end
64
+
65
+ it "thaw the box", :thaw_box => true do
66
+ FakeWeb.register_uri(:put, Rjiffy::Configuration.base_uri["/jiffyBoxes/#{@id}"].to_s, :body => fixture_file("freezed_box.json"), :content_type => "application/json")
67
+ box = Rjiffy::Box.create({:name => "Test", :planid => "1", :distribution => "centos_5_6_32bit"})
68
+ box.thaw(:planid => "2")
69
+ box.status.should == "FREEZING"
70
+ box.plan.id.should == 2
71
+ end
72
+
73
+
56
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjiffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-16 00:00:00.000000000 +02:00
12
+ date: 2011-10-07 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: wrest
17
- requirement: &2152117760 !ruby/object:Gem::Requirement
17
+ requirement: &2152627860 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 1.4.2
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152117760
25
+ version_requirements: *2152627860
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: hashie
28
- requirement: &2152117260 !ruby/object:Gem::Requirement
28
+ requirement: &2152627360 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2152117260
36
+ version_requirements: *2152627360
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: i18n
39
- requirement: &2152116880 !ruby/object:Gem::Requirement
39
+ requirement: &2152626980 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2152116880
47
+ version_requirements: *2152626980
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &2152116320 !ruby/object:Gem::Requirement
50
+ requirement: &2152626420 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 2.6.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2152116320
58
+ version_requirements: *2152626420
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: fakeweb
61
- requirement: &2152115820 !ruby/object:Gem::Requirement
61
+ requirement: &2152625920 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.3.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2152115820
69
+ version_requirements: *2152625920
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: simplecov
72
- requirement: &2152115360 !ruby/object:Gem::Requirement
72
+ requirement: &2152625460 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: 0.4.2
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2152115360
80
+ version_requirements: *2152625460
81
81
  description: Ruby Wrapper for the jiffybox.de API
82
82
  email:
83
83
  - frank@heidjer.info
@@ -113,8 +113,10 @@ files:
113
113
  - spec/fixtures/distributions_list.json
114
114
  - spec/fixtures/empty_result.json
115
115
  - spec/fixtures/error_response.json
116
+ - spec/fixtures/freezed_box.json
116
117
  - spec/fixtures/plan.json
117
118
  - spec/fixtures/plan_list.json
119
+ - spec/fixtures/updated_box.json
118
120
  - spec/rjiffy/box_spec.rb
119
121
  - spec/rjiffy/configuration_spec.rb
120
122
  - spec/rjiffy/distribution_spec.rb
@@ -158,8 +160,10 @@ test_files:
158
160
  - spec/fixtures/distributions_list.json
159
161
  - spec/fixtures/empty_result.json
160
162
  - spec/fixtures/error_response.json
163
+ - spec/fixtures/freezed_box.json
161
164
  - spec/fixtures/plan.json
162
165
  - spec/fixtures/plan_list.json
166
+ - spec/fixtures/updated_box.json
163
167
  - spec/rjiffy/box_spec.rb
164
168
  - spec/rjiffy/configuration_spec.rb
165
169
  - spec/rjiffy/distribution_spec.rb