def _update_agent_stats(self, operation_id, agent_id): """Update the total counts based on the status code. Args: operation_id (str): the operation id. agent_id (str): the agent id. Basic Usage: >>> from vFense.operations.agent_operations import AgentOperation >>> username = '******' >>> customer_name = 'default' >>> oper = AgentOperation(username, customer_name) >>> operation_id = '5dc03727-de89-460d-b2a7-7f766c83d2f1' >>> agent_id = '38c1c67e-436f-4652-8cae-f1a2ac2dd4a2' >>> oper._update_agent_stats(operation_id, agent_id) Returns: Boolean """ completed = False agent_operation_exist = ( operation_with_agentid_exists(operation_id, agent_id) ) if agent_operation_exist: operation = fetch_operation_with_agentid(operation_id, agent_id) if (operation[OperationPerAgentKey.Status] == AgentOperationCodes.ResultsReceived): status_code, count, errors, generated_ids = ( update_completed_and_pending_count( operation_id, self.db_time ) ) if (status_code == DbCodes.Replaced or status_code == DbCodes.Unchanged): completed = True elif ( operation[OperationPerAgentKey.Status] == AgentOperationCodes.ResultsReceivedWithErrors ): status_code, count, errors, generated_ids = ( update_failed_and_pending_count( operation_id, self.db_time ) ) if (status_code == DbCodes.Replaced or status_code == DbCodes.Unchanged): completed = True return completed
def operation_for_agent_exist(operation_id, agent_id): """Verify if the operation exists by operation id and agent id. Args: operation_id (str): 36 character UUID agent_id (str): 36 character UUID Basic Usage: >>> from vFense.operations.agent_operations import operation_for_agent_exist >>> operation_id = '8fed3dc7-33d4-4278-9bd4-398a68bf7f22' >>> agent_id = 'db6bf07-c5da-4494-93bb-109db205ca64' >>> operation_with_agentid_exists(operation_id, agent_id) Results: Boolean True or False """ data = ( operation_with_agentid_exists(operation_id, agent_id) ) return data