Exemplo n.º 1
0
 def reserve_provider_segment(self, session, segment):
     if self.is_partial_segment(segment):
         alloc = self.allocate_partially_specified_segment(session)
         if not alloc:
             raise exc.NoNetworkAvailable
     else:
         segmentation_id = segment.get(api.SEGMENTATION_ID)
         alloc = self.allocate_fully_specified_segment(
             session, vxlan_vni=segmentation_id)
         if not alloc:
             raise exc.TunnelIdInUse(tunnel_id=segmentation_id)
     return {api.NETWORK_TYPE: p_const.TYPE_VXLAN,
             api.PHYSICAL_NETWORK: None,
             api.SEGMENTATION_ID: alloc.vxlan_vni}
Exemplo n.º 2
0
 def reserve_provider_segment(self, session, segment):
     if self.is_partial_segment(segment):
         alloc = self.allocate_partially_specified_segment(session)
         if not alloc:
             raise exc.NoNetworkAvailable()
     else:
         segmentation_id = segment.get(api.SEGMENTATION_ID)
         alloc = self.allocate_fully_specified_segment(
             session, **{self.segmentation_key: segmentation_id})
         if not alloc:
             raise exc.TunnelIdInUse(tunnel_id=segmentation_id)
     return {api.NETWORK_TYPE: self.get_type(),
             api.PHYSICAL_NETWORK: None,
             api.SEGMENTATION_ID: getattr(alloc, self.segmentation_key)}
Exemplo n.º 3
0
def reserve_specific_tunnel(session, tunnel_id):
    with session.begin(subtransactions=True):
        try:
            alloc = (session.query(ovs_models_v2.TunnelAllocation).filter_by(
                tunnel_id=tunnel_id).with_lockmode('update').one())
            if alloc.allocated:
                raise q_exc.TunnelIdInUse(tunnel_id=tunnel_id)
            LOG.debug(_("Reserving specific tunnel %s from pool"), tunnel_id)
            alloc.allocated = True
        except exc.NoResultFound:
            LOG.debug(_("Reserving specific tunnel %s outside pool"),
                      tunnel_id)
            alloc = ovs_models_v2.TunnelAllocation(tunnel_id)
            alloc.allocated = True
            session.add(alloc)
Exemplo n.º 4
0
 def reserve_provider_segment(self, session, segment):
     segmentation_id = segment.get(api.SEGMENTATION_ID)
     with session.begin(subtransactions=True):
         try:
             alloc = (session.query(VxlanAllocation).filter_by(
                 vxlan_vni=segmentation_id).with_lockmode('update').one())
             if alloc.allocated:
                 raise exc.TunnelIdInUse(tunnel_id=segmentation_id)
             LOG.debug(_("Reserving specific vxlan tunnel %s from pool"),
                       segmentation_id)
             alloc.allocated = True
         except sa_exc.NoResultFound:
             LOG.debug(_("Reserving specific vxlan tunnel %s outside pool"),
                       segmentation_id)
             alloc = VxlanAllocation(vxlan_vni=segmentation_id)
             alloc.allocated = True
             session.add(alloc)