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 _update_agent_stats_by_app_stats(self, operation_id, agent_id, completed_count, failed_count, pending_count): """Update the total counts based on the status code. Args: operation_id (str): the operation id. agent_id (str): the agent id. completed_count (int): the completed count. failed_count (int): the failed count. pending_count (int): the pending count. 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' >>> completed_count = 1 >>> pending_count = 0 >>> failed_count = 0 >>> oper._update_agent_stats_by_app_stats( operation_id, agent_id, completed_count, failed_count, pending_count ) Returns: Boolean """ completed = False total_count = completed_count + failed_count + pending_count if total_count == completed_count: 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): self._update_completed_time_on_agents(operation_id, agent_id) self._update_operation_status_code(operation_id) completed = True elif total_count == failed_count: 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): self._update_completed_time_on_agents(operation_id, agent_id) self._update_operation_status_code(operation_id) completed = True elif total_count == (failed_count + completed_count): status_code, count, errors, generated_ids = ( update_errors_and_pending_count(operation_id, self.db_time)) if (status_code == DbCodes.Replaced or status_code == DbCodes.Unchanged): self._update_completed_time_on_agents(operation_id, agent_id) self._update_operation_status_code(operation_id) completed = True return completed
def _update_agent_stats_by_app_stats( self, operation_id, agent_id, completed_count, failed_count, pending_count ): """Update the total counts based on the status code. Args: operation_id (str): the operation id. agent_id (str): the agent id. completed_count (int): the completed count. failed_count (int): the failed count. pending_count (int): the pending count. 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' >>> completed_count = 1 >>> pending_count = 0 >>> failed_count = 0 >>> oper._update_agent_stats_by_app_stats( operation_id, agent_id, completed_count, failed_count, pending_count ) Returns: Boolean """ completed = False total_count = completed_count + failed_count + pending_count if total_count == completed_count: 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): self._update_completed_time_on_agents(operation_id, agent_id) self._update_operation_status_code(operation_id) completed = True elif total_count == failed_count: 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): self._update_completed_time_on_agents(operation_id, agent_id) self._update_operation_status_code(operation_id) completed = True elif total_count == (failed_count + completed_count): status_code, count, errors, generated_ids = ( update_errors_and_pending_count(operation_id, self.db_time) ) if (status_code == DbCodes.Replaced or status_code == DbCodes.Unchanged): self._update_completed_time_on_agents(operation_id, agent_id) self._update_operation_status_code(operation_id) completed = True return completed