mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
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:
parent
12c5fc1cbd
commit
54893cf5fb
5 changed files with 22 additions and 8 deletions
|
|
@ -53,7 +53,7 @@ This command will then ask you to log in. If successful, it will return a token
|
||||||
Grabbing vms:
|
Grabbing vms:
|
||||||
|
|
||||||
```
|
```
|
||||||
floaty get centos-7,debian-7,windows-10 --token mytokenstring --url https://vmpooler.mycompany.net
|
floaty get centos-7-x86_64=2 debian-7-x86_64=1 windows-10=3 --token mytokenstring --url https://vmpooler.mycompany.net
|
||||||
```
|
```
|
||||||
|
|
||||||
### vmfloaty dotfile
|
### vmfloaty dotfile
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ class Vmfloaty
|
||||||
config = Conf.read_config
|
config = Conf.read_config
|
||||||
|
|
||||||
command :get do |c|
|
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.summary = 'Gets a vm or vms based on the os flag'
|
||||||
c.description = ''
|
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 '--verbose', 'Enables verbose output'
|
||||||
c.option '--user STRING', String, 'User to authenticate with'
|
c.option '--user STRING', String, 'User to authenticate with'
|
||||||
c.option '--url STRING', String, 'URL of vmpooler'
|
c.option '--url STRING', String, 'URL of vmpooler'
|
||||||
|
|
@ -32,7 +32,13 @@ class Vmfloaty
|
||||||
token = options.token || config['token']
|
token = options.token || config['token']
|
||||||
user = options.user ||= config['user']
|
user = options.user ||= config['user']
|
||||||
url = options.url ||= config['url']
|
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
|
no_token = options.notoken
|
||||||
|
|
||||||
if no_token
|
if no_token
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,21 @@ class Pooler
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.retrieve(verbose, os_type, token, url)
|
def self.retrieve(verbose, os_type, token, url)
|
||||||
os = os_type.gsub(',','+')
|
|
||||||
conn = Http.get_conn(verbose, url)
|
conn = Http.get_conn(verbose, url)
|
||||||
if token
|
if token
|
||||||
conn.headers['X-AUTH-TOKEN'] = token
|
conn.headers['X-AUTH-TOKEN'] = token
|
||||||
end
|
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 = JSON.parse(response.body)
|
||||||
res_body
|
res_body
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
class Version
|
class Version
|
||||||
@version = '0.2.6'
|
@version = '0.2.7'
|
||||||
|
|
||||||
def self.get
|
def self.get
|
||||||
@version
|
@version
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = 'vmfloaty'
|
s.name = 'vmfloaty'
|
||||||
s.version = '0.2.6'
|
s.version = '0.2.7'
|
||||||
s.authors = ['Brian Cain']
|
s.authors = ['Brian Cain']
|
||||||
s.email = ['brian.cain@puppetlabs.com']
|
s.email = ['brian.cain@puppetlabs.com']
|
||||||
s.license = 'Apache'
|
s.license = 'Apache'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue