proxmox 0.0.2 → 0.0.3
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 +1 -0
- data/Gemfile +4 -1
- data/README.md +6 -2
- data/lib/proxmox.rb +22 -11
- data/lib/proxmox/version.rb +1 -1
- data/spec/lib/proxmox_spec.rb +12 -0
- metadata +4 -4
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -8,7 +8,10 @@ group :developpement do
|
|
8
8
|
gem "guard-rspec"
|
9
9
|
gem "guard-bundler"
|
10
10
|
|
11
|
-
gem "growl"
|
11
|
+
gem "growl" if RUBY_PLATFORM =~ /darwin/
|
12
|
+
gem "wdm" if RUBY_PLATFORM =~ /mingw/
|
13
|
+
gem "ruby_gntp" if RUBY_PLATFORM =~ /mingw/
|
14
|
+
|
12
15
|
gem "spork"
|
13
16
|
gem "guard-spork"
|
14
17
|
|
data/README.md
CHANGED
@@ -10,9 +10,9 @@ Current build:
|
|
10
10
|
[](https://gemnasium.com/nledez/proxmox)
|
11
11
|
[](https://codeclimate.com/github/nledez/proxmox)
|
12
12
|
|
13
|
-
[
|
13
|
+
[RubyGem](http://rubygems.org/gems/proxmox)
|
14
14
|
|
15
|
-
[
|
15
|
+
[Rubydoc](http://rubydoc.info/github/nledez/proxmox/master/frames)
|
16
16
|
|
17
17
|
Inspirated from:
|
18
18
|
https://bitbucket.org/jmoratilla/knife-proxmox/ but I would like to have
|
@@ -20,6 +20,10 @@ the same without chef.
|
|
20
20
|
https://github.com/maxschulze/uv_proxmox but listing some task does not
|
21
21
|
work for me. No tests, use ssh.
|
22
22
|
|
23
|
+
Documentation from:
|
24
|
+
- http://pve.proxmox.com/wiki/Proxmox_VE_API
|
25
|
+
- http://pve.proxmox.com/pve2-api-doc/
|
26
|
+
|
23
27
|
So I start to create one fully tested (TDD method).
|
24
28
|
|
25
29
|
|
data/lib/proxmox.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'proxmox/version'
|
2
2
|
require 'rest_client'
|
3
3
|
require 'json'
|
4
4
|
|
@@ -26,7 +26,7 @@ module Proxmox
|
|
26
26
|
@username = username
|
27
27
|
@password = password
|
28
28
|
@realm = realm
|
29
|
-
@connection_status =
|
29
|
+
@connection_status = 'error'
|
30
30
|
@site = RestClient::Resource.new(@pve_cluster)
|
31
31
|
@auth_params = create_ticket
|
32
32
|
end
|
@@ -88,7 +88,7 @@ module Proxmox
|
|
88
88
|
#
|
89
89
|
def templates
|
90
90
|
data = http_action_get "nodes/#{@node}/storage/local/content"
|
91
|
-
template_list =
|
91
|
+
template_list = {}
|
92
92
|
data.each do |ve|
|
93
93
|
name = ve['volid'].gsub(/^local:vztmpl\/(.*).tar.gz$/, '\1')
|
94
94
|
template_list[name] = ve
|
@@ -135,7 +135,7 @@ module Proxmox
|
|
135
135
|
# }
|
136
136
|
def openvz_get
|
137
137
|
data = http_action_get "nodes/#{@node}/openvz"
|
138
|
-
ve_list =
|
138
|
+
ve_list = {}
|
139
139
|
data.each do |ve|
|
140
140
|
ve_list[ve['vmid']] = ve
|
141
141
|
end
|
@@ -296,17 +296,22 @@ module Proxmox
|
|
296
296
|
http_action_get "nodes/#{@node}/openvz/#{vmid}/config"
|
297
297
|
end
|
298
298
|
|
299
|
+
def openvz_config_set(vmid, data)
|
300
|
+
http_action_put("nodes/#{@node}/openvz/#{vmid}/config", data)
|
301
|
+
end
|
302
|
+
|
299
303
|
private
|
304
|
+
|
300
305
|
# Methods manages auth
|
301
306
|
def create_ticket
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
end
|
307
|
+
post_param = { :username => @username, :realm => @realm, :password => @password }
|
308
|
+
@site['access/ticket'].post post_param do |response, request, result, &block|
|
309
|
+
if response.code == 200
|
310
|
+
extract_ticket response
|
311
|
+
else
|
312
|
+
@connection_status = "error"
|
309
313
|
end
|
314
|
+
end
|
310
315
|
end
|
311
316
|
|
312
317
|
# Method create ticket
|
@@ -340,6 +345,12 @@ module Proxmox
|
|
340
345
|
end
|
341
346
|
end
|
342
347
|
|
348
|
+
def http_action_put(url, data = "")
|
349
|
+
@site[url].put data, @auth_params do |response, request, result, &block|
|
350
|
+
check_response response
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
343
354
|
def http_action_get(url)
|
344
355
|
@site[url].get @auth_params do |response, request, result, &block|
|
345
356
|
check_response response
|
data/lib/proxmox/version.rb
CHANGED
data/spec/lib/proxmox_spec.rb
CHANGED
@@ -224,4 +224,16 @@ describe Proxmox do
|
|
224
224
|
@server1.openvz_config(200)['searchdomain'].should be_eql "domain.com"
|
225
225
|
@server1.openvz_config(200)['ostemplate'].should be_eql "ubuntu-10.04-standard_10.04-4_i386.tar.gz"
|
226
226
|
end
|
227
|
+
|
228
|
+
it "should modify container config" do
|
229
|
+
# VM config
|
230
|
+
stub_request(:put, "http://localhost:8006/api2/json/nodes/localhost/openvz/200/config").with(
|
231
|
+
:headers => @common_headers_in).to_return(
|
232
|
+
:status => 200,
|
233
|
+
:headers => @common_headers_out,
|
234
|
+
:body => '{"data":null}'
|
235
|
+
)
|
236
|
+
|
237
|
+
@server1.openvz_config_set(200, { 'searchdomain' => 'other.com' })
|
238
|
+
end
|
227
239
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxmox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -126,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
segments:
|
128
128
|
- 0
|
129
|
-
hash:
|
129
|
+
hash: 3719547986360865543
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
none: false
|
132
132
|
requirements:
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
segments:
|
137
137
|
- 0
|
138
|
-
hash:
|
138
|
+
hash: 3719547986360865543
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
141
|
rubygems_version: 1.8.23
|