Exemplo n.º 1
0
    def Set_Cluster_Core_Frequency_Percent(self, request, context):
        logger.info("running Set_Cluster_Core_Frequency_Percent()")
        errorStr = "OK"
        success = True

        nodeRequest = NodeMessages.SetFrequencyPercentRequest()
        nodeRequest.Frequency = request.Frequency

        try:
            for targetNode in _NodeList:
                with grpc.insecure_channel(targetNode) as channel:
                    rpcStub = NodeRPC.NodeFrequencyManagerServiceStub(channel)
                    response = rpcStub.Set_All_Core_Percent_Frequency(
                        nodeRequest)
                    if False == response.Success:
                        errorStr = "{0} calling Set_AllCore_Frequency_Percent() to node {1}".format(
                            response.Reason, targetNode)
                        logger.error(errorStr)
                        success = False

        except Exception as ex:
            errorStr = "{0} calling Set_AllCore_Frequency_Percent() to node {1}".format(
                ex, targetNode)
            logger.error(errorStr)
            success = False

        fnResponse = ClusterMessages.ServiceResponse()
        fnResponse.Success = success
        fnResponse.Reason = errorStr

        return fnResponse
Exemplo n.º 2
0
    def Get_Node_CPU_Info(self, request, context):
        logger.info("running Get_Node_CPU_Info()")
        fnResponse = ClusterMessages.NodeCPU_Info()

        validTarget = False
        for targetNode in _NodeList:
            if request.Node_ID == targetNode.split(":")[0]:
                validTarget = True
                break

        if False == validTarget:
            fnResponse.Response.Success = False
            fnResponse.Response.Reason = "Node {} is not valid".format(
                request.Node_ID)

            return fnResponse

        errorStr = "OK"
        success = True

        nodeRequest = NodeMessages.CoreNumber()
        nodeRequest.CoreNumber = 0  # just go ask for a core

        try:
            with grpc.insecure_channel(targetNode) as channel:
                rpcStub = NodeRPC.NodeFrequencyManagerServiceStub(channel)
                response = rpcStub.Get_Node_CPU_Info(nodeRequest)
                if False == response.Response.Success:
                    errorStr = "{0} calling Get_Node_CPU_Info() to node {1}".format(
                        response.Response.Reason, targetNode)
                    logger.error(errorStr)
                    success = False
        except Exception as ex:
            errorStr = "{0} calling Get_Node_CPU_Info() to node {1}".format(
                ex, targetNode)
            logger.error(errorStr)
            success = False

        fnResponse.Response.Success = success
        fnResponse.Response.Reason = errorStr

        fnResponse.CoreCount = response.CoreCount
        for gov in response.Supported_Scaling_Governor:
            fnResponse.Supported_Scaling_Governor.append(gov)

        for cState in response.Supported_CState:
            fnResponse.Supported_CState.append(cState)

        return fnResponse
Exemplo n.º 3
0
    def Get_Node_Core_Info(self, request, context):
        logger.info("running Get_Node_Core_Info()")
        fnResponse = ClusterMessages.CoreFrequencyInfo()

        validTarget = False
        for targetNode in _NodeList:
            if request.Node_ID == targetNode.split(":")[0]:
                validTarget = True
                break

        if False == validTarget:
            fnResponse.Response.Success = False
            fnResponse.Response.Reason = "Node {} is not valid".format(
                request.Node_ID)

            return fnResponse

        errorStr = "OK"
        success = True

        nodeRequest = NodeMessages.CoreNumber()
        nodeRequest.CoreNumber = request.CoreNumber

        try:
            with grpc.insecure_channel(targetNode) as channel:
                rpcStub = NodeRPC.NodeFrequencyManagerServiceStub(channel)
                response = rpcStub.Get_Core_Frequency_Info(nodeRequest)
                if False == response.Response.Success:
                    errorStr = "{0} calling Get_Node_Core_Info() to node {1}".format(
                        response.Response.Reason, targetNode)
                    logger.error(errorStr)
                    success = False

        except Exception as ex:
            errorStr = "{0} calling Get_Node_Core_Info() to node {1}".format(
                ex, targetNode)
            logger.error(errorStr)
            success = False

        fnResponse.Response.Success = success
        fnResponse.Response.Reason = errorStr

        fnResponse.MaxFrequency = response.MaxFrequency
        fnResponse.MinFrequency = response.MinFrequency
        fnResponse.CurrentFrequency = response.CurrentFrequency
        fnResponse.Current_Scaling_Governor = response.Current_Scaling_Governor

        return fnResponse
Exemplo n.º 4
0
    def Set_Node_Core_CState(self, objSetNodeCStateRequest, context):
        logger.info("running Set_Node_Core_CState()")
        fnResponse = ClusterMessages.ServiceResponse()

        validTarget = False
        for targetNode in _NodeList:
            if objSetNodeCStateRequest.Node_ID == targetNode.split(":")[0]:
                validTarget = True
                break

        if False == validTarget:
            fnResponse.Success = False
            fnResponse.Reason = "Node {} is not valid".format(
                objSetNodeCStateRequest.Node_ID)

            return fnResponse

        errorStr = "OK"
        success = True

        nodeRequest = NodeMessages.SetCStateRequest()
        nodeRequest.Core_List = objSetNodeCStateRequest.Core_List
        nodeRequest.Core_CState = objSetNodeCStateRequest.Core_CState
        nodeRequest.State = objSetNodeCStateRequest.State

        try:
            with grpc.insecure_channel(targetNode) as channel:
                rpcStub = NodeRPC.NodeFrequencyManagerServiceStub(channel)
                response = rpcStub.Set_Core_CState(nodeRequest)
                if False == response.Success:
                    errorStr = "{0} calling Get_Node_CPU_Info() to node {1}".format(
                        response.Reason, targetNode)
                    logger.error(errorStr)
                    success = False

        except Exception as ex:
            errorStr = "{0} calling Get_Node_CPU_Info() to node {1}".format(
                ex, targetNode)
            logger.error(errorStr)
            success = False

        fnResponse.Success = success
        fnResponse.Reason = errorStr

        return fnResponse