def getDiskPoolSpace(rh):
    """
    Obtain disk pool space information for all or a specific disk pool.

    Input:
       Request Handle with the following properties:
          function            - 'GETHOST'
          subfunction         - 'DISKPOOLSPACE'
          parms['poolName']   - Name of the disk pool. Optional,
                                if not present then information for all
                                disk pools is obtained.

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

    rh.printSysLog("Enter getHost.getDiskPoolSpace")

    results = {'overallRC': 0}

    if 'poolName' not in rh.parms:
        poolNames = ["*"]
    else:
        if isinstance(rh.parms['poolName'], list):
            poolNames = rh.parms['poolName']
        else:
            poolNames = [rh.parms['poolName']]

    if results['overallRC'] == 0:
        # Loop thru each pool getting total.  Do it for query 2 & 3
        totals = {}
        for qType in ["2", "3"]:
            parms = [
                "-q", qType,
                "-e", "3",
                "-T", "DUMMY",
                "-n", " ".join(poolNames)]

            results = invokeSMCLI(rh, "Image_Volume_Space_Query_DM", parms)
            if results['overallRC'] == 0:
                for line in results['response'].splitlines():
                    parts = line.split()
                    if len(parts) == 9:
                        poolName = parts[7]
                    else:
                        poolName = parts[4]
                    if poolName not in totals:
                        totals[poolName] = {"2": 0., "3": 0.}

                    if parts[1][:4] == "3390":
                        totals[poolName][qType] += int(parts[3]) * 737280
                    elif parts[1][:4] == "9336":
                        totals[poolName][qType] += int(parts[3]) * 512
            else:
                # SMAPI API failed.
                rh.printLn("ES", results['response'])
                rh.updateResults(results)    # Use results from invokeSMCLI
                break

        if results['overallRC'] == 0:
            if len(totals) == 0:
                # No pool information found.
                msg = msgs.msg['0402'][1] % (modId, " ".join(poolNames))
                rh.printLn("ES", msg)
                rh.updateResults(msgs.msg['0402'][0])
            else:
                # Produce a summary for each pool
                for poolName in sorted(totals):
                    total = totals[poolName]["2"] + totals[poolName]["3"]
                    rh.printLn("N", poolName + " Total: " +
                        generalUtils.cvtToMag(rh, total))
                    rh.printLn("N", poolName + " Used: " +
                        generalUtils.cvtToMag(rh, totals[poolName]["3"]))
                    rh.printLn("N", poolName + " Free: " +
                        generalUtils.cvtToMag(rh, totals[poolName]["2"]))

    rh.printSysLog("Exit getHost.getDiskPoolSpace, rc: " +
        str(rh.results['overallRC']))
    return rh.results['overallRC']
def getDiskPoolSpace ( rh ) : rh . printSysLog ( "Enter getHost.getDiskPoolSpace" ) results = { 'overallRC' : 0 } if 'poolName' not in rh . parms : poolNames = [ "*" ] else : if isinstance ( rh . parms [ 'poolName' ] , list ) : poolNames = rh . parms [ 'poolName' ] else : poolNames = [ rh . parms [ 'poolName' ] ] if results [ 'overallRC' ] == 0 : totals = { } for qType in [ "2" , "3" ] : parms = [ "-q" , qType , "-e" , "3" , "-T" , "DUMMY" , "-n" , " " . join ( poolNames ) ] results = invokeSMCLI ( rh , "Image_Volume_Space_Query_DM" , parms ) if results [ 'overallRC' ] == 0 : for line in results [ 'response' ] . splitlines ( ) : parts = line . split ( ) if len ( parts ) == 9 : poolName = parts [ 7 ] else : poolName = parts [ 4 ] if poolName not in totals : totals [ poolName ] = { "2" : 0. , "3" : 0. } if parts [ 1 ] [ : 4 ] == "3390" : totals [ poolName ] [ qType ] += int ( parts [ 3 ] ) * 737280 elif parts [ 1 ] [ : 4 ] == "9336" : totals [ poolName ] [ qType ] += int ( parts [ 3 ] ) * 512 else : rh . printLn ( "ES" , results [ 'response' ] ) rh . updateResults ( results ) break if results [ 'overallRC' ] == 0 : if len ( totals ) == 0 : msg = msgs . msg [ '0402' ] [ 1 ] % ( modId , " " . join ( poolNames ) ) rh . printLn ( "ES" , msg ) rh . updateResults ( msgs . msg [ '0402' ] [ 0 ] ) else : for poolName in sorted ( totals ) : total = totals [ poolName ] [ "2" ] + totals [ poolName ] [ "3" ] rh . printLn ( "N" , poolName + " Total: " + generalUtils . cvtToMag ( rh , total ) ) rh . printLn ( "N" , poolName + " Used: " + generalUtils . cvtToMag ( rh , totals [ poolName ] [ "3" ] ) ) rh . printLn ( "N" , poolName + " Free: " + generalUtils . cvtToMag ( rh , totals [ poolName ] [ "2" ] ) ) rh . printSysLog ( "Exit getHost.getDiskPoolSpace, rc: " + str ( rh . results [ 'overallRC' ] ) ) return rh . results [ 'overallRC' ]
Obtain disk pool space information for all or a specific disk pool.

    Input:
       Request Handle with the following properties:
          function            - 'GETHOST'
          subfunction         - 'DISKPOOLSPACE'
          parms['poolName']   - Name of the disk pool. Optional,
                                if not present then information for all
                                disk pools is obtained.

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