vmpooler 0.16.2 → 0.18.2

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: 644990026566943db404eef9299dc9b4d9acb4ed0b8bb9a99afae7db2d89936d
4
- data.tar.gz: 939950a7c6244bf06e590fe0250d358f30ef33623e94603a6d4cf1d57dae5156
3
+ metadata.gz: 9c5b00eb18e417b534119f23d2e5e8127469b345906327a1ea6d0223851c113f
4
+ data.tar.gz: edd62d5343f0a569a9ef905f31fc4d5f14c0dc0d55644d285e9ab40a5403ff2d
5
5
  SHA512:
6
- metadata.gz: ca62fe5656e5fd3e89957b145b9fa2824c7159f7e2a10f7e88dee50fcc8c2decda9025e0e82e9bdc0358683c755cce9aae0d56a68d263f9e80ccf4e35f88ce1c
7
- data.tar.gz: ab219628dd9902f8d4c501ceff7e00fc8c88583ee29b6a2beb1ba08b8c07fa2dc3c96f21caf480dae4dadb61ca41461fbd5ddbfb71bd9e4a8f1308d2e477962b
6
+ metadata.gz: 6514b53e6ff62b228c696dd195d941f217eba85cdc8b97f8eedad81800d359d598d591f2840538f4d52d48cc54f50e75a8bbbf1cf080d25e23cbf216cd1dc16f
7
+ data.tar.gz: 4c1acb611e7213419302563e7327226e688fa024168c052bb8a374375fe3cb92dca90e15748ab42de9cd87877d209d1738b2a77607ced3a924a46eb336777be7
@@ -53,17 +53,13 @@ module Vmpooler
53
53
 
54
54
  # Bail out if someone attempts to start vmpooler with dummy authentication
55
55
  # without enbaling debug mode.
56
- if parsed_config.key? :auth
57
- if parsed_config[:auth]['provider'] == 'dummy'
58
- unless ENV['VMPOOLER_DEBUG']
59
- warning = [
60
- 'Dummy authentication should not be used outside of debug mode',
61
- 'please set environment variable VMPOOLER_DEBUG to \'true\' if you want to use dummy authentication'
62
- ]
63
-
64
- raise warning.join(";\s")
65
- end
66
- end
56
+ if parsed_config.key?(:auth) && parsed_config[:auth]['provider'] == 'dummy' && !ENV['VMPOOLER_DEBUG']
57
+ warning = [
58
+ 'Dummy authentication should not be used outside of debug mode',
59
+ 'please set environment variable VMPOOLER_DEBUG to \'true\' if you want to use dummy authentication'
60
+ ]
61
+
62
+ raise warning.join(";\s")
67
63
  end
68
64
 
69
65
  # Set some configuration defaults
@@ -140,14 +136,14 @@ module Vmpooler
140
136
  parsed_config[:pool_names] << pool['name']
141
137
  pool['ready_ttl'] ||= parsed_config[:config]['ready_ttl']
142
138
  if pool['alias']
143
- if pool['alias'].is_a?(Array)
139
+ if pool['alias'].instance_of?(Array)
144
140
  pool['alias'].each do |pool_alias|
145
141
  parsed_config[:alias] ||= {}
146
142
  parsed_config[:alias][pool_alias] = [pool['name']] unless parsed_config[:alias].key? pool_alias
147
143
  parsed_config[:alias][pool_alias] << pool['name'] unless parsed_config[:alias][pool_alias].include? pool['name']
148
144
  parsed_config[:pool_names] << pool_alias
149
145
  end
150
- elsif pool['alias'].is_a?(String)
146
+ elsif pool['alias'].instance_of?(String)
151
147
  parsed_config[:alias][pool['alias']] = pool['name']
152
148
  parsed_config[:pool_names] << pool['alias']
153
149
  end
@@ -128,34 +128,32 @@ module Vmpooler
128
128
 
129
129
  pools.each do |pool|
130
130
  running = running_hash[pool['name']]
131
- pool['major'] = Regexp.last_match[1] if pool['name'] =~ /^(\w+)\-/
131
+ pool['major'] = Regexp.last_match[1] if pool['name'] =~ /^(\w+)-/
132
132
  result[pool['major']] ||= {}
133
133
  result[pool['major']]['running'] = result[pool['major']]['running'].to_i + running.to_i
134
134
  end
135
135
 
