core/rails/app/models/barclamp_bios/configure.rb
# Configure the BIOS settings we care about.
# @param nr [NodeRole] The noderole that we are acting on behalf of.
# @param data [Hash] The merged attrib data that we should use for configuration.
Configure the BIOS settings we care about.
Configure the BIOS settings we care about .
def do_transition(nr,data)
    unless Attrib.get("enable-bios-subsystem",nr.node)
      update_log(nr, "BIOS subsystem is not enabled. Skipping this function.")
      update_log(nr, "Set enable-bios-subsystem to true and rerun role to start BIOS processing.")
      return true
    end
    cfg_target = Attrib.get('bios-configuration',data)
    configs = Attrib.get('bios-config-sets',data)
    applied_configs = []
    final_config = {}
    cfg_target.each do |cfg_name|
      get_config_or_panic(cfg_name, configs, applied_configs, final_config, nr)
    end
    settings = @driver.settings
    missing_settings = final_config.keys - settings.keys
    unconfigured_settings = settings.keys - final_config.keys
    final_config.select! do |k,v|
      if settings.has_key?(k)
        update_log(nr, "BIOS: #{k}: Have #{settings[k].current_value}, want #{v}")
        settings[k].current_value != v
      else
        missing_settings << k
        false
      end
    end
    unless missing_settings.empty?
      update_log(nr, "BIOS does not support these settings:")
      missing_settings.each do |v|
        update_log(nr, "    #{v}")
      end
    end
    unless unconfigured_settings.empty?
      update_log(nr, "BIOS has settings we will not configure:")
      unconfigured_settings.each do |v|
        update_log(nr, "    #{v}")
      end
    end
    unless missing_settings.empty? && unconfigured_settings.empty?
      update_log(nr, "You may want to generate a more accurate BIOS profile for this system")
    end
    if final_config.empty?
      update_log(nr, "BIOS already configured for #{cfg_target}")
      return true
    end
    final_config.each do |k,v|
      update_log(nr, "Setting BIOS setting #{k} to #{v}")
      @driver[k] = v
    end
    update_log(nr, "Committing changes")
    if @driver.commit
      update_log(nr, "Marking node dead.")
      nr.node.alive = false
      nr.node.save!
    end
    true
  end
def do_transition ( nr , data ) unless Attrib . get ( "enable-bios-subsystem" , nr . node ) update_log ( nr , "BIOS subsystem is not enabled. Skipping this function." ) update_log ( nr , "Set enable-bios-subsystem to true and rerun role to start BIOS processing." ) return true end cfg_target = Attrib . get ( 'bios-configuration' , data ) configs = Attrib . get ( 'bios-config-sets' , data ) applied_configs = [ ] final_config = { } cfg_target . each do | cfg_name | get_config_or_panic ( cfg_name , configs , applied_configs , final_config , nr ) end settings = @driver . settings missing_settings = final_config . keys - settings . keys unconfigured_settings = settings . keys - final_config . keys final_config . select! do | k , v | if settings . has_key? ( k ) update_log ( nr , "BIOS: #{k}: Have #{settings[k].current_value}, want #{v}" ) settings [ k ] . current_value != v else missing_settings << k false end end unless missing_settings . empty? update_log ( nr , "BIOS does not support these settings:" ) missing_settings . each do | v | update_log ( nr , "    #{v}" ) end end unless unconfigured_settings . empty? update_log ( nr , "BIOS has settings we will not configure:" ) unconfigured_settings . each do | v | update_log ( nr , "    #{v}" ) end end unless missing_settings . empty? && unconfigured_settings . empty? update_log ( nr , "You may want to generate a more accurate BIOS profile for this system" ) end if final_config . empty? update_log ( nr , "BIOS already configured for #{cfg_target}" ) return true end final_config . each do | k , v | update_log ( nr , "Setting BIOS setting #{k} to #{v}" ) @driver [ k ] = v end update_log ( nr , "Committing changes" ) if @driver . commit update_log ( nr , "Marking node dead." ) nr . node . alive = false nr . node . save! end true end
Configure the BIOS settings we care about.
Configure the BIOS settings we care about .
# Throw out irrelavent settings or settings that do not need to change. # If missing_settings is not empty, then the config we selected wants to set # keys that the current system does not support. # If we threw away everything, we have nothing to do. # Propose our new settings # The node is rebooting, so mark it as not alive.
nr
The noderole that we are acting on behalf of.
The noderole that we are acting on behalf of .
data
The merged attrib data that we should use for configuration.
The merged attrib data that we should use for configuration .