def lagpGlobalSystemPriority(**kwargs):
    """
    Function to configure Global LACP system Priority

    :param deviceObj : Device object
    :type  deviceObj : object
    :param systemPriority  : Identification Default is system MAC address,
                             can be changed for another one
    :type  systemPriority  : string
    :param configure : (Optional -Default is True)
                       True to configure,
                       False to unconfigure
    :type  configure : boolean

    :return: returnStruct Object
    :returnType: object
    """

    # Params
    deviceObj = kwargs.get('deviceObj', None)
    systemPriority = kwargs.get('systemPriority', None)
    configure = kwargs.get('configure', True)

    # Variables
    overallBuffer = []
    data = dict()
    bufferString = ""
    command = ""

    # If Device object is not passed, we need to error out
    if deviceObj is None or systemPriority is None:
        opstestfw.LogOutput(
            'error', "Need to pass switch deviceObj and systemPriority"
            " to this routine")
        returnCls = opstestfw.returnStruct(returnCode=1)
        return returnCls

    # Get into vtysh
    returnStructure = deviceObj.VtyshShell(enter=True)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error', "Failed to get vtysh prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.returnStruct(returnCode=returnCode,
                                           buffer=bufferString)
        return returnCls

    # Get into config context
    returnStructure = deviceObj.ConfigVtyShell(enter=True)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error', "Failed to get vtysh config prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.returnStruct(returnCode=1, buffer=bufferString)
        return returnCls

    # Uconfigure system ID
    if configure is False:
        command = "no "

    # Normal configuration command
    command += ("lacp system-priority " + str(systemPriority))
    returnStructure = deviceObj.DeviceInteract(command=command)
    retCode = returnStructure['returnCode']
    overallBuffer.append(returnStructure['buffer'])
    if retCode != 0:
        opstestfw.LogOutput(
            'error',
            "Failed to configure LACP system priority: " + str(systemPriority))
    else:
        opstestfw.LogOutput(
            'debug', "LACP system priority configured: " + str(systemPriority))

    # Get out of config context
    returnStructure = deviceObj.ConfigVtyShell(enter=False)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error',
                            "Failed to exit configure terminal prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.retStruct(returnCode=returnCode,
                                        buffer=bufferString)
        return returnCls

    # Get out of vtyshell
    returnStructure = deviceObj.VtyshShell(enter=False)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error', "Failed to exit enable prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.retStruct(returnCode=returnCode,
                                        buffer=bufferString)
        return returnCls

    # Return results
    for curLine in overallBuffer:
        bufferString += str(curLine)
    returnCls = opstestfw.returnStruct(returnCode=0,
                                       buffer=bufferString,
                                       data=data)
    return returnCls
