vmpooler 0.18.0 → 0.18.1

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: 25f8f02e82db016ae0294993ad97c205d9560fce8fa12358022114866e92bf08
4
- data.tar.gz: c9f2c79541bd7f04084608c000f09dce9b7b2db4a4d983c473207a1e1f001374
3
+ metadata.gz: e3a176887cf8f30a94b12b6eeb6341da12bed5dc6b71d182c0dd4a4c055b78fb
4
+ data.tar.gz: 03ce6a7c2845a6b010b0948d2ed430692d4316df6175f2acdf16b924d0244db7
5
5
  SHA512:
6
- metadata.gz: 5366548250b651add0e834b094a8397556ee8912620dd6d334de5131473a0dafa420e4df43a6f805455df5de062bc00ad36eb2991aa80f2afd039a2b9a0eb6ba
7
- data.tar.gz: 2e2cd9e4cfd83152221c4c96defdc784a4332fee4c36349615b7d21697d622cef89be8bab52ce48c2acc5c8dd5216bc051cc3c28097747bd74f841568aa6232b
6
+ metadata.gz: 0f426a1ca432757c929bc7f792297dd6ad3fba50c03f0469ea0856c1c6561f9e5ca59b2139a8c088cba1c5087ec95ada0e525a4ec3cf06555e09c12dc10ea4b1
7
+ data.tar.gz: 5bca724e57bca246e7cf1c680e631cee143e3f287f9525774714b0b86a099e8ab03b75a7f36c28e6225e5de1d2ad915e62e7d981e2dfe4f767eb595717fb3aee
@@ -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
@@ -118,8 +118,8 @@ module Vmpooler
118
118
  tags.each_pair do |tag, value|
119
119
  next if value.nil? or value.empty?
120
120
 
121
- backend.hset('vmpooler__vm__' + hostname, 'tag:' + tag, value)
122
- 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
123
  end
124
124
  end
125
125
  end
@@ -147,7 +147,7 @@ module Vmpooler
147
147
 
148
148
  def hostname_shorten(hostname, domain=nil)
149
149
  if domain && hostname =~ /^[\w-]+\.#{domain}$/
150
- hostname = hostname[/[^\.]+/]
150
+ hostname = hostname[/[^.]+/]
151
151
  end
152
152
 
153
153
  hostname
@@ -253,17 +253,15 @@ module Vmpooler
253
253
 
254
254
  tags = {}
255
255
 
256
- backend.hgetall('vmpooler__tag__' + date_str).each do |key, value|
256
+ backend.hgetall("vmpooler__tag__#{date_str}").each do |key, value|
257
257
  hostname = 'unknown'
258
258
  tag = 'unknown'
259
259
 
260
- if key =~ /\:/
260
+ if key =~ /:/
261
261
  hostname, tag = key.split(':', 2)
262
262
  end
263
263
 
264
- if opts[:only]
265
- next unless tag == opts[:only]
266
- end
264
+ next if opts[:only] && tag != opts[:only]
267
265
 
268
266
  tags[tag] ||= {}
269
267
  tags[tag][value] ||= 0
@@ -321,7 +319,7 @@ module Vmpooler
321
319
  }
322
320
  }
323
321
 
324
- 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
325
323
 
326
324
  if task[:count][:total] > 0
327
325
  if opts[:bypool] == true
@@ -330,11 +328,11 @@ module Vmpooler
330
328
  task[:count][:pool] = {}
331
329
  task[:duration][:pool] = {}
332
330
 
333
- backend.hgetall('vmpooler__' + task_str + '__' + date_str).each do |key, value|
331
+ backend.hgetall("vmpooler__#{task_str}__#{date_str}").each do |key, value|
334
332
  pool = 'unknown'
335
333
  hostname = 'unknown'
336
334
 
337
- if key =~ /\:/
335
+ if key =~ /:/
338
336
  pool, hostname = key.split(':')
339
337
  else
340
338
  hostname = key
@@ -163,26 +163,31 @@ module Vmpooler
163
163
  end
164
164
 
165
165
  def return_vm_to_ready_state(template, vm)
166
+ backend.multi
167
+ backend.srem("vmpooler__migrating__#{template}", vm)
168
+ backend.hdel("vmpooler__active__#{template}", vm)
169
+ backend.hdel("vmpooler__vm__#{vm}", 'checkout', 'token:token', 'token:user')
166
170
  backend.smove("vmpooler__running__#{template}", "vmpooler__ready__#{template}", vm)
171
+ backend.exec
167
172
  end
168
173
 
169
174
  def account_for_starting_vm(template, vm)
175
+ user = backend.hget("vmpooler__token__#{request.env['HTTP_X_AUTH_TOKEN']}", 'user')
176
+ has_token_result = has_token?
177
+ backend.multi
170
178
  backend.sadd("vmpooler__migrating__#{template}", vm)
171
179
  backend.hset("vmpooler__active__#{template}", vm, Time.now)
172
180
  backend.hset("vmpooler__vm__#{vm}", 'checkout', Time.now)
173
181
 
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
- )
182
+ if Vmpooler::API.settings.config[:auth] and has_token_result
183
+ backend.hset("vmpooler__vm__#{vm}", 'token:token', request.env['HTTP_X_AUTH_TOKEN'])
184
+ backend.hset("vmpooler__vm__#{vm}", 'token:user', user)
181
185
 
182
186
  if config['vm_lifetime_auth'].to_i > 0
183
- backend.hset('vmpooler__vm__' + vm, 'lifetime', config['vm_lifetime_auth'].to_i)
187
+ backend.hset("vmpooler__vm__#{vm}", 'lifetime', config['vm_lifetime_auth'].to_i)
184
188
  end
185
189
  end
190
+ backend.exec
186
191
  end
187
192
 
188
193
  def update_result_hosts(result, template, vm)
@@ -200,16 +205,19 @@ module Vmpooler
200
205
  failed = false
201
206
  vms = []
202
207
 
208
+ validate_token(backend) if Vmpooler::API.settings.config[:auth] and has_token?
209
+
203
210
  payload.each do |requested, count|
204
211
  count.to_i.times do |_i|
205
212
  vmname, vmpool, vmtemplate = fetch_single_vm(requested)
206
- if !vmname
213
+ if vmname
214
+ account_for_starting_vm(vmpool, vmname)
215
+ vms << [vmpool, vmname, vmtemplate]
216
+ metrics.increment("checkout.success.#{vmtemplate}")
217
+ else
207
218
  failed = true
208
- metrics.increment('checkout.empty.' + requested)
219
+ metrics.increment("checkout.empty.#{requested}")
209
220
  break
210
- else
211
- vms << [vmpool, vmname, vmtemplate]
212
- metrics.increment('checkout.success.' + vmtemplate)
213
221
  end
214
222
  end
215
223
  end
@@ -220,8 +228,7 @@ module Vmpooler
220
228
  end
221
229
  status 503
222
230
  else
223
- vms.each do |(vmpool, vmname, vmtemplate)|
224
- account_for_starting_vm(vmpool, vmname)
231
+ vms.each do |(_vmpool, vmname, vmtemplate)|
225
232
  update_result_hosts(result, vmtemplate, vmname)
226
233
  end
227
234
 
@@ -337,7 +344,7 @@ module Vmpooler
337
344
  payload&.each do |poolname, count|
338
345
  next unless count.to_i > config['max_ondemand_instances_per_request']
339
346
 
340
- metrics.increment('ondemandrequest_fail.toomanyrequests.' + poolname)
347
+ metrics.increment("ondemandrequest_fail.toomanyrequests.#{poolname}")
341
348
  return true
342
349
  end
343
350
  false
@@ -380,7 +387,7 @@ module Vmpooler
380
387
  if Vmpooler::API.settings.config[:auth] and has_token?
381
388
  backend.hset("vmpooler__odrequest__#{request_id}", 'token:token', request.env['HTTP_X_AUTH_TOKEN'])
382
389
  backend.hset("vmpooler__odrequest__#{request_id}", 'token:user',
383
- backend.hget('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'user'))
390
+ backend.hget("vmpooler__token__#{request.env['HTTP_X_AUTH_TOKEN']}", 'user'))
384
391
  end
385
392
 
386
393
  result['domain'] = config['domain'] if config['domain']
@@ -542,9 +549,9 @@ module Vmpooler
542
549
  if subpool.include?(p['name'])
543
550
  true
544
551
  elsif !p['alias'].nil?
545
- if p['alias'].is_a?(Array)
552
+ if p['alias'].instance_of?(Array)
546
553
  (p['alias'] & subpool).any?
547
- elsif p['alias'].is_a?(String)
554
+ elsif p['alias'].instance_of?(String)
548
555
  subpool.include?(p['alias'])
549
556
  end
550
557
  end
@@ -727,14 +734,14 @@ module Vmpooler
727
734
  result = { 'ok' => false }
728
735
 
729
736
  if Vmpooler::API.settings.config[:auth]
730
- token = backend.hgetall('vmpooler__token__' + params[:token])
737
+ token = backend.hgetall("vmpooler__token__#{params[:token]}")
731
738
 
732
739
  if not token.nil? and not token.empty?
733
740
  status 200
734
741
 
735
742
  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]
