Merge "VlanManager creates superfluous quota reservations"

This commit is contained in:
Jenkins
2013年09月05日 03:52:15 +00:00
committed by Gerrit Code Review

View File

@@ -79,8 +79,6 @@ from nova import utils
LOG = logging.getLogger(__name__)
QUOTAS = quota.QUOTAS
network_opts = [
cfg.StrOpt('flat_network_bridge',
@@ -300,6 +298,8 @@ class NetworkManager(manager.Manager):
l3_lib = kwargs.get("l3_lib", CONF.l3_lib)
self.l3driver = importutils.import_object(l3_lib)
self.quotas = quota.QUOTAS
super(NetworkManager, self).__init__(service_name='network',
*args, **kwargs)
@@ -817,7 +817,7 @@ class NetworkManager(manager.Manager):
# Check the quota; can't put this in the API because we get
# called into from other places
try:
reservations = QUOTAS.reserve(context, fixed_ips=1)
reservations = self.quotas.reserve(context, fixed_ips=1)
except exception.OverQuota:
LOG.warn(_("Quota exceeded for %s, tried to allocate "
"fixed IP"), context.project_id)
@@ -854,12 +854,12 @@ class NetworkManager(manager.Manager):
instance_id, address, "A", self.instance_dns_domain)
self._setup_network_on_host(context, network)
QUOTAS.commit(context, reservations)
self.quotas.commit(context, reservations)
return address
except Exception:
with excutils.save_and_reraise_exception():
QUOTAS.rollback(context, reservations)
self.quotas.rollback(context, reservations)
def deallocate_fixed_ip(self, context, address, host=None, teardown=True):
"""Returns a fixed ip to the pool."""
@@ -868,7 +868,7 @@ class NetworkManager(manager.Manager):
vif_id = fixed_ip_ref['virtual_interface_id']
try:
reservations = QUOTAS.reserve(context, fixed_ips=-1)
reservations = self.quotas.reserve(context, fixed_ips=-1)
except Exception:
reservations = None
LOG.exception(_("Failed to update usages deallocating "
@@ -938,7 +938,7 @@ class NetworkManager(manager.Manager):
# Commit the reservations
if reservations:
QUOTAS.commit(context, reservations)
self.quotas.commit(context, reservations)
def lease_fixed_ip(self, context, address):
"""Called by dhcp-bridge when ip is leased."""
@@ -1678,6 +1678,14 @@ class VlanManager(RPCAllocateFixedIP, floating_ips.FloatingIP, NetworkManager):
DHCP = True
required_create_args = ['bridge_interface']
def __init__(self, network_driver=None, *args, **kwargs):
super(VlanManager, self).__init__(network_driver=network_driver,
*args, **kwargs)
# NOTE(cfb) VlanManager doesn't enforce quotas on fixed IP addresses
# because a project is assigned an entire network.
self.quotas = quota.QuotaEngine(
quota_driver_class='nova.quota.NoopQuotaDriver')
def init_host(self):
"""Do any initialization that needs to be run if this is a
standalone service.

View File

@@ -555,6 +555,10 @@ class VlanNetworkTestCase(test.TestCase):
self.context_admin = context.RequestContext('testuser', 'testproject',
is_admin=True)
def test_quota_driver_type(self):
self.assertEqual(quota.NoopQuotaDriver,
type(self.network.quotas._driver))
def test_vpn_allocate_fixed_ip(self):
self.mox.StubOutWithMock(db, 'fixed_ip_associate')
self.mox.StubOutWithMock(db, 'fixed_ip_update')
Reference in New Issue
openstack/nova
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.