mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18:41 -05:00
(POOLER-81) Add time_remaining information
Before, the only time calculation displayed for a given VM was the lifetime parameter. Added the remaining parameter which will display time until the VM is destroyed as a float. Additionally, start_time and end_time were added to api to return as UTC based times (e.g. 2018-07-10 11:01:03 -0700).
This commit is contained in:
parent
84065dd059
commit
f95b878c8a
2 changed files with 25 additions and 0 deletions
|
|
@ -645,6 +645,9 @@ module Vmpooler
|
|||
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]]['remaining'] = ((Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60 - Time.now) / 60 / 60).round(2).abs
|
||||
result[params[:hostname]]['start_time'] = Time.parse(rdata['checkout'])
|
||||
result[params[:hostname]]['end_time'] = Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60
|
||||
result[params[:hostname]]['state'] = 'running'
|
||||
elsif rdata['check']
|
||||
result[params[:hostname]]['state'] = 'ready'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue