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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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 } option :free_license, :long => "--free-license", :description => "If your Hypervisor have a free license", :boolean => true, :default => false option :insecure, :long => "--insecure", :description => "Insecure connection", :boolean => true, :default => true option :esx_templates_dir, :long => "--esx-templates-dir TEMPLATES_DIRECTORY", :description => "Your ESX Templates directory", :default => "", :proc => Proc.new { |templates_dir| Chef::Config[:knife][:esx_templates_dir] = templates_dir } end end |
Instance Method Details
#connection ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/chef/knife/esx_base.rb', line 76 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] || '', config[:insecure], {:templates_dir => Chef::Config[:knife][:esx_templates_dir], :free_license=>config[:free_license]}) else @connection end end |
#locate_config_value(key) ⇒ Object
90 91 92 93 |
# File 'lib/chef/knife/esx_base.rb', line 90 def locate_config_value(key) key = key.to_sym Chef::Config[:knife][key] || config[key] end |