'Retrieve a network domain by its name or Id.'

def get_network_domain(self, locator, location):

    if is_uuid(locator):
        network_domain = self.driver.ex_get_network_domain(locator)
    else:
        matching_network_domains = [network_domain for network_domain in self.driver.ex_list_network_domains(location=location) if (network_domain.name == locator)]
        if matching_network_domains:
            network_domain = matching_network_domains[0]
        else:
            network_domain = None
    if network_domain:
        return network_domain
    raise UnknownNetworkError(("Network    '%s'    could    not    be    found" % locator))
