rubineti 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,14 @@
1
1
  module Rubineti
2
- module Jobs
2
+ class Job
3
+ def initialize connection
4
+ @connection = connection
5
+ end
6
+
3
7
  ##
4
8
  # Returns an Array of all jobs.
5
9
 
6
- def jobs_list
7
- request.get "/#{Ganeti::Version}/jobs"
10
+ def all
11
+ @connection.get "/#{Ganeti::Version}/jobs"
8
12
  end
9
13
 
10
14
  ##
@@ -12,8 +16,8 @@ module Rubineti
12
16
  #
13
17
  # +job_id+: A String of the 'job id'.
14
18
 
15
- def job_list job_id
16
- request.get "/#{Ganeti::Version}/jobs/#{job_id}"
19
+ def list job_id
20
+ @connection.get "/#{Ganeti::Version}/jobs/#{job_id}"
17
21
  end
18
22
 
19
23
  ##
@@ -21,8 +25,8 @@ module Rubineti
21
25
  #
22
26
  # +job_id+: A String of the 'job id'.
23
27
 
24
- def job_delete job_id
25
- warn "WARNING: Jobs#job_delete not implemented."
28
+ def delete job_id
29
+ warn "WARNING: Job#job_delete not implemented."
26
30
  # delete "/#{Ganeti::Version}/jobs/#{job_id}/delete"
27
31
  end
28
32
 
@@ -34,8 +38,8 @@ module Rubineti
34
38
  # Body parameters:
35
39
  # - http://docs.ganeti.org/ganeti/#{Ganeti::Version}.1/html/rapi.html#jobs-job-id-wait
36
40
 
37
- def job_wait job_id, params = {}
38
- warn "WARNING: Jobs#job_wait not implemented."
41
+ def wait job_id, params = {}
42
+ warn "WARNING: Job#job_wait not implemented."
39
43
  # get "/#{Ganeti::Version}/jobs/#{job_id}/wait", params
40
44
  end
41
45
  end
@@ -1,5 +1,8 @@
1
1
  module Rubineti
2
- module Node
2
+ class Node
3
+ def initialize connection
4
+ @connection = connection
5
+ end
3
6
 
4
7
  ##
5
8
  # Evacuates all secondary instances off a node.
@@ -13,16 +16,16 @@ module Rubineti
13
16
  # the job will not be actually executed, only the pre-execution
14
17
  # checks will be done.
15
18
 
16
- def node_evacuate node_name, params = {}
17
- warn "WARNING: Node#node_evacuate not implemented."
18
- # post "/2/nodes/#{node_name}/evacuate", params
19
+ def evacuate name, params = {}
20
+ warn "WARNING: Node#evacuate not implemented."
21
+ # post "/2/nodes/#{name}/evacuate", params
19
22
  end
20
23
 
21
24
  ##
22
25
  # Returns information about a node.
23
26
 
24
- def node_list node_name
25
- request.get "/2/nodes/#{node_name}"
27
+ def list name
28
+ @connection.get "/2/nodes/#{name}"
26
29
  end
27
30
 
28
31
  ##
@@ -34,9 +37,9 @@ module Rubineti
34
37
  # - mode (string): Sets migration mode, live for live migration
35
38
  # and non-live for non-live migration. Supported by Ganeti 2.2 and above.
36
39
 
37
- def node_migrate node_name, params = {}
38
- warn "WARNING: Node#node_migrate not implemented."
39
- # post "/2/nodes/#{node_name}/migrate", params
40
+ def migrate name, params = {}
41
+ warn "WARNING: Node#migrate not implemented."
42
+ # post "/2/nodes/#{name}/migrate", params
40
43
  end
41
44
 
42
45
  ##
@@ -45,17 +48,17 @@ module Rubineti
45
48
  #
46
49
  # It supports the bool force argument.
47
50
 
48
- def node_role_create node_name
49
- warn "WARNING: Node#node_role_create not implemented."
51
+ def role_create name
52
+ warn "WARNING: Node#role_create not implemented."
50
53
  # TODO: API Docs do not describe it's usage well.
51
- # put "/2/nodes/#{node_name}/role"
54
+ # put "/2/nodes/#{name}/role"
52
55
  end
53
56
 
54
57
  ##
55
58
  # Returns the current node role.
56
59
 
57
- def node_role_list node_name
58
- request.get "/2/nodes/#{node_name}/role"
60
+ def role_list name
61
+ @connection.get "/2/nodes/#{name}/role"
59
62
  end
60
63
 
61
64
  ##
@@ -64,8 +67,8 @@ module Rubineti
64
67
  # If the optional bulk parameter (?bulk=1) is provided,
65
68
  # the output contains detailed information about instances as a list.
66
69
 
67
- def nodes_list params = {}
68
- request.get "/2/nodes", params
70
+ def all params = {}
71
+ @connection.get "/2/nodes", params
69
72
  end
70
73
 
71
74
  ##
@@ -74,9 +77,9 @@ module Rubineti
74
77
  #
75
78
  # Requires the parameters storage_type (one of file, lvm-pv or lvm-vg) and output_fields.
76
79
 
77
- def node_storage_list node_name, params = {}
78
- warn "WARNING: Node#node_storage_list not implemented."
79
- # get "/2/nodes/#{node_name}/storage", params
80
+ def storage_list name, params = {}
81
+ warn "WARNING: Node#storage_list not implemented."
82
+ # get "/2/nodes/#{name}/storage", params
80
83
  end
81
84
 
82
85
  ##
@@ -86,9 +89,9 @@ module Rubineti
86
89
  # Requires the parameters storage_type (one of file, lvm-pv or lvm-vg) and name (name of the storage unit).
87
90
  # Parameters can be passed additionally. Currently only allocatable (bool) is supported.
88
91
 
89
- def node_storage_modify node_name, params = {}
90
- warn "WARNING: Node#node_storage_modify not implemented."
91
- # put "/2/nodes/#{node_name}/storage/modify", params
92
+ def storage_modify name, params = {}
93
+ warn "WARNING: Node#storage_modify not implemented."
94
+ # put "/2/nodes/#{name}/storage/modify", params
92
95
  end
93
96
 
94
97
  ##
@@ -98,9 +101,9 @@ module Rubineti
98
101
  # Requires the parameters storage_type (currently only lvm-vg can be repaired) and
99
102
  # name (name of the storage unit).
100
103
 
101
- def node_storage_repair node_name, params = {}
102
- warn "WARNING: Node#node_storage_repair not implemented."
103
- # put "/2/nodes/#{node_name}/repair", params
104
+ def storage_repair name, params = {}
105
+ warn "WARNING: Node#storage_repair not implemented."
106
+ # put "/2/nodes/#{name}/repair", params
104
107
  end
105
108
 
106
109
  ##
@@ -111,9 +114,9 @@ module Rubineti
111
114
  # the job will not be actually executed, only the pre-execution
112
115
  # checks will be done.
113
116
 
114
- def node_tags_create node_name, params = {}
115
- warn "WARNING: Node#node_tags_create not implemented."
116
- # put "/2/nodes/#{node_name}/tags", params
117
+ def tags_create name, params = {}
118
+ warn "WARNING: Node#tags_create not implemented."
119
+ # put "/2/nodes/#{name}/tags", params
117
120
  end
118
121
 
119
122
  ##
@@ -124,17 +127,17 @@ module Rubineti
124
127
  # the job will not be actually executed, only the pre-execution
125
128
  # checks will be done.
126
129
 
127
- def node_tags_delete node_name, params = {}
128
- warn "WARNING: Node#node_tags_delete not implemented."
129
- # delete "/2/nodes/#{node_name}/tags", params
130
+ def tags_delete name, params = {}
131
+ warn "WARNING: Node#tags_delete not implemented."
132
+ # delete "/2/nodes/#{name}/tags", params
130
133
  end
131
134
 
132
135
  ##
133
136
  # Return a list of tags.
134
137
 
135
- def node_tags_list node_name
136
- warn "WARNING: Node#node_tags_list not implemented."
137
- # get "/2/nodes/#{node_name}/tags"
138
+ def tags_list name
139
+ warn "WARNING: Node#tags_list not implemented."
140
+ # get "/2/nodes/#{name}/tags"
138
141
  end
139
142
  end
140
143
  end
data/rubineti.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubineti}
8
- s.version = "1.3.0"
8
+ s.version = "1.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["retr0h"]
12
- s.date = %q{2010-12-12}
12
+ s.date = %q{2011-01-30}
13
13
  s.email = %q{john@dewey.ws}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -25,11 +25,11 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "lib/ganeti.rb",
27
27
  "lib/rubineti.rb",
28
- "lib/rubineti/compute.rb",
29
- "lib/rubineti/compute/cluster.rb",
30
- "lib/rubineti/compute/instances.rb",
31
- "lib/rubineti/compute/jobs.rb",
32
- "lib/rubineti/compute/node.rb",
28
+ "lib/rubineti/client.rb",
29
+ "lib/rubineti/cluster.rb",
30
+ "lib/rubineti/instance.rb",
31
+ "lib/rubineti/job.rb",
32
+ "lib/rubineti/node.rb",
33
33
  "rubineti.gemspec",
