Merge branch 'master' of github.com:sschneid/vmware-host-pooler

This commit is contained in:
Scott Schneider 2014-02-06 09:41:08 -08:00
commit e5b8d882e1

View file

@ -142,24 +142,20 @@ post '/vm/:template' do
result = {} result = {}
result[params[:template]] = {} result[params[:template]] = {}
if ( ( ! params[:folder] ) or ( ! params[:pool] )) if ( $redis.scard('vmware_host_pool__ready__'+params[:template]) > 0 )
result[params[:template]]['error'] = 'You must specify a destination \'folder\' and \'pool\'' vm = $redis.spop('vmware_host_pool__ready__'+params[:template])
else
if ( $redis.scard('vmware_host_pool__ready__'+params[:template]) > 0 )
vm = $redis.spop('vmware_host_pool__ready__'+params[:template])
unless (vm.nil?) unless (vm.nil?)
$redis.sadd('vmware_host_pool__running__'+params[:template], vm) $redis.sadd('vmware_host_pool__running__'+params[:template], vm)
$redis.hset('vmware_host_pool__active__'+params[:template], vm, Time.now) $redis.hset('vmware_host_pool__active__'+params[:template], vm, Time.now)
result[params[:template]]['ok'] = true result[params[:template]]['ok'] = true
result[params[:template]]['hostname'] = vm result[params[:template]]['hostname'] = vm
else
result[params[:template]]['ok'] = false
end
else else
result[params[:template]]['ok'] = false result[params[:template]]['ok'] = false
end end
else
result[params[:template]]['ok'] = false
end end
JSON.pretty_generate(result) JSON.pretty_generate(result)