def lagpGlobalSystemPriority(**kwargs):

    """
    Function to configure Global LACP system Priority

    :param deviceObj : Device object
    :type  deviceObj : object
    :param systemPriority  : Identification Default is system MAC address,
                             can be changed for another one
    :type  systemPriority  : string
    :param configure : (Optional -Default is True)
                       True to configure,
                       False to unconfigure
    :type  configure : boolean

    :return: returnStruct Object
    :returnType: object
    """

    # Params
    deviceObj = kwargs.get('deviceObj', None)
    systemPriority = kwargs.get('systemPriority', None)
    configure = kwargs.get('configure', True)

    # Variables
    overallBuffer = []
    data = dict()
    bufferString = ""
    command = ""

    # If Device object is not passed, we need to error out
    if deviceObj is None or systemPriority is None:
        opstestfw.LogOutput('error',
                            "Need to pass switch deviceObj and systemPriority"
                            " to this routine")
        returnCls = opstestfw.returnStruct(returnCode=1)
        return returnCls

    # Get into vtysh
    returnStructure = deviceObj.VtyshShell(enter=True)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error', "Failed to get vtysh prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.returnStruct(returnCode=returnCode,
                                           buffer=bufferString)
        return returnCls

    # Get into config context
    returnStructure = deviceObj.ConfigVtyShell(enter=True)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error', "Failed to get vtysh config prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.returnStruct(returnCode=1,
                                           buffer=bufferString)
        return returnCls

    # Uconfigure system ID
    if configure is False:
        command = "no "

    # Normal configuration command
    command += ("lacp system-priority " + str(systemPriority))
    returnStructure = deviceObj.DeviceInteract(command=command)
    retCode = returnStructure['returnCode']
    overallBuffer.append(returnStructure['buffer'])
    if retCode != 0:
        opstestfw.LogOutput('error',
                            "Failed to configure LACP system priority: "
                            + str(systemPriority))
    else:
        opstestfw.LogOutput('debug',
                            "LACP system priority configured: "
                            + str(systemPriority))

    # Get out of config context
    returnStructure = deviceObj.ConfigVtyShell(enter=False)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error',
                            "Failed to exit configure terminal prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.retStruct(returnCode=returnCode,
                                        buffer=bufferString)
        return returnCls

    # Get out of vtyshell
    returnStructure = deviceObj.VtyshShell(enter=False)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error', "Failed to exit enable prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.retStruct(returnCode=returnCode,
                                        buffer=bufferString)
        return returnCls

    # Return results
    for curLine in overallBuffer:
        bufferString += str(curLine)
    returnCls = opstestfw.returnStruct(returnCode=0, buffer=bufferString,
                                       data=data)
    return returnCls
def lagpGlobalSystemShow(**kwargs):
    """
    Function to extract Global LACP configuration

    :param deviceObj : Device object
    :type  deviceObj : object

    :return: returnStruct Object
         data    dictionary with the following keys/values
                 System-id = <int>
                 System-priority = <int> [0-65534]
    :returnType: object
    """

    # Params
    deviceObj = kwargs.get('deviceObj', None)

    # Variables
    overallBuffer = []
    data = dict()
    bufferString = ""
    command = ""

    # Dictionary initialization
    data['System-id'] = ""
    data['System-priority'] = 0

    # If Device object is not passed, we need to error out
    if deviceObj is None:
        opstestfw.LogOutput('error',
                            "Need to pass switch deviceObj to this routine")
        returnCls = opstestfw.returnStruct(returnCode=1)
        return returnCls

    # Get into vtysh
    returnStructure = deviceObj.VtyshShell(enter=True)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error', "Failed to get vtysh prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.returnStruct(returnCode=returnCode,
                                           buffer=bufferString)
        return returnCls

    # Show command
    command += ("show lacp configuration")
    returnStructure = deviceObj.DeviceInteract(command=command)
    retCode = returnStructure['returnCode']
    overallBuffer.append(returnStructure['buffer'])
    if retCode != 0:
        opstestfw.LogOutput('error',
                            "Failed to execute LACP configuration show")
    else:
        opstestfw.LogOutput('debug', "LACP configuration show succeeded")

    # Get out of vtyshell
    returnStructure = deviceObj.VtyshShell(enter=False)
    returnCode = returnStructure.returnCode()
    overallBuffer.append(returnStructure.buffer())
    if returnCode != 0:
        opstestfw.LogOutput('error', "Failed to exit enable prompt")
        bufferString = ""
        for curLine in overallBuffer:
            bufferString += str(curLine)
        returnCls = opstestfw.retStruct(returnCode=returnCode,
                                        buffer=bufferString)
        return returnCls

    # Return results
    for curLine in overallBuffer:
        bufferString += str(curLine)

    # Fill dictionary out
    for curLine in bufferString.split('\r\n'):
        print curLine
        showLine1 = re.match(
            r'System-id\s*:\s*(([A-Za-z0-9]{2}:?){6})', curLine)
        if showLine1:
            data['System-id'] = showLine1.group(1)
            continue

        showLine2 = re.match(r'System-priority \s*:\s*(\d+)', curLine)
        if showLine2:
            data['System-priority'] = int(showLine2.group(1))
            continue

    returnCls = opstestfw.returnStruct(returnCode=0, buffer=bufferString,
                                       data=data)
    return returnCls