Class: Trollop::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/rbvmomi/trollop.rb

Overview

Convenience methods for Trollop, Ruby's premier option parser.

See the examples directory for sample code. Descriptions are of the form:

<key>: <options> <environment variable> (<default>)

Instance Method Summary collapse

Instance Method Details

#rbvmomi_computer_optObject

Select a compute resource

computer: -R --computer RBVMOMI_COMPUTER


58
59
60
# File 'lib/rbvmomi/trollop.rb', line 58

def rbvmomi_computer_opt
  opt :computer, "Compute resource", :type => :string, :short => "R", :default => (ENV['RBVMOMI_COMPUTER']||'ha-compute-res')
end

#rbvmomi_connection_optsObject

Options used by VIM.connect

host: -o --host RBVMOMI_HOST
port: --port RBVMOMI_PORT (443)
no-ssl: --no-ssl RBVMOMI_SSL (false)
insecure: -k --insecure RBVMOMI_INSECURE (false)
user: -u --user RBVMOMI_USER (root)
password: -p --password RBVMOMI_PASSWORD ()
path: --path RBVMOMI_PATH (/sdk)
debug: -d --debug RBVMOMI_DEBUG (false)


27
28
29
30
31
32
33
34
35
36
# File 'lib/rbvmomi/trollop.rb', line 27

def rbvmomi_connection_opts
  opt :host, "host", :type => :string, :short => 'o', :default => ENV['RBVMOMI_HOST']
  opt :port, "port", :type => :int, :short => :none, :default => (ENV.member?('RBVMOMI_PORT') ? ENV['RBVMOMI_PORT'].to_i : 443)
  opt :"no-ssl", "don't use ssl", :short => :none, :default => (ENV['RBVMOMI_SSL'] == '0')
  opt :insecure, "don't verify ssl certificate", :short => 'k', :default => (ENV['RBVMOMI_INSECURE'] == '1')
  opt :user, "username", :short => 'u', :default => (ENV['RBVMOMI_USER'] || 'root')
  opt :password, "password", :short => 'p', :default => (ENV['RBVMOMI_PASSWORD'] || '')
  opt :path, "SOAP endpoint path", :short => :none, :default => (ENV['RBVMOMI_PATH'] || '/sdk')
  opt :debug, "Log SOAP messages", :short => 'd', :default => (ENV['RBVMOMI_DEBUG'] || false)
end

#rbvmomi_datacenter_optObject

Select a datacenter

datacenter: -D --datacenter RBVMOMI_DATACENTER (ha-datacenter)


42
43
44
# File 'lib/rbvmomi/trollop.rb', line 42

def rbvmomi_datacenter_opt
  opt :datacenter, "datacenter", :type => :string, :short => "D", :default => (ENV['RBVMOMI_DATACENTER'] || 'ha-datacenter')
end

#rbvmomi_datastore_optObject

Select a datastore

datastore: -s --datastore RBVMOMI_DATASTORE (datastore1)


66
67
68
# File 'lib/rbvmomi/trollop.rb', line 66

def rbvmomi_datastore_opt
  opt :datastore, "Datastore", :short => 's', :default => (ENV['RBVMOMI_DATASTORE'] || 'datastore1')
end

#rbvmomi_folder_optObject

Select a folder

folder: -F --folder RBVMOMI_FOLDER ()


50
51
52
# File 'lib/rbvmomi/trollop.rb', line 50

def rbvmomi_folder_opt
  opt :folder, "VM folder", :type => :string, :short => "F", :default => (ENV['RBVMOMI_FOLDER'] || '')
end