def get_dynamic_segment(context, network_id, physical_network=None, segmentation_id=None):
 with context.session.begin(subtransactions=True):
  query = context.session.query(segments_model.NetworkSegment).filter_by(network_id=network_id, is_dynamic=True)
  if physical_network:
   query = query.filter_by(physical_network=physical_network)
  if segmentation_id:
   query = query.filter_by(segmentation_id=segmentation_id)
  record = query.first()
 if record:
  return _make_segment_dict(record)
 else:
  LOG.debug('No dynamic segment found for Network:%(network_id)s, Physical network:%(physnet)s, segmentation_id:%(segmentation_id)s', {'network_id': network_id, 'physnet': physical_network, 'segmentation_id': segmentation_id})
  return None

def get_dynamic_segment ( context , network_id , physical_network = None , segmentation_id = None ) : with context . session . begin ( subtransactions = True ) : query = context . session . query ( segments_model . NetworkSegment ) . filter_by ( network_id = network_id , is_dynamic = True ) if physical_network : query = query . filter_by ( physical_network = physical_network ) if segmentation_id : query = query . filter_by ( segmentation_id = segmentation_id ) record = query . first ( ) if record : return _make_segment_dict ( record ) else : LOG . debug ( 'No dynamic segment found for Network:%(network_id)s, Physical network:%(physnet)s, segmentation_id:%(segmentation_id)s' , { 'network_id' : network_id , 'physnet' : physical_network , 'segmentation_id' : segmentation_id } ) return None
return a dynamic segment for the filters provided if one exists .