Interface #1
Visibility: Public
Change Control: Stable
Synopsis: PBS hook power control module
A new class “pbs.Power” will be made available that will provide power functionality. A hook will be able to access it via python import.
Reference to more detail on the interface. The following define the PMI operations available:
pmi_activate_profile
Activate a given power profile on a set of hosts on behalf of a given job. The parameter “profile_name” is a string containing the name of a profile. The parameter “hosts” is a list containing strings that specify hostnames. The parameter “job” is a PBS job object. If the hosts parameter is not specified, the hosts will be calculated from the job object. If the job parameter is not specified, the pbs.event().job object will be used.
The return type is bool where True indicates success and False indicates the request was made without an indication from the PMI if it was successful or not.
If an error occurs where it is appropriate for some or all of the job vnodes to be marked offline, this may be done before an exception is raised.
If an error occurs where it is appropriate for the supported profile names for some or all of the job vnodes to be refreshed, this may be done before an exception is raised.
pmi_get_usage
Retrieve power usage for a job. The parameter “job” is a PBS job object.
The return will be a float which gives the cumulative energy usage for the job at the time of the call in kilowatt-hours (kWh). If no power usage information is available, None is returned.
pmi_deactivate_profile
Inform the PMI that a job is no longer active. This would be used when a job is suspended or terminated. The parameter “job” is a PBS job object. If it is not specified, the pbs.event().job object will be used.
The return type is bool where True indicates success and False indicates the request was made without an indication from the PMI if it was successful or not.
pmi_query
Return information that matches a request type. The parameter “query_type” is used to specify what should be returned. The only value for query_type is PMI_QUERY_PROFILE, and the return will be a list of strings giving profile names supported by the PMI.
pmi_connect
Connect to the PMI. The parameter “endpoint” defaults to None and is a string which will be meaningful to the PMI. The parameter “port” defaults to None and is an integer. A typical usage would be “endpoint” specifying a hostname and “port” giving a network port for a network service connection.
Currently the connection/disconnection will be done per hook instead of creating a long lasting session.
Nothing is returned, the connection information is maintained in an instantiation of the Power class.
If the endpoint or port parameters are not specified, the underlying code specific to the PMI will determine the connection details.
pmi_disconnect
Disconnect from the PMI. There are no parameters needed since each instance of the Power class is associated to a backend power management interface.
Exceptions
InternalError - returned in cases where the underlying cause of a failure cannot be determined.
BackendError - the backend PMI call was unsuccessful.
Power module initialization
A string can optionally be passed to specify the name of the PMI to be used (see I.1.11). By default, the type of PMI to be used will be determined automatically based on the type of hardware used.
Examples
Activate a profile from a job specific event.
p = pbs.Power() p.pmi_connect(“power_master”) p.pmi_activate_profile(“LOW”) p.pmi_disconnect() |
Get profile name list.
import pbs p = pbs.Power() p.pmi_connect(port=3564) pnames = p.pmi_query(p.PMI_QUERY_PROFILE) p.pmi_disconnect() |
Deactivate profile on a specific job.
import pbs p = pbs.Power() badjob = pbs.server().job(“10”) p.pmi_connect() p.pmi_deactivate_profile(job=badjob) p.pmi_disconnect() |
Use qmgr to set the power_provisioning flag true or false. For example: qmgr -c “set server power_provisioning = true”