knife-proxmox 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -30,8 +30,31 @@ Id Node Name Type Status
30
30
  202 node-2 chef-client1 openvz down
31
31
 
32
32
  Get info for a server
33
- $ knife proxmox server info -H tetatet.example.com -F ipaddress
34
-
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
35
58
 
36
59
 
37
60
  List templates installed
@@ -56,7 +79,8 @@ debian-6-turnkey-tomcat-apache_12.0-1_i386.tar.gz debian-6
56
79
  debian-6.0-wordpress_3.4.2-1_i386.tar.gz debian-6.0 .....
57
80
 
58
81
 
59
- Create a server
82
+ Create a server (read the note at the end of the document. It's about obtaining the IPAddress)
83
+
60
84
  $ knife proxmox server create -n ankh -r "recipe[java]" -C 2 -M 1024 -H example-server -P test123 -T 4
61
85
  Creating VM 473...
62
86
  ..............OK
@@ -131,3 +155,9 @@ If you want to alter some variable by command line then you can use the followin
131
155
  -u --username <user> Same for user
132
156
  -p --password <pass> Same for password
133
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
+
@@ -19,6 +19,9 @@ class Chef
19
19
  require 'net/ssh/multi'
20
20
  require 'chef/api_client'
21
21
  require 'chef/node'
22
+ require 'readline'
23
+ require 'chef/knife/bootstrap'
24
+ Chef::Knife::Bootstrap.load_deps
22
25
  end
23
26
 
24
27
  # options
@@ -106,7 +109,7 @@ class Chef
106
109
  data.each {|entry|
107
110
  vmids.add entry['vmid']
108
111
  }
109
- (vmids.max + 1).to_s
112
+ (vmids.empty? ? 100 : (vmids.max + 1)).to_s
110
113
  end
111
114
  end
112
115
 
@@ -141,13 +144,17 @@ class Chef
141
144
  end
142
145
  end
143
146
 
144
- # vmid_to_node: Specify the vmid and get the node in which is
147
+ # vmid_to_node: Specify the vmid and get the node in which is. nil otherwise
145
148
  def vmid_to_node(vmid)
149
+ node = nil
146
150
  @connection['cluster/resources?type=vm'].get @auth_params do |response, request, result, &block|
147
151
  data = JSON.parse(response.body)['data']
148
152
  data.each {|entry|
149
- return entry['node'] if entry['vmid'].to_s.match(vmid.to_s)
153
+ if entry['vmid'].to_s.match(vmid.to_s) then
154
+ node = entry['node']
155
+ end
150
156
  }
157
+ return node
151
158
  end
152
159
  end
153
160
 
@@ -201,6 +208,9 @@ class Chef
201
208
  # take the response and extract the taskid
202
209
  action_response("server stop",response)
203
210
  end
211
+ rescue Exception => e
212
+ ui.warn("The VMID does not match any node")
213
+ exit 1
204
214
  end
205
215
 
206
216
  def server_create(vmid,vm_definition)
@@ -43,10 +43,15 @@ class Chef
43
43
  vm_id = config[:vm_id]
44
44
  end
45
45
 
46
- server_stop(vm_id)
47
- ui.msg("Preparing the server to delete")
48
- sleep(5)
49
- server_destroy(vm_id)
46
+ begin
47
+ server_stop(vm_id)
48
+ ui.msg("Preparing the server to delete")
49
+ sleep(5)
50
+ server_destroy(vm_id)
51
+ rescue Exception => e
52
+ ui.warn("Error trying to destroy the server. Does the server exists?")
53
+ exit 1
54
+ end
50
55
 
51
56
  #TODO: remove server from chef
52
57
  if config[:purge]
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Proxmox
3
- VERSION = "0.0.15"
3
+ VERSION = "0.0.16"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
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.15
4
+ version: 0.0.16
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-02-18 00:00:00.000000000 Z
13
+ date: 2013-03-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: chef