Move printing to command class instead of pooler class

This commit makes the pooler class more of a library rather than a
helper class that prints the response body of api requests
This commit is contained in:
Brian Cain 2015-09-14 21:37:12 -07:00
parent d99e401bb0
commit 44c5315bfd
2 changed files with 25 additions and 16 deletions

View file

@ -39,7 +39,8 @@ class Vmfloaty
end
unless os_types.nil?
Pooler.retrieve(os_types, token, url)
response = Pooler.retrieve(os_types, token, url)
puts response
else
puts 'You did not provide an OS to get'
end
@ -59,7 +60,8 @@ class Vmfloaty
filter = options.filter
url = options.url ||= config['url']
Pooler.list(url, filter)
os_list = Pooler.list(url, filter)
puts os_list
end
end
@ -76,7 +78,8 @@ class Vmfloaty
url = options.url ||= config['url']
hostname = options.hostname
Pooler.query(url, hostname)
query = Pooler.query(url, hostname)
puts query
end
end
@ -99,7 +102,8 @@ class Vmfloaty
tags = options.tags
token = options.token
Pooler.modify(url, hostname, token, lifetime, tags)
res_body = Pooler.modify(url, hostname, token, lifetime, tags)
puts res_body
end
end
@ -135,7 +139,8 @@ class Vmfloaty
hostname = options.hostname
token = options.token
Pooler.snapshot(url, hostname, token)
res_body = Pooler.snapshot(url, hostname, token)
puts res_body
end
end
@ -156,7 +161,8 @@ class Vmfloaty
token = options.token
snapshot_sha = options.snapshot
Pooler.revert(url, hostname, token, snapshot_sha)
res_body = Pooler.revert(url, hostname, token, snapshot_sha)
puts res_body
end
end
@ -171,7 +177,8 @@ class Vmfloaty
verbose = options.verbose || config['verbose']
url = options.url ||= config['url']
Pooler.status(url)
status = Pooler.status(url)
puts status
end
end
@ -186,7 +193,8 @@ class Vmfloaty
verbose = options.verbose || config['verbose']
url = options.url ||= config['url']
Pooler.summary(url)
summary = Pooler.summary(url)
puts summary
end
end

View file

@ -15,7 +15,7 @@ class Pooler
hosts = response_body
end
puts hosts
hosts
end
def self.retrieve(os_type, token, url)
@ -37,7 +37,8 @@ class Pooler
req.body = os_body
end
puts JSON.parse(response.body)
res_body = JSON.parse(response.body)
res_body
end
def self.modify(url, hostname, token, lifetime, tags)
@ -48,7 +49,7 @@ class Pooler
response = conn.put "/#{hostname}"
res_body = JSON.parse(response.body)
puts res_body
res_body
end
def self.delete(url, hostname)
@ -68,7 +69,7 @@ class Pooler
response = conn.get '/status'
res_body = JSON.parse(response.body)
puts res_body
res_body
end
def self.summary(url)
@ -76,7 +77,7 @@ class Pooler
response = conn.get '/summary'
res_body = JSON.parse(response.body)
puts res_body
res_body
end
def self.query(url, hostname)
@ -85,7 +86,7 @@ class Pooler
response = conn.get "/vm/#{hostname}"
res_body = JSON.parse(response.body)
puts res_body
res_body
end
def self.snapshot(url, hostname, token)
@ -94,7 +95,7 @@ class Pooler
# need to use token
response = conn.post "/#{hostname}/snapshot"
res_body = JSON.parse(response.body)
puts res_body
res_body
end
def self.revert(url, hostname, token, snapshot_sha)
@ -103,6 +104,6 @@ class Pooler
# need to use token
response = conn.post "/#{hostname}/snapshot/#{snapshot}"
res_body = JSON.parse(response.body)
puts res_body
res_body
end
end