Run all the actions specified in the rule.

    Args:
      rule: Rule which actions are to be executed.
      client_id: Id of a client where rule's actions are to be executed.

    Returns:
      Number of actions started.

def _RunAction(self, rule, client_id):
    """Run all the actions specified in the rule.

    Args:
      rule: Rule which actions are to be executed.
      client_id: Id of a client where rule's actions are to be executed.

    Returns:
      Number of actions started.
    """
    actions_count = 0

    try:
      if self._CheckIfHuntTaskWasAssigned(client_id, rule.hunt_id):
        logging.info(
            "Foreman: ignoring hunt %s on client %s: was started "
            "here before", client_id, rule.hunt_id)
      else:
        logging.info("Foreman: Starting hunt %s on client %s.", rule.hunt_id,
                     client_id)

        # hunt_name is only used for legacy hunts.
        if rule.hunt_name:
          flow_cls = registry.AFF4FlowRegistry.FlowClassByName(rule.hunt_name)
          hunt_urn = rdfvalue.RDFURN("aff4:/hunts/%s" % rule.hunt_id)
          flow_cls.StartClients(hunt_urn, [client_id])
        else:
          hunt.StartHuntFlowOnClient(client_id, rule.hunt_id)

        actions_count += 1

    # There could be all kinds of errors we don't know about when starting the
    # hunt so we catch everything here.
    except Exception as e:  # pylint: disable=broad-except
      logging.exception("Failure running foreman action on client %s: %s",
                        rule.hunt_id, e)

    return actions_count