Exemple #1
0
def parseCmdline(rh):
    """
    Parse the request command input.

    Input:
       Request Handle

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

    rh.printSysLog("Enter getHost.parseCmdline")

    rh.userid = ''

    if rh.totalParms >= 2:
        rh.subfunction = rh.request[1].upper()

    # Verify the subfunction is valid.
    if rh.subfunction not in subfuncHandler:
        # Subfunction is missing.
        subList = ', '.join(sorted(subfuncHandler.keys()))
        msg = msgs.msg['0011'][1] % (modId, subList)
        rh.printLn("ES", msg)
        rh.updateResults(msgs.msg['0011'][0])

    # Parse the rest of the command line.
    if rh.results['overallRC'] == 0:
        rh.argPos = 2               # Begin Parsing at 3rd operand
        generalUtils.parseCmdline(rh, posOpsList, keyOpsList)

    rh.printSysLog("Exit getHost.parseCmdLine, rc: " +
        str(rh.results['overallRC']))
    return rh.results['overallRC']
Exemple #2
0
def parseCmdline(rh):
    """
    Parse the request command input.

    Input:
       Request Handle

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

    rh.printSysLog("Enter makeVM.parseCmdline")

    if rh.totalParms >= 2:
        rh.userid = rh.request[1].upper()
    else:
        # Userid is missing.
        msg = msgs.msg['0010'][1] % modId
        rh.printLn("ES", msg)
        rh.updateResults(msgs.msg['0010'][0])
        rh.printSysLog("Exit makeVM.parseCmdLine, rc: " +
                       rh.results['overallRC'])
        return rh.results['overallRC']

    if rh.totalParms == 2:
        rh.subfunction = rh.userid
        rh.userid = ''

    if rh.totalParms >= 3:
        rh.subfunction = rh.request[2].upper()

    # Verify the subfunction is valid.
    if rh.subfunction not in subfuncHandler:
        # Subfunction is missing.
        subList = ', '.join(sorted(subfuncHandler.keys()))
        msg = msgs.msg['0011'][1] % (modId, subList)
        rh.printLn("ES", msg)
        rh.updateResults(msgs.msg['0011'][0])

    # Parse the rest of the command line.
    if rh.results['overallRC'] == 0:
        rh.argPos = 3  # Begin Parsing at 4th operand
        generalUtils.parseCmdline(rh, posOpsList, keyOpsList)

    if 'byUsers' in rh.parms:
        users = []
        for user in rh.parms['byUsers'].split(' '):
            users.append(user)
        rh.parms['byUsers'] = []
        rh.parms['byUsers'].extend(users)

    if rh.subfunction == 'DIRECTORY' and 'maxMemSize' not in rh.parms:
        rh.parms['maxMemSize'] = rh.parms['priMemSize']

    rh.printSysLog("Exit makeVM.parseCmdLine, rc: " +
                   str(rh.results['overallRC']))
    return rh.results['overallRC']
