def reserve_provider_segment(self, session, segment): physical_network = segment[api.PHYSICAL_NETWORK] vlan_id = segment[api.SEGMENTATION_ID] with session.begin(subtransactions=True): try: alloc = (session.query(VlanAllocation). filter_by(physical_network=physical_network, vlan_id=vlan_id). with_lockmode('update'). one()) if alloc.allocated: raise exc.VlanIdInUse(vlan_id=vlan_id, physical_network=physical_network) LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical " "network %(physical_network)s from pool"), {'vlan_id': vlan_id, 'physical_network': physical_network}) alloc.allocated = True except sa.orm.exc.NoResultFound: LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical " "network %(physical_network)s outside pool"), {'vlan_id': vlan_id, 'physical_network': physical_network}) alloc = VlanAllocation(physical_network=physical_network, vlan_id=vlan_id, allocated=True) session.add(alloc)
def reserve_specific_vlan(session, physical_network, vlan_id): with session.begin(subtransactions=True): try: alloc = (session.query(ovs_models_v2.VlanAllocation).filter_by( physical_network=physical_network, vlan_id=vlan_id).with_lockmode('update').one()) if alloc.allocated: if vlan_id == constants.FLAT_VLAN_ID: raise q_exc.FlatNetworkInUse( physical_network=physical_network) else: raise q_exc.VlanIdInUse(vlan_id=vlan_id, physical_network=physical_network) LOG.debug( _("Reserving specific vlan %(vlan_id)s on physical " "network %(physical_network)s from pool"), { 'vlan_id': vlan_id, 'physical_network': physical_network }) alloc.allocated = True except exc.NoResultFound: LOG.debug( _("Reserving specific vlan %(vlan_id)s on physical " "network %(physical_network)s outside pool"), { 'vlan_id': vlan_id, 'physical_network': physical_network }) alloc = ovs_models_v2.VlanAllocation(physical_network, vlan_id) alloc.allocated = True session.add(alloc)
def reserve_specific_network(session, physical_network, vlan_id): with session.begin(subtransactions=True): try: state = (session.query(l2network_models_v2.NetworkState).filter_by( physical_network=physical_network, vlan_id=vlan_id).one()) if state.allocated: raise q_exc.VlanIdInUse(vlan_id=vlan_id, physical_network=physical_network) LOG.debug("reserving specific vlan %s on physical network %s " "from pool" % (vlan_id, physical_network)) state.allocated = True except exc.NoResultFound: LOG.debug("reserving specific vlan %s on physical network %s " "outside pool" % (vlan_id, physical_network)) state = l2network_models_v2.NetworkState(physical_network, vlan_id) state.allocated = True session.add(state)
def reserve_specific_vlan(session, physical_network, vlan_id): with session.begin(subtransactions=True): try: alloc = (session.query(ovs_models_v2.VlanAllocation).filter_by( physical_network=physical_network, vlan_id=vlan_id).one()) if alloc.allocated: raise q_exc.VlanIdInUse(vlan_id=vlan_id, physical_network=physical_network) LOG.debug("reserving specific vlan %s on physical network %s " "from pool" % (vlan_id, physical_network)) alloc.allocated = True except exc.NoResultFound: LOG.debug("reserving specific vlan %s on physical network %s " "outside pool" % (vlan_id, physical_network)) alloc = ovs_models_v2.VlanAllocation(physical_network, vlan_id) alloc.allocated = True session.add(alloc)
def reserve_specific_vlan(self, session, physical_network, vlan_id): with session.begin(subtransactions=True): try: alloc_q = session.query(hyperv_model.VlanAllocation) alloc_q = alloc_q.filter_by(physical_network=physical_network, vlan_id=vlan_id) alloc = alloc_q.one() if alloc.allocated: if vlan_id == constants.FLAT_VLAN_ID: raise q_exc.FlatNetworkInUse( physical_network=physical_network) else: raise q_exc.VlanIdInUse( vlan_id=vlan_id, physical_network=physical_network) LOG.debug( _("Reserving specific vlan %(vlan_id)s on physical " "network %(physical_network)s from pool"), locals()) alloc.allocated = True except exc.NoResultFound: raise q_exc.NoNetworkAvailable()
def reserve_specific_network(session, physical_network, vlan_id): with session.begin(subtransactions=True): try: state = (session.query(l2network_models_v2.NetworkState).filter_by( physical_network=physical_network, vlan_id=vlan_id).one()) if state.allocated: if vlan_id == constants.FLAT_VLAN_ID: raise q_exc.FlatNetworkInUse( physical_network=physical_network) else: raise q_exc.VlanIdInUse(vlan_id=vlan_id, physical_network=physical_network) LOG.debug( _("Reserving specific vlan %(vlan_id)s on physical " "network %(physical_network)s from pool"), locals()) state.allocated = True except exc.NoResultFound: LOG.debug( _("Reserving specific vlan %(vlan_id)s on physical " "network %(physical_network)s outside pool"), locals()) state = l2network_models_v2.NetworkState(physical_network, vlan_id) state.allocated = True session.add(state)
def reserve_specific_network(session, physical_network, segmentation_id): with session.begin(subtransactions=True): log_args = {'seg_id': segmentation_id, 'phy_net': physical_network} try: entry = (session.query( mlnx_models_v2.SegmentationIdAllocation).filter_by( physical_network=physical_network, segmentation_id=segmentation_id).one()) if entry.allocated: raise q_exc.VlanIdInUse(vlan_id=segmentation_id, physical_network=physical_network) LOG.debug( _("Reserving specific vlan %(seg_id)s " "on physical network %(phy_net)s from pool"), log_args) entry.allocated = True except exc.NoResultFound: LOG.debug( _("Reserving specific vlan %(seg_id)s on " "physical network %(phy_net)s outside pool"), log_args) entry = mlnx_models_v2.SegmentationIdAllocation( physical_network, segmentation_id) entry.allocated = True session.add(entry)