136
- if params[:history]
137
- if graph_url
138
- begin
139
- buffer = URI.parse(graph_link('.running.*&from=-1hour&format=json')).read
140
- JSON.parse(buffer).each do |pool|
141
- if pool['target'] =~ /.*\.(.*)$/
142
- pool['name'] = Regexp.last_match[1]
143
- pool['major'] = Regexp.last_match[1] if pool['name'] =~ /^(\w+)\-/
144
- result[pool['major']]['history'] ||= []
145
-
146
- for i in 0..pool['datapoints'].length
147
- if pool['datapoints'][i] && pool['datapoints'][i][0]
148
- pool['last'] = pool['datapoints'][i][0]
149
- result[pool['major']]['history'][i] ||= 0
150
- result[pool['major']]['history'][i] = result[pool['major']]['history'][i].to_i + pool['datapoints'][i][0].to_i
151
- else
152
- result[pool['major']]['history'][i] = result[pool['major']]['history'][i].to_i + pool['last'].to_i
153
- end
136
+ if params[:history] && graph_url
137
+ begin
138
+ buffer = URI.parse(graph_link('.running.*&from=-1hour&format=json')).read
139
+ JSON.parse(buffer).each do |pool|
140
+ if pool['target'] =~ /.*\.(.*)$/
141
+ pool['name'] = Regexp.last_match[1]
142
+ pool['major'] = Regexp.last_match[1] if pool['name'] =~ /^(\w+)-/
143
+ result[pool['major']]['history'] ||= []
144
+
145
+ for i in 0..pool['datapoints'].length
146
+ if pool['datapoints'][i] && pool['datapoints'][i][0]
147
+ pool['last'] = pool['datapoints'][i][0]
148
+ result[pool['major']]['history'][i] ||= 0
149
+ result[pool['major']]['history'][i] = result[pool['major']]['history'][i].to_i + pool['datapoints'][i][0].to_i
150
+ else
151
+ result[pool['major']]['history'][i] = result[pool['major']]['history'][i].to_i + pool['last'].to_i
154
152
  end
155
153
  end
156
154
  end
157
- rescue StandardError
158
155
  end
156
+ rescue StandardError
159
157
  end
160
158
  end
161
159
  JSON.pretty_generate(result)
@@ -13,12 +13,12 @@ module Vmpooler
13
13
  def valid_token?(backend)
14
14
  return false unless has_token?
15
15
 
16
- backend.exists?('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN']) ? true : false
16
+ backend.exists?("vmpooler__token__#{request.env['HTTP_X_AUTH_TOKEN']}") ? true : false
17
17
  end
18
18
 
19
19
  def validate_token(backend)
20
20
  if valid_token?(backend)
21
- backend.hset('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'last', Time.now)
21
+ backend.hset("vmpooler__token__#{request.env['HTTP_X_AUTH_TOKEN']}", 'last', Time.now)
22
22
 
23
23
  return true
24
24
  end
@@ -114,11 +114,13 @@ module Vmpooler
114
114
  end
115
115
 
116
116
  def export_tags(backend, hostname, tags)
117
- tags.each_pair do |tag, value|
118
- next if value.nil? or value.empty?
117
+ backend.pipelined do
118
+ tags.each_pair do |tag, value|
119
+ next if value.nil? or value.empty?
119
120
 
120
- backend.hset('vmpooler__vm__' + hostname, 'tag:' + tag, value)
121
- backend.hset('vmpooler__tag__' + Date.today.to_s, hostname + ':' + tag, value)
121
+ backend.hset("vmpooler__vm__#{hostname}", "tag:#{tag}", value)
122
+ backend.hset("vmpooler__tag__#{Date.today}", "#{hostname}:#{tag}", value)
123
+ end
122
124
  end
123
125
  end
124
126
 
@@ -145,7 +147,7 @@ module Vmpooler
145
147
 
146
148
  def hostname_shorten(hostname, domain=nil)
147
149
  if domain && hostname =~ /^[\w-]+\.#{domain}$/
148
- hostname = hostname[/[^\.]+/]
150
+ hostname = hostname[/[^.]+/]
149
151
  end
150
152
 
151
153
  hostname
@@ -251,17 +253,15 @@ module Vmpooler
251
253
 
252
254
  tags = {}
253
255
 
254
- backend.hgetall('vmpooler__tag__' + date_str).each do |key, value|
256
+ backend.hgetall("vmpooler__tag__#{date_str}").each do |key, value|
255
257
  hostname = 'unknown'
256
258
  tag = 'unknown'
257
259
 
258
- if key =~ /\:/
260
+ if key =~ /:/
259
261
  hostname, tag = key.split(':', 2)
260
262
  end
261
263
 
262
- if opts[:only]
263
- next unless tag == opts[:only]
264
- end
264
+ next if opts[:only] && tag != opts[:only]
265
265
 
266
266
  tags[tag] ||= {}
267
267
  tags[tag][value] ||= 0
@@ -319,7 +319,7 @@ module Vmpooler
319
319
  }
