'Delete all DHCP namespaces created by DHCP agent.
In some tests for DHCP agent HA agents are killed when handling DHCP
service for network(s). In such case DHCP namespace is not deleted by
DHCP agent and such namespaces are found and deleted using agent\'s
namespace suffix.'

def clean_dhcp_namespaces(self):

    ip_wrapper = ip_lib.IPWrapper()
    for namespace in ip_wrapper.get_namespaces():
        if self.dhcp_namespace_pattern.match(namespace):
            try:
                ip_wrapper.netns.delete(namespace)
            except RuntimeError:
                pass
