Class: Chef::Knife::UcsPolicyUpdate

Inherits:
Chef::Knife show all
Includes:
UCSBase
Defined in:
lib/chef/knife/ucs_policy_update.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UCSBase

#connection, #destroyer, included, #inventory, #locate_config_value, #manager, #msg_pair, #provisioner

Instance Attribute Details

#initial_sleep_delayObject

Returns the value of attribute initial_sleep_delay.



36
37
38
# File 'lib/chef/knife/ucs_policy_update.rb', line 36

def initial_sleep_delay
  @initial_sleep_delay
end

Instance Method Details

#runObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/chef/knife/ucs_policy_update.rb', line 74

def run
  $stdout.sync = true
  
  policy = "#{Chef::Config[:knife][:policy]}".downcase
  case policy
  when 'host-firmware'
  
    json = { :host_firmware_pkg_name => Chef::Config[:knife][:name], :hardware_model => Chef::Config[:knife][:hardwaremodel].to_s,
             :hardware_type => Chef::Config[:knife][:hardwaretype].to_s,  :hardware_vendor => Chef::Config[:knife][:hardwarevendor].to_s, 
             :firmware_version => Chef::Config[:knife][:firmwareversion].to_s, :org => Chef::Config[:knife][:org] }.to_json
    

    xml_response = updater.update_host_firmware_package(json)
    xml_doc = Nokogiri::XML(xml_response)
    
    xml_doc.xpath("configConfMos/outConfigs/pair/firmwareComputeHostPack").each do |hostfw|
      puts ''
      puts "Host Firmware Pack: #{ui.color("#{hostfw.attributes['name']}", :blue)}" + 
            " status: #{ui.color("#{hostfw.attributes['status']}", :green)}"
    end
    
    xml_doc.xpath("configConfMos").each do |hostfw|
       puts "#{hostfw.attributes['errorCode']} #{ui.color("#{hostfw.attributes['errorDescr']}", :red)}"
    end
    
  else
    puts "Incorrect options. Please make sure you are using one of the following: host-firmware, mgmt-firmware"
  end     
  
end