'Check if segment can be bound.
:param segment: segment dictionary describing segment to bind
:param agent: agents_db entry describing agent to bind or None
:returns: True if segment can be bound for agent'

def check_segment_for_agent(self, segment, agent=None):

    network_type = segment[api.NETWORK_TYPE]
    if (network_type in self.get_allowed_network_types(agent)):
        if agent:
            mappings = self.get_mappings(agent)
            LOG.debug('Checking    segment:    %(segment)s    for    mappings:    %(mappings)s    ', {'segment': segment, 'mappings': mappings})
            return (segment[api.PHYSICAL_NETWORK] in mappings)
        return True
    return False