743
+ backend.smembers("vmpooler__running__#{pool['name']}").each do |vm|
744
+ if backend.hget("vmpooler__vm__#{vm}", 'token:token') == params[:token]
738
745
  token['vms'] ||= {}
739
746
  token['vms']['running'] ||= []
740
747
  token['vms']['running'].push(vm)
@@ -760,7 +767,7 @@ module Vmpooler
760
767
 
761
768
  need_auth!
762
769
 
763
- if backend.del('vmpooler__token__' + params[:token]).to_i > 0
770
+ if backend.del("vmpooler__token__#{params[:token]}").to_i > 0
764
771
  status 200
765
772
  result['ok'] = true
766
773
  end
@@ -783,8 +790,8 @@ module Vmpooler
783
790
  o = [('a'..'z'), ('0'..'9')].map(&:to_a).flatten
784
791
  result['token'] = o[rand(25)] + (0...31).map { o[rand(o.length)] }.join
785
792
 
786
- backend.hset('vmpooler__token__' + result['token'], 'user', @auth.username)
787
- backend.hset('vmpooler__token__' + result['token'], 'created', Time.now)
793
+ backend.hset("vmpooler__token__#{result['token']}", 'user', @auth.username)
794
+ backend.hset("vmpooler__token__#{result['token']}", 'created', Time.now)
788
795
 
789
796
  status 200
790
797
  result['ok'] = true
@@ -823,7 +830,7 @@ module Vmpooler
823
830
  else
824
831
  result[:bad_templates] = invalid
825
832
  invalid.each do |bad_template|
826
- metrics.increment('ondemandrequest_fail.invalid.' + bad_template)
833
+ metrics.increment("ondemandrequest_fail.invalid.#{bad_template}")
827
834
  end
828
835
  status 404
829
836
  end
@@ -858,7 +865,7 @@ module Vmpooler
858
865
  else
859
866
  result[:bad_templates] = invalid
860
867
  invalid.each do |bad_template|
861
- metrics.increment('ondemandrequest_fail.invalid.' + bad_template)
868
+ metrics.increment("ondemandrequest_fail.invalid.#{bad_template}")
862
869
  end
863
870
  status 404
864
871
  end
@@ -904,7 +911,7 @@ module Vmpooler
904
911
  result = atomically_allocate_vms(payload)
905
912
  else
906
913
  invalid.each do |bad_template|
907
- metrics.increment('checkout.invalid.' + bad_template)
914
+ metrics.increment("checkout.invalid.#{bad_template}")
908
915
  end
909
916
  status 404
910
917
  end
@@ -980,7 +987,8 @@ module Vmpooler
980
987
  result['ok'] = true
981
988
  status 202
982
989
 
983
- if request_hash['status'] == 'ready'
990
+ case request_hash['status']
991
+ when 'ready'
984
992
  result['ready'] = true
985
993
  Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, _count|
986
994
  instances = backend.smembers("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
@@ -993,10 +1001,10 @@ module Vmpooler
993
1001
  end
994
1002
  result['domain'] = config['domain'] if config['domain']
995
1003
  status 200
996
- elsif request_hash['status'] == 'failed'
1004
+ when 'failed'
997
1005
  result['message'] = "The request failed to provision instances within the configured ondemand_request_ttl '#{config['ondemand_request_ttl']}'"
998
1006
  status 200
999
- elsif request_hash['status'] == 'deleted'
1007
+ when 'deleted'
1000
1008
  result['message'] = 'The request has been deleted'
1001
1009
  status 200
1002
1010
  else
@@ -1059,7 +1067,7 @@ module Vmpooler
1059
1067
  result = atomically_allocate_vms(payload)
1060
1068
  else
1061
1069
  invalid.each do |bad_template|
1062
- metrics.increment('checkout.invalid.' + bad_template)
1070
+ metrics.increment("checkout.invalid.#{bad_template}")
1063
1071
  end
1064
1072
  status 404
1065
1073
  end
@@ -1082,7 +1090,7 @@ module Vmpooler
1082
1090
 
1083
1091
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1084
1092
 
1085
- rdata = backend.hgetall('vmpooler__vm__' + params[:hostname])
1093
+ rdata = backend.hgetall("vmpooler__vm__#{params[:hostname]}")
1086
1094
  unless rdata.empty?
1087
1095
  status 200
1088
1096
  result['ok'] = true
@@ -1093,7 +1101,7 @@ module Vmpooler
1093
1101
  result[params[:hostname]]['lifetime'] = (rdata['lifetime'] || config['vm_lifetime']).to_i
1094
1102
 
1095
1103
  if rdata['destroy']
1096
- result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
1104
+ result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2) if rdata['checkout']
1097
1105
  result[params[:hostname]]['state'] = 'destroyed'
1098
1106
  elsif rdata['checkout']
1099
1107
  result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
