def test_quota_class_unlimited(self): self.flags(quota_floating_ips=10) items = quota.allowed_floating_ips(self.context, 10) self.assertEqual(items, 10) self.context.quota_class = 'foo' db.quota_class_create(self.context, 'foo', 'floating_ips', -1) items = quota.allowed_floating_ips(self.context, 100) self.assertEqual(items, 100)
def test_quota_class_unlimited(self): self.flags(quota_floating_ips=10) items = quota.allowed_floating_ips(self.context, 10) self.assertEqual(items, 10) self.context.quota_class = 'foo' db.quota_class_create(self.context, 'foo', 'floating_ips', -1) items = quota.allowed_floating_ips(self.context, 100) self.assertEqual(items, 100)
def test_unlimited_floating_ips(self): self.flags(quota_floating_ips=10) floating_ips = quota.allowed_floating_ips(self.context, 100) self.assertEqual(floating_ips, 10) db.quota_create(self.context, self.project_id, "floating_ips", None) floating_ips = quota.allowed_floating_ips(self.context, 100) self.assertEqual(floating_ips, 100) floating_ips = quota.allowed_floating_ips(self.context, 101) self.assertEqual(floating_ips, 101)
def test_unlimited_floating_ips(self): FLAGS.quota_floating_ips = 10 floating_ips = quota.allowed_floating_ips(self.context, 100) self.assertEqual(floating_ips, 10) db.quota_create(self.context, self.project_id, 'floating_ips', None) floating_ips = quota.allowed_floating_ips(self.context, 100) self.assertEqual(floating_ips, 100) floating_ips = quota.allowed_floating_ips(self.context, 101) self.assertEqual(floating_ips, 101)
def allocate_floating_ip(self, context, project_id): """Gets an floating ip from the pool.""" # NOTE(tr3buchet): all networks hosts in zone now use the same pool LOG.debug("QUOTA: %s" % quota.allowed_floating_ips(context, 1)) if quota.allowed_floating_ips(context, 1) < 1: LOG.warn(_("Quota exceeded for %s, tried to allocate " "address"), context.project_id) raise quota.QuotaError(_("Address quota exceeded. You cannot " "allocate any more addresses")) # TODO(vish): add floating ips through manage command return self.db.floating_ip_allocate_address(context, project_id)
def test_unlimited_floating_ips(self): self.flags(quota_floating_ips=10) floating_ips = quota.allowed_floating_ips(self.context, 100) self.assertEqual(floating_ips, 10) db.quota_create(self.context, self.project_id, 'floating_ips', None) floating_ips = quota.allowed_floating_ips(self.context, 100) self.assertEqual(floating_ips, 100) floating_ips = quota.allowed_floating_ips(self.context, 101) self.assertEqual(floating_ips, 101)
def allocate_floating_ip(self, context, project_id): """Gets an floating ip from the pool.""" # NOTE(tr3buchet): all networks hosts in zone now use the same pool LOG.debug("QUOTA: %s" % quota.allowed_floating_ips(context, 1)) if quota.allowed_floating_ips(context, 1) < 1: LOG.warn(_('Quota exceeded for %s, tried to allocate ' 'address'), context.project_id) raise quota.QuotaError( _('Address quota exceeded. You cannot ' 'allocate any more addresses')) # TODO(vish): add floating ips through manage command return self.db.floating_ip_allocate_address(context, project_id)
def allocate_floating_ip(self, context): if quota.allowed_floating_ips(context, 1) < 1: LOG.warn(_("Quota exceeeded for %s, tried to allocate " "address"), context.project_id) raise quota.QuotaError(_("Address quota exceeded. You cannot " "allocate any more addresses")) # NOTE(vish): We don't know which network host should get the ip # when we allocate, so just send it to any one. This # will probably need to move into a network supervisor # at some point. return rpc.call(context, FLAGS.network_topic, {"method": "allocate_floating_ip", "args": {"project_id": context.project_id}})
def allocate_floating_ip(self, context): if quota.allowed_floating_ips(context, 1) < 1: LOG.warn(_("Quota exceeeded for %s, tried to allocate " "address"), context.project_id) raise quota.QuotaError( _("Address quota exceeded. You cannot " "allocate any more addresses")) # NOTE(vish): We don't know which network host should get the ip # when we allocate, so just send it to any one. This # will probably need to move into a network supervisor # at some point. return rpc.call( context, FLAGS.network_topic, { "method": "allocate_floating_ip", "args": { "project_id": context.project_id } })