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

View file

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