Module: Chef::Knife::ESXBase
- Included in:
- EsxTemplateDelete, EsxTemplateImport, EsxTemplateList, EsxVmCreate, EsxVmDelete, EsxVmList
- Defined in:
- lib/chef/knife/esx_base.rb
Class Method Summary collapse
-
.included(includer) ⇒ Object
:nodoc: Would prefer to do this in a rational way, but can’t be done b/c of Mixlib::CLI’s design :(.
Instance Method Summary collapse
Class Method Details
.included(includer) ⇒ Object
:nodoc: Would prefer to do this in a rational way, but can’t be done b/c of Mixlib::CLI’s design :(
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/chef/knife/esx_base.rb', line 28 def self.included(includer) includer.class_eval do deps do require 'net/ssh/multi' require 'esx' require 'readline' require 'chef/json_compat' require 'terminal-table/import' end option :esx_password, :long => "--esx-password PASSWORD", :description => "Your ESX password", :proc => Proc.new { |key| Chef::Config[:knife][:esx_password] = key } option :esx_username, :long => "--esx-username USERNAME", :default => "root", :description => "Your ESX username (default 'root')", :proc => Proc.new { |username| Chef::Config[:knife][:esx_username] = (username || 'root') } option :esx_host, :long => "--esx-host ADDRESS", :description => "Your ESX host address", :default => "127.0.0.1", :proc => Proc.new { |host| Chef::Config[:knife][:esx_host] = host } end end |
Instance Method Details
#connection ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/chef/knife/esx_base.rb', line 58 def connection Chef::Config[:knife][:esx_username] = 'root' if not Chef::Config[:knife][:esx_username] if not @connection ui.info "#{ui.color("Connecting to ESX host #{config[:esx_host]}... ", :magenta)}" @connection = ESX::Host.connect(Chef::Config[:knife][:esx_host], Chef::Config[:knife][:esx_username], Chef::Config[:knife][:esx_password] || '') else @connection end end |
#locate_config_value(key) ⇒ Object
70 71 72 73 |
# File 'lib/chef/knife/esx_base.rb', line 70 def locate_config_value(key) key = key.to_sym Chef::Config[:knife][key] || config[key] end |