summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2012-01-23 11:51:14 +0000
committerMark McLoughlin <markmc@redhat.com>2012-01-28 12:37:16 +0000
commit82049af90e86380043c59741fa4e1cd2cf24aaa7 (patch)
treefd5a35b7a373de888ece003929f8c499b34ce83c
parent02b872625b94c3c63674d8c64b23f80215b04a15 (diff)
downloadnova-82049af90e86380043c59741fa4e1cd2cf24aaa7.tar.gz
nova-82049af90e86380043c59741fa4e1cd2cf24aaa7.tar.xz
nova-82049af90e86380043c59741fa4e1cd2cf24aaa7.zip
Refactor away the flags.DEFINE_* helpers
The next obvious step in porting to cfg is to define all options using cfg schemas directly rather than using the flags.DEFINE_* helpers. This is a large change, but it is almost entirely pure refactoring and does not result in any functional changes. The only change to note is that the default values for glance_host, glance_api_servers and default_publisher_id options are now using opt value interpolation i.e. -glance_host=_get_my_ip() +glance_host='$my_ip' -glance_api_servers=['%s:%d' % (FLAGS.glance_host, FLAGS.glance_port)] +glance_api_servers=['$glance_host:$glance_port'] -default_publisher_id=FLAGS.host +default_publisher_id='$host' Also note that the lower_bound check on the {report,periodic}_interval options are no more, but this has been true since cfg was first added. Change-Id: Ia58c8f0aaf61628bb55b1b8485118a2a9852ed17
-rwxr-xr-xbin/clear_rabbit_queues8
-rwxr-xr-xbin/nova-ajax-console-proxy10
-rwxr-xr-xbin/nova-direct-api13
-rw-r--r--nova/api/auth.py11
-rw-r--r--nova/api/ec2/__init__.py31
-rw-r--r--nova/api/openstack/compute/__init__.py11
-rw-r--r--nova/auth/ldapdriver.py88
-rw-r--r--nova/auth/manager.py87
-rw-r--r--nova/cloudpipe/pipelib.py23
-rw-r--r--nova/compute/api.py8
-rw-r--r--nova/compute/manager.py80
-rw-r--r--nova/console/manager.py22
-rw-r--r--nova/console/vmrc.py17
-rw-r--r--nova/console/vmrc_manager.py14
-rw-r--r--nova/console/xvp.py35
-rw-r--r--nova/consoleauth/__init__.py9
-rw-r--r--nova/consoleauth/manager.py17
-rw-r--r--nova/crypto.py54
-rw-r--r--nova/db/api.py35
-rw-r--r--nova/db/base.py9
-rw-r--r--nova/flags.py618
-rw-r--r--nova/image/s3.py21
-rw-r--r--nova/ipv6/api.py10
-rw-r--r--nova/log.py68
-rw-r--r--nova/network/ldapdns.py73
-rwxr-xr-xnova/network/linux_net.py80
-rw-r--r--nova/network/manager.py128
-rw-r--r--nova/network/quantum/manager.py39
-rw-r--r--nova/network/quantum/melange_connection.py19
-rw-r--r--nova/network/quantum/quantum_connection.py25
-rw-r--r--nova/notifier/api.py18
-rw-r--r--nova/notifier/list_notifier.py10
-rw-r--r--nova/notifier/rabbit_notifier.py10
-rw-r--r--nova/objectstore/s3server.py9
-rw-r--r--nova/policy.py16
-rw-r--r--nova/quota.py55
-rw-r--r--nova/rpc/__init__.py12
-rw-r--r--nova/rpc/common.py15
-rw-r--r--nova/rpc/impl_qpid.py69
-rw-r--r--nova/scheduler/api.py11
-rw-r--r--nova/scheduler/driver.py21
-rw-r--r--nova/scheduler/filters/core_filter.py9
-rw-r--r--nova/scheduler/filters/ram_filter.py9
-rw-r--r--nova/scheduler/host_manager.py31
-rw-r--r--nova/scheduler/least_cost.py26
-rw-r--r--nova/scheduler/manager.py12
-rw-r--r--nova/scheduler/multi.py19
-rw-r--r--nova/scheduler/scheduler_options.py10
-rw-r--r--nova/scheduler/simple.py26
-rw-r--r--nova/scheduler/vsa.py21
-rw-r--r--nova/scheduler/zone_manager.py16
-rw-r--r--nova/service.py66
-rw-r--r--nova/test.py15
-rw-r--r--nova/tests/api/ec2/test_cloud.py10
-rw-r--r--nova/tests/declare_flags.py4
-rw-r--r--nova/tests/runtime_flags.py4
-rw-r--r--nova/tests/test_flags.py57
-rw-r--r--nova/tests/test_service.py21
-rw-r--r--nova/virt/disk/api.py59
-rw-r--r--nova/virt/disk/nbd.py16
-rw-r--r--nova/virt/firewall.py12
-rw-r--r--nova/virt/libvirt/connection.py135
-rw-r--r--nova/virt/libvirt/utils.py11
-rw-r--r--nova/virt/libvirt/vif.py10
-rw-r--r--nova/virt/vmwareapi/vim.py16
-rw-r--r--nova/virt/vmwareapi/vmops.py11
-rw-r--r--nova/virt/vmwareapi_conn.py53
-rw-r--r--nova/virt/xenapi/vif.py10
-rw-r--r--nova/virt/xenapi/vm_utils.py19
-rw-r--r--nova/virt/xenapi/vmops.py34
-rw-r--r--nova/virt/xenapi_conn.py128
-rw-r--r--nova/vnc/__init__.py44
-rw-r--r--nova/vnc/xvp_proxy.py16
-rw-r--r--nova/volume/driver.py47
-rw-r--r--nova/volume/iscsi.py9
-rw-r--r--nova/volume/manager.py27
-rw-r--r--nova/volume/san.py54
-rw-r--r--nova/vsa/api.py25
-rw-r--r--nova/vsa/manager.py9
79 files changed, 1853 insertions, 1157 deletions
diff --git a/bin/clear_rabbit_queues b/bin/clear_rabbit_queues
index 7a000e5d8..f697ef6b4 100755
--- a/bin/clear_rabbit_queues
+++ b/bin/clear_rabbit_queues
@@ -40,6 +40,7 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')):
gettext.install('nova', unicode=1)
+from nova.common import cfg
from nova import context
from nova import exception
from nova import flags
@@ -48,8 +49,13 @@ from nova import rpc
from nova import utils
+delete_exchange_opt = \
+ cfg.BoolOpt('delete_exchange',
+ default=False,
+ help='delete nova exchange too.')
+
FLAGS = flags.FLAGS
-flags.DEFINE_boolean('delete_exchange', False, 'delete nova exchange too.')
+FLAGS.add_option(delete_exchange_opt)
def delete_exchange(exch):
diff --git a/bin/nova-ajax-console-proxy b/bin/nova-ajax-console-proxy
index a6b284987..7dd5266a7 100755
--- a/bin/nova-ajax-console-proxy
+++ b/bin/nova-ajax-console-proxy
@@ -38,6 +38,7 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova import rpc
@@ -45,9 +46,14 @@ from nova import service
from nova import utils
from nova import wsgi
+
+ajax_console_idle_timeout_opt = \
+ cfg.IntOpt('ajax_console_idle_timeout',
+ default=300,
+ help='Seconds before idle connection destroyed')
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('ajax_console_idle_timeout', 300,
- 'Seconds before idle connection destroyed')
+FLAGS.add_option(ajax_console_idle_timeout_opt)
LOG = logging.getLogger('nova.ajax_console_proxy')
diff --git a/bin/nova-direct-api b/bin/nova-direct-api
index 28cc29634..f77311914 100755
--- a/bin/nova-direct-api
+++ b/bin/nova-direct-api
@@ -35,6 +35,7 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+from nova.common import cfg
from nova import compute
from nova import flags
from nova import log as logging
@@ -46,9 +47,17 @@ from nova import wsgi
from nova.api import direct
+direct_api_opts = [
+ cfg.IntOpt('direct_port',
+ default=8001,
+ help='Direct API port'),
+ cfg.StrOpt('direct_host',
+ default='0.0.0.0',
+ help='Direct API host'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('direct_port', 8001, 'Direct API port')
-flags.DEFINE_string('direct_host', '0.0.0.0', 'Direct API host')
+FLAGS.add_options(direct_api_opts)
# An example of an API that only exposes read-only methods.
diff --git a/nova/api/auth.py b/nova/api/auth.py
index 54fff94df..84ba3376d 100644
--- a/nova/api/auth.py
+++ b/nova/api/auth.py
@@ -21,17 +21,22 @@ Common Auth Middleware.
import webob.dec
import webob.exc
+from nova.common import cfg
from nova import context
from nova import flags
from nova import log as logging
from nova import wsgi
-FLAGS = flags.FLAGS
-flags.DEFINE_boolean('use_forwarded_for', False,
- 'Treat X-Forwarded-For as the canonical remote address. '
+use_forwarded_for_opt = \
+ cfg.BoolOpt('use_forwarded_for',
+ default=False,
+ help='Treat X-Forwarded-For as the canonical remote address. '
'Only enable this if you have a sanitizing proxy.')
+FLAGS = flags.FLAGS
+FLAGS.add_option(use_forwarded_for_opt)
+
class InjectContext(wsgi.Middleware):
"""Add a 'nova.context' to WSGI environ."""
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py
index b052f7010..dfcddbc4e 100644
--- a/nova/api/ec2/__init__.py
+++ b/nova/api/ec2/__init__.py
@@ -32,6 +32,7 @@ from nova.api.ec2 import ec2utils
from nova.api.ec2 import faults
from nova.api import validator
from nova.auth import manager
+from nova.common import cfg
from nova import context
from nova import exception
from nova import flags
@@ -39,17 +40,27 @@ from nova import log as logging
from nova import utils
from nova import wsgi
-FLAGS = flags.FLAGS
+
LOG = logging.getLogger("nova.api")
-flags.DEFINE_integer('lockout_attempts', 5,
- 'Number of failed auths before lockout.')
-flags.DEFINE_integer('lockout_minutes', 15,
- 'Number of minutes to lockout if triggered.')
-flags.DEFINE_integer('lockout_window', 15,
- 'Number of minutes for lockout window.')
-flags.DEFINE_string('keystone_ec2_url',
- 'http://localhost:5000/v2.0/ec2tokens',
- 'URL to get token from ec2 request.')
+
+ec2_opts = [
+ cfg.IntOpt('lockout_attempts',
+ default=5,
+ help='Number of failed auths before lockout.'),
+ cfg.IntOpt('lockout_minutes',
+ default=15,
+ help='Number of minutes to lockout if triggered.'),
+ cfg.IntOpt('lockout_window',
+ default=15,
+ help='Number of minutes for lockout window.'),
+ cfg.StrOpt('keystone_ec2_url',
+ default='http://localhost:5000/v2.0/ec2tokens',
+ help='URL to get token from ec2 request.'),
+ ]
+
+FLAGS = flags.FLAGS
+FLAGS.add_options(ec2_opts)
+
flags.DECLARE('use_forwarded_for', 'nova.api.auth')
diff --git a/nova/api/openstack/compute/__init__.py b/nova/api/openstack/compute/__init__.py
index f074ac941..514b3b319 100644
--- a/nova/api/openstack/compute/__init__.py
+++ b/nova/api/openstack/compute/__init__.py
@@ -35,16 +35,21 @@ from nova.api.openstack.compute import servers
from nova.api.openstack.compute import server_metadata
from nova.api.openstack.compute import versions
from nova.api.openstack import wsgi
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova import wsgi as base_wsgi
LOG = logging.getLogger('nova.api.openstack.compute')
+
+allow_instance_snapshots_opt = \
+ cfg.BoolOpt('allow_instance_snapshots',
+ default=True,
+ help='Permit instance snapshot operations.')
+
FLAGS = flags.FLAGS
-flags.DEFINE_bool('allow_instance_snapshots',
- True,
- 'When True, this API service will permit instance snapshot operations.')
+FLAGS.add_option(allow_instance_snapshots_opt)
class APIRouter(base_wsgi.Router):
diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py
index 6f8ae6e67..79da5bd8d 100644
--- a/nova/auth/ldapdriver.py
+++ b/nova/auth/ldapdriver.py
@@ -27,44 +27,68 @@ public methods.
import functools
import sys
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
+ldap_opts = [
+ cfg.IntOpt('ldap_schema_version',
+ default=2,
+ help='Current version of the LDAP schema'),
+ cfg.StrOpt('ldap_url',
+ default='ldap://localhost',
+ help='Point this at your ldap server'),
+ cfg.StrOpt('ldap_password',
+ default='changeme',
+ help='LDAP password'),
+ cfg.StrOpt('ldap_user_dn',
+ default='cn=Manager,dc=example,dc=com',
+ help='DN of admin user'),
+ cfg.StrOpt('ldap_user_id_attribute',
+ default='uid',
+ help='Attribute to use as id'),
+ cfg.StrOpt('ldap_user_name_attribute',
+ default='cn',
+ help='Attribute to use as name'),
+ cfg.StrOpt('ldap_user_unit',
+ default='Users',
+ help='OID for Users'),
+ cfg.StrOpt('ldap_user_subtree',
+ default='ou=Users,dc=example,dc=com',
+ help='OU for Users'),
+ cfg.BoolOpt('ldap_user_modify_only',
+ default=False,
+ help='Modify user attributes instead of creating/deleting'),
+ cfg.StrOpt('ldap_project_subtree',
+ default='ou=Groups,dc=example,dc=com',
+ help='OU for Projects'),
+ cfg.StrOpt('role_project_subtree',
+ default='ou=Groups,dc=example,dc=com',
+ help='OU for Roles'),
+
+ # NOTE(vish): mapping with these flags is necessary because we're going
+ # to tie in to an existing ldap schema
+ cfg.StrOpt('ldap_cloudadmin',
+ default='cn=cloudadmins,ou=Groups,dc=example,dc=com',
+ help='cn for Cloud Admins'),
+ cfg.StrOpt('ldap_itsec',
+ default='cn=itsec,ou=Groups,dc=example,dc=com',
+ help='cn for ItSec'),
+ cfg.StrOpt('ldap_sysadmin',
+ default='cn=sysadmins,ou=Groups,dc=example,dc=com',
+ help='cn for Sysadmins'),
+ cfg.StrOpt('ldap_netadmin',
+ default='cn=netadmins,ou=Groups,dc=example,dc=com',
+ help='cn for NetAdmins'),
+ cfg.StrOpt('ldap_developer',
+ default='cn=developers,ou=Groups,dc=example,dc=com',
+ help='cn for Developers'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('ldap_schema_version', 2,
- 'Current version of the LDAP schema')
-flags.DEFINE_string('ldap_url', 'ldap://localhost',
- 'Point this at your ldap server')
-flags.DEFINE_string('ldap_password', 'changeme', 'LDAP password')
-flags.DEFINE_string('ldap_user_dn', 'cn=Manager,dc=example,dc=com',
- 'DN of admin user')
-flags.DEFINE_string('ldap_user_id_attribute', 'uid', 'Attribute to use as id')
-flags.DEFINE_string('ldap_user_name_attribute', 'cn',
- 'Attribute to use as name')
-flags.DEFINE_string('ldap_user_unit', 'Users', 'OID for Users')
-flags.DEFINE_string('ldap_user_subtree', 'ou=Users,dc=example,dc=com',
- 'OU for Users')
-flags.DEFINE_boolean('ldap_user_modify_only', False,
- 'Modify attributes for users instead of creating/deleting')
-flags.DEFINE_string('ldap_project_subtree', 'ou=Groups,dc=example,dc=com',
- 'OU for Projects')
-flags.DEFINE_string('role_project_subtree', 'ou=Groups,dc=example,dc=com',
- 'OU for Roles')
-
-# NOTE(vish): mapping with these flags is necessary because we're going
-# to tie in to an existing ldap schema
-flags.DEFINE_string('ldap_cloudadmin',
- 'cn=cloudadmins,ou=Groups,dc=example,dc=com', 'cn for Cloud Admins')
-flags.DEFINE_string('ldap_itsec',
- 'cn=itsec,ou=Groups,dc=example,dc=com', 'cn for ItSec')
-flags.DEFINE_string('ldap_sysadmin',
- 'cn=sysadmins,ou=Groups,dc=example,dc=com', 'cn for Sysadmins')
-flags.DEFINE_string('ldap_netadmin',
- 'cn=netadmins,ou=Groups,dc=example,dc=com', 'cn for NetAdmins')
-flags.DEFINE_string('ldap_developer',
- 'cn=developers,ou=Groups,dc=example,dc=com', 'cn for Developers')
+FLAGS.add_options(ldap_opts)
LOG = logging.getLogger("nova.ldapdriver")
diff --git a/nova/auth/manager.py b/nova/auth/manager.py
index f6f55255d..234b9bf33 100644
--- a/nova/auth/manager.py
+++ b/nova/auth/manager.py
@@ -30,6 +30,7 @@ import tempfile
import uuid
import zipfile
+from nova.common import cfg
from nova import context
from nova import crypto
from nova import db
@@ -40,45 +41,61 @@ from nova import utils
from nova.auth import signer
+auth_opts = [
+ cfg.BoolOpt('use_deprecated_auth',
+ default=False,
+ help='This flag must be set to use old style auth'),
+ cfg.ListOpt('allowed_roles',
+ default=[
+ 'cloudadmin',
+ 'itsec',
+ 'sysadmin',
+ 'netadmin',
+ 'developer'
+ ],
+ help='Allowed roles for project'),
+
+ # NOTE(vish): a user with one of these roles will be a superuser and
+ # have access to all api commands
+ cfg.ListOpt('superuser_roles',
+ default=['cloudadmin'],
+ help='Roles that ignore authorization checking completely'),
+
+ # NOTE(vish): a user with one of these roles will have it for every
+ # project, even if he or she is not a member of the project
+ cfg.ListOpt('global_roles',
+ default=['cloudadmin', 'itsec'],
+ help='Roles that apply to all projects'),
+
+ cfg.StrOpt('credentials_template',
+ default=utils.abspath('auth/novarc.template'),
+ help='Template for creating users rc file'),
+ cfg.StrOpt('vpn_client_template',
+ default=utils.abspath('cloudpipe/client.ovpn.template'),
+ help='Template for creating users vpn file'),
+ cfg.StrOpt('credential_vpn_file',
+ default='nova-vpn.conf',
+ help='Filename of certificate in credentials zip'),
+ cfg.StrOpt('credential_key_file',
+ default='pk.pem',
+ help='Filename of private key in credentials zip'),
+ cfg.StrOpt('credential_cert_file',
+ default='cert.pem',
+ help='Filename of certificate in credentials zip'),
+ cfg.StrOpt('credential_rc_file',
+ default='%src',
+ help='Filename of rc in credentials zip %s will be replaced by '
+ 'name of the region (nova by default)'),
+ cfg.StrOpt('auth_driver',
+ default='nova.auth.dbdriver.DbDriver',
+ help='Driver that auth manager uses'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_bool('use_deprecated_auth',
- False,
- 'This flag must be set to use old style auth')
-
-flags.DEFINE_list('allowed_roles',
- ['cloudadmin', 'itsec', 'sysadmin', 'netadmin', 'developer'],
- 'Allowed roles for project')
-# NOTE(vish): a user with one of these roles will be a superuser and
-# have access to all api commands
-flags.DEFINE_list('superuser_roles', ['cloudadmin'],
- 'Roles that ignore authorization checking completely')
-
-# NOTE(vish): a user with one of these roles will have it for every
-# project, even if he or she is not a member of the project
-flags.DEFINE_list('global_roles', ['cloudadmin', 'itsec'],
- 'Roles that apply to all projects')
-
-flags.DEFINE_string('credentials_template',
- utils.abspath('auth/novarc.template'),
- 'Template for creating users rc file')
-flags.DEFINE_string('vpn_client_template',
- utils.abspath('cloudpipe/client.ovpn.template'),
- 'Template for creating users vpn file')
-flags.DEFINE_string('credential_vpn_file', 'nova-vpn.conf',
- 'Filename of certificate in credentials zip')
-flags.DEFINE_string('credential_key_file', 'pk.pem',
- 'Filename of private key in credentials zip')
-flags.DEFINE_string('credential_cert_file', 'cert.pem',
- 'Filename of certificate in credentials zip')
-flags.DEFINE_string('credential_rc_file', '%src',
- 'Filename of rc in credentials zip, %s will be '
- 'replaced by name of the region (nova by default)')
-flags.DEFINE_string('auth_driver', 'nova.auth.dbdriver.DbDriver',
- 'Driver that auth manager uses')
+FLAGS.add_options(auth_opts)
flags.DECLARE('osapi_compute_listen_port', 'nova.service')
-
LOG = logging.getLogger('nova.auth.manager')
diff --git a/nova/cloudpipe/pipelib.py b/nova/cloudpipe/pipelib.py
index 0e86f89b1..3c92f72b1 100644
--- a/nova/cloudpipe/pipelib.py
+++ b/nova/cloudpipe/pipelib.py
@@ -27,6 +27,7 @@ import string
import tempfile
import zipfile
+from nova.common import cfg
from nova import context
from nova import crypto
from nova import db
@@ -39,16 +40,20 @@ from nova.api.ec2 import cloud
from nova.api.ec2 import ec2utils
+cloudpipe_opts = [
+ cfg.StrOpt('boot_script_template',
+ default=utils.abspath('cloudpipe/bootscript.template'),
+ help=_('Template for cloudpipe instance boot script')),
+ cfg.StrOpt('dmz_net',
+ default='10.0.0.0',
+ help=_('Network to push into openvpn config')),
+ cfg.StrOpt('dmz_mask',
+ default='255.255.255.0',
+ help=_('Netmask to push into openvpn config')),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('boot_script_template',
- utils.abspath('cloudpipe/bootscript.template'),
- _('Template for script to run on cloudpipe instance boot'))
-flags.DEFINE_string('dmz_net',
- '10.0.0.0',
- _('Network to push into openvpn config'))
-flags.DEFINE_string('dmz_mask',
- '255.255.255.0',
- _('Netmask to push into openvpn config'))
+FLAGS.add_options(cloudpipe_opts)
LOG = logging.getLogger('nova.cloudpipe')
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 0f1587dde..622a1abfd 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -28,6 +28,7 @@ import novaclient
import webob.exc
from nova import block_device
+from nova.common import cfg
from nova.compute import aggregate_states
from nova.compute import instance_types
from nova.compute import power_state
@@ -49,12 +50,15 @@ from nova import volume
LOG = logging.getLogger('nova.compute.api')
+find_host_timeout_opt = \
+ cfg.StrOpt('find_host_timeout',
+ default=30,
+ help='Timeout after NN seconds when looking for a host.')
FLAGS = flags.FLAGS
+FLAGS.add_option(find_host_timeout_opt)
flags.DECLARE('enable_zone_routing', 'nova.scheduler.api')
flags.DECLARE('consoleauth_topic', 'nova.consoleauth')
-flags.DEFINE_integer('find_host_timeout', 30,
- 'Timeout after NN seconds when looking for a host.')
def check_instance_state(vm_state=None, task_state=None):
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index e0ac28d62..ef49718dc 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -45,6 +45,7 @@ from eventlet import greenthread
from nova import block_device
import nova.context
+from nova.common import cfg
from nova.compute import instance_types
from nova.compute import power_state
from nova.compute import task_states
@@ -64,40 +65,53 @@ from nova import vnc
from nova import volume
+compute_opts = [
+ cfg.StrOpt('instances_path',
+ default='$state_path/instances',
+ help='where instances are stored on disk'),
+ cfg.StrOpt('compute_driver',
+ default='nova.virt.connection.get_connection',
+ help='Driver to use for controlling virtualization'),
+ cfg.StrOpt('console_host',
+ default=socket.gethostname(),
+ help='Console proxy host to use to connect '
+ 'to instances on this host.'),
+ cfg.IntOpt('live_migration_retry_count',
+ default=30,
+ help="Number of 1 second retries needed in live_migration"),
+ cfg.IntOpt("reboot_timeout",
+ default=0,
+ help="Automatically hard reboot an instance if it has been "
+ "stuck in a rebooting state longer than N seconds. "
+ "Set to 0 to disable."),
+ cfg.IntOpt("rescue_timeout",
+ default=0,
+ help="Automatically unrescue an instance after N seconds. "
+ "Set to 0 to disable."),
+ cfg.IntOpt("resize_confirm_window",
+ default=0,
+ help="Automatically confirm resizes after N seconds. "
+ "Set to 0 to disable."),
+ cfg.IntOpt('host_state_interval',
+ default=120,
+ help='Interval in seconds for querying the host status'),
+ cfg.IntOpt("running_deleted_instance_timeout",
+ default=0,
+ help="Number of seconds after being deleted when a running "
+ "instance should be considered eligible for cleanup."),
+ cfg.IntOpt("running_deleted_instance_poll_interval",
+ default=30,
+ help="Number of periodic scheduler ticks to wait between "
+ "runs of the cleanup task."),
+ cfg.StrOpt("running_deleted_instance_action",
+ default="noop",
+ help="Action to take if a running deleted instance is detected."
+ "Valid options are 'noop', 'log' and 'reap'. "
+ "Set to 'noop' to disable."),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('instances_path', '$state_path/instances',
- 'where instances are stored on disk')
-flags.DEFINE_string('compute_driver', 'nova.virt.connection.get_connection',
- 'Driver to use for controlling virtualization')
-flags.DEFINE_string('console_host', socket.gethostname(),
- 'Console proxy host to use to connect to instances on'
- 'this host.')
-flags.DEFINE_integer('live_migration_retry_count', 30,
- "Retry count needed in live_migration."
- " sleep 1 sec for each count")
-flags.DEFINE_integer("reboot_timeout", 0,
- "Automatically hard reboot an instance if it has been "
- "stuck in a rebooting state longer than N seconds."
- " Set to 0 to disable.")
-flags.DEFINE_integer("rescue_timeout", 0,
- "Automatically unrescue an instance after N seconds."
- " Set to 0 to disable.")
-flags.DEFINE_integer("resize_confirm_window", 0,
- "Automatically confirm resizes after N seconds."
- " Set to 0 to disable.")
-flags.DEFINE_integer('host_state_interval', 120,
- 'Interval in seconds for querying the host status')
-flags.DEFINE_integer("running_deleted_instance_timeout", 0,
- "Number of seconds after being deleted when a"
- " still-running instance should be considered"
- " eligible for cleanup.")
-flags.DEFINE_integer("running_deleted_instance_poll_interval", 30,
- "Number of periodic scheduler ticks to wait between"
- " runs of the cleanup task.")
-flags.DEFINE_string("running_deleted_instance_action", "noop",
- "Action to take if a running deleted instance is"
- " detected. Valid options are 'noop', 'log', and"
- " 'reap'. Set to 'noop' to disable.")
+FLAGS.add_options(compute_opts)
LOG = logging.getLogger('nova.compute.manager')
diff --git a/nova/console/manager.py b/nova/console/manager.py
index bb58bcf1f..220ac32c5 100644
--- a/nova/console/manager.py
+++ b/nova/console/manager.py
@@ -19,6 +19,7 @@
import socket
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -27,15 +28,20 @@ from nova import rpc
from nova import utils
+console_manager_opts = [
+ cfg.StrOpt('console_driver',
+ default='nova.console.xvp.XVPConsoleProxy',
+ help='Driver to use for the console proxy'),
+ cfg.BoolOpt('stub_compute',
+ default=False,
+ help='Stub calls to compute worker for tests'),
+ cfg.StrOpt('console_public_hostname',
+ default=socket.gethostname(),
+ help='Publicly visable name for this console host'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('console_driver',
- 'nova.console.xvp.XVPConsoleProxy',
- 'Driver to use for the console proxy')
-flags.DEFINE_boolean('stub_compute', False,
- 'Stub calls to compute worker for tests')
-flags.DEFINE_string('console_public_hostname',
- socket.gethostname(),
- 'Publicly visable name for this console host')
+FLAGS.add_options(console_manager_opts)
class ConsoleProxyManager(manager.Manager):
diff --git a/nova/console/vmrc.py b/nova/console/vmrc.py
index 4b7f1cdfc..e29254d60 100644
--- a/nova/console/vmrc.py
+++ b/nova/console/vmrc.py
@@ -20,18 +20,23 @@
import base64
import json
+from nova.common import cfg
from nova import exception
from nova import flags
from nova.virt.vmwareapi import vim_util
+vmrc_opts = [
+ cfg.IntOpt('console_vmrc_port',
+ default=443,
+ help="port for VMware VMRC connections"),
+ cfg.IntOpt('console_vmrc_error_retries',
+ default=10,
+ help="number of retries for retrieving VMRC information"),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('console_vmrc_port',
- 443,
- "port for VMware VMRC connections")
-flags.DEFINE_integer('console_vmrc_error_retries',
- 10,
- "number of retries for retrieving VMRC information")
+FLAGS.add_options(vmrc_opts)
class VMRCConsole(object):
diff --git a/nova/console/vmrc_manager.py b/nova/console/vmrc_manager.py
index 0b5ce4a49..03cc46bf6 100644
--- a/nova/console/vmrc_manager.py
+++ b/nova/console/vmrc_manager.py
@@ -17,6 +17,7 @@
"""VMRC Console Manager."""
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -28,12 +29,17 @@ from nova.virt import vmwareapi_conn
LOG = logging.getLogger("nova.console.vmrc_manager")
+vmrc_manager_opts = [
+ cfg.StrOpt('console_public_hostname',
+ default='',
+ help='Publicly visible name for this console host'),
+ cfg.StrOpt('console_driver',
+ default='nova.console.vmrc.VMRCConsole',
+ help='Driver to use for the console'),
+ ]
FLAGS = flags.FLAGS
-flags.DEFINE_string('console_public_hostname', '',
- 'Publicly visible name for this console host')
-flags.DEFINE_string('console_driver', 'nova.console.vmrc.VMRCConsole',
- 'Driver to use for the console')
+FLAGS.add_options(vmrc_manager_opts)
class ConsoleVMRCManager(manager.Manager):
diff --git a/nova/console/xvp.py b/nova/console/xvp.py
index 17942321c..2b8dcc1e0 100644
--- a/nova/console/xvp.py
+++ b/nova/console/xvp.py
@@ -22,6 +22,7 @@ import signal
from Cheetah import Template
+from nova.common import cfg
from nova import context
from nova import db
from nova import exception
@@ -30,22 +31,26 @@ from nova import log as logging
from nova import utils
+xvp_opts = [
+ cfg.StrOpt('console_xvp_conf_template',
+ default=utils.abspath('console/xvp.conf.template'),
+ help='XVP conf template'),
+ cfg.StrOpt('console_xvp_conf',
+ default='/etc/xvp.conf',
+ help='generated XVP conf file'),
+ cfg.StrOpt('console_xvp_pid',
+ default='/var/run/xvp.pid',
+ help='XVP master process pid file'),
+ cfg.StrOpt('console_xvp_log',
+ default='/var/log/xvp.log',
+ help='XVP log file'),
+ cfg.IntOpt('console_xvp_multiplex_port',
+ default=5900,
+ help='port for XVP to multiplex VNC connections on'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('console_xvp_conf_template',
- utils.abspath('console/xvp.conf.template'),
- 'XVP conf template')
-flags.DEFINE_string('console_xvp_conf',
- '/etc/xvp.conf',
- 'generated XVP conf file')
-flags.DEFINE_string('console_xvp_pid',
- '/var/run/xvp.pid',
- 'XVP master process pid file')
-flags.DEFINE_string('console_xvp_log',
- '/var/log/xvp.log',
- 'XVP log file')
-flags.DEFINE_integer('console_xvp_multiplex_port',
- 5900,
- 'port for XVP to multiplex VNC connections on')
+FLAGS.add_options(xvp_opts)
class XVPConsoleProxy(object):
diff --git a/nova/consoleauth/__init__.py b/nova/consoleauth/__init__.py
index 9d578b77a..4048ae433 100644
--- a/nova/consoleauth/__init__.py
+++ b/nova/consoleauth/__init__.py
@@ -18,9 +18,14 @@
"""Module to authenticate Consoles."""
+from nova.common import cfg
from nova import flags
+consoleauth_topic_opt = \
+ cfg.StrOpt('consoleauth_topic',
+ default='consoleauth',
+ help='the topic console auth proxy nodes listen on')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('consoleauth_topic', 'consoleauth',
- 'the topic console auth proxy nodes listen on')
+FLAGS.add_option(consoleauth_topic_opt)
diff --git a/nova/consoleauth/manager.py b/nova/consoleauth/manager.py
index 8f86b4b8c..08ddd5a3b 100644
--- a/nova/consoleauth/manager.py
+++ b/nova/consoleauth/manager.py
@@ -22,6 +22,7 @@ import os
import sys
import time
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova import manager
@@ -29,12 +30,18 @@ from nova import utils
LOG = logging.getLogger('nova.consoleauth')
+
+consoleauth_opts = [
+ cfg.IntOpt('console_token_ttl',
+ default=600,
+ help='How many seconds before deleting tokens'),
+ cfg.StrOpt('consoleauth_manager',
+ default='nova.consoleauth.manager.ConsoleAuthManager',
+ help='Manager for console auth'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('console_token_ttl', 600,
- 'How many seconds before deleting tokens')
-flags.DEFINE_string('consoleauth_manager',
- 'nova.consoleauth.manager.ConsoleAuthManager',
- 'Manager for console auth')
+FLAGS.add_options(consoleauth_opts)
class ConsoleAuthManager(manager.Manager):
diff --git a/nova/crypto.py b/nova/crypto.py
index 5dd380fb6..35dd12697 100644
--- a/nova/crypto.py
+++ b/nova/crypto.py
@@ -37,6 +37,7 @@ import M2Crypto
gettext.install('nova', unicode=1)
+from nova.common import cfg
from nova import context
from nova import db
from nova import exception
@@ -46,30 +47,39 @@ from nova import log as logging
LOG = logging.getLogger("nova.crypto")
+crypto_opts = [
+ cfg.StrOpt('ca_file',
+ default='cacert.pem',
+ help=_('Filename of root CA')),
+ cfg.StrOpt('key_file',
+ default=os.path.join('private', 'cakey.pem'),
+ help=_('Filename of private key')),
+ cfg.StrOpt('crl_file',
+ default='crl.pem',
+ help=_('Filename of root Certificate Revocation List')),
+ cfg.StrOpt('keys_path',
+ default='$state_path/keys',
+ help=_('Where we keep our keys')),
+ cfg.StrOpt('ca_path',
+ default='$state_path/CA',
+ help=_('Where we keep our root CA')),
+ cfg.BoolOpt('use_project_ca',
+ default=False,
+ help=_('Should we use a CA for each project?')),
+ cfg.StrOpt('user_cert_subject',
+ default='/C=US/ST=California/O=OpenStack/'
+ 'OU=NovaDev/CN=%.16s-%.16s-%s',
+ help=_('Subject for certificate for users, %s for '
+ 'project, user, timestamp')),
+ cfg.StrOpt('project_cert_subject',
+ default='/C=US/ST=California/O=OpenStack/'
+ 'OU=NovaDev/CN=project-ca-%.16s-%s',
+ help=_('Subject for certificate for projects, %s for '
+ 'project, timestamp')),
+ ]
FLAGS = flags.FLAGS
-flags.DEFINE_string('ca_file', 'cacert.pem', _('Filename of root CA'))
-flags.DEFINE_string('key_file',
- os.path.join('private', 'cakey.pem'),
- _('Filename of private key'))
-flags.DEFINE_string('crl_file', 'crl.pem',
- _('Filename of root Certificate Revocation List'))
-flags.DEFINE_string('keys_path', '$state_path/keys',
- _('Where we keep our keys'))
-flags.DEFINE_string('ca_path', '$state_path/CA',
- _('Where we keep our root CA'))
-flags.DEFINE_boolean('use_project_ca', False,
- _('Should we use a CA for each project?'))
-flags.DEFINE_string('user_cert_subject',
- '/C=US/ST=California/O=OpenStack/'
- 'OU=NovaDev/CN=%.16s-%.16s-%s',
- _('Subject for certificate for users, '
- '%s for project, user, timestamp'))
-flags.DEFINE_string('project_cert_subject',
- '/C=US/ST=California/O=OpenStack/'
- 'OU=NovaDev/CN=project-ca-%.16s-%s',
- _('Subject for certificate for projects, '
- '%s for project, timestamp'))
+FLAGS.add_options(crypto_opts)
def ca_folder(project_id=None):
diff --git a/nova/db/api.py b/nova/db/api.py
index ef755b816..ad0517dbf 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -43,24 +43,35 @@ these objects be simple dictionaries.
"""
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import utils
+db_opts = [
+ cfg.StrOpt('db_backend',
+ default='sqlalchemy',
+ help='The backend to use for db'),
+ cfg.BoolOpt('enable_new_services',
+ default=True,
+ help='Services to be added to the available pool on create'),
+ cfg.StrOpt('instance_name_template',
+ default='instance-%08x',
+ help='Template string to be used to generate instance names'),
+ cfg.StrOpt('volume_name_template',
+ default='volume-%08x',
+ help='Template string to be used to generate instance names'),
+ cfg.StrOpt('snapshot_name_template',
+ default='snapshot-%08x',
+ help='Template string to be used to generate snapshot names'),
+ cfg.StrOpt('vsa_name_template',
+ default='vsa-%08x',
+ help='Template string to be used to generate VSA names'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('db_backend', 'sqlalchemy',
- 'The backend to use for db')
-flags.DEFINE_boolean('enable_new_services', True,
- 'Services to be added to the available pool on create')
-flags.DEFINE_string('instance_name_template', 'instance-%08x',
- 'Template string to be used to generate instance names')
-flags.DEFINE_string('volume_name_template', 'volume-%08x',
- 'Template string to be used to generate instance names')
-flags.DEFINE_string('snapshot_name_template', 'snapshot-%08x',
- 'Template string to be used to generate snapshot names')
-flags.DEFINE_string('vsa_name_template', 'vsa-%08x',
- 'Template string to be used to generate VSA names')
+FLAGS.add_options(db_opts)
IMPL = utils.LazyPluggable(FLAGS['db_backend'],
sqlalchemy='nova.db.sqlalchemy.api')
diff --git a/nova/db/base.py b/nova/db/base.py
index 6543b7934..77b7d82a7 100644
--- a/nova/db/base.py
+++ b/nova/db/base.py
@@ -18,13 +18,18 @@
"""Base class for classes that need modular database access."""
+from nova.common import cfg
from nova import utils
from nova import flags
+db_driver_opt = \
+ cfg.StrOpt('db_driver',
+ default='nova.db',
+ help='driver to use for database access')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('db_driver', 'nova.db',
- 'driver to use for database access')
+FLAGS.add_option(db_driver_opt)
class Base(object):
diff --git a/nova/flags.py b/nova/flags.py
index 59c44470a..146817272 100644
--- a/nova/flags.py
+++ b/nova/flags.py
@@ -151,7 +151,7 @@ class FlagValues(object):
ret[opt.dest] = getattr(self, opt.dest)
return ret
- def _add_option(self, opt):
+ def add_option(self, opt):
if opt.dest in self._opts:
return
@@ -164,57 +164,14 @@ class FlagValues(object):
self._conf.register_cli_opts(self._opts.values())
self._extra = None
- def define_string(self, name, default, help):
- self._add_option(cfg.StrOpt(name, default=default, help=help))
-
- def define_integer(self, name, default, help):
- self._add_option(cfg.IntOpt(name, default=default, help=help))
-
- def define_float(self, name, default, help):
- self._add_option(cfg.FloatOpt(name, default=default, help=help))
-
- def define_bool(self, name, default, help):
- self._add_option(cfg.BoolOpt(name, default=default, help=help))
-
- def define_list(self, name, default, help):
- self._add_option(cfg.ListOpt(name, default=default, help=help))
-
- def define_multistring(self, name, default, help):
- self._add_option(cfg.MultiStrOpt(name, default=default, help=help))
+ def add_options(self, opts):
+ for opt in opts:
+ self.add_option(opt)
FLAGS = FlagValues()
-def DEFINE_string(name, default, help, flag_values=FLAGS):
- flag_values.define_string(name, default, help)
-
-
-def DEFINE_integer(name, default, help, lower_bound=None, flag_values=FLAGS):
- # FIXME(markmc): ignoring lower_bound
- flag_values.define_integer(name, default, help)
-
-
-def DEFINE_bool(name, default, help, flag_values=FLAGS):
- flag_values.define_bool(name, default, help)
-
-
-def DEFINE_boolean(name, default, help, flag_values=FLAGS):
- DEFINE_bool(name, default, help, flag_values)
-
-
-def DEFINE_list(name, default, help, flag_values=FLAGS):
- flag_values.define_list(name, default, help)
-
-
-def DEFINE_float(name, default, help, flag_values=FLAGS):
- flag_values.define_float(name, default, help)
-
-
-def DEFINE_multistring(name, default, help, flag_values=FLAGS):
- flag_values.define_multistring(name, default, help)
-
-
class UnrecognizedFlag(Exception):
pass
@@ -238,227 +195,346 @@ def _get_my_ip():
return "127.0.0.1"
-# __GLOBAL FLAGS ONLY__
-# Define any app-specific flags in their own files, docs at:
-# http://code.google.com/p/python-gflags/source/browse/trunk/gflags.py#a9
-DEFINE_string('my_ip', _get_my_ip(), 'host ip address')
-DEFINE_list('region_list',
- [],
- 'list of region=fqdn pairs separated by commas')
-DEFINE_string('connection_type', None, 'libvirt, xenapi or fake')
-DEFINE_string('aws_access_key_id', 'admin', 'AWS Access ID')
-DEFINE_string('aws_secret_access_key', 'admin', 'AWS Access Key')
-# NOTE(sirp): my_ip interpolation doesn't work within nested structures
-DEFINE_string('glance_host', _get_my_ip(), 'default glance host')
-DEFINE_integer('glance_port', 9292, 'default glance port')
-DEFINE_list('glance_api_servers',
- ['%s:%d' % (FLAGS.glance_host, FLAGS.glance_port)],
- 'list of glance api servers available to nova (host:port)')
-DEFINE_integer('glance_num_retries', 0,
- 'The number of times to retry downloading an image from glance')
-DEFINE_integer('s3_port', 3333, 's3 port')
-DEFINE_string('s3_host', '$my_ip', 's3 host (for infrastructure)')
-DEFINE_string('s3_dmz', '$my_ip', 's3 dmz ip (for instances)')
-DEFINE_string('cert_topic', 'cert', 'the topic cert nodes listen on')
-DEFINE_string('compute_topic', 'compute', 'the topic compute nodes listen on')
-DEFINE_string('console_topic', 'console',
- 'the topic console proxy nodes listen on')
-DEFINE_string('scheduler_topic', 'scheduler',
- 'the topic scheduler nodes listen on')
-DEFINE_string('volume_topic', 'volume', 'the topic volume nodes listen on')
-DEFINE_string('network_topic', 'network', 'the topic network nodes listen on')
-DEFINE_string('ajax_console_proxy_topic', 'ajax_proxy',
- 'the topic ajax proxy nodes listen on')
-DEFINE_string('ajax_console_proxy_url',
- 'http://127.0.0.1:8000',
- 'location of ajax console proxy, \
- in the form "http://127.0.0.1:8000"')
-DEFINE_integer('ajax_console_proxy_port',
- 8000, 'port that ajax_console_proxy binds')
-DEFINE_string('vsa_topic', 'vsa', 'the topic that nova-vsa service listens on')
-DEFINE_bool('verbose', False, 'show debug output')
-DEFINE_boolean('fake_rabbit', False, 'use a fake rabbit')
-DEFINE_bool('fake_network', False,
- 'should we use fake network devices and addresses')
-DEFINE_string('rabbit_host', 'localhost', 'rabbit host')
-DEFINE_integer('rabbit_port', 5672, 'rabbit port')
-DEFINE_bool('rabbit_use_ssl', False, 'connect over SSL')
-DEFINE_string('rabbit_userid', 'guest', 'rabbit userid')
-DEFINE_string('rabbit_password', 'guest', 'rabbit password')
-DEFINE_string('rabbit_virtual_host', '/', 'rabbit virtual host')
-DEFINE_integer('rabbit_retry_interval', 1,
- 'rabbit connection retry interval to start')
-DEFINE_integer('rabbit_retry_backoff', 2,
- 'rabbit connection retry backoff in seconds')
-DEFINE_integer('rabbit_max_retries', 0,
- 'maximum rabbit connection attempts (0=try forever)')
-DEFINE_string('control_exchange', 'nova', 'the main exchange to connect to')
-DEFINE_boolean('rabbit_durable_queues', False, 'use durable queues')
-DEFINE_list('enabled_apis',
- ['ec2', 'osapi_compute', 'osapi_volume', 'metadata'],
- 'list of APIs to enable by default')
-DEFINE_string('ec2_host', '$my_ip', 'ip of api server')
-DEFINE_string('ec2_dmz_host', '$my_ip', 'internal ip of api server')
-DEFINE_integer('ec2_port', 8773, 'cloud controller port')
-DEFINE_string('ec2_scheme', 'http', 'prefix for ec2')
-DEFINE_string('ec2_path', '/services/Cloud', 'suffix for ec2')
-DEFINE_multistring('osapi_compute_extension',
- ['nova.api.openstack.compute.contrib.standard_extensions'],
- 'osapi compute extension to load')
-DEFINE_multistring('osapi_volume_extension',
- ['nova.api.openstack.volume.contrib.standard_extensions'],
- 'osapi volume extension to load')
-DEFINE_string('osapi_scheme', 'http', 'prefix for openstack')
-DEFINE_string('osapi_path', '/v1.1/', 'suffix for openstack')
-DEFINE_integer('osapi_max_limit', 1000,
- 'max number of items returned in a collection response')
-DEFINE_string('metadata_host', '$my_ip', 'ip of metadata server')
-DEFINE_integer('metadata_port', 8775, 'Metadata API port')
-DEFINE_string('default_project', 'openstack', 'default project for openstack')
-DEFINE_string('default_image', 'ami-11111',
- 'default image to use, testing only')
-DEFINE_string('default_instance_type', 'm1.small',
- 'default instance type to use, testing only')
-DEFINE_string('null_kernel', 'nokernel',
- 'kernel image that indicates not to use a kernel,'
- ' but to use a raw disk image instead')
-
-DEFINE_string('vpn_image_id', '0', 'image id for cloudpipe vpn server')
-DEFINE_string('vpn_key_suffix',
- '-vpn',
- 'Suffix to add to project name for vpn key and secgroups')
-
-DEFINE_integer('auth_token_ttl', 3600, 'Seconds for auth tokens to linger')
-
-DEFINE_string('state_path', os.path.join(os.path.dirname(__file__), '../'),
- "Top-level directory for maintaining nova's state")
-DEFINE_string('lock_path', os.path.join(os.path.dirname(__file__), '../'),
- 'Directory for lock files')
-DEFINE_string('logdir', None, 'output to a per-service log file in named '
- 'directory')
-DEFINE_string('logfile_mode', '0644', 'Default file mode of the logs.')
-DEFINE_string('sqlite_db', 'nova.sqlite', 'file name for sqlite')
-DEFINE_bool('sqlite_synchronous', True, 'Synchronous mode for sqlite')
-DEFINE_string('sql_connection',
- 'sqlite:///$state_path/$sqlite_db',
- 'connection string for sql database')
-DEFINE_integer('sql_idle_timeout',
- 3600,
- 'timeout for idle sql database connections')
-DEFINE_integer('sql_max_retries', 12, 'sql connection attempts')
-DEFINE_integer('sql_retry_interval', 10, 'sql connection retry interval')
-
-DEFINE_string('compute_manager', 'nova.compute.manager.ComputeManager',
- 'Manager for compute')
-DEFINE_string('console_manager', 'nova.console.manager.ConsoleProxyManager',
- 'Manager for console proxy')
-DEFINE_string('cert_manager', 'nova.cert.manager.CertManager',
- 'Manager for cert')
-DEFINE_string('instance_dns_manager',
- 'nova.network.dns_driver.DNSDriver',
- 'DNS Manager for instance IPs')
-DEFINE_string('instance_dns_domain', '',
- 'DNS Zone for instance IPs')
-DEFINE_string('floating_ip_dns_manager',
- 'nova.network.dns_driver.DNSDriver',
- 'DNS Manager for floating IPs')
-DEFINE_string('network_manager', 'nova.network.manager.VlanManager',
- 'Manager for network')
-DEFINE_string('volume_manager', 'nova.volume.manager.VolumeManager',
- 'Manager for volume')
-DEFINE_string('scheduler_manager', 'nova.scheduler.manager.SchedulerManager',
- 'Manager for scheduler')
-DEFINE_string('vsa_manager', 'nova.vsa.manager.VsaManager',
- 'Manager for vsa')
-DEFINE_string('vc_image_name', 'vc_image',
- 'the VC image ID (for a VC image that exists in DB Glance)')
-# VSA constants and enums
-DEFINE_string('default_vsa_instance_type', 'm1.small',
- 'default instance type for VSA instances')
-DEFINE_integer('max_vcs_in_vsa', 32,
- 'maxinum VCs in a VSA')
-DEFINE_integer('vsa_part_size_gb', 100,
- 'default partition size for shared capacity')
-# Default firewall driver for security groups and provider firewall
-DEFINE_string('firewall_driver',
- 'nova.virt.libvirt.firewall.IptablesFirewallDriver',
- 'Firewall driver (defaults to iptables)')
-# The service to use for image search and retrieval
-DEFINE_string('image_service', 'nova.image.glance.GlanceImageService',
- 'The service to use for retrieving and searching for images.')
-
-DEFINE_string('host', socket.gethostname(),
- 'Name of this node. This can be an opaque identifier. It is '
- 'not necessarily a hostname, FQDN, or IP address.')
-
-DEFINE_string('node_availability_zone', 'nova',
- 'availability zone of this node')
-
-DEFINE_string('notification_driver',
- 'nova.notifier.no_op_notifier',
- 'Default driver for sending notifications')
-DEFINE_list('memcached_servers', None,
- 'Memcached servers or None for in process cache.')
-
-DEFINE_string('zone_name', 'nova', 'name of this zone')
-DEFINE_list('zone_capabilities',
- ['hypervisor=xenserver;kvm', 'os=linux;windows'],
- 'Key/Multi-value list representng capabilities of this zone')
-DEFINE_string('build_plan_encryption_key', None,
- '128bit (hex) encryption key for scheduler build plans.')
-DEFINE_string('instance_usage_audit_period', 'month',
- 'time period to generate instance usages for.')
-DEFINE_integer('bandwith_poll_interval', 600,
- 'interval to pull bandwidth usage info')
-
-DEFINE_bool('start_guests_on_host_boot', False,
- 'Whether to restart guests when the host reboots')
-DEFINE_bool('resume_guests_state_on_host_boot', False,
- 'Whether to start guests, that was running before the host reboot')
-DEFINE_string('default_ephemeral_format',
- None,
- 'The default format a ephemeral_volume will be formatted '
- 'with on creation.')
-
-DEFINE_string('root_helper', 'sudo',
- 'Command prefix to use for running commands as root')
-
-DEFINE_string('network_driver', 'nova.network.linux_net',
- 'Driver to use for network creation')
-
-DEFINE_bool('use_ipv6', False, 'use ipv6')
-
-DEFINE_integer('password_length', 12,
- 'Length of generated instance admin passwords')
-
-DEFINE_bool('monkey_patch', False,
- 'Whether to log monkey patching')
-
-DEFINE_list('monkey_patch_modules',
- ['nova.api.ec2.cloud:nova.notifier.api.notify_decorator',
- 'nova.compute.api:nova.notifier.api.notify_decorator'],
- 'Module list representing monkey '
- 'patched module and decorator')
-
-DEFINE_bool('allow_resize_to_same_host', False,
- 'Allow destination machine to match source for resize. Useful'
- ' when testing in environments with only one host machine.')
-
-DEFINE_string('stub_network', False,
- 'Stub network related code')
-
-DEFINE_integer('reclaim_instance_interval', 0,
- 'Interval in seconds for reclaiming deleted instances')
-
-DEFINE_integer('zombie_instance_updated_at_window', 172800,
- 'Limit in seconds that a zombie instance can exist before '
- 'being cleaned up.')
-
-DEFINE_boolean('allow_ec2_admin_api', False, 'Enable/Disable EC2 Admin API')
-
-DEFINE_integer('service_down_time', 60,
- 'maximum time since last check-in for up service')
-DEFINE_string('default_schedule_zone', None,
- 'zone to use when user doesnt specify one')
-DEFINE_list('isolated_images', [], 'Images to run on isolated host')
-DEFINE_list('isolated_hosts', [], 'Host reserved for specific images')
+global_opts = [
+ cfg.StrOpt('my_ip',
+ default=_get_my_ip(),
+ help='host ip address'),
+ cfg.ListOpt('region_list',
+ default=[],
+ help='list of region=fqdn pairs separated by commas'),
+ cfg.StrOpt('connection_type',
+ default=None,
+ help='libvirt, xenapi or fake'),
+ cfg.StrOpt('aws_access_key_id',
+ default='admin',
+ help='AWS Access ID'),
+ cfg.StrOpt('aws_secret_access_key',
+ default='admin',
+ help='AWS Access Key'),
+ cfg.StrOpt('glance_host',
+ default='$my_ip',
+ help='default glance host'),
+ cfg.IntOpt('glance_port',
+ default=9292,
+ help='default glance port'),
+ cfg.ListOpt('glance_api_servers',
+ default=['$glance_host:$glance_port'],
+ help='glance api servers available to nova (host:port)'),
+ cfg.IntOpt('glance_num_retries',
+ default=0,
+ help='Number retries when downloading an image from glance'),
+ cfg.IntOpt('s3_port',
+ default=3333,
+ help='s3 port'),
+ cfg.StrOpt('s3_host',
+ default='$my_ip',
+ help='s3 host (for infrastructure)'),
+ cfg.StrOpt('s3_dmz',
+ default='$my_ip',
+ help='s3 dmz ip (for instances)'),
+ cfg.StrOpt('cert_topic',
+ default='cert',
+ help='the topic cert nodes listen on'),
+ cfg.StrOpt('compute_topic',
+ default='compute',
+ help='the topic compute nodes listen on'),
+ cfg.StrOpt('console_topic',
+ default='console',
+ help='the topic console proxy nodes listen on'),
+ cfg.StrOpt('scheduler_topic',
+ default='scheduler',
+ help='the topic scheduler nodes listen on'),
+ cfg.StrOpt('volume_topic',
+ default='volume',
+ help='the topic volume nodes listen on'),
+ cfg.StrOpt('network_topic',
+ default='network',
+ help='the topic network nodes listen on'),
+ cfg.StrOpt('ajax_console_proxy_topic',
+ default='ajax_proxy',
+ help='the topic ajax proxy nodes listen on'),
+ cfg.StrOpt('ajax_console_proxy_url',
+ default='http://127.0.0.1:8000',
+ help='URL of ajax console proxy, in the form http://host:port'),
+ cfg.IntOpt('ajax_console_proxy_port',
+ default=8000,
+ help='port that ajax_console_proxy binds'),
+ cfg.StrOpt('vsa_topic',
+ default='vsa',
+ help='the topic that nova-vsa service listens on'),
+ cfg.BoolOpt('verbose',
+ default=False,
+ help='show debug output'),
+ cfg.BoolOpt('fake_rabbit',
+ default=False,
+ help='use a fake rabbit'),
+ cfg.BoolOpt('fake_network',
+ default=False,
+ help='should we use fake network devices and addresses'),
+ cfg.StrOpt('rabbit_host',
+ default='localhost',
+ help='rabbit host'),
+ cfg.IntOpt('rabbit_port',
+ default=5672,
+ help='rabbit port'),
+ cfg.BoolOpt('rabbit_use_ssl',
+ default=False,
+ help='connect over SSL'),
+ cfg.StrOpt('rabbit_userid',
+ default='guest',
+ help='rabbit userid'),
+ cfg.StrOpt('rabbit_password',
+ default='guest',
+ help='rabbit password'),
+ cfg.StrOpt('rabbit_virtual_host',
+ default='/',
+ help='rabbit virtual host'),
+ cfg.IntOpt('rabbit_retry_interval',
+ default=1,
+ help='rabbit connection retry interval to start'),
+ cfg.IntOpt('rabbit_retry_backoff',
+ default=2,
+ help='rabbit connection retry backoff in seconds'),
+ cfg.IntOpt('rabbit_max_retries',
+ default=0,
+ help='maximum rabbit connection attempts (0=try forever)'),
+ cfg.StrOpt('control_exchange',
+ default='nova',
+ help='the main exchange to connect to'),
+ cfg.BoolOpt('rabbit_durable_queues',
+ default=False,
+ help='use durable queues'),
+ cfg.ListOpt('enabled_apis',
+ default=['ec2', 'osapi_compute', 'osapi_volume', 'metadata'],
+ help='list of APIs to enable by default'),
+ cfg.StrOpt('ec2_host',
+ default='$my_ip',
+ help='ip of api server'),
+ cfg.StrOpt('ec2_dmz_host',
+ default='$my_ip',
+ help='internal ip of api server'),
+ cfg.IntOpt('ec2_port',
+ default=8773,
+ help='cloud controller port'),
+ cfg.StrOpt('ec2_scheme',
+ default='http',
+ help='prefix for ec2'),
+ cfg.StrOpt('ec2_path',
+ default='/services/Cloud',
+ help='suffix for ec2'),
+ cfg.MultiStrOpt('osapi_compute_extension',
+ default=[
+ 'nova.api.openstack.compute.contrib.standard_extensions'
+ ],
+ help='osapi compute extension to load'),
+ cfg.MultiStrOpt('osapi_volume_extension',
+ default=[
+ 'nova.api.openstack.volume.contrib.standard_extensions'
+ ],
+ help='osapi volume extension to load'),
+ cfg.StrOpt('osapi_scheme',
+ default='http',
+ help='prefix for openstack'),
+ cfg.StrOpt('osapi_path',
+ default='/v1.1/',
+ help='suffix for openstack'),
+ cfg.IntOpt('osapi_max_limit',
+ default=1000,
+ help='max number of items returned in a collection response'),
+ cfg.StrOpt('metadata_host',
+ default='$my_ip',
+ help='ip of metadata server'),
+ cfg.IntOpt('metadata_port',
+ default=8775,
+ help='Metadata API port'),
+ cfg.StrOpt('default_project',
+ default='openstack',
+ help='default project for openstack'),
+ cfg.StrOpt('default_image',
+ default='ami-11111',
+ help='default image to use, testing only'),
+ cfg.StrOpt('default_instance_type',
+ default='m1.small',
+ help='default instance type to use, testing only'),
+ cfg.StrOpt('null_kernel',
+ default='nokernel',
+ help='kernel image that indicates not to use a kernel, but to '
+ 'use a raw disk image instead'),
+ cfg.StrOpt('vpn_image_id',
+ default='0',
+ help='image id for cloudpipe vpn server'),
+ cfg.StrOpt('vpn_key_suffix',
+ default='-vpn',
+ help='Suffix to add to project name for vpn key and secgroups'),
+ cfg.IntOpt('auth_token_ttl',
+ default=3600,
+ help='Seconds for auth tokens to linger'),
+ cfg.StrOpt('state_path',
+ default=os.path.join(os.path.dirname(__file__), '../'),
+ help="Top-level directory for maintaining nova's state"),
+ cfg.StrOpt('lock_path',
+ default=os.path.join(os.path.dirname(__file__), '../'),
+ help='Directory for lock files'),
+ cfg.StrOpt('logdir',
+ default=None,
+ help='output to a per-service log file in named directory'),
+ cfg.StrOpt('logfile_mode',
+ default='0644',
+ help='Default file mode of the logs.'),
+ cfg.StrOpt('sqlite_db',
+ default='nova.sqlite',
+ help='file name for sqlite'),
+ cfg.BoolOpt('sqlite_synchronous',
+ default=True,
+ help='Synchronous mode for sqlite'),
+ cfg.StrOpt('sql_connection',
+ default='sqlite:///$state_path/$sqlite_db',
+ help='connection string for sql database'),
+ cfg.IntOpt('sql_idle_timeout',
+ default=3600,
+ help='timeout for idle sql database connections'),
+ cfg.IntOpt('sql_max_retries',
+ default=12,
+ help='sql connection attempts'),
+ cfg.IntOpt('sql_retry_interval',
+ default=10,
+ help='sql connection retry interval'),
+ cfg.StrOpt('compute_manager',
+ default='nova.compute.manager.ComputeManager',
+ help='Manager for compute'),
+ cfg.StrOpt('console_manager',
+ default='nova.console.manager.ConsoleProxyManager',
+ help='Manager for console proxy'),
+ cfg.StrOpt('cert_manager',
+ default='nova.cert.manager.CertManager',
+ help='Manager for cert'),
+ cfg.StrOpt('instance_dns_manager',
+ default='nova.network.dns_driver.DNSDriver',
+ help='DNS Manager for instance IPs'),
+ cfg.StrOpt('instance_dns_domain',
+ default='',
+ help='DNS Zone for instance IPs'),
+ cfg.StrOpt('floating_ip_dns_manager',
+ default='nova.network.dns_driver.DNSDriver',
+ help='DNS Manager for floating IPs'),
+ cfg.StrOpt('network_manager',
+ default='nova.network.manager.VlanManager',
+ help='Manager for network'),
+ cfg.StrOpt('volume_manager',
+ default='nova.volume.manager.VolumeManager',
+ help='Manager for volume'),
+ cfg.StrOpt('scheduler_manager',
+ default='nova.scheduler.manager.SchedulerManager',
+ help='Manager for scheduler'),
+ cfg.StrOpt('vsa_manager',
+ default='nova.vsa.manager.VsaManager',
+ help='Manager for vsa'),
+ cfg.StrOpt('vc_image_name',
+ default='vc_image',
+ help='the VC image ID (for a VC image that exists in Glance)'),
+ cfg.StrOpt('default_vsa_instance_type',
+ default='m1.small',
+ help='default instance type for VSA instances'),
+ cfg.IntOpt('max_vcs_in_vsa',
+ default=32,
+ help='maxinum VCs in a VSA'),
+ cfg.IntOpt('vsa_part_size_gb',
+ default=100,
+ help='default partition size for shared capacity'),
+ cfg.StrOpt('firewall_driver',
+ default='nova.virt.libvirt.firewall.IptablesFirewallDriver',
+ help='Firewall driver (defaults to iptables)'),
+ cfg.StrOpt('image_service',
+ default='nova.image.glance.GlanceImageService',
+ help='The service to use for retrieving and searching images.'),
+ cfg.StrOpt('host',
+ default=socket.gethostname(),
+ help='Name of this node. This can be an opaque identifier. '
+ 'It is not necessarily a hostname, FQDN, or IP address.'),
+ cfg.StrOpt('node_availability_zone',
+ default='nova',
+ help='availability zone of this node'),
+ cfg.StrOpt('notification_driver',
+ default='nova.notifier.no_op_notifier',
+ help='Default driver for sending notifications'),
+ cfg.ListOpt('memcached_servers',
+ default=None,
+ help='Memcached servers or None for in process cache.'),
+ cfg.StrOpt('zone_name',
+ default='nova',
+ help='name of this zone'),
+ cfg.ListOpt('zone_capabilities',
+ default=['hypervisor=xenserver;kvm', 'os=linux;windows'],
+ help='Key/Multi-value list with the capabilities of the zone'),
+ cfg.StrOpt('build_plan_encryption_key',
+ default=None,
+ help='128bit (hex) encryption key for scheduler build plans.'),
+ cfg.StrOpt('instance_usage_audit_period',
+ default='month',
+ help='time period to generate instance usages for.'),
+ cfg.IntOpt('bandwith_poll_interval',
+ default=600,
+ help='interval to pull bandwidth usage info'),
+ cfg.BoolOpt('start_guests_on_host_boot',
+ default=False,
+ help='Whether to restart guests when the host reboots'),
+ cfg.BoolOpt('resume_guests_state_on_host_boot',
+ default=False,
+ help='Whether to start guests that were running before the '
+ 'host rebooted'),
+ cfg.StrOpt('default_ephemeral_format',
+ default=None,
+ help='The default format a ephemeral_volume will be '
+ 'formatted with on creation.'),
+ cfg.StrOpt('root_helper',
+ default='sudo',
+ help='Command prefix to use for running commands as root'),
+ cfg.StrOpt('network_driver',
+ default='nova.network.linux_net',
+ help='Driver to use for network creation'),
+ cfg.BoolOpt('use_ipv6',
+ default=False,
+ help='use ipv6'),
+ cfg.IntOpt('password_length',
+ default=12,
+ help='Length of generated instance admin passwords'),
+ cfg.BoolOpt('monkey_patch',
+ default=False,
+ help='Whether to log monkey patching'),
+ cfg.ListOpt('monkey_patch_modules',
+ default=[
+ 'nova.api.ec2.cloud:nova.notifier.api.notify_decorator',
+ 'nova.compute.api:nova.notifier.api.notify_decorator'
+ ],
+ help='List of modules/decorators to monkey patch'),
+ cfg.BoolOpt('allow_resize_to_same_host',
+ default=False,
+ help='Allow destination machine to match source for resize. '
+ 'Useful when testing in single-host environments.'),
+ cfg.StrOpt('stub_network',
+ default=False,
+ help='Stub network related code'),
+ cfg.IntOpt('reclaim_instance_interval',
+ default=0,
+ help='Interval in seconds for reclaiming deleted instances'),
+ cfg.IntOpt('zombie_instance_updated_at_window',
+ default=172800,
+ help='Number of seconds zombie instances are cleaned up.'),
+ cfg.BoolOpt('allow_ec2_admin_api',
+ default=False,
+ help='Enable/Disable EC2 Admin API'),
+ cfg.IntOpt('service_down_time',
+ default=60,
+ help='maximum time since last check-in for up service'),
+ cfg.StrOpt('default_schedule_zone',
+ default=None,
+ help='zone to use when user doesnt specify one'),
+ cfg.ListOpt('isolated_images',
+ default=[],
+ help='Images to run on isolated host'),
+ cfg.ListOpt('isolated_hosts',
+ default=[],
+ help='Host reserved for specific images'),
+ ]
+
+FLAGS.add_options(global_opts)
diff --git a/nova/image/s3.py b/nova/image/s3.py
index e73364a42..ee11c163c 100644
--- a/nova/image/s3.py
+++ b/nova/image/s3.py
@@ -31,6 +31,7 @@ import eventlet
from nova import rpc
import nova.db.api
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import image
@@ -40,13 +41,21 @@ from nova.api.ec2 import ec2utils
LOG = logging.getLogger("nova.image.s3")
+
+s3_opts = [
+ cfg.StrOpt('image_decryption_dir',
+ default='/tmp',
+ help='parent dir for tempdir used for image decryption'),
+ cfg.StrOpt('s3_access_key',
+ default='notchecked',
+ help='access key to use for s3 server for images'),
+ cfg.StrOpt('s3_secret_key',
+ default='notchecked',
+ help='secret key to use for s3 server for images'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('image_decryption_dir', '/tmp',
- 'parent dir for tempdir used for image decryption')
-flags.DEFINE_string('s3_access_key', 'notchecked',
- 'access key to use for s3 server for images')
-flags.DEFINE_string('s3_secret_key', 'notchecked',
- 'secret key to use for s3 server for images')
+FLAGS.add_options(s3_opts)
class S3ImageService(object):
diff --git a/nova/ipv6/api.py b/nova/ipv6/api.py
index da003645a..5931b8ba6 100644
--- a/nova/ipv6/api.py
+++ b/nova/ipv6/api.py
@@ -14,14 +14,18 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import flags
from nova import utils
+ipv6_backend_opt = \
+ cfg.StrOpt('ipv6_backend',
+ default='rfc2462',
+ help='Backend to use for IPv6 generation')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('ipv6_backend',
- 'rfc2462',
- 'Backend to use for IPv6 generation')
+FLAGS.add_option(ipv6_backend_opt)
def reset_backend():
diff --git a/nova/log.py b/nova/log.py
index 8400f7000..8052f79a8 100644
--- a/nova/log.py
+++ b/nova/log.py
@@ -38,40 +38,52 @@ import sys
import traceback
import nova
+from nova.common import cfg
from nova import flags
from nova import local
from nova import version
-FLAGS = flags.FLAGS
-flags.DEFINE_string('logging_context_format_string',
- '%(asctime)s %(levelname)s %(name)s '
- '[%(request_id)s %(user_id)s '
- '%(project_id)s] %(message)s',
- 'format string to use for log messages with context')
-flags.DEFINE_string('logging_default_format_string',
- '%(asctime)s %(levelname)s %(name)s [-] '
- '%(message)s',
- 'format string to use for log messages without context')
-flags.DEFINE_string('logging_debug_format_suffix',
- 'from (pid=%(process)d) %(funcName)s'
- ' %(pathname)s:%(lineno)d',
- 'data to append to log format when level is DEBUG')
-flags.DEFINE_string('logging_exception_prefix',
- '(%(name)s): TRACE: ',
- 'prefix each line of exception output with this format')
-flags.DEFINE_list('default_log_levels',
- ['amqplib=WARN',
- 'sqlalchemy=WARN',
- 'boto=WARN',
- 'suds=INFO',
- 'eventlet.wsgi.server=WARN'],
- 'list of logger=LEVEL pairs')
-flags.DEFINE_bool('use_syslog', False, 'output to syslog')
-flags.DEFINE_bool('publish_errors', False, 'publish error events')
-flags.DEFINE_string('logfile', None, 'output to named file')
-flags.DEFINE_bool('use_stderr', True, 'log to standard error')
+log_opts = [
+ cfg.StrOpt('logging_context_format_string',
+ default='%(asctime)s %(levelname)s %(name)s [%(request_id)s '
+ '%(user_id)s %(project_id)s] %(message)s',
+ help='format string to use for log messages with context'),
+ cfg.StrOpt('logging_default_format_string',
+ default='%(asctime)s %(levelname)s %(name)s [-] %(message)s',
+ help='format string to use for log messages without context'),
+ cfg.StrOpt('logging_debug_format_suffix',
+ default='from (pid=%(process)d) %(funcName)s '
+ '%(pathname)s:%(lineno)d',
+ help='data to append to log format when level is DEBUG'),
+ cfg.StrOpt('logging_exception_prefix',
+ default='(%(name)s): TRACE: ',
+ help='prefix each line of exception output with this format'),
+ cfg.ListOpt('default_log_levels',
+ default=[
+ 'amqplib=WARN',
+ 'sqlalchemy=WARN',
+ 'boto=WARN',
+ 'suds=INFO',
+ 'eventlet.wsgi.server=WARN'
+ ],
+ help='list of logger=LEVEL pairs'),
+ cfg.BoolOpt('use_syslog',
+ default=False,
+ help='output to syslog'),
+ cfg.BoolOpt('publish_errors',
+ default=False,
+ help='publish error events'),
+ cfg.StrOpt('logfile',
+ default=None,
+ help='output to named file'),
+ cfg.BoolOpt('use_stderr',
+ default=True,
+ help='log to standard error'),
+ ]
+FLAGS = flags.FLAGS
+FLAGS.add_options(log_opts)
# A list of things we want to replicate from logging.
# levels
diff --git a/nova/network/ldapdns.py b/nova/network/ldapdns.py
index a622106e2..a5491a259 100644
--- a/nova/network/ldapdns.py
+++ b/nova/network/ldapdns.py
@@ -19,6 +19,7 @@ import tempfile
import time
from nova.auth import fakeldap
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -26,40 +27,44 @@ from nova import log as logging
LOG = logging.getLogger("nova.network.manager")
-flags.DEFINE_string('ldap_dns_url',
- 'ldap://ldap.example.com:389',
- 'URL for ldap server which will store dns entries')
-flags.DEFINE_string('ldap_dns_user',
- 'uid=admin,ou=people,dc=example,dc=org',
- 'user for ldap DNS')
-flags.DEFINE_string('ldap_dns_password',
- 'password',
- 'password for ldap DNS')
-flags.DEFINE_string('ldap_dns_soa_hostmaster',
- 'hostmaster@example.org',
- 'Hostmaster for ldap dns driver Statement of Authority')
-flags.DEFINE_multistring('ldap_dns_servers',
- '[dns.example.org]',
- 'DNS Servers for ldap dns driver')
-flags.DEFINE_string('ldap_dns_base_dn',
- 'ou=hosts,dc=example,dc=org',
- 'Base DN for DNS entries in ldap')
-flags.DEFINE_string('ldap_dns_soa_refresh',
- '1800',
- 'Refresh interval (in seconds) for ldap dns driver '
- 'Statement of Authority')
-flags.DEFINE_string('ldap_dns_soa_retry',
- '3600',
- 'Retry interval (in seconds) for ldap dns driver '
- 'Statement of Authority')
-flags.DEFINE_string('ldap_dns_soa_expiry',
- '86400',
- 'Expiry interval (in seconds) for ldap dns driver '
- 'Statement of Authority')
-flags.DEFINE_string('ldap_dns_soa_minimum',
- '7200',
- 'Minimum interval (in seconds) for ldap dns driver '
- 'Statement of Authority')
+ldap_dns_opts = [
+ cfg.StrOpt('ldap_dns_url',
+ default='ldap://ldap.example.com:389',
+ help='URL for ldap server which will store dns entries'),
+ cfg.StrOpt('ldap_dns_user',
+ default='uid=admin,ou=people,dc=example,dc=org',
+ help='user for ldap DNS'),
+ cfg.StrOpt('ldap_dns_password',
+ default='password',
+ help='password for ldap DNS'),
+ cfg.StrOpt('ldap_dns_soa_hostmaster',
+ default='hostmaster@example.org',
+ help='Hostmaster for ldap dns driver Statement of Authority'),
+ cfg.MultiStrOpt('ldap_dns_servers',
+ default='[dns.example.org]',
+ help='DNS Servers for ldap dns driver'),
+ cfg.StrOpt('ldap_dns_base_dn',
+ default='ou=hosts,dc=example,dc=org',
+ help='Base DN for DNS entries in ldap'),
+ cfg.StrOpt('ldap_dns_soa_refresh',
+ default='1800',
+ help='Refresh interval (in seconds) for ldap dns driver '
+ 'Statement of Authority'),
+ cfg.StrOpt('ldap_dns_soa_retry',
+ default='3600',
+ help='Retry interval (in seconds) for ldap dns driver '
+ 'Statement of Authority'),
+ cfg.StrOpt('ldap_dns_soa_expiry',
+ default='86400',
+ help='Expiry interval (in seconds) for ldap dns driver '
+ 'Statement of Authority'),
+ cfg.StrOpt('ldap_dns_soa_minimum',
+ default='7200',
+ help='Minimum interval (in seconds) for ldap dns driver '
+ 'Statement of Authority'),
+ ]
+
+flags.FLAGS.add_options(ldap_dns_opts)
def utf8(instring):
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 996f89a5f..56d07f983 100755
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -24,6 +24,7 @@ import inspect
import netaddr
import os
+from nova.common import cfg
from nova import db
from nova import exception
from nova import flags
@@ -39,37 +40,56 @@ def _bin_file(script):
return os.path.abspath(os.path.join(__file__, '../../../bin', script))
+linux_net_opts = [
+ cfg.StrOpt('dhcpbridge_flagfile',
+ default='/etc/nova/nova-dhcpbridge.conf',
+ help='location of flagfile for dhcpbridge'),
+ cfg.StrOpt('networks_path',
+ default='$state_path/networks',
+ help='Location to keep network config files'),
+ cfg.StrOpt('public_interface',
+ default='eth0',
+ help='Interface for public IP addresses'),
+ cfg.StrOpt('network_device_mtu',
+ default=None,
+ help='MTU setting for vlan'),
+ cfg.StrOpt('dhcpbridge',
+ default=_bin_file('nova-dhcpbridge'),
+ help='location of nova-dhcpbridge'),
+ cfg.StrOpt('routing_source_ip',
+ default='$my_ip',
+ help='Public IP of network host'),
+ cfg.IntOpt('dhcp_lease_time',
+ default=120,
+ help='Lifetime of a DHCP lease in seconds'),
+ cfg.StrOpt('dns_server',
+ default=None,
+ help='if set, uses specific dns server for dnsmasq'),
+ cfg.StrOpt('dmz_cidr',
+ default='10.128.0.0/24',
+ help='dmz range that should be accepted'),
+ cfg.StrOpt('dnsmasq_config_file',
+ default="",
+ help='Override the default dnsmasq settings with this file'),
+ cfg.StrOpt('linuxnet_interface_driver',
+ default='nova.network.linux_net.LinuxBridgeInterfaceDriver',
+ help='Driver used to create ethernet devices.'),
+ cfg.StrOpt('linuxnet_ovs_integration_bridge',
+ default='br-int',
+ help='Name of Open vSwitch bridge used with linuxnet'),
+ cfg.BoolOpt('send_arp_for_ha',
+ default=False,
+ help='send gratuitous ARPs for HA setup'),
+ cfg.BoolOpt('use_single_default_gateway',
+ default=False,
+ help='Use single default gateway. Only first nic of vm will '
+ 'get default gateway from dhcp server'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('dhcpbridge_flagfile',
- '/etc/nova/nova-dhcpbridge.conf',
- 'location of flagfile for dhcpbridge')
-flags.DEFINE_string('networks_path', '$state_path/networks',
- 'Location to keep network config files')
-flags.DEFINE_string('public_interface', 'eth0',
- 'Interface for public IP addresses')
-flags.DEFINE_string('network_device_mtu', None, 'MTU setting for vlan')
-flags.DEFINE_string('dhcpbridge', _bin_file('nova-dhcpbridge'),
- 'location of nova-dhcpbridge')
-flags.DEFINE_string('routing_source_ip', '$my_ip',
- 'Public IP of network host')
-flags.DEFINE_integer('dhcp_lease_time', 120,
- 'Lifetime of a DHCP lease in seconds')
-flags.DEFINE_string('dns_server', None,
- 'if set, uses specific dns server for dnsmasq')
-flags.DEFINE_string('dmz_cidr', '10.128.0.0/24',
- 'dmz range that should be accepted')
-flags.DEFINE_string('dnsmasq_config_file', "",
- 'Override the default dnsmasq settings with this file')
-flags.DEFINE_string('linuxnet_interface_driver',
- 'nova.network.linux_net.LinuxBridgeInterfaceDriver',
- 'Driver used to create ethernet devices.')
-flags.DEFINE_string('linuxnet_ovs_integration_bridge',
- 'br-int', 'Name of Open vSwitch bridge used with linuxnet')
-flags.DEFINE_bool('send_arp_for_ha', False,
- 'send gratuitous ARPs for HA setup')
-flags.DEFINE_bool('use_single_default_gateway',
- False, 'Use single default gateway. Only first nic of vm'
- ' will get default gateway from dhcp server')
+FLAGS.add_options(linux_net_opts)
+
+
binary_name = os.path.basename(inspect.stack()[-1][1])
diff --git a/nova/network/manager.py b/nova/network/manager.py
index f1a07cd81..e364db9e5 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -56,6 +56,7 @@ import socket
from eventlet import greenpool
import netaddr
+from nova.common import cfg
from nova.compute import api as compute_api
from nova.compute import instance_types
from nova import context
@@ -75,54 +76,89 @@ from nova import rpc
LOG = logging.getLogger("nova.network.manager")
+network_opts = [
+ cfg.StrOpt('flat_network_bridge',
+ default=None,
+ help='Bridge for simple network instances'),
+ cfg.StrOpt('flat_network_dns',
+ default='8.8.4.4',
+ help='Dns for simple network'),
+ cfg.BoolOpt('flat_injected',
+ default=False,
+ help='Whether to attempt to inject network setup into guest'),
+ cfg.StrOpt('flat_interface',
+ default=None,
+ help='FlatDhcp will bridge into this interface if set'),
+ cfg.IntOpt('vlan_start',
+ default=100,
+ help='First VLAN for private networks'),
+ cfg.StrOpt('vlan_interface',
+ default=None,
+ help='vlans will bridge into this interface if set'),
+ cfg.IntOpt('num_networks',
+ default=1,
+ help='Number of networks to support'),
+ cfg.StrOpt('vpn_ip',
+ default='$my_ip',
+ help='Public IP for the cloudpipe VPN servers'),
+ cfg.IntOpt('vpn_start',
+ default=1000,
+ help='First Vpn port for private networks'),
+ cfg.BoolOpt('multi_host',
+ default=False,
+ help='Default value for multi_host in networks'),
+ cfg.IntOpt('network_size',
+ default=256,
+ help='Number of addresses in each private subnet'),
+ cfg.StrOpt('floating_range',
+ default='4.4.4.0/24',
+ help='Floating IP address block'),
+ cfg.StrOpt('default_floating_pool',
+ default='nova',
+ help='Default pool for floating ips'),
+ cfg.StrOpt('fixed_range',
+ default='10.0.0.0/8',
+ help='Fixed IP address block'),
+ cfg.StrOpt('fixed_range_v6',
+ default='fd00::/48',
+ help='Fixed IPv6 address block'),
+ cfg.StrOpt('gateway',
+ default=None,
+ help='Default IPv4 gateway'),
+ cfg.StrOpt('gateway_v6',
+ default=None,
+ help='Default IPv6 gateway'),
+ cfg.IntOpt('cnt_vpn_clients',
+ default=0,
+ help='Number of addresses reserved for vpn clients'),
+ cfg.BoolOpt('update_dhcp_on_disassociate',
+ default=False,
+ help='Whether to update dhcp when fixed_ip is disassociated'),
+ cfg.IntOpt('fixed_ip_disassociate_timeout',
+ default=600,
+ help='Seconds after which a deallocated ip is disassociated'),
+ cfg.IntOpt('create_unique_mac_address_attempts',
+ default=5,
+ help='Number of attempts to create unique mac address'),
+ cfg.BoolOpt('auto_assign_floating_ip',
+ default=False,
+ help='Autoassigning floating ip to VM'),
+ cfg.StrOpt('network_host',
+ default=socket.gethostname(),
+ help='Network host to use for ip allocation in flat modes'),
+ cfg.BoolOpt('fake_call',
+ default=False,
+ help='If True, skip using the queue and make local calls'),
+ cfg.BoolOpt('force_dhcp_release',
+ default=False,
+ help='If True, send a dhcp release on instance termination'),
+ cfg.StrOpt('dhcp_domain',
+ default='novalocal',
+ help='domain to use for building the hostnames'),
+ ]
FLAGS = flags.FLAGS
-flags.DEFINE_string('flat_network_bridge', None,
- 'Bridge for simple network instances')
-flags.DEFINE_string('flat_network_dns', '8.8.4.4',
- 'Dns for simple network')
-flags.DEFINE_bool('flat_injected', False,
- 'Whether to attempt to inject network setup into guest')
-flags.DEFINE_string('flat_interface', None,
- 'FlatDhcp will bridge into this interface if set')
-flags.DEFINE_integer('vlan_start', 100, 'First VLAN for private networks')
-flags.DEFINE_string('vlan_interface', None,
- 'vlans will bridge into this interface if set')
-flags.DEFINE_integer('num_networks', 1, 'Number of networks to support')
-flags.DEFINE_string('vpn_ip', '$my_ip',
- 'Public IP for the cloudpipe VPN servers')
-flags.DEFINE_integer('vpn_start', 1000, 'First Vpn port for private networks')
-flags.DEFINE_bool('multi_host', False,
- 'Default value for multi_host in networks')
-flags.DEFINE_integer('network_size', 256,
- 'Number of addresses in each private subnet')
-flags.DEFINE_string('floating_range', '4.4.4.0/24',
- 'Floating IP address block')
-flags.DEFINE_string('default_floating_pool', 'nova',
- 'Default pool for floating ips')
-flags.DEFINE_string('fixed_range', '10.0.0.0/8', 'Fixed IP address block')
-flags.DEFINE_string('fixed_range_v6', 'fd00::/48', 'Fixed IPv6 address block')
-flags.DEFINE_string('gateway', None, 'Default IPv4 gateway')
-flags.DEFINE_string('gateway_v6', None, 'Default IPv6 gateway')
-flags.DEFINE_integer('cnt_vpn_clients', 0,
- 'Number of addresses reserved for vpn clients')
-flags.DEFINE_bool('update_dhcp_on_disassociate', False,
- 'Whether to update dhcp when fixed_ip is disassociated')
-flags.DEFINE_integer('fixed_ip_disassociate_timeout', 600,
- 'Seconds after which a deallocated ip is disassociated')
-flags.DEFINE_integer('create_unique_mac_address_attempts', 5,
- 'Number of attempts to create unique mac address')
-flags.DEFINE_bool('auto_assign_floating_ip', False,
- 'Autoassigning floating ip to VM')
-flags.DEFINE_string('network_host', socket.gethostname(),
- 'Network host to use for ip allocation in flat modes')
-flags.DEFINE_bool('fake_call', False,
- 'If True, skip using the queue and make local calls')
-flags.DEFINE_bool('force_dhcp_release', False,
- 'If True, send a dhcp release on instance termination')
-flags.DEFINE_string('dhcp_domain',
- 'novalocal',
- 'domain to use for building the hostnames')
+FLAGS.add_options(network_opts)
class AddressAlreadyAllocated(exception.Error):
diff --git a/nova/network/quantum/manager.py b/nova/network/quantum/manager.py
index 4fc6f379e..e9a059d4b 100644
--- a/nova/network/quantum/manager.py
+++ b/nova/network/quantum/manager.py
@@ -19,6 +19,7 @@ import time
from netaddr import IPNetwork, IPAddress
+from nova.common import cfg
from nova.compute import instance_types
from nova import context
from nova import db
@@ -30,26 +31,30 @@ from nova.network.quantum import quantum_connection
from nova.network.quantum import melange_ipam_lib
from nova import utils
-LOG = logging.getLogger("nova.network.quantum.manager")
-
-FLAGS = flags.FLAGS
-
-flags.DEFINE_string('quantum_ipam_lib',
- 'nova.network.quantum.nova_ipam_lib',
- "Indicates underlying IP address management library")
-# TODO(Vek): Eventually, this needs to mean more than just using
-# Melange for assignment of MAC addresses (with an
-# appropriate flag name change, of course), but this is all
-# it does right now
-flags.DEFINE_bool('use_melange_mac_generation', False,
- "Use Melange for assignment of MAC addresses")
+LOG = logging.getLogger("nova.network.quantum.manager")
-flags.DEFINE_bool('quantum_use_dhcp', False,
- 'Whether or not to enable DHCP for networks')
+quantum_opts = [
+ cfg.StrOpt('quantum_ipam_lib',
+ default='nova.network.quantum.nova_ipam_lib',
+ help="Indicates underlying IP address management library"),
+ # TODO(Vek): Eventually, this needs to mean more than just using
+ # Melange for assignment of MAC addresses (with an
+ # appropriate flag name change, of course), but this is all
+ # it does right now
+ cfg.BoolOpt('use_melange_mac_generation',
+ default=False,
+ help="Use Melange for assignment of MAC addresses"),
+ cfg.BoolOpt('quantum_use_dhcp',
+ default=False,
+ help='Whether or not to enable DHCP for networks'),
+ cfg.BoolOpt('quantum_use_port_security',
+ default=False,
+ help='Whether or not to enable port security'),
+ ]
-flags.DEFINE_bool('quantum_use_port_security', False,
- 'Whether or not to enable port security')
+FLAGS = flags.FLAGS
+FLAGS.add_options(quantum_opts)
class QuantumManager(manager.FloatingIP, manager.FlatManager):
diff --git a/nova/network/quantum/melange_connection.py b/nova/network/quantum/melange_connection.py
index a336f9a7c..17a176e82 100644
--- a/nova/network/quantum/melange_connection.py
+++ b/nova/network/quantum/melange_connection.py
@@ -20,18 +20,21 @@ import socket
import urllib
import json
+from nova.common import cfg
from nova import flags
-FLAGS = flags.FLAGS
-
-flags.DEFINE_string('melange_host',
- '127.0.0.1',
- 'HOST for connecting to melange')
+melange_opts = [
+ cfg.StrOpt('melange_host',
+ default='127.0.0.1',
+ help='HOST for connecting to melange'),
+ cfg.StrOpt('melange_port',
+ default='9898',
+ help='PORT for connecting to melange'),
+ ]
-flags.DEFINE_string('melange_port',
- '9898',
- 'PORT for connecting to melange')
+FLAGS = flags.FLAGS
+FLAGS.add_options(melange_opts)
json_content_type = {'Content-type': "application/json"}
diff --git a/nova/network/quantum/quantum_connection.py b/nova/network/quantum/quantum_connection.py
index aa2a30325..914b816d1 100644
--- a/nova/network/quantum/quantum_connection.py
+++ b/nova/network/quantum/quantum_connection.py
@@ -15,25 +15,28 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova.network.quantum import client as quantum_client
LOG = logging.getLogger("nova.network.quantum.quantum_connection")
-FLAGS = flags.FLAGS
-
-flags.DEFINE_string('quantum_connection_host',
- '127.0.0.1',
- 'HOST for connecting to quantum')
-flags.DEFINE_string('quantum_connection_port',
- '9696',
- 'PORT for connecting to quantum')
+quantum_opts = [
+ cfg.StrOpt('quantum_connection_host',
+ default='127.0.0.1',
+ help='HOST for connecting to quantum'),
+ cfg.StrOpt('quantum_connection_port',
+ default='9696',
+ help='PORT for connecting to quantum'),
+ cfg.StrOpt('quantum_default_tenant_id',
+ default="default",
+ help='Default tenant id when creating quantum networks'),
+ ]
-flags.DEFINE_string('quantum_default_tenant_id',
- "default",
- 'Default tenant id when creating quantum networks')
+FLAGS = flags.FLAGS
+FLAGS.add_options(quantum_opts)
class QuantumClientConnection(object):
diff --git a/nova/notifier/api.py b/nova/notifier/api.py
index 043838536..50730cb0f 100644
--- a/nova/notifier/api.py
+++ b/nova/notifier/api.py
@@ -15,19 +15,25 @@
import uuid
+from nova.common import cfg
from nova import flags
from nova import utils
from nova import log as logging
-LOG = logging.getLogger('nova.exception')
-FLAGS = flags.FLAGS
+LOG = logging.getLogger('nova.exception')
-flags.DEFINE_string('default_notification_level', 'INFO',
- 'Default notification level for outgoing notifications')
-flags.DEFINE_string('default_publisher_id', FLAGS.host,
- 'Default publisher_id for outgoing notifications')
+notifier_opts = [
+ cfg.StrOpt('default_notification_level',
+ default='INFO',
+ help='Default notification level for outgoing notifications'),
+ cfg.StrOpt('default_publisher_id',
+ default='$host',
+ help='Default publisher_id for outgoing notifications'),
+ ]
+FLAGS = flags.FLAGS
+FLAGS.add_options(notifier_opts)
WARN = 'WARN'
INFO = 'INFO'
diff --git a/nova/notifier/list_notifier.py b/nova/notifier/list_notifier.py
index 62847c85f..29c6ba720 100644
--- a/nova/notifier/list_notifier.py
+++ b/nova/notifier/list_notifier.py
@@ -13,16 +13,20 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova import utils
from nova.exception import ClassNotFound
-flags.DEFINE_multistring('list_notifier_drivers',
- ['nova.notifier.no_op_notifier'],
- 'List of drivers to send notifications')
+
+list_notifier_drivers_opt = \
+ cfg.MultiStrOpt('list_notifier_drivers',
+ default=['nova.notifier.no_op_notifier'],
+ help='List of drivers to send notifications')
FLAGS = flags.FLAGS
+FLAGS.add_option(list_notifier_drivers_opt)
LOG = logging.getLogger('nova.notifier.list_notifier')
diff --git a/nova/notifier/rabbit_notifier.py b/nova/notifier/rabbit_notifier.py
index 64e03697a..c88f76cb0 100644
--- a/nova/notifier/rabbit_notifier.py
+++ b/nova/notifier/rabbit_notifier.py
@@ -16,14 +16,18 @@
import nova.context
+from nova.common import cfg
from nova import flags
from nova import rpc
-FLAGS = flags.FLAGS
+notification_topic_opt = \
+ cfg.StrOpt('notification_topic',
+ default='notifications',
+ help='RabbitMQ topic used for Nova notifications')
-flags.DEFINE_string('notification_topic', 'notifications',
- 'RabbitMQ topic used for Nova notifications')
+FLAGS = flags.FLAGS
+FLAGS.add_option(notification_topic_opt)
def notify(message):
diff --git a/nova/objectstore/s3server.py b/nova/objectstore/s3server.py
index 678a2219b..1ba8d44cf 100644
--- a/nova/objectstore/s3server.py
+++ b/nova/objectstore/s3server.py
@@ -44,15 +44,20 @@ import urllib
import routes
import webob
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova import utils
from nova import wsgi
+buckets_path_opt = \
+ cfg.StrOpt('buckets_path',
+ default='$state_path/buckets',
+ help='path to s3 buckets')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('buckets_path', '$state_path/buckets',
- 'path to s3 buckets')
+FLAGS.add_option(buckets_path_opt)
def get_wsgi_server():
diff --git a/nova/policy.py b/nova/policy.py
index 22551d6a4..ccf1f4624 100644
--- a/nova/policy.py
+++ b/nova/policy.py
@@ -17,16 +17,24 @@
"""Policy Engine For Nova"""
+from nova.common import cfg
from nova.common import policy
from nova import exception
from nova import flags
from nova import utils
+
+policy_opts = [
+ cfg.StrOpt('policy_file',
+ default='policy.json',
+ help=_('JSON file representing policy')),
+ cfg.StrOpt('policy_default_rule',
+ default='default',
+ help=_('Rule checked when requested rule is not found')),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('policy_file', 'policy.json',
- _('JSON file representing policy'))
-flags.DEFINE_string('policy_default_rule', 'default',
- _('Rule checked when requested rule is not found'))
+FLAGS.add_options(policy_opts)
_POLICY_PATH = None
_POLICY_CACHE = {}
diff --git a/nova/quota.py b/nova/quota.py
index 122959c58..95fa317d5 100644
--- a/nova/quota.py
+++ b/nova/quota.py
@@ -18,31 +18,46 @@
"""Quotas for instances, volumes, and floating ips."""
+from nova.common import cfg
from nova import db
from nova import flags
+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_volumes',
+ default=10,
+ help='number of volumes allowed per project'),
+ cfg.IntOpt('quota_gigabytes',
+ default=1000,
+ help='number of volume gigabytes allowed per project'),
+ cfg.IntOpt('quota_floating_ips',
+ default=10,
+ help='number of floating ips allowed per project'),
+ cfg.IntOpt('quota_metadata_items',
+ default=128,
+ help='number of metadata items allowed per instance'),
+ cfg.IntOpt('quota_max_injected_files',
+ default=5,
+ help='number of injected files allowed'),
+ cfg.IntOpt('quota_max_injected_file_content_bytes',
+ default=10 * 1024,
+ help='number of bytes allowed per injected file'),
+ cfg.IntOpt('quota_max_injected_file_path_bytes',
+ default=255,
+ help='number of bytes allowed per injected file path'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('quota_instances', 10,
- 'number of instances allowed per project')
-flags.DEFINE_integer('quota_cores', 20,
- 'number of instance cores allowed per project')
-flags.DEFINE_integer('quota_ram', 50 * 1024,
- 'megabytes of instance ram allowed per project')
-flags.DEFINE_integer('quota_volumes', 10,
- 'number of volumes allowed per project')
-flags.DEFINE_integer('quota_gigabytes', 1000,
- 'number of volume gigabytes allowed per project')
-flags.DEFINE_integer('quota_floating_ips', 10,
- 'number of floating ips allowed per project')
-flags.DEFINE_integer('quota_metadata_items', 128,
- 'number of metadata items allowed per instance')
-flags.DEFINE_integer('quota_max_injected_files', 5,
- 'number of injected files allowed')
-flags.DEFINE_integer('quota_max_injected_file_content_bytes', 10 * 1024,
- 'number of bytes allowed per injected file')
-flags.DEFINE_integer('quota_max_injected_file_path_bytes', 255,
- 'number of bytes allowed per injected file path')
+FLAGS.add_options(quota_opts)
def _get_default_quotas():
diff --git a/nova/rpc/__init__.py b/nova/rpc/__init__.py
index a26d53d0f..db42640b0 100644
--- a/nova/rpc/__init__.py
+++ b/nova/rpc/__init__.py
@@ -17,15 +17,19 @@
# License for the specific language governing permissions and limitations
# under the License.
-
+from nova.common import cfg
from nova.utils import import_object
from nova.rpc.common import RemoteError, LOG
from nova import flags
+
+rpc_backend_opt = \
+ cfg.StrOpt('rpc_backend',
+ default='nova.rpc.impl_kombu',
+ help="The messaging module to use, defaults to kombu.")
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('rpc_backend',
- 'nova.rpc.impl_kombu',
- "The messaging module to use, defaults to kombu.")
+FLAGS.add_option(rpc_backend_opt)
def create_connection(new=True):
diff --git a/nova/rpc/common.py b/nova/rpc/common.py
index 25f287251..ff0577011 100644
--- a/nova/rpc/common.py
+++ b/nova/rpc/common.py
@@ -19,6 +19,7 @@
import copy
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -26,10 +27,16 @@ from nova import log as logging
LOG = logging.getLogger('nova.rpc')
-flags.DEFINE_integer('rpc_thread_pool_size', 1024,
- 'Size of RPC thread pool')
-flags.DEFINE_integer('rpc_conn_pool_size', 30,
- 'Size of RPC connection pool')
+rpc_opts = [
+ cfg.IntOpt('rpc_thread_pool_size',
+ default=1024,
+ help='Size of RPC thread pool'),
+ cfg.IntOpt('rpc_conn_pool_size',
+ default=30,
+ help='Size of RPC connection pool'),
+ ]
+
+flags.FLAGS.add_options(rpc_opts)
class RemoteError(exception.NovaException):
diff --git a/nova/rpc/impl_qpid.py b/nova/rpc/impl_qpid.py
index cddc318f0..3ea921a8c 100644
--- a/nova/rpc/impl_qpid.py
+++ b/nova/rpc/impl_qpid.py
@@ -25,36 +25,59 @@ import greenlet
import qpid.messaging
import qpid.messaging.exceptions
+from nova.common import cfg
from nova import flags
from nova.rpc import amqp as rpc_amqp
from nova.rpc.common import LOG
-flags.DEFINE_string('qpid_hostname', 'localhost', 'Qpid broker hostname')
-flags.DEFINE_string('qpid_port', '5672', 'Qpid broker port')
-flags.DEFINE_string('qpid_username', '', 'Username for qpid connection')
-flags.DEFINE_string('qpid_password', '', 'Password for qpid connection')
-flags.DEFINE_string('qpid_sasl_mechanisms', '',
- 'Space separated list of SASL mechanisms to use for auth')
-flags.DEFINE_boolean('qpid_reconnect', True, 'Automatically reconnect')
-flags.DEFINE_integer('qpid_reconnect_timeout', 0,
- 'Reconnection timeout in seconds')
-flags.DEFINE_integer('qpid_reconnect_limit', 0,
- 'Max reconnections before giving up')
-flags.DEFINE_integer('qpid_reconnect_interval_min', 0,
- 'Minimum seconds between reconnection attempts')
-flags.DEFINE_integer('qpid_reconnect_interval_max', 0,
- 'Maximum seconds between reconnection attempts')
-flags.DEFINE_integer('qpid_reconnect_interval', 0,
- 'Equivalent to setting max and min to the same value')
-flags.DEFINE_integer('qpid_heartbeat', 5,
- 'Seconds between heartbeats used to keep the connection alive')
-flags.DEFINE_string('qpid_protocol', 'tcp',
- "Transport to use, either 'tcp' or 'ssl'")
-flags.DEFINE_boolean('qpid_tcp_nodelay', True, 'Disable Nagle algorithm')
-
+qpid_opts = [
+ cfg.StrOpt('qpid_hostname',
+ default='localhost',
+ help='Qpid broker hostname'),
+ cfg.StrOpt('qpid_port',
+ default='5672',
+ help='Qpid broker port'),
+ cfg.StrOpt('qpid_username',
+ default='',
+ help='Username for qpid connection'),
+ cfg.StrOpt('qpid_password',
+ default='',
+ help='Password for qpid connection'),
+ cfg.StrOpt('qpid_sasl_mechanisms',
+ default='',
+ help='Space separated list of SASL mechanisms to use for auth'),
+ cfg.BoolOpt('qpid_reconnect',
+ default=True,
+ help='Automatically reconnect'),
+ cfg.IntOpt('qpid_reconnect_timeout',
+ default=0,
+ help='Reconnection timeout in seconds'),
+ cfg.IntOpt('qpid_reconnect_limit',
+ default=0,
+ help='Max reconnections before giving up'),
+ cfg.IntOpt('qpid_reconnect_interval_min',
+ default=0,
+ help='Minimum seconds between reconnection attempts'),
+ cfg.IntOpt('qpid_reconnect_interval_max',
+ default=0,
+ help='Maximum seconds between reconnection attempts'),
+ cfg.IntOpt('qpid_reconnect_interval',
+ default=0,
+ help='Equivalent to setting max and min to the same value'),
+ cfg.IntOpt('qpid_heartbeat',
+ default=5,
+ help='Seconds between connection keepalive heartbeats'),
+ cfg.StrOpt('qpid_protocol',
+ default='tcp',
+ help="Transport to use, either 'tcp' or 'ssl'"),
+ cfg.BoolOpt('qpid_tcp_nodelay',
+ default=True,
+ help='Disable Nagle algorithm'),
+ ]
FLAGS = flags.FLAGS
+FLAGS.add_options(qpid_opts)
class ConsumerBase(object):
diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py
index 59f93b952..c814ad664 100644
--- a/nova/scheduler/api.py
+++ b/nova/scheduler/api.py
@@ -22,6 +22,7 @@ import functools
from novaclient import v1_1 as novaclient
from novaclient import exceptions as novaclient_exceptions
+from nova.common import cfg
from nova import db
from nova import exception
from nova import flags
@@ -31,10 +32,14 @@ from nova import utils
from eventlet import greenpool
+
+enable_zone_routing_opt = \
+ cfg.BoolOpt('enable_zone_routing',
+ default=False,
+ help='When True, routing to child zones will occur.')
+
FLAGS = flags.FLAGS
-flags.DEFINE_bool('enable_zone_routing',
- False,
- 'When True, routing to child zones will occur.')
+FLAGS.add_option(enable_zone_routing_opt)
LOG = logging.getLogger('nova.scheduler.api')
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py
index 06f613a45..5af98485d 100644
--- a/nova/scheduler/driver.py
+++ b/nova/scheduler/driver.py
@@ -22,6 +22,7 @@ Scheduler base class that all Schedulers should inherit from
"""
from nova.api.ec2 import ec2utils
+from nova.common import cfg
from nova.compute import api as compute_api
from nova.compute import power_state
from nova.compute import vm_states
@@ -35,14 +36,20 @@ from nova.scheduler import zone_manager
from nova import utils
-FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.scheduler.driver')
-flags.DEFINE_string('scheduler_host_manager',
- 'nova.scheduler.host_manager.HostManager',
- 'The scheduler host manager class to use')
-flags.DEFINE_string('scheduler_zone_manager',
- 'nova.scheduler.zone_manager.ZoneManager',
- 'The scheduler zone manager class to use')
+
+scheduler_driver_opts = [
+ cfg.StrOpt('scheduler_host_manager',
+ default='nova.scheduler.host_manager.HostManager',
+ help='The scheduler host manager class to use'),
+ cfg.StrOpt('scheduler_zone_manager',
+ default='nova.scheduler.zone_manager.ZoneManager',
+ help='The scheduler zone manager class to use'),
+ ]
+
+FLAGS = flags.FLAGS
+FLAGS.add_options(scheduler_driver_opts)
+
flags.DECLARE('instances_path', 'nova.compute.manager')
diff --git a/nova/scheduler/filters/core_filter.py b/nova/scheduler/filters/core_filter.py
index e9b0aa46d..d76eceeef 100644
--- a/nova/scheduler/filters/core_filter.py
+++ b/nova/scheduler/filters/core_filter.py
@@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova.scheduler.filters import abstract_filter
@@ -22,9 +23,13 @@ from nova.scheduler.filters import abstract_filter
LOG = logging.getLogger('nova.scheduler.filter.core_filter')
+cpu_allocation_ratio_opt = \
+ cfg.FloatOpt('cpu_allocation_ratio',
+ default=16.0,
+ help='Virtual CPU to Physical CPU allocation ratio')
+
FLAGS = flags.FLAGS
-flags.DEFINE_float('cpu_allocation_ratio', 16.0,
- 'Virtual CPU to Physical CPU allocation ratio')
+FLAGS.add_option(cpu_allocation_ratio_opt)
class CoreFilter(abstract_filter.AbstractHostFilter):
diff --git a/nova/scheduler/filters/ram_filter.py b/nova/scheduler/filters/ram_filter.py
index 832a2588a..67c9f72b8 100644
--- a/nova/scheduler/filters/ram_filter.py
+++ b/nova/scheduler/filters/ram_filter.py
@@ -14,15 +14,20 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova.scheduler.filters import abstract_filter
LOG = logging.getLogger('nova.scheduler.filter.ram_filter')
+ram_allocation_ratio_opt = \
+ cfg.FloatOpt("ram_allocation_ratio",
+ default=1.0,
+ help="virtual ram to physical ram allocation ratio")
+
FLAGS = flags.FLAGS
-flags.DEFINE_float("ram_allocation_ratio", 1.0,
- "virtual ram to physical ram allocation ratio")
+FLAGS.add_option(ram_allocation_ratio_opt)
class RamFilter(abstract_filter.AbstractHostFilter):
diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py
index 88ca3da61..a56f154fc 100644
--- a/nova/scheduler/host_manager.py
+++ b/nova/scheduler/host_manager.py
@@ -21,24 +21,33 @@ import datetime
import types
import UserDict
+from nova.common import cfg
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
from nova import utils
+
+host_manager_opts = [
+ cfg.IntOpt('reserved_host_disk_mb',
+ default=0,
+ help='Amount of disk in MB to reserve for host/dom0'),
+ cfg.IntOpt('reserved_host_memory_mb',
+ default=512,
+ help='Amount of memory in MB to reserve for host/dom0'),
+ cfg.ListOpt('default_host_filters',
+ default=[
+ 'AvailabilityZoneFilter',
+ 'RamFilter',
+ 'ComputeFilter'
+ ],
+ help='Which filters to use for filtering hosts when not '
+ 'specified in the request.'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('reserved_host_disk_mb', 0,
- 'Amount of disk in MB to reserve for host/dom0')
-flags.DEFINE_integer('reserved_host_memory_mb', 512,
- 'Amount of memory in MB to reserve for host/dom0')
-flags.DEFINE_list('default_host_filters', [
- 'AvailabilityZoneFilter',
- 'RamFilter',
- 'ComputeFilter',
- ],
- 'Which filters to use for filtering hosts when not specified '
- 'in the request.')
+FLAGS.add_options(host_manager_opts)
LOG = logging.getLogger('nova.scheduler.host_manager')
diff --git a/nova/scheduler/least_cost.py b/nova/scheduler/least_cost.py
index c14e93747..90ba4c2a0 100644
--- a/nova/scheduler/least_cost.py
+++ b/nova/scheduler/least_cost.py
@@ -22,24 +22,32 @@ The cost-function and weights are tabulated, and the host with the least cost
is then selected for provisioning.
"""
-
+from nova.common import cfg
from nova import flags
from nova import log as logging
+
LOG = logging.getLogger('nova.scheduler.least_cost')
-FLAGS = flags.FLAGS
-flags.DEFINE_list('least_cost_functions',
- ['nova.scheduler.least_cost.compute_fill_first_cost_fn'],
- 'Which cost functions the LeastCostScheduler should use.')
+least_cost_opts = [
+ cfg.ListOpt('least_cost_functions',
+ default=[
+ 'nova.scheduler.least_cost.compute_fill_first_cost_fn'
+ ],
+ help='Which cost functions the LeastCostScheduler should use'),
+ cfg.FloatOpt('noop_cost_fn_weight',
+ default=1.0,
+ help='How much weight to give the noop cost function'),
+ cfg.FloatOpt('compute_fill_first_cost_fn_weight',
+ default=1.0,
+ help='How much weight to give the fill-first cost function'),
+ ]
+FLAGS = flags.FLAGS
+FLAGS.add_options(least_cost_opts)
# TODO(sirp): Once we have enough of these rules, we can break them out into a
# cost_functions.py file (perhaps in a least_cost_scheduler directory)
-flags.DEFINE_float('noop_cost_fn_weight', 1.0,
- 'How much weight to give the noop cost function')
-flags.DEFINE_float('compute_fill_first_cost_fn_weight', 1.0,
- 'How much weight to give the fill-first cost function')
class WeightedHost(object):
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index 4a701496c..dc1b2c56a 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -23,6 +23,7 @@ Scheduler Service
import functools
+from nova.common import cfg
from nova.compute import vm_states
from nova import db
from nova import exception
@@ -32,11 +33,16 @@ from nova import manager
from nova import rpc
from nova import utils
+
LOG = logging.getLogger('nova.scheduler.manager')
+
+scheduler_driver_opt = \
+ cfg.StrOpt('scheduler_driver',
+ default='nova.scheduler.multi.MultiScheduler',
+ help='Default driver to use for the scheduler')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('scheduler_driver',
- 'nova.scheduler.multi.MultiScheduler',
- 'Default driver to use for the scheduler')
+FLAGS.add_option(scheduler_driver_opt)
class SchedulerManager(manager.Manager):
diff --git a/nova/scheduler/multi.py b/nova/scheduler/multi.py
index 31d92583b..3bc67052f 100644
--- a/nova/scheduler/multi.py
+++ b/nova/scheduler/multi.py
@@ -20,19 +20,24 @@
"""
Scheduler that allows routing some calls to one driver and others to another.
"""
+
+from nova.common import cfg
from nova import flags
from nova import utils
from nova.scheduler import driver
-FLAGS = flags.FLAGS
-flags.DEFINE_string('compute_scheduler_driver',
- 'nova.scheduler.chance.ChanceScheduler',
- 'Driver to use for scheduling compute calls')
-flags.DEFINE_string('volume_scheduler_driver',
- 'nova.scheduler.chance.ChanceScheduler',
- 'Driver to use for scheduling volume calls')
+multi_scheduler_opts = [
+ cfg.StrOpt('compute_scheduler_driver',
+ default='nova.scheduler.chance.ChanceScheduler',
+ help='Driver to use for scheduling compute calls'),
+ cfg.StrOpt('volume_scheduler_driver',
+ default='nova.scheduler.chance.ChanceScheduler',
+ help='Driver to use for scheduling volume calls'),
+ ]
+FLAGS = flags.FLAGS
+FLAGS.add_options(multi_scheduler_opts)
# A mapping of methods to topics so we can figure out which driver to use.
_METHOD_MAP = {'run_instance': 'compute',
diff --git a/nova/scheduler/scheduler_options.py b/nova/scheduler/scheduler_options.py
index 61966dc50..0a6086fc6 100644
--- a/nova/scheduler/scheduler_options.py
+++ b/nova/scheduler/scheduler_options.py
@@ -24,14 +24,18 @@ import datetime
import json
import os
+from nova.common import cfg
from nova import flags
from nova import log as logging
+scheduler_json_config_location_opt = \
+ cfg.StrOpt('scheduler_json_config_location',
+ default='',
+ help='Absolute path to scheduler configuration JSON file.')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('scheduler_json_config_location',
- '',
- 'Absolute path to scheduler configuration JSON file.')
+FLAGS.add_option(scheduler_json_config_location_opt)
LOG = logging.getLogger('nova.scheduler.scheduler_options')
diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py
index a61005bfa..e913730c7 100644
--- a/nova/scheduler/simple.py
+++ b/nova/scheduler/simple.py
@@ -21,6 +21,7 @@
Simple Scheduler
"""
+from nova.common import cfg
from nova import db
from nova import flags
from nova import exception
@@ -28,15 +29,24 @@ from nova.scheduler import driver
from nova.scheduler import chance
from nova import utils
+
+simple_scheduler_opts = [
+ cfg.IntOpt("max_cores",
+ default=16,
+ help="maximum number of instance cores to allow per host"),
+ cfg.IntOpt("max_gigabytes",
+ default=10000,
+ help="maximum number of volume gigabytes to allow per host"),
+ cfg.IntOpt("max_networks",
+ default=1000,
+ help="maximum number of networks to allow per host"),
+ cfg.BoolOpt('skip_isolated_core_check',
+ default=True,
+ help='Allow overcommitting vcpus on isolated hosts'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer("max_cores", 16,
- "maximum number of instance cores to allow per host")
-flags.DEFINE_integer("max_gigabytes", 10000,
- "maximum number of volume gigabytes to allow per host")
-flags.DEFINE_integer("max_networks", 1000,
- "maximum number of networks to allow per host")
-flags.DEFINE_boolean('skip_isolated_core_check', True,
- 'Allow overcommitting vcpus on isolated hosts')
+FLAGS.add_options(simple_scheduler_opts)
class SimpleScheduler(chance.ChanceScheduler):
diff --git a/nova/scheduler/vsa.py b/nova/scheduler/vsa.py
index 7b45e93e5..989841d37 100644
--- a/nova/scheduler/vsa.py
+++ b/nova/scheduler/vsa.py
@@ -19,6 +19,7 @@
VSA Simple Scheduler
"""
+from nova.common import cfg
from nova import context
from nova import db
from nova import flags
@@ -31,15 +32,23 @@ from nova.scheduler import simple
from nova.vsa.api import VsaState
from nova.volume import volume_types
+
LOG = logging.getLogger('nova.scheduler.vsa')
+vsa_scheduler_opts = [
+ cfg.IntOpt('drive_type_approx_capacity_percent',
+ default=10,
+ help='The percentage range for capacity comparison'),
+ cfg.IntOpt('vsa_unique_hosts_per_alloc',
+ default=10,
+ help='The number of unique hosts per storage allocation'),
+ cfg.BoolOpt('vsa_select_unique_drives',
+ default=True,
+ help='Allow selection of same host for multiple drives'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('drive_type_approx_capacity_percent', 10,
- 'The percentage range for capacity comparison')
-flags.DEFINE_integer('vsa_unique_hosts_per_alloc', 10,
- 'The number of unique hosts per storage allocation')
-flags.DEFINE_boolean('vsa_select_unique_drives', True,
- 'Allow selection of same host for multiple drives')
+FLAGS.add_options(vsa_scheduler_opts)
def BYTES_TO_GB(bytes):
diff --git a/nova/scheduler/zone_manager.py b/nova/scheduler/zone_manager.py
index 0e86a89c0..c27e6bdbe 100644
--- a/nova/scheduler/zone_manager.py
+++ b/nova/scheduler/zone_manager.py
@@ -23,16 +23,24 @@ import traceback
from eventlet import greenpool
from novaclient import v1_1 as novaclient
+from nova.common import cfg
from nova import db
from nova import flags
from nova import log as logging
from nova import utils
+
+zone_manager_opts = [
+ cfg.IntOpt('zone_db_check_interval',
+ default=60,
+ help='Seconds between getting fresh zone info from db.'),
+ cfg.IntOpt('zone_failures_to_offline',
+ default=3,
+ help='Number of consecutive errors before offlining a zone'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('zone_db_check_interval', 60,
- 'Seconds between getting fresh zone info from db.')
-flags.DEFINE_integer('zone_failures_to_offline', 3,
- 'Number of consecutive errors before marking zone offline')
+FLAGS.add_options(zone_manager_opts)
LOG = logging.getLogger('nova.scheduler.zone_manager')
diff --git a/nova/service.py b/nova/service.py
index 3b930c91c..88ba1ef10 100644
--- a/nova/service.py
+++ b/nova/service.py
@@ -25,6 +25,7 @@ import os
import eventlet
import greenlet
+from nova.common import cfg
from nova import context
from nova import db
from nova import exception
@@ -38,32 +39,47 @@ from nova import wsgi
LOG = logging.getLogger('nova.service')
+service_opts = [
+ cfg.IntOpt('report_interval',
+ default=10,
+ help='seconds between nodes reporting state to datastore'),
+ cfg.IntOpt('periodic_interval',
+ default=60,
+ help='seconds between running periodic tasks'),
+ cfg.StrOpt('ec2_listen',
+ default="0.0.0.0",
+ help='IP address for EC2 API to listen'),
+ cfg.IntOpt('ec2_listen_port',
+ default=8773,
+ help='port for ec2 api to listen'),
+ cfg.StrOpt('osapi_compute_listen',
+ default="0.0.0.0",
+ help='IP address for OpenStack API to listen'),
+ cfg.IntOpt('osapi_compute_listen_port',
+ default=8774,
+ help='list port for osapi compute'),
+ cfg.StrOpt('metadata_manager',
+ default='nova.api.manager.MetadataManager',
+ help='OpenStack metadata service manager'),
+ cfg.StrOpt('metadata_listen',
+ default="0.0.0.0",
+ help='IP address for metadata api to listen'),
+ cfg.IntOpt('metadata_listen_port',
+ default=8775,
+ help='port for metadata api to listen'),
+ cfg.StrOpt('api_paste_config',
+ default="api-paste.ini",
+ help='File name for the paste.deploy config for nova-api'),
+ cfg.StrOpt('osapi_volume_listen',
+ default="0.0.0.0",
+ help='IP address for OpenStack Volume API to listen'),
+ cfg.IntOpt('osapi_volume_listen_port',
+ default=8776,
+ help='port for os volume api to listen'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('report_interval', 10,
- 'seconds between nodes reporting state to datastore',
- lower_bound=1)
-flags.DEFINE_integer('periodic_interval', 60,
- 'seconds between running periodic tasks',
- lower_bound=1)
-flags.DEFINE_string('ec2_listen', "0.0.0.0",
- 'IP address for EC2 API to listen')
-flags.DEFINE_integer('ec2_listen_port', 8773, 'port for ec2 api to listen')
-flags.DEFINE_string('osapi_compute_listen', "0.0.0.0",
- 'IP address for OpenStack API to listen')
-flags.DEFINE_integer('osapi_compute_listen_port', 8774,
- 'list port for osapi compute')
-flags.DEFINE_string('metadata_manager', 'nova.api.manager.MetadataManager',
- 'OpenStack metadata service manager')
-flags.DEFINE_string('metadata_listen', "0.0.0.0",
- 'IP address for metadata api to listen')
-flags.DEFINE_integer('metadata_listen_port', 8775,
- 'port for metadata api to listen')
-flags.DEFINE_string('api_paste_config', "api-paste.ini",
- 'File name for the paste.deploy config for nova-api')
-flags.DEFINE_string('osapi_volume_listen', "0.0.0.0",
- 'IP address for OpenStack Volume API to listen')
-flags.DEFINE_integer('osapi_volume_listen_port', 8776,
- 'port for os volume api to listen')
+FLAGS.add_options(service_opts)
class Launcher(object):
diff --git a/nova/test.py b/nova/test.py
index 1fc47f507..f8e9c390f 100644
--- a/nova/test.py
+++ b/nova/test.py
@@ -33,6 +33,7 @@ import mox
import nose.plugins.skip
import stubout
+from nova.common import cfg
from nova import flags
import nova.image.fake
from nova import log
@@ -42,11 +43,17 @@ from nova.testing.fake import rabbit
from nova.virt import fake
+test_opts = [
+ cfg.StrOpt('sqlite_clean_db',
+ default='clean.sqlite',
+ help='File name of clean sqlite db'),
+ cfg.BoolOpt('fake_tests',
+ default=True,
+ help='should we use everything for testing'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('sqlite_clean_db', 'clean.sqlite',
- 'File name of clean sqlite db')
-flags.DEFINE_bool('fake_tests', True,
- 'should we use everything for testing')
+FLAGS.add_options(test_opts)
LOG = log.getLogger('nova.tests')
diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py
index ffdb74c8c..d5fccffb9 100644
--- a/nova/tests/api/ec2/test_cloud.py
+++ b/nova/tests/api/ec2/test_cloud.py
@@ -28,6 +28,7 @@ from M2Crypto import RSA
from nova.api.ec2 import cloud
from nova.api.ec2 import ec2utils
from nova.api.ec2 import inst_state
+from nova.common import cfg
from nova.compute import power_state
from nova.compute import vm_states
from nova import context
@@ -43,12 +44,15 @@ from nova import test
from nova import utils
-FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.tests.cloud')
+ajax_proxy_manager_opt = \
+ cfg.StrOpt('ajax_proxy_manager',
+ default='nova.tests.api.ec2.test_cloud.AjaxProxyManager',
+ help='')
-flags.DEFINE_string('ajax_proxy_manager',
- 'nova.tests.api.ec2.test_cloud.AjaxProxyManager', '')
+FLAGS = flags.FLAGS
+FLAGS.add_option(ajax_proxy_manager_opt)
class AjaxProxyManager(manager.SchedulerDependentManager):
diff --git a/nova/tests/declare_flags.py b/nova/tests/declare_flags.py
index 51a55ec72..9dc578867 100644
--- a/nova/tests/declare_flags.py
+++ b/nova/tests/declare_flags.py
@@ -16,8 +16,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import flags
FLAGS = flags.FLAGS
-
-flags.DEFINE_integer('answer', 42, 'test flag')
+FLAGS.add_option(cfg.IntOpt('answer', default=42, help='test flag'))
diff --git a/nova/tests/runtime_flags.py b/nova/tests/runtime_flags.py
index 1eb501406..1a28f4fbd 100644
--- a/nova/tests/runtime_flags.py
+++ b/nova/tests/runtime_flags.py
@@ -16,8 +16,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import flags
FLAGS = flags.FLAGS
-
-flags.DEFINE_integer('runtime_answer', 54, 'test flag')
+FLAGS.add_option(cfg.IntOpt('runtime_answer', default=54, help='test flag'))
diff --git a/nova/tests/test_flags.py b/nova/tests/test_flags.py
index b5fe11983..02ee49ef0 100644
--- a/nova/tests/test_flags.py
+++ b/nova/tests/test_flags.py
@@ -21,11 +21,14 @@ import exceptions
import os
import tempfile
+from nova.common import cfg
from nova import flags
from nova import test
FLAGS = flags.FLAGS
-flags.DEFINE_string('flags_unittest', 'foo', 'for testing purposes only')
+FLAGS.add_option(cfg.StrOpt('flags_unittest',
+ default='foo',
+ help='for testing purposes only'))
class FlagsTestCase(test.TestCase):
@@ -41,11 +44,11 @@ class FlagsTestCase(test.TestCase):
self.assert_('false' not in self.FLAGS)
self.assert_('true' not in self.FLAGS)
- flags.DEFINE_string('string', 'default', 'desc',
- flag_values=self.FLAGS)
- flags.DEFINE_integer('int', 1, 'desc', flag_values=self.FLAGS)
- flags.DEFINE_bool('false', False, 'desc', flag_values=self.FLAGS)
- flags.DEFINE_bool('true', True, 'desc', flag_values=self.FLAGS)
+ self.FLAGS.add_option(cfg.StrOpt('string',
+ default='default', help='desc'))
+ self.FLAGS.add_option(cfg.IntOpt('int', default=1, help='desc'))
+ self.FLAGS.add_option(cfg.BoolOpt('false', default=False, help='desc'))
+ self.FLAGS.add_option(cfg.BoolOpt('true', default=True, help='desc'))
self.assert_(self.FLAGS['string'])
self.assert_(self.FLAGS['int'])
@@ -69,12 +72,12 @@ class FlagsTestCase(test.TestCase):
self.assertEqual(self.FLAGS.true, False)
def test_define_float(self):
- flags.DEFINE_float('float', 6.66, 'desc', flag_values=self.FLAGS)
+ self.FLAGS.add_option(cfg.FloatOpt('float', default=6.66, help='desc'))
self.assertEqual(self.FLAGS.float, 6.66)
def test_define_multistring(self):
- flags.DEFINE_multistring('multi', ['blaa'], 'desc',
- flag_values=self.FLAGS)
+ self.FLAGS.add_option(cfg.MultiStrOpt('multi',
+ default=['blaa'], help='desc'))
self.assert_(self.FLAGS['multi'])
self.assertEqual(self.FLAGS.multi, ['blaa'])
@@ -89,7 +92,8 @@ class FlagsTestCase(test.TestCase):
self.assertEqual(self.FLAGS.multi, ['foo', 'bar'])
def test_define_list(self):
- flags.DEFINE_list('list', ['foo'], 'desc', flag_values=self.FLAGS)
+ self.FLAGS.add_option(cfg.ListOpt('list',
+ default=['foo'], help='desc'))
self.assert_(self.FLAGS['list'])
self.assertEqual(self.FLAGS.list, ['foo'])
@@ -100,7 +104,7 @@ class FlagsTestCase(test.TestCase):
self.assertEqual(self.FLAGS.list, ['a', 'b', 'c', 'd'])
def test_error(self):
- flags.DEFINE_integer('error', 1, 'desc', flag_values=self.FLAGS)
+ self.FLAGS.add_option(cfg.IntOpt('error', default=1, help='desc'))
self.assertEqual(self.FLAGS.error, 1)
@@ -143,16 +147,16 @@ class FlagsTestCase(test.TestCase):
self.assertEqual(self.global_FLAGS.runtime_answer, 60)
def test_long_vs_short_flags(self):
- flags.DEFINE_string('duplicate_answer_long', 'val', 'desc',
- flag_values=self.global_FLAGS)
+ self.global_FLAGS.add_option(cfg.StrOpt('duplicate_answer_long',
+ default='val', help='desc'))
argv = ['flags_test', '--duplicate_answer=60', 'extra_arg']
args = self.global_FLAGS(argv)
self.assert_('duplicate_answer' not in self.global_FLAGS)
self.assert_(self.global_FLAGS.duplicate_answer_long, 60)
- flags.DEFINE_integer('duplicate_answer', 60, 'desc',
- flag_values=self.global_FLAGS)
+ self.global_FLAGS.add_option(cfg.IntOpt('duplicate_answer',
+ default=60, help='desc'))
self.assertEqual(self.global_FLAGS.duplicate_answer, 60)
self.assertEqual(self.global_FLAGS.duplicate_answer_long, 'val')
@@ -178,13 +182,13 @@ class FlagsTestCase(test.TestCase):
self.assertEqual(FLAGS.FlagValuesDict()['flags_unittest'], 'foo')
def test_flagfile(self):
- flags.DEFINE_string('string', 'default', 'desc',
- flag_values=self.FLAGS)
- flags.DEFINE_integer('int', 1, 'desc', flag_values=self.FLAGS)
- flags.DEFINE_bool('false', False, 'desc', flag_values=self.FLAGS)
- flags.DEFINE_bool('true', True, 'desc', flag_values=self.FLAGS)
- flags.DEFINE_multistring('multi', ['blaa'], 'desc',
- flag_values=self.FLAGS)
+ self.FLAGS.add_option(cfg.StrOpt('string',
+ default='default', help='desc'))
+ self.FLAGS.add_option(cfg.IntOpt('int', default=1, help='desc'))
+ self.FLAGS.add_option(cfg.BoolOpt('false', default=False, help='desc'))
+ self.FLAGS.add_option(cfg.BoolOpt('true', default=True, help='desc'))
+ self.FLAGS.add_option(cfg.MultiStrOpt('multi',
+ default=['blaa'], help='desc'))
(fd, path) = tempfile.mkstemp(prefix='nova', suffix='.flags')
@@ -208,14 +212,15 @@ class FlagsTestCase(test.TestCase):
os.remove(path)
def test_defaults(self):
- flags.DEFINE_string('foo', 'bar', 'help', flag_values=self.FLAGS)
+ self.FLAGS.add_option(cfg.StrOpt('foo', default='bar', help='desc'))
self.assertEqual(self.FLAGS.foo, 'bar')
self.FLAGS['foo'].SetDefault('blaa')
self.assertEqual(self.FLAGS.foo, 'blaa')
def test_templated_values(self):
- flags.DEFINE_string('foo', 'foo', 'help', flag_values=self.FLAGS)
- flags.DEFINE_string('bar', 'bar', 'help', flag_values=self.FLAGS)
- flags.DEFINE_string('blaa', '$foo$bar', 'help', flag_values=self.FLAGS)
+ self.FLAGS.add_option(cfg.StrOpt('foo', default='foo', help='desc'))
+ self.FLAGS.add_option(cfg.StrOpt('bar', default='bar', help='desc'))
+ self.FLAGS.add_option(cfg.StrOpt('blaa',
+ default='$foo$bar', help='desc'))
self.assertEqual(self.FLAGS.blaa, 'foobar')
diff --git a/nova/tests/test_service.py b/nova/tests/test_service.py
index 99f091b22..c8a18f7d8 100644
--- a/nova/tests/test_service.py
+++ b/nova/tests/test_service.py
@@ -22,6 +22,7 @@ Unit Tests for remote procedure calls using queue
import mox
+from nova.common import cfg
from nova import context
from nova import db
from nova import exception
@@ -31,12 +32,20 @@ from nova import service
from nova import manager
from nova import wsgi
-flags.DEFINE_string("fake_manager", "nova.tests.test_service.FakeManager",
- "Manager for testing")
-flags.DEFINE_string("test_service_listen", None,
- "Host to bind test service to")
-flags.DEFINE_integer("test_service_listen_port", 0,
- "Port number to bind test service to")
+
+test_service_opts = [
+ cfg.StrOpt("fake_manager",
+ default="nova.tests.test_service.FakeManager",
+ help="Manager for testing"),
+ cfg.StrOpt("test_service_listen",
+ default=None,
+ help="Host to bind test service to"),
+ cfg.IntOpt("test_service_listen_port",
+ default=0,
+ help="Port number to bind test service to"),
+ ]
+
+flags.FLAGS.add_options(test_service_opts)
class FakeManager(manager.Manager):
diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py
index 1cd697347..0f0b13b7f 100644
--- a/nova/virt/disk/api.py
+++ b/nova/virt/disk/api.py
@@ -29,6 +29,7 @@ import json
import os
import tempfile
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -37,35 +38,41 @@ from nova.virt.disk import guestfs
from nova.virt.disk import loop
from nova.virt.disk import nbd
+
LOG = logging.getLogger('nova.compute.disk')
-FLAGS = flags.FLAGS
-flags.DEFINE_string('injected_network_template',
- utils.abspath('virt/interfaces.template'),
- 'Template file for injected network')
-flags.DEFINE_list('img_handlers', ['loop', 'nbd', 'guestfs'],
- 'Order of methods used to mount disk images')
+disk_opts = [
+ cfg.StrOpt('injected_network_template',
+ default=utils.abspath('virt/interfaces.template'),
+ help='Template file for injected network'),
+ cfg.ListOpt('img_handlers',
+ default=['loop', 'nbd', 'guestfs'],
+ help='Order of methods used to mount disk images'),
+
+ # NOTE(yamahata): ListOpt won't work because the command may include a
+ # comma. For example:
+ #
+ # mkfs.ext3 -O dir_index,extent -E stride=8,stripe-width=16
+ # --label %(fs_label)s %(target)s
+ #
+ # list arguments are comma separated and there is no way to
+ # escape such commas.
+ #
+ cfg.MultiStrOpt('virt_mkfs',
+ default=[
+ 'default=mkfs.ext3 -L %(fs_label)s -F %(target)s',
+ 'linux=mkfs.ext3 -L %(fs_label)s -F %(target)s',
+ 'windows='
+ 'mkfs.ntfs --fast --label %(fs_label)s %(target)s',
+ # NOTE(yamahata): vfat case
+ #'windows=mkfs.vfat -n %(fs_label)s %(target)s',
+ ],
+ help='mkfs commands for ephemeral device. '
+ 'The format is <os_type>=<mkfs command>'),
+ ]
-# NOTE(yamahata): DEFINE_list() doesn't work because the command may
-# include ','. For example,
-# mkfs.ext3 -O dir_index,extent -E stride=8,stripe-width=16
-# --label %(fs_label)s %(target)s
-#
-# DEFINE_list() parses its argument by
-# [s.strip() for s in argument.split(self._token)]
-# where self._token = ','
-# No escape nor exceptional handling for ','.
-# DEFINE_list() doesn't give us what we need.
-flags.DEFINE_multistring('virt_mkfs',
- ['windows=mkfs.ntfs --fast --label %(fs_label)s '
- '%(target)s',
- # NOTE(yamahata): vfat case
- #'windows=mkfs.vfat -n %(fs_label)s %(target)s',
- 'linux=mkfs.ext3 -L %(fs_label)s -F %(target)s',
- 'default=mkfs.ext3 -L %(fs_label)s -F %(target)s'],
- 'mkfs commands for ephemeral device. The format is'
- '<os_type>=<mkfs command>')
-
+FLAGS = flags.FLAGS
+FLAGS.add_options(disk_opts)
_MKFS_COMMAND = {}
_DEFAULT_MKFS_COMMAND = None
diff --git a/nova/virt/disk/nbd.py b/nova/virt/disk/nbd.py
index 55b287ebb..19904d694 100644
--- a/nova/virt/disk/nbd.py
+++ b/nova/virt/disk/nbd.py
@@ -18,15 +18,23 @@
import os
import time
+from nova.common import cfg
from nova import flags
from nova import utils
from nova.virt.disk import mount
+
+nbd_opts = [
+ cfg.IntOpt('timeout_nbd',
+ default=10,
+ help='time to wait for a NBD device coming up'),
+ cfg.IntOpt('max_nbd_devices',
+ default=16,
+ help='maximum number of possible nbd devices'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_integer('timeout_nbd', 10,
- 'time to wait for a NBD device coming up')
-flags.DEFINE_integer('max_nbd_devices', 16,
- 'maximum number of possible nbd devices')
+FLAGS.add_options(nbd_opts)
class Mount(mount.Mount):
diff --git a/nova/virt/firewall.py b/nova/virt/firewall.py
index ed60051d9..604aa101a 100644
--- a/nova/virt/firewall.py
+++ b/nova/virt/firewall.py
@@ -17,6 +17,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import context
from nova import db
from nova import flags
@@ -24,11 +25,16 @@ from nova import log as logging
from nova import utils
from nova.virt import netutils
+
LOG = logging.getLogger("nova.virt.firewall")
+
+allow_same_net_traffic_opt = \
+ cfg.BoolOpt('allow_same_net_traffic',
+ default=True,
+ help='Whether to allow network traffic from same network')
+
FLAGS = flags.FLAGS
-flags.DEFINE_bool('allow_same_net_traffic',
- True,
- 'Whether to allow network traffic from same network')
+FLAGS.add_option(allow_same_net_traffic_opt)
class FirewallDriver(object):
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index df0cd5725..edd2c4741 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -54,6 +54,7 @@ from xml.etree import ElementTree
from nova.auth import manager
from nova import block_device
+from nova.common import cfg
from nova.compute import instance_types
from nova.compute import power_state
from nova import context as nova_context
@@ -75,70 +76,84 @@ Template = None
LOG = logging.getLogger('nova.virt.libvirt_conn')
+libvirt_opts = [
+ cfg.StrOpt('rescue_image_id',
+ default=None,
+ help='Rescue ami image'),
+ cfg.StrOpt('rescue_kernel_id',
+ default=None,
+ help='Rescue aki image'),
+ cfg.StrOpt('rescue_ramdisk_id',
+ default=None,
+ help='Rescue ari image'),
+ cfg.StrOpt('libvirt_xml_template',
+ default=utils.abspath('virt/libvirt.xml.template'),
+ help='Libvirt XML Template'),
+ cfg.StrOpt('libvirt_type',
+ default='kvm',
+ help='Libvirt domain type (valid options are: '
+ 'kvm, lxc, qemu, uml, xen)'),
+ cfg.StrOpt('libvirt_uri',
+ default='',
+ help='Override the default libvirt URI '
+ '(which is dependent on libvirt_type)'),
+ cfg.BoolOpt('use_cow_images',
+ default=True,
+ help='Whether to use cow images'),
+ cfg.StrOpt('ajaxterm_portrange',
+ default='10000-12000',
+ help='Range of ports that ajaxterm should try to bind'),
+ cfg.StrOpt('cpuinfo_xml_template',
+ default=utils.abspath('virt/cpuinfo.xml.template'),
+ help='CpuInfo XML Template (Used only live migration now)'),
+ cfg.StrOpt('live_migration_uri',
+ default="qemu+tcp://%s/system",
+ help='Define protocol used by live_migration feature'),
+ cfg.StrOpt('live_migration_flag',
+ default='VIR_MIGRATE_UNDEFINE_SOURCE, VIR_MIGRATE_PEER2PEER',
+ help='Define live migration behavior.'),
+ cfg.StrOpt('block_migration_flag',
+ default='VIR_MIGRATE_UNDEFINE_SOURCE, VIR_MIGRATE_PEER2PEER, '
+ 'VIR_MIGRATE_NON_SHARED_INC',
+ help='Define block migration behavior.'),
+ cfg.IntOpt('live_migration_bandwidth',
+ default=0,
+ help='Define live migration behavior'),
+ cfg.StrOpt('snapshot_image_format',
+ default=None,
+ help='Snapshot image format (valid options are : '
+ 'raw, qcow2, vmdk, vdi). '
+ 'Defaults to same as source image'),
+ cfg.StrOpt('libvirt_vif_type',
+ default='bridge',
+ help='Type of VIF to create.'),
+ cfg.StrOpt('libvirt_vif_driver',
+ default='nova.virt.libvirt.vif.LibvirtBridgeDriver',
+ help='The libvirt VIF driver to configure the VIFs.'),
+ cfg.ListOpt('libvirt_volume_drivers',
+ default=[
+ 'iscsi=nova.virt.libvirt.volume.LibvirtISCSIVolumeDriver',
+ 'local=nova.virt.libvirt.volume.LibvirtVolumeDriver',
+ 'fake=nova.virt.libvirt.volume.LibvirtFakeVolumeDriver',
+ 'rbd=nova.virt.libvirt.volume.LibvirtNetVolumeDriver',
+ 'sheepdog=nova.virt.libvirt.volume.LibvirtNetVolumeDriver'
+ ],
+ help='Libvirt handlers for remote volumes.'),
+ cfg.BoolOpt('libvirt_use_virtio_for_bridges',
+ default=False,
+ help='Use virtio for bridge interfaces'),
+ cfg.StrOpt('libvirt_disk_prefix',
+ default=None,
+ help='Override the default disk prefix for the devices attached'
+ ' to a server, which is dependent on libvirt_type. '
+ '(valid options are: sd, xvd, uvd, vd)'),
+ ]
FLAGS = flags.FLAGS
+FLAGS.add_options(libvirt_opts)
+
flags.DECLARE('live_migration_retry_count', 'nova.compute.manager')
flags.DECLARE('vncserver_proxyclient_address', 'nova.vnc')
-# TODO(vish): These flags should probably go into a shared location
-flags.DEFINE_string('rescue_image_id', None, 'Rescue ami image')
-flags.DEFINE_string('rescue_kernel_id', None, 'Rescue aki image')
-flags.DEFINE_string('rescue_ramdisk_id', None, 'Rescue ari image')
-flags.DEFINE_string('libvirt_xml_template',
- utils.abspath('virt/libvirt.xml.template'),
- 'Libvirt XML Template')
-flags.DEFINE_string('libvirt_type',
- 'kvm',
- 'Libvirt domain type (valid options are: '
- 'kvm, lxc, qemu, uml, xen)')
-flags.DEFINE_string('libvirt_uri',
- '',
- 'Override the default libvirt URI (which is dependent'
- ' on libvirt_type)')
-flags.DEFINE_bool('use_cow_images',
- True,
- 'Whether to use cow images')
-flags.DEFINE_string('ajaxterm_portrange',
- '10000-12000',
- 'Range of ports that ajaxterm should randomly try to bind')
-flags.DEFINE_string('cpuinfo_xml_template',
- utils.abspath('virt/cpuinfo.xml.template'),
- 'CpuInfo XML Template (Used only live migration now)')
-flags.DEFINE_string('live_migration_uri',
- "qemu+tcp://%s/system",
- 'Define protocol used by live_migration feature')
-flags.DEFINE_string('live_migration_flag',
- "VIR_MIGRATE_UNDEFINE_SOURCE, VIR_MIGRATE_PEER2PEER",
- 'Define live migration behavior.')
-flags.DEFINE_string('block_migration_flag',
- "VIR_MIGRATE_UNDEFINE_SOURCE, VIR_MIGRATE_PEER2PEER, "
- "VIR_MIGRATE_NON_SHARED_INC",
- 'Define block migration behavior.')
-flags.DEFINE_integer('live_migration_bandwidth', 0,
- 'Define live migration behavior')
-flags.DEFINE_string('snapshot_image_format', None,
- 'Snapshot image format (valid options are : '
- 'raw, qcow2, vmdk, vdi).'
- 'Defaults to same as source image')
-flags.DEFINE_string('libvirt_vif_type', 'bridge',
- 'Type of VIF to create.')
-flags.DEFINE_string('libvirt_vif_driver',
- 'nova.virt.libvirt.vif.LibvirtBridgeDriver',
- 'The libvirt VIF driver to configure the VIFs.')
-flags.DEFINE_list('libvirt_volume_drivers',
- ['iscsi=nova.virt.libvirt.volume.LibvirtISCSIVolumeDriver',
- 'local=nova.virt.libvirt.volume.LibvirtVolumeDriver',
- 'fake=nova.virt.libvirt.volume.LibvirtFakeVolumeDriver',
- 'rbd=nova.virt.libvirt.volume.LibvirtNetVolumeDriver',
- 'sheepdog=nova.virt.libvirt.volume.LibvirtNetVolumeDriver'],
- 'Libvirt handlers for remote volumes.')
-flags.DEFINE_bool('libvirt_use_virtio_for_bridges',
- False,
- 'Use virtio for bridge interfaces')
-flags.DEFINE_string('libvirt_disk_prefix',
- None,
- 'Override the default disk prefix for the devices '
- 'attached to a server, which is dependent on '
- 'libvirt_type. (valid options are: sd, xvd, uvd, vd)')
def get_connection(read_only):
diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py
index c21b003bb..51fd9044f 100644
--- a/nova/virt/libvirt/utils.py
+++ b/nova/virt/libvirt/utils.py
@@ -23,16 +23,21 @@ import os
import random
import shutil
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import utils
from nova.virt.disk import api as disk
from nova.virt import images
-FLAGS = flags.FLAGS
-flags.DEFINE_string('qemu_img', 'qemu-img',
- 'binary to use for qemu-img commands')
+qemu_img_opt = \
+ cfg.StrOpt('qemu_img',
+ default='qemu-img',
+ help='binary to use for qemu-img commands')
+
+FLAGS = flags.FLAGS
+FLAGS.add_option(qemu_img_opt)
def execute(*args, **kwargs):
diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py
index d4375f6da..503c33d0f 100644
--- a/nova/virt/libvirt/vif.py
+++ b/nova/virt/libvirt/vif.py
@@ -19,6 +19,7 @@
"""VIF drivers for libvirt."""
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -30,10 +31,13 @@ from nova.virt.vif import VIFDriver
LOG = logging.getLogger('nova.virt.libvirt.vif')
-FLAGS = flags.FLAGS
+libvirt_ovs_bridge_opt = \
+ cfg.StrOpt('libvirt_ovs_bridge',
+ default='br-int',
+ help='Name of Integration Bridge used by Open vSwitch')
-flags.DEFINE_string('libvirt_ovs_bridge', 'br-int',
- 'Name of Integration Bridge used by Open vSwitch')
+FLAGS = flags.FLAGS
+FLAGS.add_option(libvirt_ovs_bridge_opt)
class LibvirtBridgeDriver(VIFDriver):
diff --git a/nova/virt/vmwareapi/vim.py b/nova/virt/vmwareapi/vim.py
index 9a0647b28..0ce1be645 100644
--- a/nova/virt/vmwareapi/vim.py
+++ b/nova/virt/vmwareapi/vim.py
@@ -26,6 +26,7 @@ try:
except ImportError:
suds = None
+from nova.common import cfg
from nova import flags
from nova.virt.vmwareapi import error_util
@@ -33,13 +34,16 @@ RESP_NOT_XML_ERROR = 'Response is "text/html", not "text/xml"'
CONN_ABORT_ERROR = 'Software caused connection abort'
ADDRESS_IN_USE_ERROR = 'Address already in use'
+vmwareapi_wsdl_loc_opt = \
+ cfg.StrOpt('vmwareapi_wsdl_loc',
+ default=None,
+ help='VIM Service WSDL Location '
+ 'e.g http://<server>/vimService.wsdl. '
+ 'Due to a bug in vSphere ESX 4.1 default wsdl. '
+ 'Refer readme-vmware to setup')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('vmwareapi_wsdl_loc',
- None,
- 'VIM Service WSDL Location'
- 'e.g http://<server>/vimService.wsdl'
- 'Due to a bug in vSphere ESX 4.1 default wsdl'
- 'Refer readme-vmware to setup')
+FLAGS.add_option(vmwareapi_wsdl_loc_opt)
if suds:
diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py
index 780caa65b..172936def 100644
--- a/nova/virt/vmwareapi/vmops.py
+++ b/nova/virt/vmwareapi/vmops.py
@@ -26,6 +26,7 @@ import urllib
import urllib2
import uuid
+from nova.common import cfg
from nova.compute import power_state
from nova import exception
from nova import flags
@@ -36,10 +37,14 @@ from nova.virt.vmwareapi import vm_util
from nova.virt.vmwareapi import vmware_images
from nova.virt.vmwareapi import network_utils
+
+vmware_vif_driver_opt = \
+ cfg.StrOpt('vmware_vif_driver',
+ default='nova.virt.vmwareapi.vif.VMWareVlanBridgeDriver',
+ help='The VMWare VIF driver to configure the VIFs.')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('vmware_vif_driver',
- 'nova.virt.vmwareapi.vif.VMWareVlanBridgeDriver',
- 'The VMWare VIF driver to configure the VIFs.')
+FLAGS.add_option(vmware_vif_driver_opt)
LOG = logging.getLogger("nova.virt.vmwareapi.vmops")
diff --git a/nova/virt/vmwareapi_conn.py b/nova/virt/vmwareapi_conn.py
index 620407c78..d71b922c9 100644
--- a/nova/virt/vmwareapi_conn.py
+++ b/nova/virt/vmwareapi_conn.py
@@ -36,6 +36,7 @@ import time
from eventlet import event
+from nova.common import cfg
from nova import context
from nova import db
from nova import exception
@@ -51,31 +52,35 @@ from nova.virt.vmwareapi.vmops import VMWareVMOps
LOG = logging.getLogger("nova.virt.vmwareapi_conn")
+vmwareapi_opts = [
+ cfg.StrOpt('vmwareapi_host_ip',
+ default=None,
+ help='URL for connection to VMWare ESX host.Required if '
+ 'connection_type is vmwareapi.'),
+ cfg.StrOpt('vmwareapi_host_username',
+ default=None,
+ help='Username for connection to VMWare ESX host. '
+ 'Used only if connection_type is vmwareapi.'),
+ cfg.StrOpt('vmwareapi_host_password',
+ default=None,
+ help='Password for connection to VMWare ESX host. '
+ 'Used only if connection_type is vmwareapi.'),
+ cfg.FloatOpt('vmwareapi_task_poll_interval',
+ default=5.0,
+ help='The interval used for polling of remote tasks. '
+ 'Used only if connection_type is vmwareapi'),
+ cfg.FloatOpt('vmwareapi_api_retry_count',
+ default=10,
+ help='The number of times we retry on failures, e.g., '
+ 'socket error, etc. '
+ 'Used only if connection_type is vmwareapi'),
+ cfg.StrOpt('vmwareapi_vlan_interface',
+ default='vmnic0',
+ help='Physical ethernet adapter name for vlan networking'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('vmwareapi_host_ip',
- None,
- 'URL for connection to VMWare ESX host.'
- 'Required if connection_type is vmwareapi.')
-flags.DEFINE_string('vmwareapi_host_username',
- None,
- 'Username for connection to VMWare ESX host.'
- 'Used only if connection_type is vmwareapi.')
-flags.DEFINE_string('vmwareapi_host_password',
- None,
- 'Password for connection to VMWare ESX host.'
- 'Used only if connection_type is vmwareapi.')
-flags.DEFINE_float('vmwareapi_task_poll_interval',
- 5.0,
- 'The interval used for polling of remote tasks '
- 'Used only if connection_type is vmwareapi')
-flags.DEFINE_float('vmwareapi_api_retry_count',
- 10,
- 'The number of times we retry on failures, '
- 'e.g., socket error, etc.'
- 'Used only if connection_type is vmwareapi')
-flags.DEFINE_string('vmwareapi_vlan_interface',
- 'vmnic0',
- 'Physical ethernet adapter name for vlan networking')
+FLAGS.add_options(vmwareapi_opts)
TIME_BETWEEN_API_CALL_RETRIES = 2.0
diff --git a/nova/virt/xenapi/vif.py b/nova/virt/xenapi/vif.py
index b53b456f1..80278e8c6 100644
--- a/nova/virt/xenapi/vif.py
+++ b/nova/virt/xenapi/vif.py
@@ -19,15 +19,21 @@
"""VIF drivers for XenAPI."""
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova.virt.vif import VIFDriver
from nova.virt.xenapi.network_utils import NetworkHelper
from nova.virt.xenapi.vm_utils import VMHelper
+
+xenapi_ovs_integration_bridge_opt = \
+ cfg.StrOpt('xenapi_ovs_integration_bridge',
+ default='xapi1',
+ help='Name of Integration Bridge used by Open vSwitch')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('xenapi_ovs_integration_bridge', 'xapi1',
- 'Name of Integration Bridge used by Open vSwitch')
+FLAGS.add_option(xenapi_ovs_integration_bridge_opt)
LOG = logging.getLogger("nova.virt.xenapi.vif")
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 75ff011b3..4c7ece9c5 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -33,6 +33,7 @@ import uuid
from decimal import Decimal
from xml.dom import minidom
+from nova.common import cfg
from nova import exception
from nova import flags
from nova.image import glance
@@ -47,12 +48,20 @@ from nova.virt.xenapi import volume_utils
LOG = logging.getLogger("nova.virt.xenapi.vm_utils")
+xenapi_vm_utils_opts = [
+ cfg.StrOpt('default_os_type',
+ default='linux',
+ help='Default OS type'),
+ cfg.IntOpt('block_device_creation_timeout',
+ default=10,
+ help='time to wait for a block device to be created'),
+ cfg.IntOpt('max_kernel_ramdisk_size',
+ default=16 * 1024 * 1024,
+ help='maximum size in bytes of kernel or ramdisk images'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('default_os_type', 'linux', 'Default OS type')
-flags.DEFINE_integer('block_device_creation_timeout', 10,
- 'time to wait for a block device to be created')
-flags.DEFINE_integer('max_kernel_ramdisk_size', 16 * 1024 * 1024,
- 'maximum size in bytes of kernel or ramdisk images')
+FLAGS.add_options(xenapi_vm_utils_opts)
XENAPI_POWER_STATE = {
'Halted': power_state.SHUTDOWN,
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index f681aceef..cb07bd255 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -30,6 +30,7 @@ import uuid
from eventlet import greenthread
import M2Crypto
+from nova.common import cfg
from nova.compute import api as compute
from nova.compute import power_state
from nova import context as nova_context
@@ -49,21 +50,28 @@ VMHelper = vm_utils.VMHelper
XenAPI = None
LOG = logging.getLogger("nova.virt.xenapi.vmops")
+xenapi_vmops_opts = [
+ cfg.IntOpt('agent_version_timeout',
+ default=300,
+ help='number of seconds to wait for agent '
+ 'to be fully operational'),
+ cfg.IntOpt('xenapi_running_timeout',
+ default=60,
+ help='number of seconds to wait for instance '
+ 'to go to running state'),
+ cfg.StrOpt('xenapi_vif_driver',
+ default='nova.virt.xenapi.vif.XenAPIBridgeDriver',
+ help='The XenAPI VIF driver using XenServer Network APIs.'),
+ cfg.BoolOpt('xenapi_generate_swap',
+ default=False,
+ help='Whether to generate swap '
+ '(False means fetching it from OVA)'),
+ ]
+
FLAGS = flags.FLAGS
+FLAGS.add_options(xenapi_vmops_opts)
+
flags.DECLARE('vncserver_proxyclient_address', 'nova.vnc')
-flags.DEFINE_integer('agent_version_timeout', 300,
- 'number of seconds to wait for agent to be fully '
- 'operational')
-flags.DEFINE_integer('xenapi_running_timeout', 60,
- 'number of seconds to wait for instance to go to '
- 'running state')
-flags.DEFINE_string('xenapi_vif_driver',
- 'nova.virt.xenapi.vif.XenAPIBridgeDriver',
- 'The XenAPI VIF driver using XenServer Network APIs.')
-flags.DEFINE_bool('xenapi_generate_swap',
- False,
- 'Whether to generate swap (False means fetching it'
- ' from OVA)')
RESIZE_TOTAL_STEPS = 5
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index 42f035217..6b67b8b88 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -70,6 +70,7 @@ from eventlet import queue
from eventlet import tpool
from eventlet import timeout
+from nova.common import cfg
from nova import context
from nova import db
from nova import exception
@@ -84,69 +85,74 @@ from nova.virt.xenapi.volumeops import VolumeOps
LOG = logging.getLogger("nova.virt.xenapi")
+xenapi_opts = [
+ cfg.StrOpt('xenapi_connection_url',
+ default=None,
+ help='URL for connection to XenServer/Xen Cloud Platform. '
+ 'Required if connection_type=xenapi.'),
+ cfg.StrOpt('xenapi_connection_username',
+ default='root',
+ help='Username for connection to XenServer/Xen Cloud Platform. '
+ 'Used only if connection_type=xenapi.'),
+ cfg.StrOpt('xenapi_connection_password',
+ default=None,
+ help='Password for connection to XenServer/Xen Cloud Platform. '
+ 'Used only if connection_type=xenapi.'),
+ cfg.IntOpt('xenapi_connection_concurrent',
+ default=5,
+ help='Maximum number of concurrent XenAPI connections. '
+ 'Used only if connection_type=xenapi.'),
+ cfg.FloatOpt('xenapi_task_poll_interval',
+ default=0.5,
+ help='The interval used for polling of remote tasks '
+ '(Async.VM.start, etc). '
+ 'Used only if connection_type=xenapi.'),
+ cfg.FloatOpt('xenapi_vhd_coalesce_poll_interval',
+ default=5.0,
+ help='The interval used for polling of coalescing vhds. '
+ 'Used only if connection_type=xenapi.'),
+ cfg.IntOpt('xenapi_vhd_coalesce_max_attempts',
+ default=5,
+ help='Max number of times to poll for VHD to coalesce. '
+ 'Used only if connection_type=xenapi.'),
+ cfg.StrOpt('xenapi_agent_path',
+ default='usr/sbin/xe-update-networking',
+ help='Specifies the path in which the xenapi guest agent '
+ 'should be located. If the agent is present, network '
+ 'configuration is not injected into the image. '
+ 'Used if connection_type=xenapi and flat_injected=True'),
+ cfg.StrOpt('xenapi_sr_base_path',
+ default='/var/run/sr-mount',
+ help='Base path to the storage repository'),
+ cfg.BoolOpt('xenapi_log_instance_actions',
+ default=False,
+ help='Log all instance calls to XenAPI in the database.'),
+ cfg.StrOpt('target_host',
+ default=None,
+ help='iSCSI Target Host'),
+ cfg.StrOpt('target_port',
+ default='3260',
+ help='iSCSI Target Port, 3260 Default'),
+ cfg.StrOpt('iqn_prefix',
+ default='iqn.2010-10.org.openstack',
+ help='IQN Prefix'),
+ # NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick,
+ # when we pull support for it, we should remove this
+ cfg.BoolOpt('xenapi_remap_vbd_dev',
+ default=False,
+ help='Used to enable the remapping of VBD dev '
+ '(Works around an issue in Ubuntu Maverick)'),
+ cfg.StrOpt('xenapi_remap_vbd_dev_prefix',
+ default='sd',
+ help='Specify prefix to remap VBD dev to '
+ '(ex. /dev/xvdb -> /dev/sdb)'),
+ cfg.IntOpt('xenapi_login_timeout',
+ default=10,
+ help='Timeout in seconds for XenAPI login.'),
+ ]
FLAGS = flags.FLAGS
-
-flags.DEFINE_string('xenapi_connection_url',
- None,
- 'URL for connection to XenServer/Xen Cloud Platform.'
- ' Required if connection_type=xenapi.')
-flags.DEFINE_string('xenapi_connection_username',
- 'root',
- 'Username for connection to XenServer/Xen Cloud Platform.'
- ' Used only if connection_type=xenapi.')
-flags.DEFINE_string('xenapi_connection_password',
- None,
- 'Password for connection to XenServer/Xen Cloud Platform.'
- ' Used only if connection_type=xenapi.')
-flags.DEFINE_integer('xenapi_connection_concurrent',
- 5,
- 'Maximum number of concurrent XenAPI connections.'
- ' Used only if connection_type=xenapi.')
-flags.DEFINE_float('xenapi_task_poll_interval',
- 0.5,
- 'The interval used for polling of remote tasks '
- '(Async.VM.start, etc). Used only if '
- 'connection_type=xenapi.')
-flags.DEFINE_float('xenapi_vhd_coalesce_poll_interval',
- 5.0,
- 'The interval used for polling of coalescing vhds.'
- ' Used only if connection_type=xenapi.')
-flags.DEFINE_integer('xenapi_vhd_coalesce_max_attempts',
- 5,
- 'Max number of times to poll for VHD to coalesce.'
- ' Used only if connection_type=xenapi.')
-flags.DEFINE_string('xenapi_agent_path',
- 'usr/sbin/xe-update-networking',
- 'Specifies the path in which the xenapi guest agent'
- ' should be located. If the agent is present,'
- ' network configuration is not injected into the image'
- ' Used only if connection_type=xenapi.'
- ' and flat_injected=True')
-flags.DEFINE_string('xenapi_sr_base_path', '/var/run/sr-mount',
- 'Base path to the storage repository')
-flags.DEFINE_bool('xenapi_log_instance_actions', False,
- 'Log all instance calls to XenAPI in the database.')
-flags.DEFINE_string('target_host',
- None,
- 'iSCSI Target Host')
-flags.DEFINE_string('target_port',
- '3260',
- 'iSCSI Target Port, 3260 Default')
-flags.DEFINE_string('iqn_prefix',
- 'iqn.2010-10.org.openstack',
- 'IQN Prefix')
-# NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick, when we pull
-# support for it, we should remove this
-flags.DEFINE_bool('xenapi_remap_vbd_dev', False,
- 'Used to enable the remapping of VBD dev '
- '(Works around an issue in Ubuntu Maverick)')
-flags.DEFINE_string('xenapi_remap_vbd_dev_prefix', 'sd',
- 'Specify prefix to remap VBD dev to '
- '(ex. /dev/xvdb -> /dev/sdb)')
-flags.DEFINE_integer('xenapi_login_timeout',
- 10,
- 'Timeout in seconds for XenAPI login.')
+FLAGS.add_options(xenapi_opts)
def get_connection(_):
diff --git a/nova/vnc/__init__.py b/nova/vnc/__init__.py
index 03cb75639..0b2581203 100644
--- a/nova/vnc/__init__.py
+++ b/nova/vnc/__init__.py
@@ -18,25 +18,33 @@
"""Module for VNC Proxying."""
+from nova.common import cfg
from nova import flags
+vnc_opts = [
+ cfg.StrOpt('novncproxy_base_url',
+ default='http://127.0.0.1:6080/vnc_auto.html',
+ help='location of vnc console proxy, in the form '
+ '"http://127.0.0.1:6080/vnc_auto.html"'),
+ cfg.StrOpt('xvpvncproxy_base_url',
+ default='http://127.0.0.1:6081/console',
+ help='location of nova xvp vnc console proxy, in the form '
+ '"http://127.0.0.1:6081/console"'),
+ cfg.StrOpt('vncserver_listen',
+ default='127.0.0.1',
+ help='Ip address on which instance vncserversshould listen'),
+ cfg.StrOpt('vncserver_proxyclient_address',
+ default='127.0.0.1',
+ help='the address to which proxy clients '
+ '(like nova-xvpvncproxy) should connect'),
+ cfg.BoolOpt('vnc_enabled',
+ default=True,
+ help='enable vnc related features'),
+ cfg.StrOpt('vnc_keymap',
+ default='en-us',
+ help='keymap for vnc'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('novncproxy_base_url',
- 'http://127.0.0.1:6080/vnc_auto.html',
- 'location of vnc console proxy, \
- in the form "http://127.0.0.1:6080/vnc_auto.html"')
-flags.DEFINE_string('xvpvncproxy_base_url',
- 'http://127.0.0.1:6081/console',
- 'location of nova xvp vnc console proxy, \
- in the form "http://127.0.0.1:6081/console"')
-flags.DEFINE_string('vncserver_listen', '127.0.0.1',
- 'Ip address on which instance vncservers\
- should listen')
-flags.DEFINE_string('vncserver_proxyclient_address', '127.0.0.1',
- 'the address to which proxy clients \
- (like nova-xvpvncproxy) should connect')
-flags.DEFINE_bool('vnc_enabled', True,
- 'enable vnc related features')
-flags.DEFINE_string('vnc_keymap', 'en-us',
- 'keymap for vnc')
+FLAGS.add_options(vnc_opts)
diff --git a/nova/vnc/xvp_proxy.py b/nova/vnc/xvp_proxy.py
index 1bcc83240..bf9ee5975 100644
--- a/nova/vnc/xvp_proxy.py
+++ b/nova/vnc/xvp_proxy.py
@@ -26,6 +26,7 @@ import eventlet.green
import eventlet.greenio
import eventlet.wsgi
+from nova.common import cfg
from nova import context
from nova import flags
from nova import log as logging
@@ -35,13 +36,20 @@ from nova import wsgi
LOG = logging.getLogger('nova.xvpvncproxy')
+
+xvp_proxy_opts = [
+ cfg.IntOpt('xvpvncproxy_port',
+ default=6081,
+ help='Port that the XCP VNC proxy should bind to'),
+ cfg.StrOpt('xvpvncproxy_host',
+ default='0.0.0.0',
+ help='Address that the XCP VNC proxy should bind to'),
+ ]
+
FLAGS = flags.FLAGS
+FLAGS.add_options(xvp_proxy_opts)
flags.DECLARE('consoleauth_topic', 'nova.consoleauth')
-flags.DEFINE_integer('xvpvncproxy_port', 6081,
- 'Port that the XCP VNC proxy should bind to')
-flags.DEFINE_string('xvpvncproxy_host', '0.0.0.0',
- 'Address that the XCP VNC proxy should bind to')
class XCPVNCProxy(object):
diff --git a/nova/volume/driver.py b/nova/volume/driver.py
index 475a5434c..0505b89b1 100644
--- a/nova/volume/driver.py
+++ b/nova/volume/driver.py
@@ -24,6 +24,7 @@ import os
import time
from xml.etree import ElementTree
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -33,24 +34,36 @@ from nova.volume import volume_types
LOG = logging.getLogger("nova.volume.driver")
+
+volume_opts = [
+ cfg.StrOpt('volume_group',
+ default='nova-volumes',
+ help='Name for the VG that will contain exported volumes'),
+ cfg.StrOpt('num_shell_tries',
+ default=3,
+ help='number of times to attempt to run flakey shell commands'),
+ cfg.StrOpt('num_iscsi_scan_tries',
+ default=3,
+ help='number of times to rescan iSCSI target to find volume'),
+ cfg.IntOpt('iscsi_num_targets',
+ default=100,
+ help='Number of iscsi target ids per host'),
+ cfg.StrOpt('iscsi_target_prefix',
+ default='iqn.2010-10.org.openstack:',
+ help='prefix for iscsi volumes'),
+ cfg.StrOpt('iscsi_ip_address',
+ default='$my_ip',
+ help='use this ip for iscsi'),
+ cfg.IntOpt('iscsi_port',
+ default=3260,
+ help='The port that the iSCSI daemon is listening on'),
+ cfg.StrOpt('rbd_pool',
+ default='rbd',
+ help='the rbd pool in which volumes are stored'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('volume_group', 'nova-volumes',
- 'Name for the VG that will contain exported volumes')
-flags.DEFINE_string('num_shell_tries', 3,
- 'number of times to attempt to run flakey shell commands')
-flags.DEFINE_string('num_iscsi_scan_tries', 3,
- 'number of times to rescan iSCSI target to find volume')
-flags.DEFINE_integer('iscsi_num_targets',
- 100,
- 'Number of iscsi target ids per host')
-flags.DEFINE_string('iscsi_target_prefix', 'iqn.2010-10.org.openstack:',
- 'prefix for iscsi volumes')
-flags.DEFINE_string('iscsi_ip_address', '$my_ip',
- 'use this ip for iscsi')
-flags.DEFINE_integer('iscsi_port', 3260,
- 'The port that the iSCSI daemon is listening on')
-flags.DEFINE_string('rbd_pool', 'rbd',
- 'the rbd pool in which volumes are stored')
+FLAGS.add_options(volume_opts)
class VolumeDriver(object):
diff --git a/nova/volume/iscsi.py b/nova/volume/iscsi.py
index d50dd5fd7..66c293f15 100644
--- a/nova/volume/iscsi.py
+++ b/nova/volume/iscsi.py
@@ -20,13 +20,18 @@ Helper code for the iSCSI volume driver.
"""
+from nova.common import cfg
from nova import flags
from nova import utils
+iscsi_helper_opt = \
+ cfg.StrOpt('iscsi_helper',
+ default='ietadm',
+ help='iscsi target user-land tool to use')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('iscsi_helper', 'ietadm',
- 'iscsi target user-land tool to use')
+FLAGS.add_option(iscsi_helper_opt)
class TargetAdmin(object):
diff --git a/nova/volume/manager.py b/nova/volume/manager.py
index 63eb04664..f22fcc2ca 100644
--- a/nova/volume/manager.py
+++ b/nova/volume/manager.py
@@ -38,6 +38,7 @@ intact.
"""
+from nova.common import cfg
from nova import context
from nova import exception
from nova import flags
@@ -49,16 +50,24 @@ from nova.volume import volume_types
LOG = logging.getLogger('nova.volume.manager')
+
+volume_manager_opts = [
+ cfg.StrOpt('storage_availability_zone',
+ default='nova',
+ help='availability zone of this service'),
+ cfg.StrOpt('volume_driver',
+ default='nova.volume.driver.ISCSIDriver',
+ help='Driver to use for volume creation'),
+ cfg.BoolOpt('use_local_volumes',
+ default=True,
+ help='if True, will not discover local volumes'),
+ cfg.BoolOpt('volume_force_update_capabilities',
+ default=False,
+ help='if True will force update capabilities on each check'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('storage_availability_zone',
- 'nova',
- 'availability zone of this service')
-flags.DEFINE_string('volume_driver', 'nova.volume.driver.ISCSIDriver',
- 'Driver to use for volume creation')
-flags.DEFINE_boolean('use_local_volumes', True,
- 'if True, will not discover local volumes')
-flags.DEFINE_boolean('volume_force_update_capabilities', False,
- 'if True will force update capabilities on each check')
+FLAGS.add_options(volume_manager_opts)
class VolumeManager(manager.SchedulerDependentManager):
diff --git a/nova/volume/san.py b/nova/volume/san.py
index c87841feb..0c88e9d75 100644
--- a/nova/volume/san.py
+++ b/nova/volume/san.py
@@ -26,6 +26,7 @@ import paramiko
from xml.etree import ElementTree
+from nova.common import cfg
from nova import exception
from nova import flags
from nova import log as logging
@@ -34,27 +35,40 @@ from nova.utils import ssh_execute
from nova.volume.driver import ISCSIDriver
LOG = logging.getLogger("nova.volume.driver")
+
+san_opts = [
+ cfg.BoolOpt('san_thin_provision',
+ default='true',
+ help='Use thin provisioning for SAN volumes?'),
+ cfg.StrOpt('san_ip',
+ default='',
+ help='IP address of SAN controller'),
+ cfg.StrOpt('san_login',
+ default='admin',
+ help='Username for SAN controller'),
+ cfg.StrOpt('san_password',
+ default='',
+ help='Password for SAN controller'),
+ cfg.StrOpt('san_private_key',
+ default='',
+ help='Filename of private key to use for SSH authentication'),
+ cfg.StrOpt('san_clustername',
+ default='',
+ help='Cluster name to use for creating volumes'),
+ cfg.IntOpt('san_ssh_port',
+ default=22,
+ help='SSH port to use with SAN'),
+ cfg.BoolOpt('san_is_local',
+ default='false',
+ help='Execute commands locally instead of over SSH; '
+ 'use if the volume service is running on the SAN device'),
+ cfg.StrOpt('san_zfs_volume_base',
+ default='rpool/',
+ help='The ZFS path under which to create zvols for volumes.'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_boolean('san_thin_provision', 'true',
- 'Use thin provisioning for SAN volumes?')
-flags.DEFINE_string('san_ip', '',
- 'IP address of SAN controller')
-flags.DEFINE_string('san_login', 'admin',
- 'Username for SAN controller')
-flags.DEFINE_string('san_password', '',
- 'Password for SAN controller')
-flags.DEFINE_string('san_private_key', '',
- 'Filename of private key to use for SSH authentication')
-flags.DEFINE_string('san_clustername', '',
- 'Cluster name to use for creating volumes')
-flags.DEFINE_integer('san_ssh_port', 22,
- 'SSH port to use with SAN')
-flags.DEFINE_boolean('san_is_local', 'false',
- 'Execute commands locally instead of over SSH; '
- 'use if the volume service is running on the SAN device')
-flags.DEFINE_string('san_zfs_volume_base',
- 'rpool/',
- 'The ZFS path under which to create zvols for volumes.')
+FLAGS.add_options(san_opts)
class SanISCSIDriver(ISCSIDriver):
diff --git a/nova/vsa/api.py b/nova/vsa/api.py
index 27baff151..9c2bc0ce2 100644
--- a/nova/vsa/api.py
+++ b/nova/vsa/api.py
@@ -25,6 +25,7 @@ For assistance and guidelines pls contact
import sys
+from nova.common import cfg
from nova import compute
from nova import exception
from nova import flags
@@ -45,15 +46,23 @@ class VsaState:
DELETING = 'deleting' # VSA started the deletion procedure
+vsa_opts = [
+ cfg.StrOpt('vsa_ec2_access_key',
+ default=None,
+ help='EC2 access key used by VSA for accessing nova'),
+ cfg.StrOpt('vsa_ec2_user_id',
+ default=None,
+ help='User ID used by VSA for accessing nova'),
+ cfg.BoolOpt('vsa_multi_vol_creation',
+ default=True,
+ help='Ask scheduler to create multiple volumes in one call'),
+ cfg.StrOpt('vsa_volume_type_name',
+ default='VSA volume type',
+ help='Name of volume type associated with FE VSA volumes'),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('vsa_ec2_access_key', None,
- 'EC2 access key used by VSA for accessing nova')
-flags.DEFINE_string('vsa_ec2_user_id', None,
- 'User ID used by VSA for accessing nova')
-flags.DEFINE_boolean('vsa_multi_vol_creation', True,
- 'Ask scheduler to create multiple volumes in one call')
-flags.DEFINE_string('vsa_volume_type_name', 'VSA volume type',
- 'Name of volume type associated with FE VSA volumes')
+FLAGS.add_options(vsa_opts)
LOG = logging.getLogger('nova.vsa')
diff --git a/nova/vsa/manager.py b/nova/vsa/manager.py
index 850d99581..42b5b1032 100644
--- a/nova/vsa/manager.py
+++ b/nova/vsa/manager.py
@@ -22,6 +22,7 @@ Handles all processes relating to Virtual Storage Arrays (VSA).
"""
+from nova.common import cfg
from nova import compute
from nova import exception
from nova import flags
@@ -34,9 +35,13 @@ from nova.compute import instance_types
from nova.vsa import utils as vsa_utils
from nova.vsa.api import VsaState
+vsa_driver_opt = \
+ cfg.StrOpt('vsa_driver',
+ default='nova.vsa.connection.get_connection',
+ help='Driver to use for controlling VSAs')
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('vsa_driver', 'nova.vsa.connection.get_connection',
- 'Driver to use for controlling VSAs')
+FLAGS.add_option(vsa_driver_opt)
LOG = logging.getLogger('nova.vsa.manager')