@@ -1155,12 +1163,12 @@ module Vmpooler
1155
1163
 
1156
1164
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1157
1165
 
1158
- rdata = backend.hgetall('vmpooler__vm__' + params[:hostname])
1166
+ rdata = backend.hgetall("vmpooler__vm__#{params[:hostname]}")
1159
1167
  unless rdata.empty?
1160
1168
  need_token! if rdata['token:token']
1161
1169
 
1162
- if backend.srem('vmpooler__running__' + rdata['template'], params[:hostname])
1163
- backend.sadd('vmpooler__completed__' + rdata['template'], params[:hostname])
1170
+ if backend.srem("vmpooler__running__#{rdata['template']}", params[:hostname])
1171
+ backend.sadd("vmpooler__completed__#{rdata['template']}", params[:hostname])
1164
1172
 
1165
1173
  status 200
1166
1174
  result['ok'] = true
@@ -1184,7 +1192,7 @@ module Vmpooler
1184
1192
 
1185
1193
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1186
1194
 
1187
- if backend.exists?('vmpooler__vm__' + params[:hostname])
1195
+ if backend.exists?("vmpooler__vm__#{params[:hostname]}")
1188
1196
  begin
1189
1197
  jdata = JSON.parse(request.body.read)
1190
1198
  rescue StandardError
@@ -1212,13 +1220,8 @@ module Vmpooler
1212
1220
  end
1213
1221
 
1214
1222
  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
1223
+ failure.push("You provided tags (#{arg}) as something other than a hash.") unless arg.is_a?(Hash)
1224
+ failure.push("You provided unsuppored tags (#{arg}).") if config['allowed_tags'] && !(arg.keys - config['allowed_tags']).empty?
1222
1225
  else
1223
1226
  failure.push("Unknown argument #{arg}.")
1224
1227
  end
@@ -1235,7 +1238,7 @@ module Vmpooler
1235
1238
 
1236
1239
  arg = arg.to_i
1237
1240
 
1238
- backend.hset('vmpooler__vm__' + params[:hostname], param, arg)
1241
+ backend.hset("vmpooler__vm__#{params[:hostname]}", param, arg)
1239
1242
  when 'tags'
1240
1243
  filter_tags(arg)
1241
1244
  export_tags(backend, params[:hostname], arg)
@@ -1261,11 +1264,11 @@ module Vmpooler
1261
1264
 
1262
1265
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1263
1266
 
1264
- if ((params[:size].to_i > 0 )and (backend.exists?('vmpooler__vm__' + params[:hostname])))
1267
+ if ((params[:size].to_i > 0 )and (backend.exists?("vmpooler__vm__#{params[:hostname]}")))
1265
1268
  result[params[:hostname]] = {}
1266
1269
  result[params[:hostname]]['disk'] = "+#{params[:size]}gb"
1267
1270
 
1268
- backend.sadd('vmpooler__tasks__disk', params[:hostname] + ':' + params[:size])
1271
+ backend.sadd('vmpooler__tasks__disk', "#{params[:hostname]}:#{params[:size]}")
1269
1272
 
1270
1273
  status 202
1271
1274
  result['ok'] = true
@@ -1285,13 +1288,13 @@ module Vmpooler
1285
1288
 
1286
1289
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1287
1290
 
1288
- if backend.exists?('vmpooler__vm__' + params[:hostname])
1291
+ if backend.exists?("vmpooler__vm__#{params[:hostname]}")
1289
1292
  result[params[:hostname]] = {}
1290
1293
 
1291
1294
  o = [('a'..'z'), ('0'..'9')].map(&:to_a).flatten
1292
1295
  result[params[:hostname]]['snapshot'] = o[rand(25)] + (0...31).map { o[rand(o.length)] }.join
1293
1296
 
1294
- backend.sadd('vmpooler__tasks__snapshot', params[:hostname] + ':' + result[params[:hostname]]['snapshot'])
1297
+ backend.sadd('vmpooler__tasks__snapshot', "#{params[:hostname]}:#{result[params[:hostname]]['snapshot']}")
1295
1298
 
1296
1299
  status 202
1297
1300
  result['ok'] = true
@@ -1311,8 +1314,8 @@ module Vmpooler
1311
1314
 
1312
1315
  params[:hostname] = hostname_shorten(params[:hostname], config['domain'])
1313
1316
 
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])
1317
+ unless backend.hget("vmpooler__vm__#{params[:hostname]}", "snapshot:#{params[:snapshot]}").to_i.zero?
1318
+ backend.sadd('vmpooler__tasks__snapshot-revert', "#{params[:hostname]}:#{params[:snapshot]}")
1316
1319
 
1317
1320
  status 202
1318
1321
  result['ok'] = true