34
34
  "test/fixtures/cassettes/cluster_info.yml",
35
35
  "test/fixtures/cassettes/cluster_oses.yml",
@@ -49,22 +49,22 @@ Gem::Specification.new do |s|
49
49
  "test/fixtures/cassettes/node_list.yml",
50
50
  "test/fixtures/cassettes/node_role_list.yml",
51
51
  "test/fixtures/cassettes/nodes.yml",
52
- "test/lib/rubineti/compute/test_cluster.rb",
53
- "test/lib/rubineti/compute/test_instances.rb",
54
- "test/lib/rubineti/compute/test_jobs.rb",
55
- "test/lib/rubineti/compute/test_node.rb",
56
- "test/support.rb"
52
+ "test/lib/rubineti/cluster_test.rb",
53
+ "test/lib/rubineti/instance_test.rb",
54
+ "test/lib/rubineti/job_test.rb",
55
+ "test/lib/rubineti/node_test.rb",
56
+ "test/test_helper.rb"
57
57
  ]
58
58
  s.homepage = %q{http://github.com/retr0h/rubineti}
59
59
  s.require_paths = ["lib"]
60
60
  s.rubygems_version = %q{1.3.7}
61
61
  s.summary = %q{Ruby bindings to Ganeti's v2 Remote API.}
62
62
  s.test_files = [
63
- "test/lib/rubineti/compute/test_cluster.rb",
64
- "test/lib/rubineti/compute/test_instances.rb",
65
- "test/lib/rubineti/compute/test_jobs.rb",
66
- "test/lib/rubineti/compute/test_node.rb",
67
- "test/support.rb"
63
+ "test/lib/rubineti/cluster_test.rb",
64
+ "test/lib/rubineti/instance_test.rb",
65
+ "test/lib/rubineti/job_test.rb",
66
+ "test/lib/rubineti/node_test.rb",
67
+ "test/test_helper.rb"
68
68
  ]
69
69
 
70
70
  if s.respond_to? :specification_version then
@@ -72,30 +72,30 @@ Gem::Specification.new do |s|
72
72
  s.specification_version = 3
73
73
 
74
74
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
75
- s.add_runtime_dependency(%q<hugs>, ["~> 1.1.0"])
75
+ s.add_runtime_dependency(%q<hugs>, ["~> 2.3.0"])
76
76
  s.add_development_dependency(%q<rake>, [">= 0"])
77
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
78
- s.add_development_dependency(%q<vcr>, ["~> 1.3.3"])
79
- s.add_development_dependency(%q<webmock>, ["~> 1.6.1"])
80
- s.add_development_dependency(%q<minitest>, ["~> 2.0.0"])
81
- s.add_development_dependency(%q<yajl-ruby>, ["~> 0.7.8"])
77
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
78
+ s.add_development_dependency(%q<vcr>, [">= 0"])
79
+ s.add_development_dependency(%q<webmock>, [">= 0"])
80
+ s.add_development_dependency(%q<minitest>, [">= 0"])
81
+ s.add_development_dependency(%q<yajl-ruby>, [">= 0"])
82
82
  else
83
- s.add_dependency(%q<hugs>, ["~> 1.1.0"])
83
+ s.add_dependency(%q<hugs>, ["~> 2.3.0"])
84
84
  s.add_dependency(%q<rake>, [">= 0"])
85
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
86
- s.add_dependency(%q<vcr>, ["~> 1.3.3"])
87
- s.add_dependency(%q<webmock>, ["~> 1.6.1"])
88
- s.add_dependency(%q<minitest>, ["~> 2.0.0"])
89
- s.add_dependency(%q<yajl-ruby>, ["~> 0.7.8"])
85
+ s.add_dependency(%q<jeweler>, [">= 0"])
86
+ s.add_dependency(%q<vcr>, [">= 0"])
87
+ s.add_dependency(%q<webmock>, [">= 0"])
88
+ s.add_dependency(%q<minitest>, [">= 0"])
89
+ s.add_dependency(%q<yajl-ruby>, [">= 0"])
90
90
  end
91
91
  else
92
- s.add_dependency(%q<hugs>, ["~> 1.1.0"])
92
+ s.add_dependency(%q<hugs>, ["~> 2.3.0"])
93
93
  s.add_dependency(%q<rake>, [">= 0"])
94
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
95
- s.add_dependency(%q<vcr>, ["~> 1.3.3"])
96
- s.add_dependency(%q<webmock>, ["~> 1.6.1"])
97
- s.add_dependency(%q<minitest>, ["~> 2.0.0"])
98
- s.add_dependency(%q<yajl-ruby>, ["~> 0.7.8"])
94
+ s.add_dependency(%q<jeweler>, [">= 0"])
95
+ s.add_dependency(%q<vcr>, [">= 0"])
96
+ s.add_dependency(%q<webmock>, [">= 0"])
97
+ s.add_dependency(%q<minitest>, [">= 0"])
98
+ s.add_dependency(%q<yajl-ruby>, [">= 0"])
99
99
  end
100
100
  end
101
101
 
@@ -0,0 +1,69 @@
1
+ require "test_helper"
2
+
3
+ describe Rubineti::Cluster do
4
+ describe "#features" do
5
+ it "is not implemented" do
6
+ out, err = capture_io { CONNECTION.cluster.features }
7
+
8
+ err.must_match Not_Implemented_Matcher
9
+ end
10
+ end
11
+
12
+ describe "#info" do
13
+ it "returns a Hash" do
14
+ VCR.use_cassette "cluster_info" do
15
+ response = CONNECTION.cluster.info.body
16
+
17
+ response.must_be_kind_of Hash
18
+ end
19
+ end
20
+ end
21
+
22
+ describe "#redistribute_config" do
23
+ it "returns a job_id" do
24
+ VCR.use_cassette "cluster_redistribute_config" do
25
+ CONNECTION.cluster.redistribute_config.body.must_match Job_Matcher
26
+ end
27
+ end
28
+ end
29
+
30
+ describe "#tags_create" do
31
+ it "is not implemented" do
32
+ out, err = capture_io { CONNECTION.cluster.tags_create }
33
+
34
+ err.must_match Not_Implemented_Matcher
35
+ end
36
+ end
37
+
38
+ describe "#tags_delete" do
39
+ it "is not implemented" do
40
+ out, err = capture_io { CONNECTION.cluster.tags_create }
41
+
42
+ err.must_match Not_Implemented_Matcher
43
+ end
44
+ end
45
+
46
+ describe "#tags_list" do
47
+ it "is not implemented" do
48
+ out, err = capture_io { CONNECTION.cluster.tags_list }
49
+
50
+ err.must_match Not_Implemented_Matcher
51
+ end
52
+ end
53
+
54
+ describe "#version" do
55
+ it "returns a version string" do
56
+ VCR.use_cassette "cluster_version" do
57
+ CONNECTION.cluster.version.body.must_equal 2
58
+ end
59
+ end
60
+ end
61
+
62
+ describe "#os_list" do
63
+ it "returns an Array" do
64
+ VCR.use_cassette "cluster_oses" do
65
+ CONNECTION.cluster.os_list.body.size.must_equal 1
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,199 @@
1
+ require "test_helper"
2
+
3
+ describe Rubineti::Instance do
4
+ describe "#activate_disks" do
5
+ it "is not implemented" do
6
+ out, err = capture_io { CONNECTION.instance.activate_disks(:invalid_instance_name) }
7
+
8
+ err.must_match Not_Implemented_Matcher
9
+ end
10
+ end
11
+
12
+ describe "#create" do
13
+ it "returns a job_id" do
14
+ params = {
15
+ :__version__ => Ganeti::Version,
16
+ :name => "compute1",
17
+ :pnode => "node1",
18
+ :snode => "node2",
19
+ :disk_template => "drbd8",
20
+ :disks => [4096],
21
+ :beparams => { :vcpus => 1, :memory => 512 },
22
+ :os => "debootstrap+default"
23
+ }
24
+
25
+ VCR.use_cassette "instance_create" do
26
+ response = CONNECTION.instance.create :body => params, :query => "dry-run=1"
27
+
28
+ response.body.must_match Job_Matcher
29
+ end
30
+ end
31
+ end
32
+
33
+ describe "#deactivate_disks" do
34
+ it "is not implemented" do
35
+ out, err = capture_io { CONNECTION.instance.deactivate_disks :invalid_instance_name }
36
+
37
+ err.must_match Not_Implemented_Matcher
38
+ end
39
+ end
40
+
41
+ describe "#delete" do
42
+ it "returns a job_id" do
43
+ VCR.use_cassette "instance_delete" do
44
+ response = CONNECTION.instance.delete :invalid_instance_name, :query => "dry-run=1"
45
+
46
+ response.body.must_match Job_Matcher
47
+ end
48
+ end
49
+ end
50
+
51
+ describe "#export" do
52
+ it "is not implemented" do
53
+ out, err = capture_io { CONNECTION.instance.export :invalid_instance_name }
54
+
55
+ err.must_match Not_Implemented_Matcher
56
+ end
57
+ end
58
+
59
+ describe "#info" do
60
+ it "returns a job_id" do
61
+ name = cassette_for("instances").first["name"]
62
+
63
+ VCR.use_cassette "instance_info" do
64
+ response = CONNECTION.instance.info name
65
+
66
+ response.body.must_match Job_Matcher
67
+ end
68
+ end
69
+ end
70
+
71
+ describe "#list" do
72
+ it "returns a Hash" do
73
+ name = cassette_for("instances").first["name"]
74
+
75
+ VCR.use_cassette "instance_list" do
76
+ response = CONNECTION.instance.list name
77
+
78
+ response.body.must_be_kind_of Hash
79
+ end
80
+ end
81
+ end
82
+
83
+ describe "#migrate" do
84
+ it "is not implemented" do
85
+ out, err = capture_io { CONNECTION.instance.migrate :invalid_instance_name }
86
+
87
+ err.must_match Not_Implemented_Matcher
88
+ end
89
+ end
90
+
91
+ describe "#modify" do
92
+ it "is not implemented" do
93
+ out, err = capture_io { CONNECTION.instance.modify :invalid_instance_name }
94
+
95
+ err.must_match Not_Implemented_Matcher
96
+ end
97
+ end
98
+
99
+ describe "#prepare_export" do
100
+ it "is not implemented" do
101
+ out, err = capture_io { CONNECTION.instance.prepare_export :invalid_instance_name }
102
+
103
+ err.must_match Not_Implemented_Matcher
104
+ end
105
+ end
106
+
107
+ describe "#reboot" do
108
+ it "returns a job_id" do
109
+ VCR.use_cassette "instance_reboot" do
110
+ response = CONNECTION.instance.reboot :invalid_instance_name, :query => "dry-run=1"
111
+
112
+ response.body.must_match Job_Matcher
113
+ end
114
+ end
115
+ end
116
+
117
+ describe "#reinstall" do
118
+ it "returns a job_id" do
119
+ name = cassette_for("instances").first["name"]
120
+ params = {
121
+ :os => "debootstrap+default"
122
+ }
123
+
124
+ VCR.use_cassette "instance_reinstall" do
125
+ response = CONNECTION.instance.reinstall name, :body => params
126
+
127
+ response.body.must_match Job_Matcher
128
+ end
129
+ end
130
+ end
131
+
132
+ describe "#rename" do
133
+ it "is not implemented" do
134
+ lambda { CONNECTION.instance.rename :invalid_instance_name }.must_output(nil, nil).must_equal true
135
+ end
136
+ end
137
+
138
+ describe "#replace_disks" do
139
+ it "is not implemented" do
140
+ out, err = capture_io { CONNECTION.instance.replace_disks :invalid_instance_name }
141
+
142
+ err.must_match Not_Implemented_Matcher
143
+ end
144
+ end
145
+
146
+ describe "#shutdown" do
147
+ it "returns a job_id" do
148
+ VCR.use_cassette "instance_shutdown" do
149
+ response = CONNECTION.instance.shutdown :invalid_instance_name, :query => "dry-run=1"
150
+
151
+ response.body.must_match Job_Matcher
152
+ end
153
+ end
154
+ end
155
+
156
+ describe "#all" do
157
+ it "returns an Array of Hashes" do
158
+ VCR.use_cassette "instances" do
159
+ response = CONNECTION.instance.all :query => "bulk=1"
160
+
161
+ response.body.size.must_equal 1
162
+ end
163
+ end
164
+ end
165
+
166
+ describe "#startup" do
167
+ it "returns a job_id" do
168
+ VCR.use_cassette "instance_startup" do
169
+ response = CONNECTION.instance.startup :invalid_instance_name, :query => "dry-run=1"
170
+
171
+ response.body.must_match Job_Matcher
172
+ end
173
+ end
174
+ end
175
+
176
+ describe "#tag_create" do
177
+ it "is not implemented" do
178
+ out, err = capture_io { CONNECTION.instance.tag_create :invalid_instance_name }
179
+
180
+ err.must_match Not_Implemented_Matcher
181
+ end
182
+ end
183
+
184
+ describe "#tag_delete" do
185
+ it "is not implemented" do
186
+ out, err = capture_io { CONNECTION.instance.tag_delete :invalid_instance_name }
187
+
188
+ err.must_match Not_Implemented_Matcher
189
+ end
190
+ end
191
+
192
+ describe "#tag_list" do
193
+ it "is not implemented" do
194
+ out, err = capture_io { CONNECTION.instance.tag_list :invalid_instance_name }
195
+
196
+ err.must_match Not_Implemented_Matcher
197
+ end
198
+ end
199
+ end