rubineti 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/Gemfile +6 -6
- data/Gemfile.lock +17 -13
- data/README.md +15 -9
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/ganeti.rb +1 -1
- data/lib/rubineti.rb +1 -1
- data/lib/rubineti/client.rb +44 -0
- data/lib/rubineti/{compute/cluster.rb → cluster.rb} +21 -17
- data/lib/rubineti/{compute/instances.rb → instance.rb} +56 -52
- data/lib/rubineti/{compute/jobs.rb → job.rb} +13 -9
- data/lib/rubineti/{compute/node.rb → node.rb} +37 -34
- data/rubineti.gemspec +35 -35
- data/test/lib/rubineti/cluster_test.rb +69 -0
- data/test/lib/rubineti/instance_test.rb +199 -0
- data/test/lib/rubineti/job_test.rb +39 -0
- data/test/lib/rubineti/node_test.rb +75 -0
- data/test/{support.rb → test_helper.rb} +7 -7
- metadata +34 -44
- data/lib/rubineti/compute.rb +0 -33
- data/test/lib/rubineti/compute/test_cluster.rb +0 -71
- data/test/lib/rubineti/compute/test_instances.rb +0 -202
- data/test/lib/rubineti/compute/test_jobs.rb +0 -41
- data/test/lib/rubineti/compute/test_node.rb +0 -77
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm ruby-1.9.2-
|
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", "~>
|
3
|
+
gem "hugs", "~> 2.3.0"
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem "rake"
|
7
|
-
gem "jeweler"
|
8
|
-
gem "vcr"
|
9
|
-
gem "webmock"
|
10
|
-
gem "minitest"
|
11
|
-
gem "yajl-ruby"
|
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.
|
4
|
+
addressable (2.2.4)
|
5
5
|
crack (0.1.8)
|
6
6
|
git (1.2.5)
|
7
|
-
hugs (
|
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.
|
12
|
+
jeweler (1.5.2)
|
11
13
|
bundler (~> 1.0.0)
|
12
14
|
git (>= 1.2.5)
|
13
15
|
rake
|
14
|
-
minitest (2.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.
|
18
|
-
webmock (1.6.
|
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.
|
25
|
+
yajl-ruby (0.7.9)
|
22
26
|
|
23
27
|
PLATFORMS
|
24
28
|
ruby
|
25
29
|
|
26
30
|
DEPENDENCIES
|
27
|
-
hugs (~>
|
28
|
-
jeweler
|
29
|
-
minitest
|
31
|
+
hugs (~> 2.3.0)
|
32
|
+
jeweler
|
33
|
+
minitest
|
30
34
|
rake
|
31
|
-
vcr
|
32
|
-
webmock
|
33
|
-
yajl-ruby
|
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
|
13
|
+
See the examples section in the [wiki](http://github.com/retr0h/rubineti/wiki).
|
14
14
|
|
15
|
-
##
|
15
|
+
## Compatability
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
ruby 1.9.2
|
18
|
+
|
19
|
+
## Testing
|
19
20
|
|
20
|
-
|
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
|
-
|
25
|
+
Tests can run offline thanks to [VCR](https://github.com/myronmarston/vcr).
|
23
26
|
|
24
|
-
|
27
|
+
$ bundle exec rake
|
25
28
|
|
26
|
-
|
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
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0
|
data/lib/ganeti.rb
CHANGED
data/lib/rubineti.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require "rubineti/
|
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
|
-
|
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
|
7
|
-
warn "WARNING: Cluster#
|
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
|
15
|
-
|
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
|
23
|
-
|
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
|
35
|
-
warn "WARNING: Cluster#
|
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
|
48
|
-
warn "WARNING: Cluster#
|
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
|
56
|
-
warn "WARNING: Cluster#
|
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
|
64
|
-
|
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
|
71
|
-
|
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
|
-
|
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
|
11
|
-
warn "WARNING:
|
12
|
-
# put "/#{Ganeti::Version}/instances/#{
|
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
|
27
|
-
|
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
|
35
|
-
warn "WARNING:
|
36
|
-
# put "/#{Ganeti::Version}/instances/#{
|
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
|
48
|
-
|
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
|
59
|
-
warn "WARNING:
|
60
|
-
# put "/#{Ganeti::Version}/instances/#{
|
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
|
71
|
-
|
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
|
79
|
-
|
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
|
90
|
-
warn "WARNING:
|
91
|
-
# put "/#{Ganeti::Version}/instances/#{
|
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
|
102
|
-
warn "WARNING:
|
103
|
-
# put "/#{Ganeti::Version}/instances/#{
|
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
|
113
|
-
warn "WARNING:
|
114
|
-
# put "/#{Ganeti::Version}/instances/#{
|
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
|
135
|
-
|
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
|
145
|
-
|
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
|
156
|
-
warn "WARNING:
|
157
|
-
# put "/#{Ganeti::Version}/instances/#{
|
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
|
173
|
-
warn "WARNING:
|
174
|
-
# post "/#{Ganeti::Version}/instances/#{
|
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
|
186
|
-
|
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
|
196
|
-
|
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
|
208
|
-
|
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
|
220
|
-
warn "WARNING:
|
221
|
-
# put "/#{Ganeti::Version}/instances/#{
|
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
|
233
|
-
warn "WARNING:
|
234
|
-
# delete "/#{Ganeti::Version}/instances/#{
|
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
|
241
|
-
warn "WARNING:
|
242
|
-
# get "/#{Ganeti::Version}/instances/#{
|
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
|