def deactivate(rh):
    """
    Deactivate a virtual machine.

    Input:
       Request Handle with the following properties:
          function    - 'POWERVM'
          subfunction - 'OFF'
          userid      - userid of the virtual machine
          parms['maxQueries']     - Maximum number of queries to issue.
                                    Optional.
          parms['maxWait']        - Maximum time to wait in seconds. Optional,
                                    unless 'maxQueries' is specified.
          parms['poll']           - Polling interval in seconds. Optional,
                                    unless 'maxQueries' is specified.

    Output:
       Request Handle updated with the results.
       Return code - 0: ok, non-zero: error
    """

    rh.printSysLog("Enter powerVM.deactivate, userid: " +
        rh.userid)

    parms = ["-T", rh.userid, "-f", "IMMED"]
    results = invokeSMCLI(rh, "Image_Deactivate", parms)
    if results['overallRC'] == 0:
        pass
    elif (results['overallRC'] == 8 and results['rc'] == 200 and
        (results['rs'] == 12 or results['rs'] == 16)):
        # Tolerable error.  Machine is already in or going into the state
        # we want it to enter.
        rh.printLn("N", rh.userid + ": off")
        rh.updateResults({}, reset=1)
    else:
        # SMAPI API failed.
        rh.printLn("ES", results['response'])
        rh.updateResults(results)    # Use results from invokeSMCLI

    if results['overallRC'] == 0 and 'maxQueries' in rh.parms:
        results = waitForVMState(
            rh,
            rh.userid,
            'off',
            maxQueries=rh.parms['maxQueries'],
            sleepSecs=rh.parms['poll'])
        if results['overallRC'] == 0:
            rh.printLn("N", rh.userid + ": off")
        else:
            rh.updateResults(results)

    rh.printSysLog("Exit powerVM.deactivate, rc: " +
        str(rh.results['overallRC']))
    return rh.results['overallRC']
def deactivate ( rh ) : rh . printSysLog ( "Enter powerVM.deactivate, userid: " + rh . userid ) parms = [ "-T" , rh . userid , "-f" , "IMMED" ] results = invokeSMCLI ( rh , "Image_Deactivate" , parms ) if results [ 'overallRC' ] == 0 : pass elif ( results [ 'overallRC' ] == 8 and results [ 'rc' ] == 200 and ( results [ 'rs' ] == 12 or results [ 'rs' ] == 16 ) ) : rh . printLn ( "N" , rh . userid + ": off" ) rh . updateResults ( { } , reset = 1 ) else : rh . printLn ( "ES" , results [ 'response' ] ) rh . updateResults ( results ) if results [ 'overallRC' ] == 0 and 'maxQueries' in rh . parms : results = waitForVMState ( rh , rh . userid , 'off' , maxQueries = rh . parms [ 'maxQueries' ] , sleepSecs = rh . parms [ 'poll' ] ) if results [ 'overallRC' ] == 0 : rh . printLn ( "N" , rh . userid + ": off" ) else : rh . updateResults ( results ) rh . printSysLog ( "Exit powerVM.deactivate, rc: " + str ( rh . results [ 'overallRC' ] ) ) return rh . results [ 'overallRC' ]
Deactivate a virtual machine.

    Input:
       Request Handle with the following properties:
          function    - 'POWERVM'
          subfunction - 'OFF'
          userid      - userid of the virtual machine
          parms['maxQueries']     - Maximum number of queries to issue.
                                    Optional.
          parms['maxWait']        - Maximum time to wait in seconds. Optional,
                                    unless 'maxQueries' is specified.
          parms['poll']           - Polling interval in seconds. Optional,
                                    unless 'maxQueries' is specified.

    Output:
       Request Handle updated with the results.
       Return code - 0: ok, non-zero: error