rubineti 1.3.0 → 1.4.0

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/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm ruby-1.9.2-p0@rubineti
1
+ rvm ruby-1.9.2-p136@rubineti
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "hugs", "~> 1.1.0"
3
+ gem "hugs", "~> 2.3.0"
4
4
 
5
5
  group :development do
6
6
  gem "rake"
7
- gem "jeweler", "~> 1.5.1"
8
- gem "vcr", "~> 1.3.3"
9
- gem "webmock", "~> 1.6.1"
10
- gem "minitest", "~> 2.0.0"
11
- gem "yajl-ruby", "~> 0.7.8"
7
+ gem "jeweler"
8
+ gem "vcr"
9
+ gem "webmock"
10
+ gem "minitest"
11
+ gem "yajl-ruby"
12
12
  end
data/Gemfile.lock CHANGED
@@ -1,33 +1,37 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.2.2)
4
+ addressable (2.2.4)
5
5
  crack (0.1.8)
6
6
  git (1.2.5)
7
- hugs (1.1.0)
7
+ hugs (2.3.0)
8
+ multipart-post (~> 1.0.1)
8
9
  net-http-persistent (~> 1.4.1)
10
+ nokogiri (~> 1.4.4)
9
11
  yajl-ruby (~> 0.7.8)
10
- jeweler (1.5.1)
12
+ jeweler (1.5.2)
11
13
  bundler (~> 1.0.0)
12
14
  git (>= 1.2.5)
13
15
  rake
14
- minitest (2.0.0)
16
+ minitest (2.0.2)
17
+ multipart-post (1.0.1)
15
18
  net-http-persistent (1.4.1)
19
+ nokogiri (1.4.4)
16
20
  rake (0.8.7)
17
- vcr (1.3.3)
18
- webmock (1.6.1)
21
+ vcr (1.5.1)
22
+ webmock (1.6.2)
19
23
  addressable (>= 2.2.2)
20
24
  crack (>= 0.1.7)
21
- yajl-ruby (0.7.8)
25
+ yajl-ruby (0.7.9)
22
26
 
23
27
  PLATFORMS
24
28
  ruby
25
29
 
26
30
  DEPENDENCIES
27
- hugs (~> 1.1.0)
28
- jeweler (~> 1.5.1)
29
- minitest (~> 2.0.0)
31
+ hugs (~> 2.3.0)
32
+ jeweler
33
+ minitest
30
34
  rake
31
- vcr (~> 1.3.3)
32
- webmock (~> 1.6.1)
33
- yajl-ruby (~> 0.7.8)
35
+ vcr
36
+ webmock
37
+ yajl-ruby
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # rubineti
2
2
 
