Skip to content

Instantly share code, notes, and snippets.

@MattDietz
Created July 23, 2013 22:56
Show Gist options
  • Save MattDietz/6066882 to your computer and use it in GitHub Desktop.
Save MattDietz/6066882 to your computer and use it in GitHub Desktop.
Quota driver fixup
commit 93894e70b7313e37f97a58565c75d114d9e180e7
Author: Matt Dietz <[email protected]>
Date: Tue Jul 23 22:53:56 2013 +0000
Moves quota config back to plugin
Moves the quota configuration lines back into plugin.py which in turn
solves a weird dependency issue when loading the Quark quota driver via
the neutron.conf.
diff --git a/quark/__init__.py b/quark/__init__.py
index 94b4de0..cb6f498 100644
--- a/quark/__init__.py
+++ b/quark/__init__.py
@@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from neutron import quota
+# Import neutron to ensure gettext is installed for "_" support
+import neutron # noqa
from oslo.config import cfg
-
CONF = cfg.CONF
@@ -36,23 +36,5 @@ quark_opts = [
help=_("Path to the config for the net driver"))
]
-quark_quota_opts = [
- cfg.IntOpt('quota_ports_per_network',
- default=64,
- help=_('Maximum ports per network per tenant')),
- cfg.IntOpt('quota_security_rules_per_group',
- default=20,
- help=_('Maximum security group rules in a group')),
-]
-
-quark_resources = [
- quota.BaseResource('ports_per_network',
- 'quota_ports_per_network'),
- quota.BaseResource('security_rules_per_group',
- 'quota_security_rules_per_group'),
-]
CONF.register_opts(quark_opts, "QUARK")
-CONF.register_opts(quark_quota_opts, "QUOTAS")
-
-quota.QUOTAS.register_resources(quark_resources)
diff --git a/quark/plugin.py b/quark/plugin.py
index 0c70e98..9e7e70b 100644
--- a/quark/plugin.py
+++ b/quark/plugin.py
@@ -23,9 +23,9 @@ from zope import sqlalchemy as zsa
from neutron.db import api as neutron_db_api
from neutron.extensions import securitygroup as sg_ext
-from neutron.openstack.common.db.sqlalchemy import session as neutron_session
-
from neutron import neutron_plugin_base_v2
+from neutron.openstack.common.db.sqlalchemy import session as neutron_session
+from neutron import quota
from quark.api import extensions
from quark.db import models
@@ -40,6 +40,22 @@ from quark.plugin_modules import subnets
CONF = cfg.CONF
+quark_resources = [
+ quota.BaseResource('ports_per_network',
+ 'quota_ports_per_network'),
+ quota.BaseResource('security_rules_per_group',
+ 'quota_security_rules_per_group'),
+]
+
+quark_quota_opts = [
+ cfg.IntOpt('quota_ports_per_network',
+ default=64,
+ help=_('Maximum ports per network per tenant')),
+ cfg.IntOpt('quota_security_rules_per_group',
+ default=20,
+ help=_('Maximum security group rules in a group')),
+]
+
def append_quark_extensions(conf):
"""Adds the Quark API Extensions to the extension path.
@@ -51,6 +67,9 @@ def append_quark_extensions(conf):
append_quark_extensions(CONF)
+CONF.register_opts(quark_quota_opts, "QUOTAS")
+quota.QUOTAS.register_resources(quark_resources)
+
class Plugin(neutron_plugin_base_v2.NeutronPluginBaseV2,
sg_ext.SecurityGroupPluginBase):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment