Improve how to retrieve vms

This commit changes the get command to have users request vms by
specifying the hosts they want and then the number of hosts rather than
having to say each one separated by a comma.
This commit is contained in:
Brian Cain 2015-10-09 22:06:14 -07:00
parent 12c5fc1cbd
commit 54893cf5fb
5 changed files with 22 additions and 8 deletions

View file

@ -18,10 +18,10 @@ class Vmfloaty
config = Conf.read_config
command :get do |c|
c.syntax = 'floaty get [hostname,...]'
c.syntax = 'floaty get os_type1=x ox_type2=y ...'
c.summary = 'Gets a vm or vms based on the os flag'
c.description = ''
c.example 'Gets 3 vms', 'floaty get centos,centos,debian --user brian --url http://vmpooler.example.com'
c.example 'Gets 3 vms', 'floaty get centos=3 debian=1 --user brian --url http://vmpooler.example.com'
c.option '--verbose', 'Enables verbose output'
c.option '--user STRING', String, 'User to authenticate with'
c.option '--url STRING', String, 'URL of vmpooler'
@ -32,7 +32,13 @@ class Vmfloaty
token = options.token || config['token']
user = options.user ||= config['user']
url = options.url ||= config['url']
os_types = args[0]
os_types = {}
args.each do |arg|
os_arr = arg.split("=")
os_types[os_arr[0]] = os_arr[1].to_i
end
no_token = options.notoken
if no_token

View file

@ -19,13 +19,21 @@ class Pooler
end
def self.retrieve(verbose, os_type, token, url)
os = os_type.gsub(',','+')
conn = Http.get_conn(verbose, url)
if token
conn.headers['X-AUTH-TOKEN'] = token
end
response = conn.post "/vm/#{os}"
os_string = ""
os_type.each do |os,num|
num.times do |i|
os_string << os+"+"
end
end
os_string = os_string.chomp("+")
response = conn.post "/vm/#{os_string}"
res_body = JSON.parse(response.body)
res_body

View file

@ -1,6 +1,6 @@
class Version
@version = '0.2.6'
@version = '0.2.7'
def self.get
@version