knife-proxmox 0.0.17 → 0.0.18
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/CHANGELOG +5 -0
- data/README.md +180 -0
- data/knife-proxmox.gemspec +1 -1
- data/lib/chef/knife/proxmox_server_list.rb +9 -2
- data/lib/knife-proxmox/version.rb +1 -1
- metadata +5 -5
- data/README +0 -163
data/CHANGELOG
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
Author: Jorge Moratilla
|
2
2
|
Date: 2012-10-07
|
3
|
+
|
4
|
+
[2013-04-29]
|
5
|
+
Version: 0.0.17
|
6
|
+
* knife proxmox server destroy now requests confirmation to delete a server
|
7
|
+
|
3
8
|
[2013-01-23]
|
4
9
|
Version: 0.0.10
|
5
10
|
* knife proxmox server create can bootstrap a server, enabled by default
|
data/README.md
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
# Chef::Knife::Proxmox
|
2
|
+
|
3
|
+
Authors: Jorge Moratilla, Sergio Galvan
|
4
|
+
Date: 2012-10-07
|
5
|
+
|
6
|
+
|
7
|
+
## Description
|
8
|
+
|
9
|
+
This knife plugin allows to access Proxmox Virtualization Environment (Proxmox VE or PVE) through its API.
|
10
|
+
It allows you to lists templates installed on the server/cluster (like images or amis), create a server or
|
11
|
+
destroy it.
|
12
|
+
|
13
|
+
Currently it only supports management of openVZ instances, but KVM instances will be able in a future.
|
14
|
+
|
15
|
+
## Requirements
|
16
|
+
|
17
|
+
* zlib (zlib1g-dev)
|
18
|
+
* openssl (libopenssl-ruby, libssl-dev)
|
19
|
+
|
20
|
+
Then install your ruby language (recommended ruby-1.9.3-xxx)
|
21
|
+
|
22
|
+
(See installation instructions beneath)
|
23
|
+
|
24
|
+
|
25
|
+
## Actions implemented
|
26
|
+
|
27
|
+
+ proxmox server list
|
28
|
+
+ proxmox server info
|
29
|
+
+ proxmox server create
|
30
|
+
+ proxmox server start
|
31
|
+
+ proxmox server stop
|
32
|
+
+ proxmox server destroy
|
33
|
+
+ proxmox template available
|
34
|
+
+ proxmox template list
|
35
|
+
|
36
|
+
## Some Examples
|
37
|
+
|
38
|
+
### List servers
|
39
|
+
$ knife proxmox server list
|
40
|
+
Id Node Name Type Status
|
41
|
+
104 node-1 tetatet.example.com openvz down
|
42
|
+
470 node-2 sg-node1.example.com openvz up
|
43
|
+
102 node-1 test qemu down
|
44
|
+
202 node-2 chef-client1 openvz down
|
45
|
+
|
46
|
+
### Get info for a server
|
47
|
+
$ knife proxmox server info -H tetatet.example.com -P ip
|
48
|
+
192.168.1.1
|
49
|
+
|
50
|
+
$ knife proxmox server info -H tetatet.example.com
|
51
|
+
knife proxmox server info -H tetatet.example.com -P ip
|
52
|
+
cpu: 0.00281876923420022
|
53
|
+
cpus: 2
|
54
|
+
disk: 5833015296
|
55
|
+
diskread: 316895232
|
56
|
+
diskwrite: 3805184
|
57
|
+
failcnt: 0
|
58
|
+
ha: 0
|
59
|
+
ip: 192.168.42.200
|
60
|
+
maxdisk: 8589934592
|
61
|
+
maxmem: 4294967296
|
62
|
+
maxswap: 536870912
|
63
|
+
mem: 1145778176
|
64
|
+
name: tetatet.example.com
|
65
|
+
netin: 27888604
|
66
|
+
netout: 2829601
|
67
|
+
nproc: 140
|
68
|
+
status: running
|
69
|
+
swap: 54460416
|
70
|
+
type: openvz
|
71
|
+
uptime: 61018
|
72
|
+
|
73
|
+
|
74
|
+
### List templates installed
|
75
|
+
$ knife proxmox template list -U https://localhost:8006/api2/json/ -n localhost -u test -p test123 -R pve -VV
|
76
|
+
DEBUG: Using configuration from /home/jorge/workspace/chef-repo/.chef/knife.rb
|
77
|
+
Id Name Size
|
78
|
+
0 local:vztmpl/debian-6.0-request-tracker_3.8.8-2_i386.tar.gz 171 MB
|
79
|
+
1 local:vztmpl/old_ubuntu-11.10-x86_64.tar.gz 124 MB
|
80
|
+
2 local:vztmpl/ubuntu-10.04-standard_10.04-4_i386.tar.gz 135 MB
|
81
|
+
3 local:vztmpl/ubuntu-11.10-x86_64-jorge1-.tar.gz 124 MB
|
82
|
+
4 local:vztmpl/ubuntu-11.10-x86_64-jorge2-.tar.gz 154 MB
|
83
|
+
|
84
|
+
|
85
|
+
### List templates available to download
|
86
|
+
$ knife proxmox template available -U https://localhost:8006/api2/json/ -u test -p test123 -n localhost -R pve -VV
|
87
|
+
DEBUG: Using configuration from /home/jorge/workspace/chef-repo/.chef/knife.rb
|
88
|
+
Name Operating System
|
89
|
+
debian-6-turnkey-concrete5_12.0-1_i386.tar.gz debian-6
|
90
|
+
ubuntu-10.04-turnkey-prestashop_11.3-1_i386.tar.gz ubuntu-10.04
|
91
|
+
debian-6-turnkey-joomla25_12.0-1_i386.tar.gz debian-6
|
92
|
+
debian-6-turnkey-tomcat-apache_12.0-1_i386.tar.gz debian-6
|
93
|
+
debian-6.0-wordpress_3.4.2-1_i386.tar.gz debian-6.0 .....
|
94
|
+
|
95
|
+
|
96
|
+
### Create a server (read the note at the end of the document. It's about obtaining the IPAddress)
|
97
|
+
|
98
|
+
$ knife proxmox server create -n ankh -r "recipe[java]" -C 2 -M 1024 -H example-server -P test123 -T 4
|
99
|
+
Creating VM 473...
|
100
|
+
..............OK
|
101
|
+
Preparing the server to start
|
102
|
+
Starting VM 473 on node ankh....
|
103
|
+
..OK
|
104
|
+
New Server 473 has IP Address: 10.0.2.19
|
105
|
+
done
|
106
|
+
Bootstrapping Chef on 10.0.2.19
|
107
|
+
10.0.2.19 --2013-01-23 01:27:20-- http://opscode.com/chef/install.sh
|
108
|
+
10.0.2.19 Resolving opscode.com...
|
109
|
+
10.0.2.19 184.106.28.83
|
110
|
+
10.0.2.19 Connecting to opscode.com|184.106.28.83|:80...
|
111
|
+
10.0.2.19 connected.
|
112
|
+
10.0.2.19 HTTP request sent, awaiting response...
|
113
|
+
10.0.2.19 301 Moved Permanently
|
114
|
+
10.0.2.19 Location: http://www.opscode.com/chef/install.sh [following]
|
115
|
+
10.0.2.19 --2013-01-23 01:27:21-- http://www.opscode.com/chef/install.sh
|
116
|
+
10.0.2.19 Resolving www.opscode.com...
|
117
|
+
10.0.2.19 184.106.28.83
|
118
|
+
10.0.2.19 Reusing existing connection to opscode.com:80.
|
119
|
+
10.0.2.19 HTTP request sent, awaiting response...
|
120
|
+
10.0.2.19 200 OK
|
121
|
+
|
122
|
+
|
123
|
+
### Starting a server
|
124
|
+
$ knife proxmox server start --vmid 401
|
125
|
+
Starting VM 401....
|
126
|
+
Result: 200
|
127
|
+
|
128
|
+
|
129
|
+
### Stopping a server
|
130
|
+
$ knife proxmox server stop --vmid 103
|
131
|
+
Stoping VM 103....
|
132
|
+
Result: 200
|
133
|
+
|
134
|
+
|
135
|
+
### Destroy a server
|
136
|
+
$ knife proxmox server destroy -U https://localhost:8006/api2/json/ -u test -p test123 -n localhost -R pve -N vm-node1 -VV
|
137
|
+
DEBUG: Using configuration from /home/jorge/workspace/chef-repo/.chef/knife.rb
|
138
|
+
node to destroy: vm-node1 [vmid: 200]
|
139
|
+
Continue? (Y/N) y
|
140
|
+
Stopping VM 303....
|
141
|
+
Result: 200
|
142
|
+
..............................
|
143
|
+
Result: 200
|
144
|
+
|
145
|
+
## Installation
|
146
|
+
|
147
|
+
This gem must be installed on your system using the command
|
148
|
+
|
149
|
+
$ gem install knife-proxmox
|
150
|
+
|
151
|
+
If you want to read values from the environment variables modify your knife.rb:
|
152
|
+
|
153
|
+
knife[:pve_cluster_url] ||= "#{ENV['PVE_CLUSTER_URL']}"
|
154
|
+
knife[:pve_user_name] ||= "#{ENV['PVE_USER_NAME']}"
|
155
|
+
knife[:pve_node_name] ||= "#{ENV['PVE_NODE_NAME']}"
|
156
|
+
knife[:pve_user_realm] ||= "#{ENV['PVE_USER_REALM']}"
|
157
|
+
|
158
|
+
However I don't recommend to have the user password as a environment variable.
|
159
|
+
knife[:pve_user_password] = "#{ENV['PVE_CLUSTER_URL']}"
|
160
|
+
|
161
|
+
### Environment Variables
|
162
|
+
|
163
|
+
PVE_CLUSTER_URL = https://<proxmox_server>:8006/api2/json/
|
164
|
+
PVE_USER_NAME = <user>
|
165
|
+
PVE_PASSWORD_NAME = <password>
|
166
|
+
PVE_USER_REALM = <pam|pve|others>
|
167
|
+
PVE_NODE_NAME = <nodename>
|
168
|
+
|
169
|
+
If you want to alter some variable by command line then you can use the following options:
|
170
|
+
-n --node <node> If in a cluster, this argument will specify which node of the cluster will do the action
|
171
|
+
-U --pve_cluster_url <http://localhost...> Will change the cluster to access to
|
172
|
+
-u --username <user> Same for user
|
173
|
+
-p --password <pass> Same for password
|
174
|
+
-r --realm <realm> Same for the realm used to authenticate
|
175
|
+
|
176
|
+
### ABOUT CHEF AND PROXMOX
|
177
|
+
|
178
|
+
To bootstrap a newly created VM, you should apply the patch inside the extra directory. Otherwise you must
|
179
|
+
specify the IP address in the knife proxmox server create --ipaddress argument.
|
180
|
+
|
data/knife-proxmox.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "https://bitbucket.org/jmoratilla/knife-proxmox"
|
12
12
|
s.summary = "ProxmoxVE Support for Chef's Knife Command"
|
13
13
|
s.description = s.summary
|
14
|
-
s.extra_rdoc_files = ["README", "LICENSE","TODO","CHANGELOG" ]
|
14
|
+
s.extra_rdoc_files = ["README.md", "LICENSE","TODO","CHANGELOG" ]
|
15
15
|
|
16
16
|
s.files = Dir['lib/**/*.rb'] + Dir['./*']
|
17
17
|
s.add_dependency "chef", ">= 0.10.10"
|
@@ -9,6 +9,11 @@ class Chef
|
|
9
9
|
|
10
10
|
banner "knife proxmox server list (options)"
|
11
11
|
|
12
|
+
option :field,
|
13
|
+
:short => "-f field",
|
14
|
+
:field => "--field field",
|
15
|
+
:description => "Sort by field <field>"
|
16
|
+
|
12
17
|
def run
|
13
18
|
# Needed
|
14
19
|
connection
|
@@ -20,10 +25,12 @@ class Chef
|
|
20
25
|
ui.color('Type', :bold),
|
21
26
|
ui.color('Status',:bold),
|
22
27
|
ui.color('IP Address',:bold)
|
23
|
-
|
24
28
|
]
|
29
|
+
|
30
|
+
field = config[:field] || 'vmid'
|
31
|
+
|
25
32
|
@connection['cluster/resources?type=vm'].get @auth_params do |response, request, result, &block|
|
26
|
-
JSON.parse(response.body)['data'].each {|entry|
|
33
|
+
JSON.parse(response.body)['data'].sort_by{ |entry| entry[field] }.each {|entry|
|
27
34
|
vm_id = entry['vmid']
|
28
35
|
type = entry['type']
|
29
36
|
server_list << vm_id.to_s
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-proxmox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chef
|
@@ -67,7 +67,7 @@ email:
|
|
67
67
|
executables: []
|
68
68
|
extensions: []
|
69
69
|
extra_rdoc_files:
|
70
|
-
- README
|
70
|
+
- README.md
|
71
71
|
- LICENSE
|
72
72
|
- TODO
|
73
73
|
- CHANGELOG
|
@@ -91,9 +91,9 @@ files:
|
|
91
91
|
- ./knife-proxmox.iml
|
92
92
|
- ./CHANGELOG
|
93
93
|
- ./LICENSE
|
94
|
-
- ./README
|
95
94
|
- ./TODO
|
96
|
-
- README
|
95
|
+
- ./README.md
|
96
|
+
- README.md
|
97
97
|
- LICENSE
|
98
98
|
- TODO
|
99
99
|
- CHANGELOG
|
data/README
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
Authors: Jorge Moratilla, Sergio Galvan
|
2
|
-
Date: 2012-10-07
|
3
|
-
|
4
|
-
This knife plugin allows to access Proxmox Virtualization Environment (Proxmox VE or PVE) through its API.
|
5
|
-
It allows you to lists templates installed on the server/cluster (like images or amis), create a server or
|
6
|
-
destroy it.
|
7
|
-
|
8
|
-
Currently it only supports management of openVZ instances, but KVM instances will be able too.
|
9
|
-
|
10
|
-
|
11
|
-
Actions implemented
|
12
|
-
|
13
|
-
proxmox server list
|
14
|
-
proxmox server info
|
15
|
-
proxmox server create
|
16
|
-
proxmox server start
|
17
|
-
proxmox server stop
|
18
|
-
proxmox server destroy
|
19
|
-
proxmox template available
|
20
|
-
proxmox template list
|
21
|
-
|
22
|
-
Some Examples
|
23
|
-
|
24
|
-
List servers
|
25
|
-
$ knife proxmox server list
|
26
|
-
Id Node Name Type Status
|
27
|
-
104 node-1 tetatet.example.com openvz down
|
28
|
-
470 node-2 sg-node1.example.com openvz up
|
29
|
-
102 node-1 test qemu down
|
30
|
-
202 node-2 chef-client1 openvz down
|
31
|
-
|
32
|
-
Get info for a server
|
33
|
-
$ knife proxmox server info -H tetatet.example.com -P ip
|
34
|
-
192.168.1.1
|
35
|
-
|
36
|
-
$ knife proxmox server info -H tetatet.example.com
|
37
|
-
knife proxmox server info -H tetatet.example.com -P ip
|
38
|
-
cpu: 0.00281876923420022
|
39
|
-
cpus: 2
|
40
|
-
disk: 5833015296
|
41
|
-
diskread: 316895232
|
42
|
-
diskwrite: 3805184
|
43
|
-
failcnt: 0
|
44
|
-
ha: 0
|
45
|
-
ip: 192.168.42.200
|
46
|
-
maxdisk: 8589934592
|
47
|
-
maxmem: 4294967296
|
48
|
-
maxswap: 536870912
|
49
|
-
mem: 1145778176
|
50
|
-
name: tetatet.example.com
|
51
|
-
netin: 27888604
|
52
|
-
netout: 2829601
|
53
|
-
nproc: 140
|
54
|
-
status: running
|
55
|
-
swap: 54460416
|
56
|
-
type: openvz
|
57
|
-
uptime: 61018
|
58
|
-
|
59
|
-
|
60
|
-
List templates installed
|
61
|
-
$ knife proxmox template list -U https://localhost:8006/api2/json/ -n localhost -u test -p test123 -R pve -VV
|
62
|
-
DEBUG: Using configuration from /home/jorge/workspace/chef-repo/.chef/knife.rb
|
63
|
-
Id Name Size
|
64
|
-
0 local:vztmpl/debian-6.0-request-tracker_3.8.8-2_i386.tar.gz 171 MB
|
65
|
-
1 local:vztmpl/old_ubuntu-11.10-x86_64.tar.gz 124 MB
|
66
|
-
2 local:vztmpl/ubuntu-10.04-standard_10.04-4_i386.tar.gz 135 MB
|
67
|
-
3 local:vztmpl/ubuntu-11.10-x86_64-jorge1-.tar.gz 124 MB
|
68
|
-
4 local:vztmpl/ubuntu-11.10-x86_64-jorge2-.tar.gz 154 MB
|
69
|
-
|
70
|
-
|
71
|
-
List templates available to download
|
72
|
-
$ knife proxmox template available -U https://localhost:8006/api2/json/ -u test -p test123 -n localhost -R pve -VV
|
73
|
-
DEBUG: Using configuration from /home/jorge/workspace/chef-repo/.chef/knife.rb
|
74
|
-
Name Operating System
|
75
|
-
debian-6-turnkey-concrete5_12.0-1_i386.tar.gz debian-6
|
76
|
-
ubuntu-10.04-turnkey-prestashop_11.3-1_i386.tar.gz ubuntu-10.04
|
77
|
-
debian-6-turnkey-joomla25_12.0-1_i386.tar.gz debian-6
|
78
|
-
debian-6-turnkey-tomcat-apache_12.0-1_i386.tar.gz debian-6
|
79
|
-
debian-6.0-wordpress_3.4.2-1_i386.tar.gz debian-6.0 .....
|
80
|
-
|
81
|
-
|
82
|
-
Create a server (read the note at the end of the document. It's about obtaining the IPAddress)
|
83
|
-
|
84
|
-
$ knife proxmox server create -n ankh -r "recipe[java]" -C 2 -M 1024 -H example-server -P test123 -T 4
|
85
|
-
Creating VM 473...
|
86
|
-
..............OK
|
87
|
-
Preparing the server to start
|
88
|
-
Starting VM 473 on node ankh....
|
89
|
-
..OK
|
90
|
-
New Server 473 has IP Address: 10.0.2.19
|
91
|
-
done
|
92
|
-
Bootstrapping Chef on 10.0.2.19
|
93
|
-
10.0.2.19 --2013-01-23 01:27:20-- http://opscode.com/chef/install.sh
|
94
|
-
10.0.2.19 Resolving opscode.com...
|
95
|
-
10.0.2.19 184.106.28.83
|
96
|
-
10.0.2.19 Connecting to opscode.com|184.106.28.83|:80...
|
97
|
-
10.0.2.19 connected.
|
98
|
-
10.0.2.19 HTTP request sent, awaiting response...
|
99
|
-
10.0.2.19 301 Moved Permanently
|
100
|
-
10.0.2.19 Location: http://www.opscode.com/chef/install.sh [following]
|
101
|
-
10.0.2.19 --2013-01-23 01:27:21-- http://www.opscode.com/chef/install.sh
|
102
|
-
10.0.2.19 Resolving www.opscode.com...
|
103
|
-
10.0.2.19 184.106.28.83
|
104
|
-
10.0.2.19 Reusing existing connection to opscode.com:80.
|
105
|
-
10.0.2.19 HTTP request sent, awaiting response...
|
106
|
-
10.0.2.19 200 OK
|
107
|
-
|
108
|
-
|
109
|
-
Starting a server
|
110
|
-
$ knife proxmox server start --vmid 401
|
111
|
-
Starting VM 401....
|
112
|
-
Result: 200
|
113
|
-
|
114
|
-
|
115
|
-
Stopping a server
|
116
|
-
$ knife proxmox server stop --vmid 103
|
117
|
-
Stoping VM 103....
|
118
|
-
Result: 200
|
119
|
-
|
120
|
-
|
121
|
-
Destroy a server
|
122
|
-
$ knife proxmox server destroy -U https://localhost:8006/api2/json/ -u test -p test123 -n localhost -R pve -N vm-node1 -VV
|
123
|
-
DEBUG: Using configuration from /home/jorge/workspace/chef-repo/.chef/knife.rb
|
124
|
-
node to destroy: vm-node1
|
125
|
-
Stopping VM 303....
|
126
|
-
Result: 200
|
127
|
-
..............................
|
128
|
-
Result: 200
|
129
|
-
|
130
|
-
This gem must be installed on your system using the command
|
131
|
-
|
132
|
-
$ gem install knife-proxmox
|
133
|
-
|
134
|
-
If you want to read values from the environment variables modify your knife.rb:
|
135
|
-
|
136
|
-
knife[:pve_cluster_url] ||= "#{ENV['PVE_CLUSTER_URL']}"
|
137
|
-
knife[:pve_user_name] ||= "#{ENV['PVE_USER_NAME']}"
|
138
|
-
knife[:pve_node_name] ||= "#{ENV['PVE_NODE_NAME']}"
|
139
|
-
knife[:pve_user_realm] ||= "#{ENV['PVE_USER_REALM']}"
|
140
|
-
|
141
|
-
However I don't recommend to have the user password as a environment variable.
|
142
|
-
knife[:pve_user_password] = "#{ENV['PVE_CLUSTER_URL']}"
|
143
|
-
|
144
|
-
Environment Variables
|
145
|
-
|
146
|
-
PVE_CLUSTER_URL = https://<proxmox_server>:8006/api2/json/
|
147
|
-
PVE_USER_NAME = <user>
|
148
|
-
PVE_PASSWORD_NAME = <password>
|
149
|
-
PVE_USER_REALM = <pam|pve|others>
|
150
|
-
PVE_NODE_NAME = <nodename>
|
151
|
-
|
152
|
-
If you want to alter some variable by command line then you can use the following options:
|
153
|
-
-n --node <node> If in a cluster, this argument will specify which node of the cluster will do the action
|
154
|
-
-U --pve_cluster_url <http://localhost...> Will change the cluster to access to
|
155
|
-
-u --username <user> Same for user
|
156
|
-
-p --password <pass> Same for password
|
157
|
-
-r --realm <realm> Same for the realm used to authenticate
|
158
|
-
|
159
|
-
ABOUT CHEF AND PROXMOX
|
160
|
-
|
161
|
-
To bootstrap a newly created VM, you should apply the patch inside the extra directory. Otherwise you must
|
162
|
-
specify the IP address in the knife proxmox server create --ipaddress argument.
|
163
|
-
|