3
- [Ruby](http://www.ruby-lang.org/) bindings to [Ganeti's](http://code.google.com/p/ganeti/) Version 2 Remote API.
3
+ [Ruby](http://www.ruby-lang.org/) bindings to [Ganeti's](http://code.google.com/p/ganeti/) Version 2 Remote API.
4
4
 
5
5
  ## Usage
6
6
 
@@ -10,17 +10,23 @@
10
10
 
11
11
  ### Examples
12
12
 
13
- See the examples section in the [wiki](http://github.com/retr0h/rubineti/wiki/Examples).
13
+ See the examples section in the [wiki](http://github.com/retr0h/rubineti/wiki).
14
14
 
15
- ## Contributions
15
+ ## Compatability
16
16
 
17
- I have implemented the end-points immediately needed. Feel free to send me pull requests, if you
18
- wish to help out.
17
+ ruby 1.9.2
18
+
19
+ ## Testing
19
20
 
20
- ## TODO
21
+ MiniTest will run the tests in a random order. When rebuilding the fixtures, the entity
22
+ tests depend on the pool tests having already been run. Since the fixtures change infrequently,
23
+ this should be acceptable.
21
24
 
22
- * Remove #cassette_for test helper. It's a bad idea to use fixture data to test other fixtures.
25
+ Tests can run offline thanks to [VCR](https://github.com/myronmarston/vcr).
23
26
 
24
- ## Credits
27
+ $ bundle exec rake
25
28
 
26
- Wesley Beary's [fog](https://github.com/geemus/fog), for which I referenced.
29
+ ## Contributions
30
+
31
+ I have implemented the end-points immediately needed. Feel free to send me pull requests, if you
32
+ wish to help out.
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ end
15
15
  require "rake/testtask"
16
16
  Rake::TestTask.new(:test) do |test|
17
17
  test.libs << "./lib" << "./test"
18
- test.pattern = "test/**/test_*.rb"
18
+ test.pattern = "test/**/*_test.rb"
19
19
  test.verbose = true
20
20
  end
21
21
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.4.0
data/lib/ganeti.rb CHANGED
@@ -2,5 +2,5 @@ module Ganeti
2
2
  ##
3
3
  # Remote API Version.
4
4
 
5
- Version = 2
5
+ Version = 2.freeze
6
6
  end
data/lib/rubineti.rb CHANGED
@@ -1,2 +1,2 @@
1
- require "rubineti/compute"
1
+ require "rubineti/client"
2
2
  require "ganeti"
@@ -0,0 +1,44 @@
1
+ require "hugs"
2
+
3
+ require "rubineti/cluster"
4
+ require "rubineti/instance"
5
+ require "rubineti/job"
6
+ require "rubineti/node"
7
+
8
+ module Rubineti
9
+ class Client
10
+ ##
11
+ # Required:
12
+ # +user+: A String containing the username for use in HTTP Basic auth.
13
+ # +password+: A String containing the password for use in HTTP Basic auth.
14
+ # +host+: A String with the host to connect.
15
+
16
+ def initialize options
17
+ @connection = Hugs::Client.new(
18
+ :user => options[:user],
19
+ :password => options[:password],
20
+ :host => options[:host],
21
+ :port => options[:port] || 5080,
22
+ :scheme => "https"
23
+ )
24
+ @connection.raise_4xx = true
25
+ @connection.raise_5xx = true
26
+ end
27
+
28
+ def cluster
29
+ @cluster ||= Rubineti::Cluster.new @connection
30
+ end
31
+
32
+ def instance
33
+ @instance ||= Rubineti::Instance.new @connection
34
+ end
35
+
36
+ def job
37
+ @job ||= Rubineti::Job.new @connection
38
+ end
39
+
40
+ def node
41
+ @node ||= Rubineti::Node.new @connection
42
+ end
43
+ end
44
+ end
@@ -1,26 +1,30 @@
1
1
  module Rubineti
2
- module Cluster
2
+ class Cluster
3
+ def initialize connection
4
+ @connection = connection
5
+ end
6
+
3
7
  ##
4
8
  # Returns a list of features supported by the RAPI server.
5
9
 
6
- def cluster_features
7
- warn "WARNING: Cluster#cluster_features not implemented."
10
+ def features
11
+ warn "WARNING: Cluster#features not implemented."
8
12
  # get "/#{Ganeti::Version}/features"
9
13
  end
10
14
 
11
15
  ##
12
16
  # Returns a list of cluster information.
13
17
 
14
- def cluster_info
15
- request.get "/#{Ganeti::Version}/info"
18
+ def info
19
+ @connection.get "/#{Ganeti::Version}/info"
16
20
  end
17
21
 
18
22
  ##
19
23
  # Redistribute configuration to all nodes.
20
24
  # Returns a job_id.
21
25
 
22
- def cluster_redistribute_config
23
- request.put "/#{Ganeti::Version}/redistribute-config"
26
+ def redistribute_config
27
+ @connection.put "/#{Ganeti::Version}/redistribute-config"
24
28
  end
25
29
 
26
30
  ##
@@ -31,8 +35,8 @@ module Rubineti
31
35
  # the job will not be actually executed, only the pre-execution
32
36
  # checks will be done.
33
37
 
34
- def cluster_tags_create params = {}
35
- warn "WARNING: Cluster#cluster_tags_create not implemented."
38
+ def tags_create params = {}
39
+ warn "WARNING: Cluster#tags_create not implemented."
36
40
  # put "/#{Ganeti::Version}/tags", params
37
41
  end
38
42
 
@@ -44,31 +48,31 @@ module Rubineti
44
48
  # the job will not be actually executed, only the pre-execution
45
49
  # checks will be done.
46
50
 
47
- def cluster_tags_delete params = {}
48
- warn "WARNING: Cluster#cluster_tags_delete not implemented."
51
+ def tags_delete params = {}
52
+ warn "WARNING: Cluster#tags_delete not implemented."
49
53
  # delete "/#{Ganeti::Version}/tags", params
50
54
  end
51
55
 
52
56
  ##
53
57
  # Returns the cluster tags.
54
58
 
55
- def cluster_tags_list
56
- warn "WARNING: Cluster#cluster_tags_list not implemented."
59
+ def tags_list
60
+ warn "WARNING: Cluster#tags_list not implemented."
57
61
  # get "/#{Ganeti::Version}/tags"
58
62
  end
59
63
 
60
64
  ##
61
65
  # Returns the cluster API version.
62
66
 
63
- def cluster_version
64
- request.get "/version"
67
+ def version
68
+ @connection.get "/version"
65
69
  end
66
70
 
67
71
  ##
68
72
  # Return a list of all OSes.
69
73
 
70
- def cluster_os_list
71
- request.get "/#{Ganeti::Version}/os"
74
+ def os_list
75
+ @connection.get "/#{Ganeti::Version}/os"
72
76
  end
73
77
  end
74
78
  end
@@ -1,5 +1,9 @@
1
1
  module Rubineti
2
- module Instances
2
+ class Instance
3
+ def initialize connection
4
+ @connection = connection
5
+ end
6
+
3
7
  ##
4
8
  # Activate disks on an instance.
5
9
  # Returns a job id.
@@ -7,9 +11,9 @@ module Rubineti
7
11
  # Takes the bool parameter ignore_size.
8
12
  # (useful for forcing activation when recorded size is wrong).
9
13
 
10
- def instance_activate_disks instance_name, params = {}
11
- warn "WARNING: Instances#instance_activate_disks not implemented."
12
- # put "/#{Ganeti::Version}/instances/#{instance_name}/activate-disks", params
14
+ def activate_disks name, params = {}
15
+ warn "WARNING: Instance#activate_disks not implemented."
16
+ # put "/#{Ganeti::Version}/instances/#{name}/activate-disks", params
13
17
  end
14
18
 
15
19
  ##
@@ -23,17 +27,17 @@ module Rubineti
23
27
  # the job will not be actually executed, only the pre-execution
24
28
  # checks will be done.
25
29
 
26
- def instance_create params = {}
27
- request.post "/#{Ganeti::Version}/instances", params
30
+ def create params = {}
31
+ @connection.post "/#{Ganeti::Version}/instances", params
28
32
  end
29
33
 
30
34
  ##
31
35
  # Deactivate disks on an instance.
32
36
  # Returns a job id.
33
37
 
34
- def instance_deactivate_disks instance_name
35
- warn "WARNING: Instances#instance_deactivate_disks not implemented."
36
- # put "/#{Ganeti::Version}/instances/#{instance_name}/deactivate-disks"
38
+ def deactivate_disks name
39
+ warn "WARNING: Instance#deactivate_disks not implemented."
40
+ # put "/#{Ganeti::Version}/instances/#{name}/deactivate-disks"
37
41
  end
38
42
 
39
43
  ##
@@ -44,8 +48,8 @@ module Rubineti
44
48
  # the job will not be actually executed, only the pre-execution
45
49
  # checks will be done.
46
50
 
47
- def instance_delete instance_name, params = {}
48
- request.delete "/#{Ganeti::Version}/instances/#{instance_name}", params
51
+ def delete name, params = {}
52
+ @connection.delete "/#{Ganeti::Version}/instances/#{name}", params
49
53
  end
50
54
 
51
55
  ##
@@ -55,9 +59,9 @@ module Rubineti
55
59
  # Body parameters:
56
60
  # - http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances-instance-name-export
57
61
 
58
- def instance_export instance_name, params = {}
59
- warn "WARNING: Instances#instance_export not implemented."
60
- # put "/#{Ganeti::Version}/instances/#{instance_name}/export", params
62
+ def export name, params = {}
63
+ warn "WARNING: Instance#export not implemented."
64
+ # put "/#{Ganeti::Version}/instances/#{name}/export", params
61
65
  end
62
66
 
63
67
  ##
@@ -67,16 +71,16 @@ module Rubineti
67
71
  # information from the configuration without querying the instance’s nodes.
68
72
  # The result will be a job id.
69
73
 
70
- def instance_info instance_name, params = {}
71
- request.get "/#{Ganeti::Version}/instances/#{instance_name}/info", params
74
+ def info name, params = {}
75
+ @connection.get "/#{Ganeti::Version}/instances/#{name}/info", params
72
76
  end
73
77
 
74
78
  ##
75
79
  # Returns information about an instance, similar to
76
80
  # the bulk output from +#instances_list+.
77
81
 
78
- def instance_list instance_name
79
- request.get "/#{Ganeti::Version}/instances/#{instance_name}"
82
+ def list name
83
+ @connection.get "/#{Ganeti::Version}/instances/#{name}"
80
84
  end
81
85
 
82
86
  ##
@@ -86,9 +90,9 @@ module Rubineti
86
90
  # Body parameters:
87
91
  # - http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances-instance-name-migrate
88
92
 
89
- def instance_migrate instance_name, params = {}
90
- warn "WARNING: Instances#instance_migrate not implemented."
91
- # put "/#{Ganeti::Version}/instances/#{instance_name}/migrate", params
93
+ def migrate name, params = {}
94
+ warn "WARNING: Instance#migrate not implemented."
95
+ # put "/#{Ganeti::Version}/instances/#{name}/migrate", params
92
96
  end
93
97
 
94
98
  ##
@@ -98,9 +102,9 @@ module Rubineti
98
102
  # Body parameters:
99
103
  # - http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances-instance-name-modify
100
104
 
101
- def instance_modify instance_name, params = {}
102
- warn "WARNING: Instances#instance_modify not implemented."
103
- # put "/#{Ganeti::Version}/instances/#{instance_name}/modify", params
105
+ def modify name, params = {}
106
+ warn "WARNING: Instance#modify not implemented."
107
+ # put "/#{Ganeti::Version}/instances/#{name}/modify", params
104
108
  end
105
109
 
106
110
  ##
@@ -109,9 +113,9 @@ module Rubineti
109
113
  #
110
114
  # Takes one parameter, mode, for the export mode.
111
115
 
112
- def instance_prepare_export instance_name, params = {}
113
- warn "WARNING: Instances#instance_prepare_export not implemented."
114
- # put "/#{Ganeti::Version}/instances/#{instance_name}/prepare-disks", params
116
+ def prepare_export name, params = {}
117
+ warn "WARNING: Instance#prepare_export not implemented."
118
+ # put "/#{Ganeti::Version}/instances/#{name}/prepare-disks", params
115
119
  end
116
120
 
117
121
  ##
@@ -131,8 +135,8 @@ module Rubineti
131
135
  # the job will not be actually executed, only the pre-execution
132
136
  # checks will be done.
133
137
 
134
- def instance_reboot instance_name, params = {}
135
- request.post "/#{Ganeti::Version}/instances/#{instance_name}/reboot", params
138
+ def reboot name, params = {}
139
+ @connection.post "/#{Ganeti::Version}/instances/#{name}/reboot", params
136
140
  end
137
141
 
138
142
  ##
@@ -141,8 +145,8 @@ module Rubineti
141
145
  #
142
146
  # Takes the parameters os (OS template name) and nostartup (bool).
143
147
 
144
- def instance_reinstall instance_name, params = {}
145
- request.post "/#{Ganeti::Version}/instances/#{instance_name}/reinstall", params
148
+ def reinstall name, params = {}
149
+ @connection.post "/#{Ganeti::Version}/instances/#{name}/reinstall", params
146
150
  end
147
151
 
148
152
  ##
@@ -152,9 +156,9 @@ module Rubineti
152
156
  # Body parameters:
153
157
  # - http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances-instance-name-rename
154
158
 
155
- def instance_rename instance_name, params = {}
156
- warn "WARNING: Instances#instance_rename not implemented."
157
- # put "/#{Ganeti::Version}/instances/#{instance_name}/rename", params
159
+ def rename name, params = {}
160
+ warn "WARNING: Instance#rename not implemented."
161
+ # put "/#{Ganeti::Version}/instances/#{name}/rename", params
158
162
  end
159
163
 
160
164
  ##
@@ -169,9 +173,9 @@ module Rubineti
169
173
  # Either remote_node or iallocator needs to be defined when using mode=replace_new_secondary.
170
174
  # replace_auto tries to determine the broken disk(s) on its own and replacing it.
171
175
 
172
- def instance_replace_disks instance_name, params = {}
173
- warn "WARNING: Instances#instance_replace_disks not implemented."
174
- # post "/#{Ganeti::Version}/instances/#{instance_name}/replace-disks", params
176
+ def replace_disks name, params = {}
177
+ warn "WARNING: Instance#replace_disks not implemented."
178
+ # post "/#{Ganeti::Version}/instances/#{name}/replace-disks", params
175
179
  end
176
180
 
177
181
  ##
@@ -182,8 +186,8 @@ module Rubineti
182
186
  # the job will not be actually executed, only the pre-execution
183
187
  # checks will be done.
184
188
 
185
- def instance_shutdown instance_name, params = {}
186
- request.put "/#{Ganeti::Version}/instances/#{instance_name}/shutdown", params
189
+ def shutdown name, params = {}
190
+ @connection.put "/#{Ganeti::Version}/instances/#{name}/shutdown", params
187
191
  end
188
192
 
189
193
  ##
@@ -192,8 +196,8 @@ module Rubineti
192
196
  # If the optional bulk parameter (?bulk=1) is provided,
193
197
  # the output contains detailed information about instances as a list.
194
198
 
195
- def instances_list params = {}
196
- request.get "/#{Ganeti::Version}/instances", params
199
+ def all params = {}
200
+ @connection.get "/#{Ganeti::Version}/instances", params
197
201
  end
198
202
 
199
203
  ##
@@ -204,8 +208,8 @@ module Rubineti
204
208
  # the job will not be actually executed, only the pre-execution
205
209
  # checks will be done.
206
210
 
207
- def instance_startup instance_name, params = {}
208
- request.put "/#{Ganeti::Version}/instances/#{instance_name}/startup", params
211
+ def startup name, params = {}
212
+ @connection.put "/#{Ganeti::Version}/instances/#{name}/startup", params
209
213
  end
210
214
 
211
215
  ##
@@ -216,9 +220,9 @@ module Rubineti
216
220
  # the job will not be actually executed, only the pre-execution
217
221
  # checks will be done.
218
222
 
219
- def instance_tag_create instance_name, params = {}
220
- warn "WARNING: Instances#instance_tag_create not implemented."
221
- # put "/#{Ganeti::Version}/instances/#{instance_name}/tags", params
223
+ def tag_create name, params = {}
224
+ warn "WARNING: Instance#tag_create not implemented."
225
+ # put "/#{Ganeti::Version}/instances/#{name}/tags", params
222
226
  end
223
227
 
224
228
  ##
@@ -229,17 +233,17 @@ module Rubineti
229
233
  # the job will not be actually executed, only the pre-execution
230
234
  # checks will be done.
231
235
 
232
- def instance_tag_delete instance_name, params = {}
233
- warn "WARNING: Instances#instance_tag_delete not implemented."
234
- # delete "/#{Ganeti::Version}/instances/#{instance_name}/tags", params
236
+ def tag_delete name, params = {}
237
+ warn "WARNING: Instance#tag_delete not implemented."
238
+ # delete "/#{Ganeti::Version}/instances/#{name}/tags", params
235
239
  end
236
240
 
237
241
  ##
238
242
  # Return a list of tags.
239
243
 
240
- def instance_tag_list instance_name, params = {}
241
- warn "WARNING: Instances#instance_tag_list not implemented."
242
- # get "/#{Ganeti::Version}/instances/#{instance_name}/tags", params
244
+ def tag_list name, params = {}
245
+ warn "WARNING: Instance#tag_list not implemented."
246
+ # get "/#{Ganeti::Version}/instances/#{name}/tags", params
243
247
  end
244
248
  end
245
249
  end