(#25) Remove printing from delete method in pooler api

This commit is contained in:
Brian Cain 2016-07-09 19:53:12 -07:00
parent a6c5f1dceb
commit 5f6cd1df1d
4 changed files with 16 additions and 10 deletions

View file

@ -212,7 +212,14 @@ class Vmfloaty
if ans
# delete vms
Pooler.delete(verbose, url, running_vms, token)
puts "Scheduling all vms for for deletion"
response = Pooler.delete(verbose, url, running_vms, token)
response.each do |host,vals|
if vals['ok'] == false
STDERR.puts "There was a problem with your request for vm #{host}."
STDERR.puts vals
end
end
end
end

View file

@ -85,17 +85,15 @@ class Pooler
conn.headers['X-AUTH-TOKEN'] = token
end
response_body = {}
hosts.each do |host|
puts "Scheduling host #{host} for deletion"
response = conn.delete "vm/#{host}"
res_body = JSON.parse(response.body)
if res_body['ok']
puts "Deletion for vm #{host} successfully scheduled"
else
STDERR.puts "There was a problem with your request for vm #{host}."
STDERR.puts res_body
end
response_body[host] = res_body
end
response_body
end
def self.status(verbose, url)

View file

@ -1,6 +1,6 @@
class Version
@version = '0.4.0'
@version = '0.5.0'
def self.get
@version

View file

@ -94,6 +94,7 @@ describe Pooler do
describe "#delete" do
before :each do
@delete_response_body_success = "{\"ok\":true}"
@delete_response = {"fq6qlpjlsskycq6"=>{"ok"=>true}}
end
it "deletes a specified vm" do
@ -101,7 +102,7 @@ describe Pooler do
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1', 'X-Auth-Token'=>'mytokenfile'}).
to_return(:status => 200, :body => @delete_response_body_success, :headers => {})
#expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile')).to output(/Scheduling host fq6qlpjlsskycq6 for deletion/).to_stdout
expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile')).to eq @delete_response
end
end