mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 21:38:41 -05:00
Merge branch 'master' of github.com:briancain/vmfloaty
This commit is contained in:
commit
2153507098
8 changed files with 207 additions and 17 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
require 'rubygems'
|
||||
require 'commander'
|
||||
require 'pp'
|
||||
require 'vmfloaty/auth'
|
||||
require 'vmfloaty/pooler'
|
||||
require 'vmfloaty/version'
|
||||
|
|
@ -58,7 +59,7 @@ class Vmfloaty
|
|||
|
||||
unless os_types.nil?
|
||||
response = Pooler.retrieve(verbose, os_types, token, url)
|
||||
puts response
|
||||
Format.get_hosts(response)
|
||||
else
|
||||
puts 'You did not provide an OS to get'
|
||||
end
|
||||
|
|
@ -94,8 +95,8 @@ class Vmfloaty
|
|||
url = options.url ||= config['url']
|
||||
hostname = args[0]
|
||||
|
||||
query = Pooler.query(verbose, url, hostname)
|
||||
puts query
|
||||
query_req = Pooler.query(verbose, url, hostname)
|
||||
pp query_req
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -117,8 +118,10 @@ class Vmfloaty
|
|||
tags = JSON.parse(options.tags) if options.tags
|
||||
token = options.token || config['token']
|
||||
|
||||
res_body = Pooler.modify(verbose, url, hostname, token, lifetime, tags)
|
||||
puts res_body
|
||||
modify_req = Pooler.modify(verbose, url, hostname, token, lifetime, tags)
|
||||
if modify_req["ok"]
|
||||
puts "Successfully modified vm #{hostname}."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -154,8 +157,8 @@ class Vmfloaty
|
|||
hostname = args[0]
|
||||
token = options.token ||= config['token']
|
||||
|
||||
res_body = Pooler.snapshot(verbose, url, hostname, token)
|
||||
puts res_body
|
||||
snapshot_req = Pooler.snapshot(verbose, url, hostname, token)
|
||||
pp snapshot_req
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -175,8 +178,8 @@ class Vmfloaty
|
|||
token = options.token || config['token']
|
||||
snapshot_sha = options.snapshot
|
||||
|
||||
res_body = Pooler.revert(verbose, url, hostname, token, snapshot_sha)
|
||||
puts res_body
|
||||
revert_req = Pooler.revert(verbose, url, hostname, token, snapshot_sha)
|
||||
pp revert_req
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -192,7 +195,7 @@ class Vmfloaty
|
|||
url = options.url ||= config['url']
|
||||
|
||||
status = Pooler.status(verbose, url)
|
||||
puts status
|
||||
pp status
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -208,7 +211,7 @@ class Vmfloaty
|
|||
url = options.url ||= config['url']
|
||||
|
||||
summary = Pooler.summary(verbose, url)
|
||||
puts summary
|
||||
pp summary
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,5 +3,13 @@ class Format
|
|||
# TODO: Takes the json response body from an HTTP GET
|
||||
# request and "pretty prints" it
|
||||
def self.get_hosts(hostname_hash)
|
||||
host_hash = {}
|
||||
|
||||
hostname_hash.delete("ok")
|
||||
hostname_hash.each do |type, hosts|
|
||||
host_hash[type] = hosts["hostname"]
|
||||
end
|
||||
|
||||
puts host_hash.to_json
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -41,7 +41,13 @@ class Pooler
|
|||
response = conn.post "/vm/#{os_string}"
|
||||
|
||||
res_body = JSON.parse(response.body)
|
||||
res_body
|
||||
if res_body["ok"]
|
||||
res_body
|
||||
else
|
||||
STDERR.puts "There was a problem with your request"
|
||||
STDERR.puts res_body
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
def self.modify(verbose, url, hostname, token, lifetime, tags)
|
||||
|
|
@ -127,7 +133,7 @@ class Pooler
|
|||
conn = Http.get_conn(verbose, url)
|
||||
conn.headers['X-AUTH-TOKEN'] = token
|
||||
|
||||
response = conn.post "/vm/#{hostname}/snapshot/#{snapshot}"
|
||||
response = conn.post "/vm/#{hostname}/snapshot/#{snapshot_sha}"
|
||||
res_body = JSON.parse(response.body)
|
||||
res_body
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
class Version
|
||||
@version = '0.2.7'
|
||||
@version = '0.2.10'
|
||||
|
||||
def self.get
|
||||
@version
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue