'Get a VLAN object by its name or id'

def get_vlan(self, locator, location, network_domain):

    if is_uuid(locator):
        vlan = self.driver.ex_get_vlan(locator)
    else:
        matching_vlans = [vlan for vlan in self.driver.ex_list_vlans(location, network_domain) if (vlan.name == locator)]
        if matching_vlans:
            vlan = matching_vlans[0]
        else:
            vlan = None
    if vlan:
        return vlan
    raise UnknownVLANError(("VLAN    '%s'    could    not    be    found" % locator))
