Remove host options and use argument instead

This commit is contained in:
Brian Cain 2015-09-17 21:05:09 -07:00
parent 279a0d98ce
commit 40fd138214

View file

@ -16,22 +16,21 @@ class Vmfloaty
config = read_config
command :get do |c|
c.syntax = 'floaty get [options]'
c.syntax = 'floaty get [hostname,...]'
c.summary = 'Gets a vm or vms based on the os flag'
c.description = ''
c.example 'Gets 3 vms', 'floaty get --user brian --url http://vmpooler.example.com --os centos,centos,debian'
c.example 'Gets 3 vms', 'floaty get centos,centos,debian --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'
c.option '--token STRING', String, 'Token for vmpooler'
c.option '--os STRING', String, 'Operating systems to retrieve'
c.option '--notoken', 'Makes a request without a token'
c.action do |args, options|
verbose = options.verbose || config['verbose']
token = options.token || config['token']
user = options.user ||= config['user']
url = options.url ||= config['url']
os_types = options.os
os_types = args[0]
no_token = options.notoken
unless no_token.nil?
@ -55,16 +54,15 @@ class Vmfloaty
end
command :list do |c|
c.syntax = 'floaty list [options]'
c.syntax = 'floaty list [hostname]'
c.summary = 'Shows a list of available vms from the pooler'
c.description = ''
c.example 'Filter the list on centos', 'floaty list --filter centos --url http://vmpooler.example.com'
c.example 'Filter the list on centos', 'floaty list centos --url http://vmpooler.example.com'
c.option '--verbose', 'Enables verbose output'
c.option '--filter STRING', String, 'A filter to apply to the list'
c.option '--url STRING', String, 'URL of vmpooler'
c.action do |args, options|
verbose = options.verbose || config['verbose']
filter = options.filter
filter = args[0]
url = options.url ||= config['url']
os_list = Pooler.list(verbose, url, filter)
@ -76,14 +74,13 @@ class Vmfloaty
c.syntax = 'floaty query [options]'
c.summary = 'Get information about a given vm'
c.description = ''
c.example 'Get information about a sample host', 'floaty query --url http://vmpooler.example.com --host myvmhost.example.com'
c.example 'Get information about a sample host', 'floaty query hostname --url http://vmpooler.example.com'
c.option '--verbose', 'Enables verbose output'
c.option '--url STRING', String, 'URL of vmpooler'
c.option '--host STRING', String, 'Hostname to query'
c.action do |args, options|
verbose = options.verbose || config['verbose']
url = options.url ||= config['url']
hostname = options.host
hostname = args[0]
query = Pooler.query(verbose, url, hostname)
puts query
@ -91,20 +88,19 @@ class Vmfloaty
end
command :modify do |c|
c.syntax = 'floaty modify [options]'
c.syntax = 'floaty modify [hostname]'
c.summary = 'Modify a vms tags and TTL'
c.description = ''
c.example 'description', 'command example'
c.option '--verbose', 'Enables verbose output'
c.option '--url STRING', String, 'URL of vmpooler'
c.option '--token STRING', String, 'Token for vmpooler'
c.option '--host STRING', String, 'Hostname to modify'
c.option '--lifetime INT', Integer, 'VM TTL (Integer, in hours)'
c.option '--tags HASH', Hash, 'free-form VM tagging'
c.action do |args, options|
verbose = options.verbose || config['verbose']
url = options.url ||= config['url']
hostname = options.host
hostname = args[0]
lifetime = options.lifetime
tags = options.tags
token = options.token || config['token']
@ -115,16 +111,15 @@ class Vmfloaty
end
command :delete do |c|
c.syntax = 'floaty delete [options]'
c.syntax = 'floaty delete [hostname,...]'
c.summary = 'Schedules the deletion of a host or hosts'
c.description = ''
c.example 'Schedules the deletion of a host or hosts', 'floaty delete --hosts myhost1,myhost2 --url http://vmpooler.example.com'
c.example 'Schedules the deletion of a host or hosts', 'floaty delete myhost1,myhost2 --url http://vmpooler.example.com'
c.option '--verbose', 'Enables verbose output'
c.option '--hosts STRING', String, 'Hostname(s) to delete'
c.option '--url STRING', String, 'URL of vmpooler'
c.action do |args, options|
verbose = options.verbose || config['verbose']
hosts = options.hosts
hosts = args[0]
url = options.url ||= config['url']
Pooler.delete(verbose, url, hosts)
@ -135,15 +130,14 @@ class Vmfloaty
c.syntax = 'floaty snapshot [options]'
c.summary = 'Takes a snapshot of a given vm'
c.description = ''
c.example 'Takes a snapshot for a given host', 'floaty snapshot --url http://vmpooler.example.com --host myvm.example.com --token a9znth9dn01t416hrguu56ze37t790bl'
c.example 'Takes a snapshot for a given host', 'floaty snapshot myvm.example.com --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl'
c.option '--verbose', 'Enables verbose output'
c.option '--url STRING', String, 'URL of vmpooler'
c.option '--host STRING', String, 'Hostname to modify'
c.option '--token STRING', String, 'Token for vmpooler'
c.action do |args, options|
verbose = options.verbose || config['verbose']
url = options.url ||= config['url']
hostname = options.host
hostname = args[0]
token = options.token ||= config['token']
res_body = Pooler.snapshot(verbose, url, hostname, token)
@ -155,16 +149,15 @@ class Vmfloaty
c.syntax = 'floaty revert [options]'
c.summary = 'Reverts a vm to a specified snapshot'
c.description = ''
c.example 'Reverts to a snapshot for a given host', 'floaty revert --url http://vmpooler.example.com --host myvm.example.com --token a9znth9dn01t416hrguu56ze37t790bl --snapshot n4eb4kdtp7rwv4x158366vd9jhac8btq'
c.example 'Reverts to a snapshot for a given host', 'floaty revert myvm.example.com --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl --snapshot n4eb4kdtp7rwv4x158366vd9jhac8btq'
c.option '--verbose', 'Enables verbose output'
c.option '--url STRING', String, 'URL of vmpooler'
c.option '--host STRING', String, 'Hostname to modify'
c.option '--token STRING', String, 'Token for vmpooler'
c.option '--snapshot STRING', String, 'SHA of snapshot'
c.action do |args, options|
verbose = options.verbose || config['verbose']
url = options.url ||= config['url']
hostname = options.host
hostname = args[0]
token = options.token || config['token']
snapshot_sha = options.snapshot