(maint) Have pooler delete class take array

Prior to this commit, the pooler class was expecting a comma separated
string of hosts to delete. This commit updates that to expect hostnames
to be an array instead.
This commit is contained in:
Brian Cain 2015-11-10 11:35:17 -08:00
parent fa92da5c05
commit bc4cff5363
3 changed files with 9 additions and 9 deletions

View file

@ -144,10 +144,16 @@ class Vmfloaty
c.option '--url STRING', String, 'URL of vmpooler' c.option '--url STRING', String, 'URL of vmpooler'
c.action do |args, options| c.action do |args, options|
verbose = options.verbose || config['verbose'] verbose = options.verbose || config['verbose']
hosts = args[0] hostnames = args[0]
token = options.token || config['token'] token = options.token || config['token']
url = options.url ||= config['url'] url = options.url ||= config['url']
if hostnames.nil?
STDERR.puts "You did not provide any hosts to delete"
exit 1
end
hosts = hostnames.split(',')
Pooler.delete(verbose, url, hosts, token) Pooler.delete(verbose, url, hosts, token)
end end
end end

View file

@ -71,13 +71,7 @@ class Pooler
res_body res_body
end end
def self.delete(verbose, url, hostnames, token) def self.delete(verbose, url, hosts, token)
if hostnames.nil?
STDERR.puts "You did not provide any hosts to delete"
exit 1
end
hosts = hostnames.split(',')
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, url)
if token if token

View file

@ -101,7 +101,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'}). 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 => {}) 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 output(/Scheduling host fq6qlpjlsskycq6 for deletion/).to_stdout
end end
end end