vmpooler 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b65cd0483ea44e3ad8642c8c6ed8e22825601c5e707f7e277795eebb76057dd1
4
- data.tar.gz: 1244464e0d901dac2878364dcd37a0e5c67ec19ae7736064751889913e8997c8
3
+ metadata.gz: 4642648148ddd5b7d470163c4509ccad6f3a377f0f20dc1a43a940aaacf6a157
4
+ data.tar.gz: 7fe2d19cbfb839a750872d09adf01048d23dba9aa345b6e1150e3787f5c47f51
5
5
  SHA512:
6
- metadata.gz: cbc749d93c4da92e0009ccd8e792067b088fa024209355d7e9a71a8357dd91de05be6c3b62704adcace89da7b99328a9b282edc1be8b2e6753dc69f709625db9
7
- data.tar.gz: d7c8071069919512beb841dd3ad453f0e12020565464fc62f24beff4353cffe9c997d2b0a805dde6eddc42fe00a7784eec82a319a8b7954e56f683a1bf856c05
6
+ metadata.gz: bf2dc2f68527913308264c10f7c986523e9bc4922cc1b1283a9125596d74e474f30ae973ecec7c29c6c7f524ab016cc98e59caffa690185af588e00505de7a0e
7
+ data.tar.gz: 357a8436751c0e47d29bd00cea9f9e380548f6a19ed541e6c0487d5da9afc7840aadae79911d17439571339cf1b8a6e8c414fb2653ac6a72f1c254c8903bcb3d
@@ -181,14 +181,9 @@ module Vmpooler
181
181
  /^\d{4}-\d{2}-\d{2}$/ === date_str
182
182
  end
183
183
 
184
+ # NOTE: domain is not needed here, so we should update the callers of this method
184
185
  def hostname_shorten(hostname, domain=nil)
185
- if domain && hostname =~ /^[\w-]+\.#{domain}$/
186
- hostname = hostname[/[^.]+/]
187
- elsif hostname =~ /^[\w-]+\..+$/
188
- hostname = hostname[/[^.]+/]
189
- end
190
-
191
- hostname
186
+ hostname[/[^.]+/]
192
187
  end
193
188
 
194
189
  def get_task_times(backend, task, date_str)
@@ -1519,7 +1519,7 @@ module Vmpooler
1519
1519
 
1520
1520
  post "#{api_prefix}/vm/:hostname/snapshot/:snapshot/?" do
1521
1521
  content_type :json
1522
- metrics.increment('http_requests_vm_total.post.vm.disksize')
1522
+ metrics.increment('http_requests_vm_total.post.vm.snapshot')
1523
1523
 
1524
1524
  need_token! if Vmpooler::API.settings.config[:auth]
1525
1525
 
@@ -258,6 +258,82 @@ module Vmpooler
258
258
  JSON.pretty_generate(result)
259
259
  end
260
260
 
261
+ get "#{api_prefix}/vm/:hostname/?" do
262
+ content_type :json
263
+ metrics.increment('http_requests_vm_total.get.vm.hostname')
264
+
265
+ result = {}
266
+
267
+ status 404
268
+ result['ok'] = false
269
+
270
+ params[:hostname] = hostname_shorten(params[:hostname], nil)
271
+
272
+ rdata = backend.hgetall("vmpooler__vm__#{params[:hostname]}")
273
+ unless rdata.empty?
274
+ status 200
275
+ result['ok'] = true
276
+
277
+ result[params[:hostname]] = {}
278
+
279
+ result[params[:hostname]]['template'] = rdata['template']
280
+ result[params[:hostname]]['lifetime'] = (rdata['lifetime'] || config['vm_lifetime']).to_i
281
+
282
+ if rdata['destroy']
283
+ result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2) if rdata['checkout']
284
+ result[params[:hostname]]['state'] = 'destroyed'
285
+ elsif rdata['checkout']
286
+ result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
287
+ result[params[:hostname]]['remaining'] = ((Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60 - Time.now) / 60 / 60).round(2)
288
+ result[params[:hostname]]['start_time'] = Time.parse(rdata['checkout']).to_datetime.rfc3339
289
+ result[params[:hostname]]['end_time'] = (Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60).to_datetime.rfc3339
290
+ result[params[:hostname]]['state'] = 'running'
291
+ elsif rdata['check']
292
+ result[params[:hostname]]['state'] = 'ready'
293
+ else
294
+ result[params[:hostname]]['state'] = 'pending'
295
+ end
296
+
297
+ rdata.keys.each do |key|
298
+ if key.match('^tag\:(.+?)$')
299
+ result[params[:hostname]]['tags'] ||= {}
300
+ result[params[:hostname]]['tags'][$1] = rdata[key]
301
+ end
302
+
303
+ if key.match('^snapshot\:(.+?)$')
304
+ result[params[:hostname]]['snapshots'] ||= []
305
+ result[params[:hostname]]['snapshots'].push($1)
306
+ end
307
+ end
308
+
309
+ if rdata['disk']
310
+ result[params[:hostname]]['disk'] = rdata['disk'].split(':')
311
+ end
312
+
313
+ # Look up IP address of the hostname
314
+ begin
315
+ ipAddress = TCPSocket.gethostbyname(params[:hostname])[3]
316
+ rescue StandardError
317
+ ipAddress = ""
318
+ end
319
+
320
+ result[params[:hostname]]['ip'] = ipAddress
321
+
322
+ if rdata['pool']
323
+ vmdomain = Parsing.get_domain_for_pool(full_config, rdata['pool'])
324
+ if vmdomain
325
+ result[params[:hostname]]['fqdn'] = "#{params[:hostname]}.#{vmdomain}"
326
+ end
327
+ end
328
+
329
+ result[params[:hostname]]['host'] = rdata['host'] if rdata['host']
330
+ result[params[:hostname]]['migrated'] = rdata['migrated'] if rdata['migrated']
331
+
332
+ end
333
+
334
+ JSON.pretty_generate(result)
335
+ end
336
+
261
337
  post "#{api_prefix}/ondemandvm/?" do
262
338
  content_type :json
263
339
  metrics.increment('http_requests_vm_total.post.ondemand.requestid')
@@ -119,7 +119,13 @@ module Vmpooler
119
119
  pool_alias = redis.hget("vmpooler__vm__#{vm}", 'pool_alias') if request_id
120
120
  redis.multi
121
121
  redis.smove("vmpooler__pending__#{pool}", "vmpooler__completed__#{pool}", vm)
122
- redis.zadd('vmpooler__odcreate__task', 1, "#{pool_alias}:#{pool}:1:#{request_id}") if request_id
122
+ if request_id
123
+ ondemandrequest_hash = redis.hgetall("vmpooler__odrequest__#{request_id}")
124
+ if ondemandrequest_hash && ondemandrequest_hash['status'] != 'failed' && ondemandrequest_hash['status'] != 'deleted'
125
+ # will retry a VM that did not come up as vm_ready? only if it has not been market failed or deleted
126
+ redis.zadd('vmpooler__odcreate__task', 1, "#{pool_alias}:#{pool}:1:#{request_id}")
127
+ end
128
+ end
123
129
  redis.exec
124
130
  $metrics.increment("errors.markedasfailed.#{pool}")
125
131
  $logger.log('d', "[!] [#{pool}] '#{vm}' marked as 'failed' after #{timeout} minutes")
@@ -1596,19 +1602,19 @@ module Vmpooler
1596
1602
  $config[:pools].each do |pool|
1597
1603
  provider_name = pool['provider']
1598
1604
  # The provider_class parameter can be defined in the provider's data eg
1599
- #:providers:
1600
- # :vsphere:
1601
- # provider_class: 'vsphere'
1602
- # :another-vsphere:
1603
- # provider_class: 'vsphere'
1605
+ # :providers:
1606
+ # :vsphere:
1607
+ # provider_class: 'vsphere'
1608
+ # :another-vsphere:
1609
+ # provider_class: 'vsphere'
1604
1610
  # the above would create two providers/vsphere.rb class objects named 'vsphere' and 'another-vsphere'
1605
1611
  # each pools would then define which provider definition to use: vsphere or another-vsphere
