mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(POOLER-81) Add time remaining information (#280)
* (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). * Remove abs eval from GET, rework spec tests to check each field. This allows us to account for "flakiness" of the remaining return. * Change datetime to RFC3339 for start_time and end_time
This commit is contained in:
parent
84065dd059
commit
12bba418d1
2 changed files with 21 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)
|
||||
result[params[:hostname]]['start_time'] = Time.parse(rdata['checkout']).to_datetime.rfc3339
|
||||
result[params[:hostname]]['end_time'] = (Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60).to_datetime.rfc3339
|
||||
result[params[:hostname]]['state'] = 'running'
|
||||
elsif rdata['check']
|
||||
result[params[:hostname]]['state'] = 'ready'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue