config options: centralize quota options

The quota options got moved from
"nova/quota.py"
to the new central location
"nova/conf/quota.py".

Change-Id: I54c38ee3fcc086b222eb89ea1377e1906f1bc617
Implements: blueprint centralize-config-options-newton
This commit is contained in:
Allen Gao 2016-04-04 13:19:28 +08:00 committed by Allen Gao
parent b69296eb74
commit 68a4b4729a
5 changed files with 99 additions and 73 deletions

View File

@ -62,6 +62,7 @@ from nova.conf import neutron
from nova.conf import novnc
# from nova.conf import osapi_v21
from nova.conf import pci
from nova.conf import quota
from nova.conf import rdp
from nova.conf import remote_debug
from nova.conf import rpc
@ -128,6 +129,7 @@ neutron.register_opts(CONF)
novnc.register_opts(CONF)
# osapi_v21.register_opts(CONF)
pci.register_opts(CONF)
quota.register_opts(CONF)
rdp.register_opts(CONF)
rpc.register_opts(CONF)
scheduler.register_opts(CONF)

93
nova/conf/quota.py Normal file
View File

@ -0,0 +1,93 @@
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
quota_opts = [
cfg.IntOpt('quota_instances',
default=10,
help='Number of instances allowed per project'),
cfg.IntOpt('quota_cores',
default=20,
help='Number of instance cores allowed per project'),
cfg.IntOpt('quota_ram',
default=50 * 1024,
help='Megabytes of instance RAM allowed per project'),
cfg.IntOpt('quota_floating_ips',
default=10,
help='Number of floating IPs allowed per project'),
cfg.IntOpt('quota_fixed_ips',
default=-1,
help='Number of fixed IPs allowed per project (this should be '
'at least the number of instances allowed)'),
cfg.IntOpt('quota_metadata_items',
default=128,
help='Number of metadata items allowed per instance'),
cfg.IntOpt('quota_injected_files',
default=5,
help='Number of injected files allowed'),
cfg.IntOpt('quota_injected_file_content_bytes',
default=10 * 1024,
help='Number of bytes allowed per injected file'),
cfg.IntOpt('quota_injected_file_path_length',
default=255,
help='Length of injected file path'),
cfg.IntOpt('quota_security_groups',
default=10,
help='Number of security groups per project'),
cfg.IntOpt('quota_security_group_rules',
default=20,
help='Number of security rules per security group'),
cfg.IntOpt('quota_key_pairs',
default=100,
help='Number of key pairs per user'),
cfg.IntOpt('quota_server_groups',
default=10,
help='Number of server groups per project'),
cfg.IntOpt('quota_server_group_members',
default=10,
help='Number of servers per server group'),
cfg.IntOpt('reservation_expire',
default=86400,
help='Number of seconds until a reservation expires'),
cfg.IntOpt('until_refresh',
default=0,
help='Count of reservations until usage is refreshed. This '
'defaults to 0(off) to avoid additional load but it is '
'useful to turn on to help keep quota usage up to date '
'and reduce the impact of out of sync usage issues.'),
cfg.IntOpt('max_age',
default=0,
help='Number of seconds between subsequent usage refreshes. '
'This defaults to 0(off) to avoid additional load but it '
'is useful to turn on to help keep quota usage up to date '
'and reduce the impact of out of sync usage issues. '
'Note that quotas are not updated on a periodic task, '
'they will update on a new reservation if max_age has '
'passed since the last reservation'),
cfg.StrOpt('quota_driver',
default='nova.quota.DbQuotaDriver',
help='Default driver to use for quota checks'),
]
def register_opts(conf):
conf.register_opts(quota_opts)
def list_opts():
return {'DEFAULT': quota_opts}

View File

@ -61,6 +61,7 @@ from sqlalchemy.sql import true
from nova import block_device
from nova.compute import task_states
from nova.compute import vm_states
import nova.conf
import nova.context
from nova.db.sqlalchemy import models
from nova import exception
@ -125,11 +126,10 @@ api_db_opts = [
'SQLAlchemy.'),
]
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.register_opts(db_opts)
CONF.register_opts(oslo_db_options.database_opts, 'database')
CONF.register_opts(api_db_opts, group='api_database')
CONF.import_opt('until_refresh', 'nova.quota')
LOG = logging.getLogger(__name__)

View File

@ -33,7 +33,6 @@ import nova.ipv6.api
import nova.netconf
import nova.notifications
import nova.paths
import nova.quota
import nova.servicegroup.api
import nova.spice
import nova.volume
@ -57,7 +56,6 @@ def list_opts():
nova.netconf.netconf_opts,
nova.notifications.notify_opts,
nova.paths.path_opts,
nova.quota.quota_opts,
nova.volume._volume_opts,
)),
('cinder', nova.volume.cinder.cinder_opts),

View File

@ -18,12 +18,12 @@
import datetime
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import timeutils
import six
import nova.conf
from nova import db
from nova import exception
from nova.i18n import _LE
@ -31,75 +31,8 @@ from nova import objects
LOG = logging.getLogger(__name__)
quota_opts = [
cfg.IntOpt('quota_instances',
default=10,
help='Number of instances allowed per project'),
cfg.IntOpt('quota_cores',
default=20,
help='Number of instance cores allowed per project'),
cfg.IntOpt('quota_ram',
default=50 * 1024,
help='Megabytes of instance RAM allowed per project'),
cfg.IntOpt('quota_floating_ips',
default=10,
help='Number of floating IPs allowed per project'),
cfg.IntOpt('quota_fixed_ips',
default=-1,
help='Number of fixed IPs allowed per project (this should be '
'at least the number of instances allowed)'),
cfg.IntOpt('quota_metadata_items',
default=128,
help='Number of metadata items allowed per instance'),
cfg.IntOpt('quota_injected_files',
default=5,
help='Number of injected files allowed'),
cfg.IntOpt('quota_injected_file_content_bytes',
default=10 * 1024,
help='Number of bytes allowed per injected file'),
cfg.IntOpt('quota_injected_file_path_length',
default=255,
help='Length of injected file path'),
cfg.IntOpt('quota_security_groups',
default=10,
help='Number of security groups per project'),
cfg.IntOpt('quota_security_group_rules',
default=20,
help='Number of security rules per security group'),
cfg.IntOpt('quota_key_pairs',
default=100,
help='Number of key pairs per user'),
cfg.IntOpt('quota_server_groups',
default=10,
help='Number of server groups per project'),
cfg.IntOpt('quota_server_group_members',
default=10,
help='Number of servers per server group'),
cfg.IntOpt('reservation_expire',
default=86400,
help='Number of seconds until a reservation expires'),
cfg.IntOpt('until_refresh',
default=0,
help='Count of reservations until usage is refreshed. This '
'defaults to 0(off) to avoid additional load but it is '
'useful to turn on to help keep quota usage up to date '
'and reduce the impact of out of sync usage issues.'),
cfg.IntOpt('max_age',
default=0,
help='Number of seconds between subsequent usage refreshes. '
'This defaults to 0(off) to avoid additional load but it '
'is useful to turn on to help keep quota usage up to date '
'and reduce the impact of out of sync usage issues. '
'Note that quotas are not updated on a periodic task, '
'they will update on a new reservation if max_age has '
'passed since the last reservation'),
cfg.StrOpt('quota_driver',
default='nova.quota.DbQuotaDriver',
help='Default driver to use for quota checks'),
]
CONF = cfg.CONF
CONF.register_opts(quota_opts)
CONF = nova.conf.CONF
class DbQuotaDriver(object):