(#1) Add summary command

Right now it does not support timespans, and just does current day.
This commit is contained in:
Brian Cain 2015-09-06 11:35:42 -07:00
parent 4c249c0ce4
commit 13f5a282c7
3 changed files with 16 additions and 6 deletions

View file

@ -23,7 +23,7 @@ gem install vmfloaty
revert revert
snapshot snapshot
status Prints the status of vmpooler status Prints the status of vmpooler
summary summary Prints the summary of vmpooler
GLOBAL OPTIONS: GLOBAL OPTIONS:

View file

@ -17,7 +17,6 @@ class Vmfloaty
config = read_config config = read_config
command :get do |c| command :get do |c|
puts config
c.syntax = 'floaty get [options]' c.syntax = 'floaty get [options]'
c.summary = 'Gets a vm or vms based on the os flag' c.summary = 'Gets a vm or vms based on the os flag'
c.description = '' c.description = ''
@ -135,12 +134,14 @@ class Vmfloaty
command :summary do |c| command :summary do |c|
c.syntax = 'floaty summary [options]' c.syntax = 'floaty summary [options]'
c.summary = '' c.summary = 'Prints the summary of vmpooler'
c.description = '' c.description = ''
c.example 'description', 'command example' c.example 'Gets the current day summary of vmpooler', 'floaty summary --url http://vmpooler.example.com'
c.option '--some-switch', 'Some switch that does something' c.option '--url STRING', String, 'URL of vmpooler'
c.action do |args, options| c.action do |args, options|
# Do something or c.when_called Floaty::Commands::Summary url = options.url ||= config['url']
Pooler.summary(url)
end end
end end

View file

@ -62,5 +62,14 @@ class Pooler
response = conn.get '/v1/status' response = conn.get '/v1/status'
res_body = JSON.parse(response.body) res_body = JSON.parse(response.body)
puts res_body
end
def self.summary(url)
conn = Http.get_conn(url)
response = conn.get '/v1/summary'
res_body = JSON.parse(response.body)
puts res_body
end end
end end