def restart_ovs_on_controllers(self, env, os_conn):
     ovs_agent_ids, ovs_conroller_agents = self.get_ovs_agents(env, os_conn)
     os_conn.wait_agents_alive(ovs_agent_ids)
     common.ban_ovs_agents_controllers(env)
     os_conn.wait_agents_down(ovs_conroller_agents)
     common.clear_ovs_agents_controllers(env)
     common.restart_ovs_agents_on_computes(env)
     os_conn.wait_agents_alive(ovs_agent_ids)
     # sleep to make sure that system will be stable after ovs restarting
     time.sleep(30)
    def test_ovs_restart_pcs_ban_clear(self):
        """Restart openvswitch-agents with pcs ban/clear on controllers

        Steps:
            1. Update default security group
            2. Create router01, create networks.
            3. Launch vm1 in net01 network and vm2 in net02 network
                on different computes.
            4. Go to vm1 console and send pings to vm2
            5. Ban ovs-agents on all controllers, clear them and restart
                service neutron-plugin-openvswitch-agent on all computes.
                To do this, launch the script against master node.
            6. Wait 30 seconds, send pings from vm1 to vm2 and
                check that it is successful.

        Duration 10m

        """
        self._prepare_openstack()
        # Check that all ovs agents are alive
        self.os_conn.wait_agents_alive(self.ovs_agent_ids)

        # Ban ovs agents on all controllers
        common.ban_ovs_agents_controllers(self.env)

        # Then check that all ovs went down
        self.os_conn.wait_agents_down(self.ovs_conroller_agents)

        # Cleat ovs agent on all controllers
        common.clear_ovs_agents_controllers(self.env)

        # Restart ovs agent service on all computes
        common.restart_ovs_agents_on_computes(self.env)

        # Then check that all ovs agents are alive
        self.os_conn.wait_agents_alive(self.ovs_agent_ids)

        # sleep is used to check that system will be stable for some time
        # after restarting service
        time.sleep(30)

        network_checks.check_ping_from_vm(
            self.env, self.os_conn, self.server1, self.instance_keypair,
            self.server2_ip, timeout=3 * 60)

        # check all agents are alive
        assert all([agt['alive'] for agt in
                    self.os_conn.neutron.list_agents()['agents']])