Module: Chef::Knife::UCSBase
- Included in:
- UcsBladesList, UcsCpusList, UcsFirmwareList, UcsOrgCreate, UcsOrgDelete, UcsOrgsList, UcsPolicyCreate, UcsPolicyDelete, UcsPolicyUpdate, UcsPoolCreate, UcsPoolDelete, UcsPoolList, UcsServiceProfileCreate, UcsServiceProfileDelete, UcsServiceprofilesList, UcsSet, UcsTemplateCreate, UcsTemplateDelete, UcsVlanCreate, UcsVlanDelete, UcsVlansList, UcsVsansList
- Defined in:
- lib/chef/knife/ucs_base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
- #destroyer ⇒ Object
-
#inventory ⇒ Object
Intialize objects.
- #locate_config_value(key) ⇒ Object
- #manager ⇒ Object
- #msg_pair(label, value, color = :cyan) ⇒ Object
- #provisioner ⇒ Object
Class Method Details
.included(includer) ⇒ Object
27 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 |
# File 'lib/chef/knife/ucs_base.rb', line 27 def self.included(includer) includer.class_eval do deps do require 'readline' require 'chef/json_compat' end option :ucsm_username, :short => "-U USERNAME", :long => "--cisco-ucsm-username USERNAME", :description => "Your Cisco UCS Manager Username", :proc => Proc.new { |key| Chef::Config[:knife][:ucsm_username] = key } option :ucsm_password, :short => "-P PASSWORD", :long => "--cisco-ucsm-password PASSWORD", :description => "Your Cisco UCS Manager password", :proc => Proc.new { |key| Chef::Config[:knife][:ucsm_password] = key } option :ucsm_host, :short => "-H HOST", :long => "--cisco-ucsm-host HOST", :description => "Your Cisco UCS Manager FI name or IP address", :proc => Proc.new { |endpoint| Chef::Config[:knife][:ucsm_host] = endpoint } end end |
Instance Method Details
#connection ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chef/knife/ucs_base.rb', line 57 def connection ucs_session = UCSToken.new Chef::Log.debug("username: #{Chef::Config[:knife][:ucsm_username]}") Chef::Log.debug("password: #{Chef::Config[:knife][:ucsm_password]}") Chef::Log.debug("host: #{Chef::Config[:knife][:ucsm_host]}") @connection ||= begin connection = ucs_session.get_token({ :username => Chef::Config[:knife][:ucsm_username], :password => Chef::Config[:knife][:ucsm_password], :ip => Chef::Config[:knife][:ucsm_host] }.to_json) end end |
#destroyer ⇒ Object
92 93 94 95 96 |
# File 'lib/chef/knife/ucs_base.rb', line 92 def destroyer @destroyer ||= begin destroyer = UCSDestroy.new(connection) end end |
#inventory ⇒ Object
Intialize objects
72 73 74 75 76 77 |
# File 'lib/chef/knife/ucs_base.rb', line 72 def inventory ucs_inventory = UCSInventory.new @inventory ||= begin inventory = ucs_inventory.discover(connection) end end |
#locate_config_value(key) ⇒ Object
98 99 100 101 |
# File 'lib/chef/knife/ucs_base.rb', line 98 def locate_config_value(key) key = key.to_sym Chef::Config[:knife][key] || config[key] end |
#manager ⇒ Object
85 86 87 88 89 90 |
# File 'lib/chef/knife/ucs_base.rb', line 85 def manager ucs_manager = UCSManage.new(connection) @manager ||= begin manager = ucs_manager.discover_state end end |
#msg_pair(label, value, color = :cyan) ⇒ Object
103 104 105 106 107 |
# File 'lib/chef/knife/ucs_base.rb', line 103 def msg_pair(label, value, color=:cyan) if value && !value.to_s.empty? puts "#{ui.color(label, color)}: #{value}" end end |
#provisioner ⇒ Object
79 80 81 82 83 |
# File 'lib/chef/knife/ucs_base.rb', line 79 def provisioner @provisioner ||= begin provisioner = UCSProvision.new(connection) end end |