woensdag 28 september 2016

Setting dell 11g power management profile from cli

We want to lower our power usage because of cost reasons and respect for the environment. The company I work for has enough machines to render doing this change manually not a good idea. It would mean scheduling downtime for the machine in the monitoring, draining it of traffic in the loadbalancer, rebooting it, waiting for the POST screen to enter the bios, change the setting, exit, reboot again, and give the machine traffic again. Lots of steps, error prone, not fun work at all.
Luckily Dell has the 'iDrac' that allows us to manage server settings such as this. Unfortunately the iDrac interface only supports changing BIOS settings since iDrac 7 (http://en.community.dell.com/techcenter/b/techcenter/archive/2013/01/04/idrac7-now-support-configuring-server-idrac-bios-perc-and-nic-using-xml-file-and-racadm).

We have a bunch of 12g and 13g servers, but most of them are 11g (iDrac 6) so using racadm to change the BIOS would be only a partial solution.

But there is also the lifecycle controller. This can be used to achieve the same result, but also for the 11th generation servers. Here I show how to do it for an m610 (but all dell's should be equal in this area):

git clone https://github.com/dell/recite.git
cd recite
python recite.py IP=root@<host.domain.tld>
then enter your iDrac password. Or if you want to script this, you could use
python recite.py IP=root:password@<host.domain.tld>

That will put you into recite's command mode. To get the current value of the power management setting you do this:

--> GetBIOSEnumeration InstanceID=BIOS.Setup.1-1:PowerMgmt
Wed Sep 28 11:59:36 2016: GetBIOSEnumeration InstanceID=BIOS.Setup.1-1:PowerMgmt
wsman get "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_BIOSEnumeration?InstanceID=BIOS.Setup.1-1:PowerMgmt" -h xxxxx.xxx.xxx -P 443 -u root -p ****** -V -v -c dummy.cert -j utf-8 -y basic

DCIM_BIOSEnumeration

  AttributeName = PowerMgmt
  CurrentValue = MaxPerf
  DefaultValue
  FQDD = BIOS.Setup.1-1
  InstanceID = BIOS.Setup.1-1:PowerMgmt
  IsReadOnly = false
  PendingValue
  PossibleValues = OsCtrl
  PossibleValues = ActivePwrCtrl
  PossibleValues = Custom
  PossibleValues = MaxPerf

--> 


Then to change the setting, do this:

--> SetBIOSAttribute Target=BIOS.Setup.1-1 AttributeName=PowerMgmt AttributeValue=OsCtrl
Wed Sep 28 12:37:04 2016: SetBIOSAttribute Target=BIOS.Setup.1-1 AttributeName=PowerMgmt AttributeValue=OsCtrl
wsman invoke -a SetAttribute "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_BIOSService?SystemCreationClassName=DCIM_ComputerSystem,CreationClassName=DCIM_BIOSService,SystemName=DCIM:ComputerSystem,Name=DCIM:BIOSService" -k "AttributeName=PowerMgmt" -k "AttributeValue=OsCtrl" -k "Target=BIOS.Setup.1-1" -h xxxxx.xxx.xxx -P 443 -u root -p ****** -V -v -c dummy.cert -j utf-8 -y basic

SetAttribute_OUTPUT

  Message = The command was successful
  MessageID = BIOS001
  RebootRequired = Yes
  ReturnValue = 0
  SetResult = Set PendingValue

--> 


This will have changed the value, but it's *not applied yet*. It's 'pending'. For this a reboot is needed. You can trigger such a reboot through your orchestration tool (like Mcollective, pssh, etc), through IPMI and it should then apply the change (see below). But it can also be done through the lifecycle controller. To do this, a reboot job needs to be created:
--> CreateBIOSConfigJob Target=BIOS.Setup.1-1 ScheduledStartTime=TIME_NOW RebootJobType=1
Wed Sep 28 14:54:53 2016: CreateBIOSConfigJob Target=BIOS.Setup.1-1 ScheduledStartTime=TIME_NOW RebootJobType=1
wsman invoke -a CreateTargetedConfigJob "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_BIOSService?SystemCreationClassName=DCIM_ComputerSystem,CreationClassName=DCIM_BIOSService,SystemName=DCIM:ComputerSystem,Name=DCIM:BIOSService" -k "RebootJobType=1" -k "ScheduledStartTime=TIME_NOW" -k "Target=BIOS.Setup.1-1" -h xxxxx.xxx.xxx -P 443 -u root -p ****** -V -v -c dummy.cert -j utf-8 -y basic

CreateTargetedConfigJob_OUTPUT

  ReturnValue = 4096
  Job
    EndpointReference
      Address = https://127.0.0.1:443/wsman
      ReferenceParameters
        ResourceURI = http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_LifecycleJob
        SelectorSet
          __cimnamespace = root/dcim
          InstanceID = JID_001475067508

-->


If all is well, the machine will reboot within a few seconds. Sometimes all is not well (jobs stuck in the queue, bugs, etc) and it may take a (long) while fore the LC actually picks up and executes the job. You'll be better off taking matters into your own (scripted) hands.
If you have the iDrac console open you'll see the server boot into the USC (the lifecyclecontroller interface), update the setting (it says it can take up to 10 minutes !!) and reboot again. Be patient.
After the reboot, you can check whether the value was correctly changed (not during the POST, this value is only updated once the OS is booting or has booted fully):

--> GetBIOSEnumeration InstanceID=BIOS.Setup.1-1:PowerMgmt
Wed Sep 28 15:10:10 2016: GetBIOSEnumeration InstanceID=BIOS.Setup.1-1:PowerMgmt
wsman get "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_BIOSEnumeration?InstanceID=BIOS.Setup.1-1:PowerMgmt" -h xxxxx.xxx.xxx -P 443 -u root -p ****** -V -v -c dummy.cert -j utf-8 -y basic

DCIM_BIOSEnumeration
  AttributeName = PowerMgmt
  Caption
  CurrentValue = OsCtrl
  DefaultValue
  Description
  ElementName
  FQDD = BIOS.Setup.1-1
  InstanceID = BIOS.Setup.1-1:PowerMgmt
  IsOrderedList
  IsReadOnly = FALSE
  PendingValue
  PossibleValues = MaxPerf
  PossibleValues = Custom
  PossibleValues = ActivePwrCtrl
  PossibleValues = OsCtrl

-->