def parseCmdline(rh):
    """
    Parse the request command input.

    Input:
       Request Handle

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

    rh.printSysLog("Enter changeVM.parseCmdline")

    if rh.totalParms >= 2:
        rh.userid = rh.request[1].upper()
    else:
        # Userid is missing.
        msg = msgs.msg['0010'][1] % modId
        rh.printLn("ES", msg)
        rh.updateResults(msgs.msg['0010'][0])
        rh.printSysLog("Exit changeVM.parseCmdLine, rc: " +
            str(rh.results['overallRC']))
        return rh.results['overallRC']

    if rh.totalParms == 2:
        rh.subfunction = rh.userid
        rh.userid = ''

    if rh.totalParms >= 3:
        rh.subfunction = rh.request[2].upper()

    # Verify the subfunction is valid.
    if rh.subfunction not in subfuncHandler:
        # Subfunction is missing.
        subList = ', '.join(sorted(subfuncHandler.keys()))
        msg = msgs.msg['0011'][1] % (modId, subList)
        rh.printLn("ES", msg)
        rh.updateResults(msgs.msg['0011'][0])

    # Parse the rest of the command line.
    if rh.results['overallRC'] == 0:
        rh.argPos = 3               # Begin Parsing at 4th operand
        generalUtils.parseCmdline(rh, posOpsList, keyOpsList)

    if rh.results['overallRC'] == 0:
        if rh.subfunction in ['ADD3390', 'ADD9336']:
            if ('fileSystem' in rh.parms and rh.parms['fileSystem'] not in
                ['ext2', 'ext3', 'ext4', 'xfs', 'swap']):
                # Invalid file system specified.
                msg = msgs.msg['0015'][1] % (modId, rh.parms['fileSystem'])
                rh.printLn("ES", msg)
                rh.updateResults(msgs.msg['0015'][0])

    rh.printSysLog("Exit changeVM.parseCmdLine, rc: " +
        str(rh.results['overallRC']))
    return rh.results['overallRC']
Exemple #4
0
def parseCmdline(rh):
    """
    Parse the request command input.

    Input:
       Request Handle

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

    rh.printSysLog("Enter powerVM.parseCmdline")

    if rh.totalParms >= 2:
        rh.userid = rh.request[1].upper()
    else:
        # Userid is missing.
        msg = msgs.msg['0010'][1] % modId
        rh.printLn("ES", msg)
        rh.updateResults(msgs.msg['0010'][0])
        rh.printSysLog("Exit powerVM.parseCmdLine, rc: " +
                       rh.results['overallRC'])
        return rh.results['overallRC']

    if rh.totalParms == 2:
        rh.subfunction = rh.userid
        rh.userid = ''

    if rh.totalParms >= 3:
        rh.subfunction = rh.request[2].upper()

    # Verify the subfunction is valid.
    if rh.subfunction not in subfuncHandler:
        # Subfunction is missing.
        subList = ', '.join(sorted(subfuncHandler.keys()))
        msg = msgs.msg['0011'][1] % (modId, subList)
        rh.printLn("ES", msg)
        rh.updateResults(msgs.msg['0011'][0])

    # Parse the rest of the command line.
    if rh.results['overallRC'] == 0:
        rh.argPos = 3  # Begin Parsing at 4th operand
        generalUtils.parseCmdline(rh, posOpsList, keyOpsList)

    waiting = 0
    if rh.results['overallRC'] == 0:
        if rh.subfunction == 'WAIT':
            waiting = 1
            if rh.parms['desiredState'] not in vmOSUpDownStates:
                # Desired state is not: down, off, on or up.
                msg = msgs.msg['0013'][1] % (modId, rh.parms['desiredState'],
                                             ", ".join(vmOSUpDownStates))
                rh.printLn("ES", msg)
                rh.updateResults(msgs.msg['0013'][0])

    if (rh.results['overallRC'] == 0 and 'wait' in rh.parms):
        waiting = 1
        if 'desiredState' not in rh.parms:
            if rh.subfunction in ['ON', 'RESET', 'REBOOT']:
                rh.parms['desiredState'] = 'up'
            else:
                # OFF and SOFTOFF default to 'off'.
                rh.parms['desiredState'] = 'off'

    if rh.results['overallRC'] == 0 and waiting == 1:
        if rh.subfunction == 'ON' or rh.subfunction == 'RESET':
            if ('desiredState' not in rh.parms
                    or rh.parms['desiredState'] not in vmOSUpStates):
                # Desired state is not: on or up.
                msg = msgs.msg['0013'][1] % (modId, rh.parms['desiredState'],
                                             ", ".join(vmOSUpStates))
                rh.printLn("ES", msg)
                rh.updateResults(msgs.msg['0013'][0])

        if rh.results['overallRC'] == 0:
            if 'maxWait' not in rh.parms:
                rh.parms['maxWait'] = 300
            if 'poll' not in rh.parms:
                rh.parms['poll'] = 15
            rh.parms['maxQueries'] = (rh.parms['maxWait'] + rh.parms['poll'] -
                                      1) / rh.parms['poll']
            # If we had to do some rounding, give a warning
            # out to the command line user that the wait
            # won't be what they expected.
            if rh.parms['maxWait'] % rh.parms['poll'] != 0:
                msg = msgs.msg['0017'][1] % (
                    modId, rh.parms['maxWait'], rh.parms['poll'],
                    rh.parms['maxQueries'] * rh.parms['poll'],
                    rh.parms['maxQueries'])
                rh.printLn("W", msg)

    rh.printSysLog("Exit powerVM.parseCmdLine, rc: " +
                   str(rh.results['overallRC']))
    return rh.results['overallRC']