def test_ban_l3_dhcp_agents(self):
        """[Neutron VLAN and VXLAN] Check that no errors would be found
        in neutron log after ban two dhcp and two l3 agents.

        Steps:
            1. Update quotas for creation a lot of networks:
                neutron quota-update --network 1000 --subnet 1000
                                     --router 1000 --port 1000:
            2. Create 50 networks, subnets, launch and terminate instance
            3. Look on what DHCP-agents chosen network is:
                ``neutron dhcp-agent-list-hosting-net <network_name>``
            4. Ban DHCP-agents on what chosen network is:
                from primary controller:
                ``pcs resource ban neutron-dhcp-agent node-3``
            5. Ban l3-agent on what router1 is:
                ``pcs resource ban neutron-l3-agent router01``
            6. Check that no ERROR messages are appeared in log.
        """
        controllers = self.env.get_nodes_by_role('controller')
        logs_path, logs_start_marker = func.mark_neutron_logs(controllers)

        # Create 50 networks, launch and terminate instances
        # According to the test requirements 50 networks should be created
        # However during implementation found that only about 34 nets
        # can be created for one tenant. Need to clarify that situation.
        router = self.os_conn.neutron.list_routers(
            name='router01')['routers'][0]
        network_ids_list = []

        self.create_delete_number_of_instances(9, router, network_ids_list,
                                               self.instance_keypair,
                                               self.security_group)
        net_id = network_ids_list[8]

        # Get dhcp agents
        agents = self.os_conn.get_node_with_dhcp_for_network(
            net_id=net_id)

        # determine primary controller
        leader_node_ip = self.env.leader_controller.data['ip']

        for i in range(2):
            logger.info('Ban iteration #{}'.format(i + 1))
            # ban agent on current network
            func.ban_dhcp_agent(self.os_conn, self.env, node_to_ban=agents[i],
                                host=leader_node_ip, wait_for_die=True,
                                wait_for_rescheduling=False)

        devops_node = self.get_node_with_dhcp(net_id)
        ip = devops_node.data['ip']

        # ban l3 agents
        for _ in range(1):
            self.ban_l3_agent(router_name="router01", _ip=ip,
                              wait_for_migrate=False)

        err_trace = "ERROR"
        func.check_neutron_logs(controllers, logs_path, logs_start_marker,
                                err_trace)
    def test_ban_l3_dhcp_agents(self):
        """[Neutron VLAN and VXLAN] Check that no errors would be found
        in neutron log after ban two dhcp and two l3 agents.

        Steps:
            1. Update quotas for creation a lot of networks:
                neutron quota-update --network 50 --subnet 50
                                     --router 50 --port 250:
            2. Create max count of networks, subnets, launch and terminate
                instance on each
            3. Look on what DHCP-agents chosen network is:
                ``neutron dhcp-agent-list-hosting-net <network_name>``
            4. Ban DHCP-agents on what chosen network is:
                from primary controller:
                ``pcs resource ban neutron-dhcp-agent node-3``
            5. Ban l3-agent on what router1 is:
                ``pcs resource ban neutron-l3-agent router01``
            6. Check that no ERROR messages are appeared in log.

        [Bug] - https://bugs.launchpad.net/mos/+bug/1493754
        """
        controllers = self.env.get_nodes_by_role('controller')
        logs_path, logs_start_marker = func.mark_neutron_logs(controllers)

        router = self.os_conn.neutron.list_routers(
            name='router01')['routers'][0]

        self.set_neutron_quota(network=50, router=50, subnet=50, port=250)
        network_ids_list = self.create_max_networks_with_instances(router)

        net_id = network_ids_list[-1]

        # Get dhcp agents
        dhcp_agent_nodes = self.os_conn.get_node_with_dhcp_for_network(
            net_id=net_id)

        # determine primary controller
        leader_node_ip = self.env.leader_controller.data['ip']

        for node in dhcp_agent_nodes:
            logger.info('Ban DHCP agent on {}'.format(node))
            # ban agent on current network
            func.ban_dhcp_agent(self.os_conn, self.env, node_to_ban=node,
                                host=leader_node_ip, wait_for_die=True,
                                wait_for_rescheduling=False)

        ip = controllers[0].data['ip']

        # ban l3 agents
        self.ban_l3_agent(router_name="router01", _ip=ip,
                          wait_for_migrate=False)

        err_trace = "ERROR neutron.db.l3_agentschedulers_db"
        func.check_neutron_logs(controllers, logs_path, logs_start_marker,
                                err_trace)