1606
1612
  #
1607
1613
  # if provider_class is not defined it will try to use the provider_name as the class, this is to be
1608
1614
  # backwards compatible for example when there is only one provider listed
1609
1615
  # :providers:
1610
- # :dummy:
1611
- # filename: 'db.txs'
1616
+ # :dummy:
1617
+ # filename: 'db.txs'
1612
1618
  # the above example would create an object based on the class providers/dummy.rb
1613
1619
  if $config[:providers].nil? || $config[:providers][provider_name.to_sym].nil? || $config[:providers][provider_name.to_sym]['provider_class'].nil?
1614
1620
  provider_class = provider_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vmpooler
4
- VERSION = '2.3.0'
4
+ VERSION = '2.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmpooler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-07 00:00:00.000000000 Z
11
+ date: 2022-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -17,8 +17,8 @@ dependencies:
17
17
  - !ruby/object:Gem::Version
18
18
  version: '1.1'
19
19
  name: concurrent-ruby
20
- type: :runtime
21
20
  prerelease: false
21
+ type: :runtime
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
@@ -31,8 +31,8 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.2'
33
33
  name: connection_pool
34
- type: :runtime
35
34
  prerelease: false
35
+ type: :runtime
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
@@ -45,8 +45,8 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.2'
47
47
  name: deep_merge
48
- type: :runtime
49
48
  prerelease: false
49
+ type: :runtime
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
@@ -59,27 +59,13 @@ dependencies:
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0.16'
61
61
  name: net-ldap
62
- type: :runtime
63
62
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.16'
69
- - !ruby/object:Gem::Dependency
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.10'
75
- name: nokogiri
76
63
  type: :runtime
77
- prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '1.10'
68
+ version: '0.16'
83
69
  - !ruby/object:Gem::Dependency
84
70
  requirement: !ruby/object:Gem::Requirement
85
71
  requirements:
@@ -87,8 +73,8 @@ dependencies:
87
73
  - !ruby/object:Gem::Version
88
74
  version: 0.20.1
89
75
  name: opentelemetry-exporter-jaeger
90
- type: :runtime
91
76
  prerelease: false
77
+ type: :runtime
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - '='
@@ -101,8 +87,8 @@ dependencies:
101
87
  - !ruby/object:Gem::Version
102
88
  version: 0.19.2
103
89
  name: opentelemetry-instrumentation-concurrent_ruby
104
- type: :runtime
105
90
  prerelease: false
91
+ type: :runtime
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - '='
@@ -113,29 +99,29 @@ dependencies:
113
99
  requirements:
114
100
  - - '='
115
101
  - !ruby/object:Gem::Version
116
- version: 0.19.3
102
+ version: 0.19.4
117
103
  name: opentelemetry-instrumentation-http_client
118
- type: :runtime
119
104
  prerelease: false
105
+ type: :runtime
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - '='
123
109
  - !ruby/object:Gem::Version
124
- version: 0.19.3
110
+ version: 0.19.4
125
111
  - !ruby/object:Gem::Dependency
126
112
  requirement: !ruby/object:Gem::Requirement
127
113
  requirements:
128
114
  - - '='
129
115
  - !ruby/object:Gem::Version
130
- version: 0.21.2
116
+ version: 0.21.3
131
117
  name: opentelemetry-instrumentation-redis
132
- type: :runtime
133
118
  prerelease: false
119
+ type: :runtime
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - '='
137
123
  - !ruby/object:Gem::Version
138
- version: 0.21.2
124
+ version: 0.21.3
139
125
  - !ruby/object:Gem::Dependency
140
126
  requirement: !ruby/object:Gem::Requirement
141
127
  requirements:
@@ -143,8 +129,8 @@ dependencies:
143
129
  - !ruby/object:Gem::Version
144
130
  version: 0.19.3
145
131
  name: opentelemetry-instrumentation-sinatra
146
- type: :runtime
147
132
  prerelease: false
133
+ type: :runtime
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - '='
@@ -157,8 +143,8 @@ dependencies:
157
143
  - !ruby/object:Gem::Version
158
144
  version: 0.19.1
159
145
  name: opentelemetry-resource_detectors
160
- type: :runtime
161
146
  prerelease: false
147
+ type: :runtime
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - '='
@@ -174,8 +160,8 @@ dependencies:
174
160
  - !ruby/object:Gem::Version
175
161
  version: 1.0.2
176
162
  name: opentelemetry-sdk
177
- type: :runtime
178
163
  prerelease: false
164
+ type: :runtime
179
165
  version_requirements: !ruby/object:Gem::Requirement
180
166
  requirements:
181
167
  - - "~>"
@@ -191,8 +177,8 @@ dependencies:
191
177
  - !ruby/object:Gem::Version
192
178
  version: 0.0.11
193
179
  name: pickup
194
- type: :runtime
195
180
  prerelease: false
181
+ type: :runtime
196
182
  version_requirements: !ruby/object:Gem::Requirement
197
183
  requirements:
198
184
  - - "~>"
@@ -205,8 +191,8 @@ dependencies:
205
191
  - !ruby/object:Gem::Version
206
192
  version: '2.0'
207
193
  name: prometheus-client
208
- type: :runtime
209
194
  prerelease: false
195
+ type: :runtime
210
196
  version_requirements: !ruby/object:Gem::Requirement
211
197
  requirements:
212
198
  - - "~>"
@@ -222,8 +208,8 @@ dependencies:
222
208
  - !ruby/object:Gem::Version
223
209
  version: 5.0.4
224
210
  name: puma
225
- type: :runtime
226
211
  prerelease: false
212
+ type: :runtime
227
213
  version_requirements: !ruby/object:Gem::Requirement
228
214
  requirements:
229
215
  - - "~>"
@@ -239,8 +225,8 @@ dependencies:
239
225
  - !ruby/object:Gem::Version
240
226
  version: '2.2'
241
227
  name: rack
242
- type: :runtime
243
228
  prerelease: false
229
+ type: :runtime
244
230
  version_requirements: !ruby/object:Gem::Requirement
245
231
  requirements:
246
232
  - - "~>"
@@ -253,8 +239,8 @@ dependencies:
253
239
  - !ruby/object:Gem::Version
254
240
  version: '13.0'
255
241
  name: rake
256
- type: :runtime
257
242
  prerelease: false
243
+ type: :runtime
258
244
  version_requirements: !ruby/object:Gem::Requirement
259
245
  requirements:
260
246
  - - "~>"
@@ -267,8 +253,8 @@ dependencies:
267
253
  - !ruby/object:Gem::Version
268
254
  version: '4.1'
269
255
  name: redis
270
- type: :runtime
271
256
  prerelease: false
257
+ type: :runtime
272
258
  version_requirements: !ruby/object:Gem::Requirement
273
259
  requirements:
274
260
  - - "~>"
@@ -281,8 +267,8 @@ dependencies:
281
267
  - !ruby/object:Gem::Version
282
268
  version: '2.0'
283
269
  name: sinatra
284
- type: :runtime
285
270
  prerelease: false
271
+ type: :runtime
286
272
  version_requirements: !ruby/object:Gem::Requirement
287
273
  requirements:
288
274
  - - "~>"
@@ -295,8 +281,8 @@ dependencies:
295
281
  - !ruby/object:Gem::Version
296
282
  version: '2.1'
297
283
  name: spicy-proton
298
- type: :runtime
299
284
  prerelease: false
285
+ type: :runtime
300
286
  version_requirements: !ruby/object:Gem::Requirement
301
287
  requirements:
302
288
  - - "~>"
@@ -309,8 +295,8 @@ dependencies:
309
295
  - !ruby/object:Gem::Version
310
296
  version: '1.4'
311
297
  name: statsd-ruby
312
- type: :runtime
313
298
  prerelease: false
299
+ type: :runtime
314
300
  version_requirements: !ruby/object:Gem::Requirement
315
301
  requirements:
316
302
  - - "~>"
@@ -323,8 +309,8 @@ dependencies:
323
309
  - !ruby/object:Gem::Version
324
310
  version: 0.2.0
325
311
  name: climate_control
326
- type: :development
327
312
  prerelease: false
313
+ type: :development
328
314
  version_requirements: !ruby/object:Gem::Requirement
329
315
  requirements:
330
316
  - - ">="
@@ -337,8 +323,8 @@ dependencies:
337
323
  - !ruby/object:Gem::Version
338
324
  version: 0.17.0
339
325
  name: mock_redis
340
- type: :development
341
326
  prerelease: false
327
+ type: :development
342
328
  version_requirements: !ruby/object:Gem::Requirement
343
329
  requirements:
344
330
  - - ">="
@@ -351,8 +337,8 @@ dependencies:
351
337
  - !ruby/object:Gem::Version
352
338
  version: '0'
353
339
  name: pry
354
- type: :development
355
340
  prerelease: false
341
+ type: :development
356
342
  version_requirements: !ruby/object:Gem::Requirement
357
343
  requirements:
358
344
  - - ">="
@@ -365,8 +351,8 @@ dependencies:
365
351
  - !ruby/object:Gem::Version
366
352
  version: '0.6'
367
353
  name: rack-test
368
- type: :development
369
354
  prerelease: false
355
+ type: :development
370
356
  version_requirements: !ruby/object:Gem::Requirement
371
357
  requirements:
372
358
  - - ">="
@@ -379,8 +365,8 @@ dependencies:
379
365
  - !ruby/object:Gem::Version
380
366
  version: '3.2'
381
367
  name: rspec
382
- type: :development
383
368
  prerelease: false
369
+ type: :development
384
370
  version_requirements: !ruby/object:Gem::Requirement
385
371
  requirements:
386
372
  - - ">="
@@ -391,15 +377,15 @@ dependencies:
391
377
  requirements:
392
378
  - - "~>"
393
379
  - !ruby/object:Gem::Version
394
- version: 1.1.0
380
+ version: 1.28.2
395
381
  name: rubocop
396
- type: :development
397
382
  prerelease: false
383
+ type: :development
398
384
  version_requirements: !ruby/object:Gem::Requirement
399
385
  requirements:
400
386
  - - "~>"
401
387
  - !ruby/object:Gem::Version
402
- version: 1.1.0
388
+ version: 1.28.2
403
389
  - !ruby/object:Gem::Dependency
404
390
  requirement: !ruby/object:Gem::Requirement
405
391
  requirements:
@@ -407,8 +393,8 @@ dependencies:
407
393
  - !ruby/object:Gem::Version
408
394
  version: 0.11.2
409
395
  name: simplecov
410
- type: :development
411
396
  prerelease: false
397
+ type: :development
412
398
  version_requirements: !ruby/object:Gem::Requirement
413
399
  requirements:
414
400
  - - ">="
@@ -424,8 +410,8 @@ dependencies:
424
410
  - !ruby/object:Gem::Version
425
411
  version: 1.0.1
426
412
  name: thor
427
- type: :development
428
413
  prerelease: false
414
+ type: :development
429
415
  version_requirements: !ruby/object:Gem::Requirement
430
416
  requirements:
431
417
  - - "~>"
@@ -441,8 +427,8 @@ dependencies:
441
427
  - !ruby/object:Gem::Version
442
428
  version: '2.0'
443
429
  name: yarjuf
444
- type: :development
445
430
  prerelease: false
431
+ type: :development
446
432
  version_requirements: !ruby/object:Gem::Requirement
447
433
  requirements:
448
434
  - - ">="
@@ -507,14 +493,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
507
493
  requirements:
508
494
  - - ">="
509
495
  - !ruby/object:Gem::Version
510
- version: 2.3.0
496
+ version: '0'
511
497
  required_rubygems_version: !ruby/object:Gem::Requirement
512
498
  requirements:
513
499
  - - ">="
514
500
  - !ruby/object:Gem::Version
515
501
  version: '0'
516
502
  requirements: []
517
- rubygems_version: 3.0.6
503
+ rubygems_version: 3.2.29
518
504
  signing_key:
519
505
  specification_version: 4
520
506
  summary: vmpooler provides configurable pools of instantly-available (running) virtual