320
320
  }
321
321
 
322
- task[:count][:total] = backend.hlen('vmpooler__' + task_str + '__' + date_str).to_i
322
+ task[:count][:total] = backend.hlen("vmpooler__#{task_str}__#{date_str}").to_i
323
323
 
324
324
  if task[:count][:total] > 0
325
325
  if opts[:bypool] == true
@@ -328,11 +328,11 @@ module Vmpooler
328
328
  task[:count][:pool] = {}
329
329
  task[:duration][:pool] = {}
330
330
 
331
- backend.hgetall('vmpooler__' + task_str + '__' + date_str).each do |key, value|
331
+ backend.hgetall("vmpooler__#{task_str}__#{date_str}").each do |key, value|
332
332
  pool = 'unknown'
333
333
  hostname = 'unknown'
334
334
 
335
- if key =~ /\:/
335
+ if key =~ /:/
336
336
  pool, hostname = key.split(':')
337
337
  else
338
338
  hostname = key
@@ -163,24 +163,25 @@ module Vmpooler
163
163
  end
164
164
 
165
165
  def return_vm_to_ready_state(template, vm)
166
+ backend.srem("vmpooler__migrating__#{template}", vm)
167
+ backend.hdel("vmpooler__active__#{template}", vm)
168
+ backend.hdel("vmpooler__vm__#{vm}", 'checkout', 'token:token', 'token:user')
166
169
  backend.smove("vmpooler__running__#{template}", "vmpooler__ready__#{template}", vm)
167
170
  end
168
171
 
169
172
  def account_for_starting_vm(template, vm)
173
+ user = backend.hget("vmpooler__token__#{request.env['HTTP_X_AUTH_TOKEN']}", 'user')
174
+ has_token_result = has_token?
170
175
  backend.sadd("vmpooler__migrating__#{template}", vm)
171
176
  backend.hset("vmpooler__active__#{template}", vm, Time.now)
172
177
  backend.hset("vmpooler__vm__#{vm}", 'checkout', Time.now)
173
178
 
174
- if Vmpooler::API.settings.config[:auth] and has_token?
175
- validate_token(backend)
176
-
177
- backend.hset('vmpooler__vm__' + vm, 'token:token', request.env['HTTP_X_AUTH_TOKEN'])
178
- backend.hset('vmpooler__vm__' + vm, 'token:user',
179
- backend.hget('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'user')
180
- )
179
+ if Vmpooler::API.settings.config[:auth] and has_token_result
180
+ backend.hset("vmpooler__vm__#{vm}", 'token:token', request.env['HTTP_X_AUTH_TOKEN'])
181
+ backend.hset("vmpooler__vm__#{vm}", 'token:user', user)
181
182
 
182
183
  if config['vm_lifetime_auth'].to_i > 0
183
- backend.hset('vmpooler__vm__' + vm, 'lifetime', config['vm_lifetime_auth'].to_i)
184
+ backend.hset("vmpooler__vm__#{vm}", 'lifetime', config['vm_lifetime_auth'].to_i)
184
185
  end
185
186
  end
186
187
  end
@@ -200,16 +201,19 @@ module Vmpooler
200
201
  failed = false
201
202
  vms = []
202
203
 
204
+ validate_token(backend) if Vmpooler::API.settings.config[:auth] and has_token?
205
+
203
206
  payload.each do |requested, count|
204
207
  count.to_i.times do |_i|
205
208
  vmname, vmpool, vmtemplate = fetch_single_vm(requested)
206
- if !vmname
209
+ if vmname
210
+ account_for_starting_vm(vmpool, vmname)
211
+ vms << [vmpool, vmname, vmtemplate]
212
+ metrics.increment("checkout.success.#{vmpool}")
213
+ else
207
214
  failed = true
208
- metrics.increment('checkout.empty.' + requested)
215
+ metrics.increment("checkout.empty.#{requested}")
209
216
  break
210
- else
211
- vms << [vmpool, vmname, vmtemplate]
212
- metrics.increment('checkout.success.' + vmtemplate)
213
217
  end
214
218
  end
215
219
  end
@@ -220,8 +224,7 @@ module Vmpooler
220
224
  end
221
225
  status 503
222
226
  else
223
- vms.each do |(vmpool, vmname, vmtemplate)|
224
- account_for_starting_vm(vmpool, vmname)
227
+ vms.each do |(_vmpool, vmname, vmtemplate)|
225
228
  update_result_hosts(result, vmtemplate, vmname)
226
229
  end
227
230
 
@@ -337,7 +340,7 @@ module Vmpooler
337
340
  payload&.each do |poolname, count|
338
341
  next unless count.to_i > config['max_ondemand_instances_per_request']
339
342
 
340
- metrics.increment('ondemandrequest_fail.toomanyrequests.' + poolname)
343
+ metrics.increment("ondemandrequest_fail.toomanyrequests.#{poolname}")
341
344
  return true
342
345
  end
343
346
  false
@@ -380,7 +383,7 @@ module Vmpooler
380
383
  if Vmpooler::API.settings.config[:auth] and has_token?
381
384
  backend.hset("vmpooler__odrequest__#{request_id}", 'token:token', request.env['HTTP_X_AUTH_TOKEN'])
382
385
  backend.hset("vmpooler__odrequest__#{request_id}", 'token:user',
383
- backend.hget('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'user'))
386
+ backend.hget("vmpooler__token__#{request.env['HTTP_X_AUTH_TOKEN']}", 'user'))
384
387
  end
385
388
 
386
389
  result['domain'] = config['domain'] if config['domain']
@@ -542,9 +545,9 @@ module Vmpooler
542
545
  if subpool.include?(p['name'])
543
546
  true
544
547
  elsif !p['alias'].nil?
545
- if p['alias'].is_a?(Array)
548
+ if p['alias'].instance_of?(Array)
546
549
  (p['alias'] & subpool).any?
547
- elsif p['alias'].is_a?(String)
550
+ elsif p['alias'].instance_of?(String)
548
551
  subpool.include?(p['alias'])
549
552
  end
550
553
  end
@@ -727,14 +730,14 @@ module Vmpooler
727
730
  result = { 'ok' => false }
728
731
 
729
732
  if Vmpooler::API.settings.config[:auth]
730
- token = backend.hgetall('vmpooler__token__' + params[:token])
733
+ token = backend.hgetall("vmpooler__token__#{params[:token]}")
731
734
 
732
735
  if not token.nil? and not token.empty?
733
736
  status 200
734
737
 
735
738
  pools.each do |pool|
736
- backend.smembers('vmpooler__running__' + pool['name']).each do |vm|
737
- if backend.hget('vmpooler__vm__' + vm, 'token:token') == params[:token]
739
+ backend.smembers("vmpooler__running__#{pool['name']}").each do |vm|
740
+ if backend.hget("vmpooler__vm__#{vm}", 'token:token') == params[:token]
738
741
  token['vms'] ||= {}
739
742
  token['vms']['running'] ||= []
740
743
  token['vms']['running'].push(vm)
@@ -760,7 +763,7 @@ module Vmpooler
760
763
 
761
764
  need_auth!
762
765
 
763
- if backend.del('vmpooler__token__' + params[:token]).to_i > 0
766
+ if backend.del("vmpooler__token__#{params[:token]}").to_i > 0
764
767
  status 200
765
768
  result['ok'] = true
766
769
  end
@@ -783,8 +786,8 @@ module Vmpooler
783
786
  o = [('a'..'z'), ('0'..'9')].map(&:to_a).flatten
784
787
  result['token'] = o[rand(25)] + (0...31).map { o[rand(o.length)] }.join
785
788
 
786
- backend.hset('vmpooler__token__' + result['token'], 'user', @auth.username)
787
- backend.hset('vmpooler__token__' + result['token'], 'created', Time.now)
789
+ backend.hset("vmpooler__token__#{result['token']}", 'user', @auth.username)
790
+ backend.hset("vmpooler__token__#{result['token']}", 'created', Time.now)
788
791
 
789
792
  status 200
790
793
  result['ok'] = true
@@ -823,7 +826,7 @@ module Vmpooler
823
826
  else
824
827
  result[:bad_templates] = invalid
825
828
  invalid.each do |bad_template|
826
- metrics.increment('ondemandrequest_fail.invalid.' + bad_template)
829
+ metrics.increment("ondemandrequest_fail.invalid.#{bad_template}")
827
830
  end
828
831
  status 404
829
832
  end
@@ -858,7 +861,7 @@ module Vmpooler
858
861
  else
859
862
  result[:bad_templates] = invalid
860
863
  invalid.each do |bad_template|
861
- metrics.increment('ondemandrequest_fail.invalid.' + bad_template)
864
+ metrics.increment("ondemandrequest_fail.invalid.#{bad_template}")
862
865
  end
863
866
  status 404
864
867
  end
@@ -904,7 +907,7 @@ module Vmpooler
904
907
  result = atomically_allocate_vms(payload)
905
908
  else
906
909
  invalid.each do |bad_template|
907
- metrics.increment('checkout.invalid.' + bad_template)
910
+ metrics.increment("checkout.invalid.#{bad_template}")
908
911
  end
909
912
  status 404
910
913
  end
@@ -980,7 +983,8 @@ module Vmpooler
980
983
  result['ok'] = true
981
984
  status 202
982
985
 
983
- if request_hash['status'] == 'ready'
986
+ case request_hash['status']
987
+ when 'ready'
984
988
  result['ready'] = true
985
989
  Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, _count|
986
990
  instances = backend.smembers("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
@@ -993,10 +997,10 @@ module Vmpooler
993
997
  end
994
998
  result['domain'] = config['domain'] if config['domain']
995
999
  status 200
996
- elsif request_hash['status'] == 'failed'
1000
+ when 'failed'
997
1001
  result['message'] = "The request failed to provision instances within the configured ondemand_request_ttl '#{config['ondemand_request_ttl']}'"
998
1002
  status 200
999
- elsif request_hash['status'] == 'deleted'
1003
+ when 'deleted'
1000
1004
  result['message'] = 'The request has been deleted'
1001
1005
  status 200
1002
1006
  else
@@ -1059,7 +1063,7 @@ module Vmpooler
1059
1063
  result = atomically_allocate_vms(payload)
1060
1064
  else
1061
1065
  invalid.each do |bad_template|
1062
- metrics.increment('checkout.invalid.' + bad_template)
1066
+ metrics.increment("checkout.invalid.#{bad_template}")
1063
1067
  end
1064
1068
  status 404
1065
1069
  end
@@ -1082,7 +1086,7 @@ module Vmpooler
1082
1086
 
1083
1087
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1084
1088
 
1085
- rdata = backend.hgetall('vmpooler__vm__' + params[:hostname])
1089
+ rdata = backend.hgetall("vmpooler__vm__#{params[:hostname]}")
1086
1090
  unless rdata.empty?
1087
1091
  status 200
1088
1092
  result['ok'] = true
@@ -1093,7 +1097,7 @@ module Vmpooler
1093
1097
  result[params[:hostname]]['lifetime'] = (rdata['lifetime'] || config['vm_lifetime']).to_i
1094
1098
 
1095
1099
  if rdata['destroy']
1096
- result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
1100
+ result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2) if rdata['checkout']
1097
1101
  result[params[:hostname]]['state'] = 'destroyed'
1098
1102
  elsif rdata['checkout']
1099
1103
  result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
@@ -1155,12 +1159,12 @@ module Vmpooler
1155
1159
 
1156
1160
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1157
1161
 
1158
- rdata = backend.hgetall('vmpooler__vm__' + params[:hostname])
1162
+ rdata = backend.hgetall("vmpooler__vm__#{params[:hostname]}")
1159
1163
  unless rdata.empty?
1160
1164
  need_token! if rdata['token:token']
1161
1165
 
1162
- if backend.srem('vmpooler__running__' + rdata['template'], params[:hostname])
1163
- backend.sadd('vmpooler__completed__' + rdata['template'], params[:hostname])
1166
+ if backend.srem("vmpooler__running__#{rdata['template']}", params[:hostname])
1167
+ backend.sadd("vmpooler__completed__#{rdata['template']}", params[:hostname])
1164
1168
 
1165
1169
  status 200
1166
1170
  result['ok'] = true
@@ -1184,7 +1188,7 @@ module Vmpooler
1184
1188
 
1185
1189
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1186
1190
 
1187
- if backend.exists?('vmpooler__vm__' + params[:hostname])
1191
+ if backend.exists?("vmpooler__vm__#{params[:hostname]}")
1188
1192
  begin
1189
1193
  jdata = JSON.parse(request.body.read)
1190
1194
  rescue StandardError
@@ -1212,13 +1216,8 @@ module Vmpooler
1212
1216
  end
1213
1217
 
1214
1218
  when 'tags'
1215
- unless arg.is_a?(Hash)
1216
- failure.push("You provided tags (#{arg}) as something other than a hash.")
1217
- end
1218
-
1219
- if config['allowed_tags']
1220
- failure.push("You provided unsuppored tags (#{arg}).") if not (arg.keys - config['allowed_tags']).empty?
1221
- end
1219
+ failure.push("You provided tags (#{arg}) as something other than a hash.") unless arg.is_a?(Hash)
1220
+ failure.push("You provided unsuppored tags (#{arg}).") if config['allowed_tags'] && !(arg.keys - config['allowed_tags']).empty?
1222
1221
  else
1223
1222
  failure.push("Unknown argument #{arg}.")
1224
1223
  end
@@ -1235,7 +1234,7 @@ module Vmpooler
1235
1234
 
1236
1235
  arg = arg.to_i
1237
1236
 
1238
- backend.hset('vmpooler__vm__' + params[:hostname], param, arg)
1237
+ backend.hset("vmpooler__vm__#{params[:hostname]}", param, arg)
1239
1238
  when 'tags'
1240
1239
  filter_tags(arg)
1241
1240
  export_tags(backend, params[:hostname], arg)
@@ -1261,11 +1260,11 @@ module Vmpooler
1261
1260
 
1262
1261
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1263
1262
 
1264
- if ((params[:size].to_i > 0 )and (backend.exists?('vmpooler__vm__' + params[:hostname])))
1263
+ if ((params[:size].to_i > 0 )and (backend.exists?("vmpooler__vm__#{params[:hostname]}")))
1265
1264
  result[params[:hostname]] = {}
1266
1265
  result[params[:hostname]]['disk'] = "+#{params[:size]}gb"
1267
1266
 
1268
- backend.sadd('vmpooler__tasks__disk', params[:hostname] + ':' + params[:size])
1267
+ backend.sadd('vmpooler__tasks__disk', "#{params[:hostname]}:#{params[:size]}")
1269
1268
 
1270
1269
  status 202
1271
1270
  result['ok'] = true
@@ -1285,13 +1284,13 @@ module Vmpooler
1285
1284
 
1286
1285
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1287
1286
 
1288
- if backend.exists?('vmpooler__vm__' + params[:hostname])
1287
+ if backend.exists?("vmpooler__vm__#{params[:hostname]}")
1289
1288
  result[params[:hostname]] = {}
1290
1289
 
1291
1290
  o = [('a'..'z'), ('0'..'9')].map(&:to_a).flatten
1292
1291
  result[params[:hostname]]['snapshot'] = o[rand(25)] + (0...31).map { o[rand(o.length)] }.join
1293
1292
 
1294
- backend.sadd('vmpooler__tasks__snapshot', params[:hostname] + ':' + result[params[:hostname]]['snapshot'])
1293
+ backend.sadd('vmpooler__tasks__snapshot', "#{params[:hostname]}:#{result[params[:hostname]]['snapshot']}")
1295
1294
 
1296
1295
  status 202
1297
1296
  result['ok'] = true
@@ -1311,8 +1310,8 @@ module Vmpooler
1311
1310
 
1312
1311
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1313
1312
 
1314
- unless backend.hget('vmpooler__vm__' + params[:hostname], 'snapshot:' + params[:snapshot]).to_i.zero?
1315
- backend.sadd('vmpooler__tasks__snapshot-revert', params[:hostname] + ':' + params[:snapshot])
1313
+ unless backend.hget("vmpooler__vm__#{params[:hostname]}", "snapshot:#{params[:snapshot]}").to_i.zero?
1314
+ backend.sadd('vmpooler__tasks__snapshot-revert', "#{params[:hostname]}:#{params[:snapshot]}")
1316
1315
 
1317
1316
  status 202
1318
1317
  result['ok'] = true