fog-proxmox 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/fog/identity/proxmox/requests/change_password.rb +1 -1
- data/lib/fog/proxmox.rb +9 -8
- data/lib/fog/proxmox/version.rb +1 -1
- data/spec/compute_spec.rb +106 -106
- data/spec/fixtures/proxmox/compute/containers.yml +1387 -2096
- data/spec/fixtures/proxmox/compute/identity_ticket.yml +8 -8
- data/spec/fixtures/proxmox/compute/nodes.yml +24 -24
- data/spec/fixtures/proxmox/compute/servers.yml +2849 -2920
- data/spec/fixtures/proxmox/compute/snapshots.yml +308 -293
- data/spec/fixtures/proxmox/compute/storages.yml +32 -32
- data/spec/fixtures/proxmox/compute/tasks.yml +57 -55
- data/spec/fixtures/proxmox/identity/auth.yml +125 -8
- data/spec/fixtures/proxmox/identity/domains.yml +120 -118
- data/spec/fixtures/proxmox/identity/groups.yml +52 -52
- data/spec/fixtures/proxmox/identity/identity_ticket.yml +8 -8
- data/spec/fixtures/proxmox/identity/permissions.yml +119 -119
- data/spec/fixtures/proxmox/identity/pools.yml +97 -97
- data/spec/fixtures/proxmox/identity/read_version.yml +8 -8
- data/spec/fixtures/proxmox/identity/roles.yml +55 -55
- data/spec/fixtures/proxmox/identity/users.yml +115 -115
- data/spec/fixtures/proxmox/network/identity_ticket.yml +8 -8
- data/spec/fixtures/proxmox/network/networks.yml +84 -64
- data/spec/identity_spec.rb +82 -60
- data/spec/network_spec.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c327b80ae98f3f8868ad071d74ed181cc84817c049ad69fa244f7dea3fceb39
|
4
|
+
data.tar.gz: 748ec5a7786e00c3630a6efa54c4c0936a7ae93bb98b4160b45cad74233e0795
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f13a62fb4343dfd8717e495452f6d5b628cf14ea757b961348e2447205baaa3db3e840347d7ce0af9c4c3119e571897e075f03dd96c9dfe23d51d1f3ef2e675
|
7
|
+
data.tar.gz: 8c4d8286d6cfed6839aedca88f9bca574c4983274ed4fade81a030eb243a0846a82ff5f725dc8ca4eca91e2331b477e62ee388f551ef067dd2ef128e84842cd4
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/fog/proxmox.rb
CHANGED
@@ -47,6 +47,7 @@ module Fog
|
|
47
47
|
attr_reader :credentials
|
48
48
|
attr_reader :version
|
49
49
|
attr_accessor :now # tests only
|
50
|
+
attr_accessor :ticket_lifetime # tests only
|
50
51
|
end
|
51
52
|
|
52
53
|
def self.clear_credentials
|
@@ -54,7 +55,7 @@ module Fog
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def self.authenticate(options, connection_options = {})
|
57
|
-
|
58
|
+
get_credentials(options, connection_options)
|
58
59
|
self
|
59
60
|
end
|
60
61
|
|
@@ -71,7 +72,7 @@ module Fog
|
|
71
72
|
options[:pve_password] = ticket unless ticket
|
72
73
|
end
|
73
74
|
|
74
|
-
def self.
|
75
|
+
def self.get_credentials(options, connection_options = {})
|
75
76
|
username = options[:pve_username].to_s
|
76
77
|
password = options[:pve_password].to_s
|
77
78
|
url = options[:pve_url]
|
@@ -79,15 +80,15 @@ module Fog
|
|
79
80
|
uri = URI.parse(url)
|
80
81
|
@api_path = uri.path
|
81
82
|
connection_options = connection_options.merge(path_prefix: @api_path)
|
82
|
-
password = @credentials[:
|
83
|
-
|
83
|
+
password = @credentials[:ticket] if credentials_has_expired?
|
84
|
+
request_credentials(uri, connection_options, username, password) unless authenticated? && !credentials_has_expired?
|
84
85
|
end
|
85
86
|
|
86
|
-
def self.
|
87
|
+
def self.request_credentials(uri, connection_options, username, password)
|
87
88
|
request = {
|
88
89
|
expects: [200, 204],
|
89
90
|
headers: { 'Accept' => 'application/json' },
|
90
|
-
body:
|
91
|
+
body: URI.encode_www_form(username: username, password: password),
|
91
92
|
method: 'POST',
|
92
93
|
path: 'access/ticket'
|
93
94
|
}
|
@@ -102,10 +103,10 @@ module Fog
|
|
102
103
|
username = data['username']
|
103
104
|
csrftoken = data['CSRFPreventionToken']
|
104
105
|
deadline = Time.at(@now.to_i + @ticket_lifetime)
|
105
|
-
|
106
|
+
save_credentials(username, ticket, csrftoken, deadline)
|
106
107
|
end
|
107
108
|
|
108
|
-
def self.
|
109
|
+
def self.save_credentials(username, ticket, csrftoken, deadline)
|
109
110
|
@credentials = {
|
110
111
|
username: username,
|
111
112
|
ticket: ticket,
|
data/lib/fog/proxmox/version.rb
CHANGED
data/spec/compute_spec.rb
CHANGED
@@ -38,92 +38,92 @@ describe Fog::Proxmox::Compute do
|
|
38
38
|
VCR.use_cassette('tasks') do
|
39
39
|
# List all tasks
|
40
40
|
filters = { limit: 1 }
|
41
|
-
node_name = '
|
41
|
+
node_name = 'pve'
|
42
42
|
node = @service.nodes.get node_name
|
43
43
|
tasks = node.tasks.all(filters)
|
44
|
-
tasks.wont_be_nil
|
45
|
-
tasks.wont_be_empty
|
46
|
-
tasks.size.must_equal 1
|
44
|
+
_(tasks).wont_be_nil
|
45
|
+
_(tasks).wont_be_empty
|
46
|
+
_(tasks.size).must_equal 1
|
47
47
|
# Get task
|
48
48
|
upid = tasks[0].upid
|
49
49
|
task = node.tasks.get(upid)
|
50
|
-
task.wont_be_nil
|
50
|
+
_(task).wont_be_nil
|
51
51
|
# Stop task
|
52
52
|
task.stop
|
53
53
|
task.wait_for { finished? }
|
54
|
-
task.finished
|
54
|
+
_(task.finished?).must_equal true
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'Manage nodes' do
|
59
59
|
VCR.use_cassette('nodes') do
|
60
60
|
# Get node
|
61
|
-
node_name = '
|
61
|
+
node_name = 'pve'
|
62
62
|
node = @service.nodes.get node_name
|
63
63
|
# Get statistics data
|
64
64
|
data = node.statistics
|
65
|
-
data.wont_be_nil
|
66
|
-
data.wont_be_empty
|
65
|
+
_(data).wont_be_nil
|
66
|
+
_(data).wont_be_empty
|
67
67
|
# Get statistics image
|
68
68
|
data = node.statistics('rrd', { timeframe: 'hour', ds: 'cpu,memused', cf: 'AVERAGE' })
|
69
|
-
data.wont_be_nil
|
70
|
-
data['image'].wont_be_nil
|
69
|
+
_(data).wont_be_nil
|
70
|
+
_(data['image']).wont_be_nil
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'Manage storages' do
|
75
75
|
VCR.use_cassette('storages') do
|
76
76
|
# Get node
|
77
|
-
node_name = '
|
77
|
+
node_name = 'pve'
|
78
78
|
node = @service.nodes.get node_name
|
79
79
|
# List all storages
|
80
80
|
storages = node.storages.all
|
81
|
-
storages.wont_be_nil
|
82
|
-
storages.wont_be_empty
|
83
|
-
storages.size.must_equal 2
|
81
|
+
_(storages).wont_be_nil
|
82
|
+
_(storages).wont_be_empty
|
83
|
+
_(storages.size).must_equal 2
|
84
84
|
# List by content type
|
85
85
|
storages = node.storages.list_by_content_type 'iso'
|
86
|
-
storages.wont_be_nil
|
87
|
-
storages.wont_be_empty
|
88
|
-
storages.size.must_equal 1
|
86
|
+
_(storages).wont_be_nil
|
87
|
+
_(storages).wont_be_empty
|
88
|
+
_(storages.size).must_equal 1
|
89
89
|
# Get storage
|
90
90
|
storage = node.storages.get('local')
|
91
|
-
storage.wont_be_nil
|
92
|
-
storage.identity.must_equal 'local'
|
91
|
+
_(storage).wont_be_nil
|
92
|
+
_(storage.identity).must_equal 'local'
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'CRUD servers' do
|
97
97
|
VCR.use_cassette('servers') do
|
98
|
-
node_name = '
|
98
|
+
node_name = 'pve'
|
99
99
|
node = @service.nodes.get node_name
|
100
100
|
# Get next vmid
|
101
101
|
vmid = node.servers.next_id
|
102
102
|
server_hash = { vmid: vmid }
|
103
103
|
# Check valid vmid
|
104
104
|
valid = node.servers.id_valid? vmid
|
105
|
-
valid.must_equal true
|
105
|
+
_(valid).must_equal true
|
106
106
|
# Check not valid vmid
|
107
107
|
valid = node.servers.id_valid? 99
|
108
|
-
valid.must_equal false
|
108
|
+
_(valid).must_equal false
|
109
109
|
# Create 1st time
|
110
110
|
server = node.servers.create(server_hash)
|
111
111
|
ok = server.persisted?
|
112
|
-
ok.must_equal true
|
112
|
+
_(ok).must_equal true
|
113
113
|
# Check already used vmid
|
114
114
|
valid = node.servers.id_valid? vmid
|
115
|
-
valid.must_equal false
|
115
|
+
_(valid).must_equal false
|
116
116
|
# Clone server
|
117
117
|
newid = node.servers.next_id
|
118
118
|
# Get server
|
119
119
|
server = node.servers.get vmid
|
120
|
-
server.wont_be_nil
|
120
|
+
_(server).wont_be_nil
|
121
121
|
# Backup it
|
122
122
|
server.backup(compress: 'lzo')
|
123
123
|
# Get this backup image
|
124
124
|
# Find available backup volumes
|
125
125
|
volume = server.backups.first
|
126
|
-
volume.wont_be_nil
|
126
|
+
_(volume).wont_be_nil
|
127
127
|
# Restore it
|
128
128
|
server.restore(volume, storage: 'local')
|
129
129
|
# Delete it
|
@@ -148,16 +148,16 @@ describe Fog::Proxmox::Compute do
|
|
148
148
|
clone.create_template
|
149
149
|
# Get clone disk image
|
150
150
|
image = clone.images.first
|
151
|
-
image.wont_be_nil
|
151
|
+
_(image).wont_be_nil
|
152
152
|
# Delete clone
|
153
153
|
clone.destroy
|
154
|
-
proc do
|
154
|
+
_(proc do
|
155
155
|
clone = node.servers.get newid
|
156
|
-
end.must_raise Fog::Errors::NotFound
|
156
|
+
end).must_raise Fog::Errors::NotFound
|
157
157
|
# Create 2nd time must fails
|
158
|
-
proc do
|
158
|
+
_(proc do
|
159
159
|
node.servers.create server_hash
|
160
|
-
end.must_raise Excon::Errors::InternalServerError
|
160
|
+
end).must_raise Excon::Errors::InternalServerError
|
161
161
|
# Update config server
|
162
162
|
# Add empty cdrom
|
163
163
|
config_hash = { ide2: 'none,media=cdrom' }
|
@@ -175,109 +175,109 @@ describe Fog::Proxmox::Compute do
|
|
175
175
|
server.update(config_hash)
|
176
176
|
# server config
|
177
177
|
config = server.config
|
178
|
-
config.identity.must_equal vmid
|
178
|
+
_(config.identity).must_equal vmid
|
179
179
|
disks = server.config.disks
|
180
180
|
interfaces = server.config.interfaces
|
181
|
-
interfaces.wont_be_nil
|
182
|
-
interfaces.wont_be_empty
|
181
|
+
_(interfaces).wont_be_nil
|
182
|
+
_(interfaces).wont_be_empty
|
183
183
|
net0 = interfaces.get('net0')
|
184
|
-
net0.wont_be_nil
|
185
|
-
disks.wont_be_nil
|
186
|
-
disks.wont_be_empty
|
184
|
+
_(net0).wont_be_nil
|
185
|
+
_(disks).wont_be_nil
|
186
|
+
_(disks).wont_be_empty
|
187
187
|
virtio0 = disks.get('virtio0')
|
188
|
-
virtio0.wont_be_nil
|
188
|
+
_(virtio0).wont_be_nil
|
189
189
|
ide2 = disks.get('ide2')
|
190
|
-
ide2.wont_be_nil
|
190
|
+
_(ide2).wont_be_nil
|
191
191
|
# Get a mac adress
|
192
192
|
mac_address = server.config.mac_addresses.first
|
193
|
-
mac_address.wont_be_nil
|
193
|
+
_(mac_address).wont_be_nil
|
194
194
|
# all servers
|
195
195
|
servers_all = node.servers.all
|
196
|
-
servers_all.wont_be_empty
|
197
|
-
servers_all.must_include server
|
196
|
+
_(servers_all).wont_be_empty
|
197
|
+
_(servers_all).must_include server
|
198
198
|
# server not running exception
|
199
|
-
proc do
|
199
|
+
_(proc do
|
200
200
|
server.start_console(websocket: 1)
|
201
|
-
end.must_raise Fog::Proxmox::Errors::ServiceError
|
201
|
+
end).must_raise Fog::Proxmox::Errors::ServiceError
|
202
202
|
# Start server
|
203
203
|
server.action('start')
|
204
204
|
server.wait_for { ready? }
|
205
205
|
status = server.ready?
|
206
|
-
status.must_equal true
|
206
|
+
_(status).must_equal true
|
207
207
|
# server vga not set exception
|
208
|
-
proc do
|
208
|
+
_(proc do
|
209
209
|
server.start_console(websocket: 1)
|
210
|
-
end.must_raise Fog::Proxmox::Errors::ServiceError
|
210
|
+
end).must_raise Fog::Proxmox::Errors::ServiceError
|
211
211
|
# Stop server
|
212
212
|
server.action('stop')
|
213
213
|
server.wait_for { server.status == 'stopped' }
|
214
214
|
status = server.status
|
215
|
-
status.must_equal 'stopped'
|
215
|
+
_(status).must_equal 'stopped'
|
216
216
|
server.update(vga: 'std')
|
217
217
|
# Start server
|
218
218
|
server.action('start')
|
219
219
|
server.wait_for { ready? }
|
220
220
|
status = server.ready?
|
221
|
-
status.must_equal true
|
221
|
+
_(status).must_equal true
|
222
222
|
vnc = server.start_console(websocket: 1)
|
223
|
-
vnc['cert'].wont_be_nil
|
223
|
+
_(vnc['cert']).wont_be_nil
|
224
224
|
port = server.connect_vnc(vnc)
|
225
|
-
port.wont_be_nil
|
225
|
+
_(port).wont_be_nil
|
226
226
|
# Stop server
|
227
227
|
server.action('stop')
|
228
228
|
server.wait_for { server.status == 'stopped' }
|
229
229
|
status = server.status
|
230
|
-
status.must_equal 'stopped'
|
230
|
+
_(status).must_equal 'stopped'
|
231
231
|
server.update(serial0: 'socket', vga: 'serial0')
|
232
232
|
# Start server
|
233
233
|
server.action('start')
|
234
234
|
server.wait_for { ready? }
|
235
235
|
status = server.ready?
|
236
|
-
status.must_equal true
|
236
|
+
_(status).must_equal true
|
237
237
|
term = server.start_console
|
238
|
-
term['ticket'].wont_be_nil
|
238
|
+
_(term['ticket']).wont_be_nil
|
239
239
|
# Stop server
|
240
240
|
server.action('stop')
|
241
241
|
server.wait_for { server.status == 'stopped' }
|
242
242
|
status = server.status
|
243
|
-
status.must_equal 'stopped'
|
243
|
+
_(status).must_equal 'stopped'
|
244
244
|
server.update(vga: 'qxl')
|
245
245
|
# Start server
|
246
246
|
server.action('start')
|
247
247
|
server.wait_for { ready? }
|
248
248
|
status = server.ready?
|
249
|
-
status.must_equal true
|
249
|
+
_(status).must_equal true
|
250
250
|
spice = server.start_console
|
251
|
-
spice['password'].wont_be_nil
|
251
|
+
_(spice['password']).wont_be_nil
|
252
252
|
# Suspend server
|
253
253
|
server.action('suspend')
|
254
254
|
server.wait_for { server.qmpstatus == 'paused' }
|
255
255
|
qmpstatus = server.qmpstatus
|
256
|
-
qmpstatus.must_equal 'paused'
|
256
|
+
_(qmpstatus).must_equal 'paused'
|
257
257
|
# Resume server
|
258
258
|
server.action('resume')
|
259
259
|
server.wait_for { ready? }
|
260
260
|
status = server.ready?
|
261
|
-
status.must_equal true
|
261
|
+
_(status).must_equal true
|
262
262
|
# Stop server
|
263
263
|
server.action('stop')
|
264
264
|
server.wait_for { server.status == 'stopped' }
|
265
265
|
status = server.status
|
266
|
-
status.must_equal 'stopped'
|
267
|
-
proc do
|
266
|
+
_(status).must_equal 'stopped'
|
267
|
+
_(proc do
|
268
268
|
server.action('hello')
|
269
|
-
end.must_raise Fog::Errors::Error
|
269
|
+
end).must_raise Fog::Errors::Error
|
270
270
|
# Delete
|
271
271
|
server.destroy
|
272
|
-
proc do
|
272
|
+
_(proc do
|
273
273
|
node.servers.get vmid
|
274
|
-
end.must_raise Fog::Errors::NotFound
|
274
|
+
end).must_raise Fog::Errors::NotFound
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
278
|
it 'CRUD snapshots' do
|
279
279
|
VCR.use_cassette('snapshots') do
|
280
|
-
node_name = '
|
280
|
+
node_name = 'pve'
|
281
281
|
node = @service.nodes.get node_name
|
282
282
|
vmid = node.servers.next_id
|
283
283
|
server_hash = { vmid: vmid }
|
@@ -289,15 +289,15 @@ describe Fog::Proxmox::Compute do
|
|
289
289
|
server.snapshots.create(snapshot_hash)
|
290
290
|
# Find by id
|
291
291
|
snapshot = server.snapshots.get snapname
|
292
|
-
snapshot.wont_be_nil
|
292
|
+
_(snapshot).wont_be_nil
|
293
293
|
# Update
|
294
294
|
snapshot.description = 'Snapshot 1'
|
295
295
|
snapshot.update
|
296
296
|
# all snapshots
|
297
297
|
snapshots_all = server.snapshots.all
|
298
|
-
snapshots_all.wont_be_nil
|
299
|
-
snapshots_all.wont_be_empty
|
300
|
-
snapshots_all.must_include snapshot
|
298
|
+
_(snapshots_all).wont_be_nil
|
299
|
+
_(snapshots_all).wont_be_empty
|
300
|
+
_(snapshots_all).must_include snapshot
|
301
301
|
# Delete
|
302
302
|
snapshot.destroy
|
303
303
|
server.destroy
|
@@ -306,44 +306,44 @@ describe Fog::Proxmox::Compute do
|
|
306
306
|
|
307
307
|
it 'CRUD containers' do
|
308
308
|
VCR.use_cassette('containers') do
|
309
|
-
node_name = '
|
309
|
+
node_name = 'pve'
|
310
310
|
node = @service.nodes.get node_name
|
311
|
-
node.wont_be_nil
|
311
|
+
_(node).wont_be_nil
|
312
312
|
# Get next vmid
|
313
313
|
vmid = node.containers.next_id
|
314
314
|
ostemplate = 'local:vztmpl/alpine-3.8-default_20180913_amd64.tar.xz'
|
315
315
|
container_hash = { ostemplate: ostemplate, storage: 'local-lvm', password: 'proxmox01', rootfs: 'local-lvm:1' }
|
316
316
|
# Check valid vmid
|
317
317
|
valid = node.containers.id_valid? vmid
|
318
|
-
valid.must_equal true
|
318
|
+
_(valid).must_equal true
|
319
319
|
# Check not valid vmid
|
320
320
|
valid = node.containers.id_valid? 99
|
321
|
-
valid.must_equal false
|
321
|
+
_(valid).must_equal false
|
322
322
|
# Create 1st time
|
323
323
|
node.containers.create(container_hash.merge(vmid: vmid))
|
324
324
|
# Check already used vmid
|
325
325
|
valid = node.containers.id_valid? vmid
|
326
|
-
valid.must_equal false
|
326
|
+
_(valid).must_equal false
|
327
327
|
# Clone container
|
328
328
|
newid = node.containers.next_id
|
329
329
|
# Get container
|
330
330
|
container = node.containers.get vmid
|
331
|
-
container.wont_be_nil
|
331
|
+
_(container).wont_be_nil
|
332
332
|
rootfs_a = container.config.disks.select { |disk| disk.rootfs? }
|
333
|
-
rootfs_a.wont_be_empty
|
333
|
+
_(rootfs_a).wont_be_empty
|
334
334
|
rootfs = rootfs_a.first
|
335
|
-
rootfs.wont_be_nil
|
335
|
+
_(rootfs).wont_be_nil
|
336
336
|
# Backup it
|
337
337
|
container.backup(compress: 'lzo')
|
338
338
|
# Get this backup image
|
339
339
|
# Find available backup volumes
|
340
340
|
backup = container.backups.first
|
341
|
-
container.wont_be_nil
|
341
|
+
_(container).wont_be_nil
|
342
342
|
# Restore it
|
343
343
|
container.restore(backup, storage: 'local-lvm')
|
344
344
|
# Delete it
|
345
345
|
backup.destroy
|
346
|
-
container.backups.must_be_empty
|
346
|
+
_(container.backups).must_be_empty
|
347
347
|
# Add mount points
|
348
348
|
# Find available storages with images
|
349
349
|
storages = node.storages.list_by_content_type 'images'
|
@@ -353,8 +353,8 @@ describe Fog::Proxmox::Compute do
|
|
353
353
|
container.attach(mp0, options)
|
354
354
|
# Fetch mount points
|
355
355
|
mount_points = container.config.disks.select { |disk| disk.mount_point? }
|
356
|
-
mount_points.wont_be_empty
|
357
|
-
mount_points.get('mp0').wont_be_nil
|
356
|
+
_(mount_points).wont_be_empty
|
357
|
+
_(mount_points.get('mp0')).wont_be_nil
|
358
358
|
# Remove mount points
|
359
359
|
container.detach('mp0')
|
360
360
|
container.detach('unused0')
|
@@ -367,16 +367,16 @@ describe Fog::Proxmox::Compute do
|
|
367
367
|
clone.template
|
368
368
|
# Get clone disk image
|
369
369
|
image = clone.images.first
|
370
|
-
image.wont_be_nil
|
370
|
+
_(image).wont_be_nil
|
371
371
|
# Delete clone
|
372
372
|
clone.destroy
|
373
|
-
proc do
|
373
|
+
_(proc do
|
374
374
|
node.containers.get newid
|
375
|
-
end.must_raise Fog::Errors::NotFound
|
375
|
+
end).must_raise Fog::Errors::NotFound
|
376
376
|
# Create 2nd time must fails
|
377
|
-
proc do
|
377
|
+
_(proc do
|
378
378
|
node.containers.create(container_hash.merge(vmid: vmid))
|
379
|
-
end.must_raise Excon::Errors::InternalServerError
|
379
|
+
end).must_raise Excon::Errors::InternalServerError
|
380
380
|
# Update config container
|
381
381
|
# Resize rootfs container
|
382
382
|
container.extend('rootfs', '+5M')
|
@@ -391,56 +391,56 @@ describe Fog::Proxmox::Compute do
|
|
391
391
|
container.update(config_hash)
|
392
392
|
# get container config
|
393
393
|
config = container.config
|
394
|
-
config.wont_be_nil
|
395
|
-
config.identity.must_equal vmid
|
394
|
+
_(config).wont_be_nil
|
395
|
+
_(config.identity).must_equal vmid
|
396
396
|
# Fetch nics
|
397
397
|
interfaces = container.config.interfaces
|
398
|
-
interfaces.wont_be_empty
|
399
|
-
interfaces.get('net0').wont_be_nil
|
398
|
+
_(interfaces).wont_be_empty
|
399
|
+
_(interfaces.get('net0')).wont_be_nil
|
400
400
|
# Get a mac address
|
401
401
|
mac_address = container.config.mac_addresses.first
|
402
|
-
mac_address.wont_be_nil
|
402
|
+
_(mac_address).wont_be_nil
|
403
403
|
# all containers
|
404
404
|
containers_all = node.containers.all
|
405
|
-
containers_all.wont_be_nil
|
406
|
-
containers_all.wont_be_empty
|
407
|
-
containers_all.first.vmid.must_equal container.vmid.to_s
|
405
|
+
_(containers_all).wont_be_nil
|
406
|
+
_(containers_all).wont_be_empty
|
407
|
+
_(containers_all.first.vmid).must_equal container.vmid.to_s
|
408
408
|
# Start container
|
409
409
|
container.action('start')
|
410
410
|
container.wait_for { ready? }
|
411
411
|
status = container.ready?
|
412
|
-
status.must_equal true
|
412
|
+
_(status).must_equal true
|
413
413
|
# Start console
|
414
|
-
proc do
|
414
|
+
_(proc do
|
415
415
|
container.start_console
|
416
|
-
end.must_raise Fog::Errors::Error
|
416
|
+
end).must_raise Fog::Errors::Error
|
417
417
|
spice = container.start_console(console: 'spice')
|
418
|
-
spice['password'].wont_be_nil
|
418
|
+
_(spice['password']).wont_be_nil
|
419
419
|
# Suspend container (: command 'lxc-checkpoint -n 100 -s -D /var/lib/vz/dump' failed: exit code 1)
|
420
420
|
# container.action('suspend')
|
421
421
|
# container.wait_for { container.qmpstatus == 'paused' }
|
422
422
|
# qmpstatus = container.qmpstatus
|
423
|
-
# qmpstatus.must_equal 'paused'
|
423
|
+
# _(qmpstatus).must_equal 'paused'
|
424
424
|
# Resume server
|
425
425
|
# container.action('resume')
|
426
426
|
# container.wait_for { ready? }
|
427
427
|
# status = container.ready?
|
428
|
-
# status.must_equal true
|
428
|
+
# _(status).must_equal true
|
429
429
|
# Stop container
|
430
430
|
container.action('stop')
|
431
431
|
container.wait_for { container.status == 'stopped' }
|
432
432
|
status = container.status
|
433
|
-
status.must_equal 'stopped'
|
434
|
-
proc do
|
433
|
+
_(status).must_equal 'stopped'
|
434
|
+
_(proc do
|
435
435
|
container.action('hello')
|
436
|
-
end.must_raise Fog::Errors::Error
|
436
|
+
end).must_raise Fog::Errors::Error
|
437
437
|
# Delete
|
438
438
|
container.destroy
|
439
439
|
# Delete container does not delete images
|
440
440
|
storage.volumes.each(&:destroy)
|
441
|
-
proc do
|
441
|
+
_(proc do
|
442
442
|
node.containers.get vmid
|
443
|
-
end.must_raise Fog::Errors::NotFound
|
443
|
+
end).must_raise Fog::Errors::NotFound
|
444
444
|
end
|
445
445
|
end
|
446
446
|
end
|