mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
Merge pull request #100 from sschneid/display_vm_state
Display VM state in GET /vm/:hostname route
This commit is contained in:
commit
cf20c418bc
2 changed files with 9 additions and 2 deletions
|
|
@ -211,7 +211,8 @@ $ curl --url vmpooler.company.com/vm/pxpmtoonx7fiqg6
|
||||||
"pxpmtoonx7fiqg6": {
|
"pxpmtoonx7fiqg6": {
|
||||||
"template": "centos-6-x86_64",
|
"template": "centos-6-x86_64",
|
||||||
"lifetime": 12,
|
"lifetime": 12,
|
||||||
"running": 3,
|
"running": 3.1,
|
||||||
|
"state": "running",
|
||||||
"domain": "company.com"
|
"domain": "company.com"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -426,8 +426,14 @@ module Vmpooler
|
||||||
|
|
||||||
if rdata['destroy']
|
if rdata['destroy']
|
||||||
result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
|
result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
|
||||||
else
|
result[params[:hostname]]['state'] = 'destroyed'
|
||||||
|
elsif rdata['checkout']
|
||||||
result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
|
result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
|
||||||
|
result[params[:hostname]]['state'] = 'running'
|
||||||
|
elsif rdata['check']
|
||||||
|
result[params[:hostname]]['state'] = 'ready'
|
||||||
|
else
|
||||||
|
result[params[:hostname]]['state'] = 'pending'
|
||||||
end
|
end
|
||||||
|
|
||||||
rdata.keys.each do |key|
|
rdata.keys.each do |key|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue