From 2cd83afeb2722eb532b74aed3892aa7b81d3688f Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Fri, 20 May 2016 14:27:21 -0500 Subject: [PATCH] Aggregate API helper methods --- lib/vmpooler/api/v1.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/vmpooler/api/v1.rb b/lib/vmpooler/api/v1.rb index 33d5503..0ee0efb 100644 --- a/lib/vmpooler/api/v1.rb +++ b/lib/vmpooler/api/v1.rb @@ -86,6 +86,16 @@ module Vmpooler result end + def update_result_hosts(result, template, vm) + result[template] ||= {} + if result[template]['hostname'] + result[template]['hostname'] = Array(result[template]['hostname']) + result[template]['hostname'].push(vm) + else + result[template]['hostname'] = vm + end + end + get "#{api_prefix}/status/?" do content_type :json @@ -379,16 +389,6 @@ module Vmpooler JSON.pretty_generate(result) end - def update_result_hosts(result, template, vm) - result[template] ||= {} - if result[template]['hostname'] - result[template]['hostname'] = Array(result[template]['hostname']) - result[template]['hostname'].push(vm) - else - result[template]['hostname'] = vm - end - end - post "#{api_prefix}/vm/:template/?" do content_type :json