def CTPC_RESPONSE(self, node, content): if not self.__ocm_table.exist_owner(node): MessageOutput.NODE_UNFOUND(node) return ReturnCode.gen(ReturnCode.CTPC_NODE_UNFOUND) if self.__ocm_table.get_owner(node) != self: MessageOutput.CONTROLLER_ALREADY_ASSIGNED(node, 'self') return ReturnCode.gen(ReturnCode.CTPC_REJECTED) if not self.__ocm_table.exist_controller(node): MessageOutput.NODE_NOT_ASSIGNED(node, CTPCommandParser.COMMANDPARA_CONTROLLER, 'self') return ReturnCode.gen(ReturnCode.CTPC_NOT_ASSIGNED) controller = self.__ocm_table.get_controller(node) ctpcmd_response = CTPCommandParser.generate_response(node, controller, repr(ReturnCode.gen(argv=content))) self.receive(self, ctpcmd_response) return ReturnCode.gen(ReturnCode.CTPC_SUCCESS)
def __response(self, node, peer, return_code): ctpcmd_response = CTPCommandParser.generate_response(node, peer, ReturnCode.gen_str(return_code)) self.receive(peer, ctpcmd_response)