def get_l3_agents(self, context, active=None, filters=None):
        query = context.session.query(agents_db.Agent)
        query = query.filter(agents_db.Agent.agent_type == constants.AGENT_TYPE_L3)
        if active is not None:
            query = query.filter(agents_db.Agent.admin_state_up == active)
        if filters:
            for key, value in filters.iteritems():
                column = getattr(agents_db.Agent, key, None)
                if column:
                    query = query.filter(column.in_(value))

        return [l3_agent for l3_agent in query if AgentSchedulerDbMixin.is_eligible_agent(active, l3_agent)]
    def get_l3_agents(self, context, active=None, filters=None):
        query = context.session.query(agents_db.Agent)
        query = query.filter(
            agents_db.Agent.agent_type == constants.AGENT_TYPE_L3)
        if active is not None:
            query = (query.filter(agents_db.Agent.admin_state_up == active))
        if filters:
            for key, value in filters.iteritems():
                column = getattr(agents_db.Agent, key, None)
                if column:
                    query = query.filter(column.in_(value))

        return [
            l3_agent for l3_agent in query
            if AgentSchedulerDbMixin.is_eligible_agent(active, l3_agent)
        ]
Beispiel #3
0
    def get_l3_agents(self, context, active=None, filters=None):
        query = context.session.query(agents_db.Agent)
        query = query.filter(
            agents_db.Agent.agent_type == constants.AGENT_TYPE_L3)
        if active is not None:
            query = (query.filter(agents_db.Agent.admin_state_up == active))
        if filters:
            for key, value in filters.iteritems():
                column = getattr(agents_db.Agent, key, None)
                if column:
                    query = query.filter(column.in_(value))

        return [l3_agent
                for l3_agent in query
                if AgentSchedulerDbMixin.is_eligible_agent(active, l3_agent)]

    def get_l3_agent_candidates(self, sync_firewall, l3_agents):
        """Get the valid l3 agents for the firewall from a list of l3_agents."""
        candidates = []
        for l3_agent in l3_agents:
            if not l3_agent.admin_state_up:
                continue
            agent_conf = self.get_configuration_dict(l3_agent)
            firewall_id = agent_conf.get('firewall_id', None)
            use_namespaces = agent_conf.get('use_namespaces', True)
            handle_internal_only_firewalls = agent_conf.get(
                'handle_internal_only_firewalls', True)
            gateway_external_network_id = agent_conf.get(
                'gateway_external_network_id', None)
            if not use_namespaces and firewall_id != sync_firewall['id']: