Replace FLAGS with cfg.CONF in other modules, unless tests
Replace all the FLAGS with cfg.CONF in cinder/ Large commit was split into several parts Change-Id: Iacd645997a0c50aa47079c856e1b4e33e3001243 Fixes: bug #1182037
This commit is contained in:
parent
74f25c7d52
commit
1fcbd01d64
|
@ -16,8 +16,12 @@
|
||||||
# Importing full names to not pollute the namespace and cause possible
|
# Importing full names to not pollute the namespace and cause possible
|
||||||
# collisions with use of 'from cinder.backup import <foo>' elsewhere.
|
# collisions with use of 'from cinder.backup import <foo>' elsewhere.
|
||||||
|
|
||||||
import cinder.flags
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
import cinder.openstack.common.importutils
|
import cinder.openstack.common.importutils
|
||||||
|
|
||||||
API = cinder.openstack.common.importutils.import_class(
|
|
||||||
cinder.flags.FLAGS.backup_api_class)
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
API = cinder.openstack.common.importutils.import_class(CONF.backup_api_class)
|
||||||
|
|
|
@ -22,14 +22,11 @@ from eventlet import greenthread
|
||||||
from cinder.backup import rpcapi as backup_rpcapi
|
from cinder.backup import rpcapi as backup_rpcapi
|
||||||
from cinder.db import base
|
from cinder.db import base
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
import cinder.policy
|
import cinder.policy
|
||||||
import cinder.volume
|
import cinder.volume
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,12 @@ from oslo.config import cfg
|
||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder import manager
|
from cinder import manager
|
||||||
from cinder.openstack.common import excutils
|
from cinder.openstack.common import excutils
|
||||||
from cinder.openstack.common import importutils
|
from cinder.openstack.common import importutils
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
backup_manager_opts = [
|
backup_manager_opts = [
|
||||||
|
@ -50,8 +50,8 @@ backup_manager_opts = [
|
||||||
help='Service to use for backups.'),
|
help='Service to use for backups.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(backup_manager_opts)
|
CONF.register_opts(backup_manager_opts)
|
||||||
|
|
||||||
|
|
||||||
class BackupManager(manager.SchedulerDependentManager):
|
class BackupManager(manager.SchedulerDependentManager):
|
||||||
|
@ -60,9 +60,10 @@ class BackupManager(manager.SchedulerDependentManager):
|
||||||
RPC_API_VERSION = '1.0'
|
RPC_API_VERSION = '1.0'
|
||||||
|
|
||||||
def __init__(self, service_name=None, *args, **kwargs):
|
def __init__(self, service_name=None, *args, **kwargs):
|
||||||
self.service = importutils.import_module(FLAGS.backup_service)
|
self.service = importutils.import_module(CONF.backup_service)
|
||||||
self.az = FLAGS.storage_availability_zone
|
self.az = CONF.storage_availability_zone
|
||||||
self.volume_manager = importutils.import_object(FLAGS.volume_manager)
|
self.volume_manager = importutils.import_object(
|
||||||
|
CONF.volume_manager)
|
||||||
self.driver = self.volume_manager.driver
|
self.driver = self.volume_manager.driver
|
||||||
super(BackupManager, self).__init__(service_name='backup',
|
super(BackupManager, self).__init__(service_name='backup',
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
|
@ -120,7 +121,7 @@ class BackupManager(manager.SchedulerDependentManager):
|
||||||
'volume: %(volume_id)s') % locals())
|
'volume: %(volume_id)s') % locals())
|
||||||
self.db.backup_update(context, backup_id, {'host': self.host,
|
self.db.backup_update(context, backup_id, {'host': self.host,
|
||||||
'service':
|
'service':
|
||||||
FLAGS.backup_service})
|
CONF.backup_service})
|
||||||
|
|
||||||
expected_status = 'backing-up'
|
expected_status = 'backing-up'
|
||||||
actual_status = volume['status']
|
actual_status = volume['status']
|
||||||
|
@ -194,7 +195,7 @@ class BackupManager(manager.SchedulerDependentManager):
|
||||||
backup['id'], backup['size'])
|
backup['id'], backup['size'])
|
||||||
|
|
||||||
backup_service = backup['service']
|
backup_service = backup['service']
|
||||||
configured_service = FLAGS.backup_service
|
configured_service = CONF.backup_service
|
||||||
if backup_service != configured_service:
|
if backup_service != configured_service:
|
||||||
err = _('restore_backup aborted, the backup service currently'
|
err = _('restore_backup aborted, the backup service currently'
|
||||||
' configured [%(configured_service)s] is not the'
|
' configured [%(configured_service)s] is not the'
|
||||||
|
@ -239,7 +240,7 @@ class BackupManager(manager.SchedulerDependentManager):
|
||||||
|
|
||||||
backup_service = backup['service']
|
backup_service = backup['service']
|
||||||
if backup_service is not None:
|
if backup_service is not None:
|
||||||
configured_service = FLAGS.backup_service
|
configured_service = CONF.backup_service
|
||||||
if backup_service != configured_service:
|
if backup_service != configured_service:
|
||||||
err = _('delete_backup aborted, the backup service currently'
|
err = _('delete_backup aborted, the backup service currently'
|
||||||
' configured [%(configured_service)s] is not the'
|
' configured [%(configured_service)s] is not the'
|
||||||
|
|
|
@ -19,15 +19,17 @@
|
||||||
Client side of the volume backup RPC API.
|
Client side of the volume backup RPC API.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from cinder import flags
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder.openstack.common import rpc
|
from cinder.openstack.common import rpc
|
||||||
import cinder.openstack.common.rpc.proxy
|
import cinder.openstack.common.rpc.proxy
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
CONF = cfg.CONF
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class BackupAPI(cinder.openstack.common.rpc.proxy.RpcProxy):
|
class BackupAPI(cinder.openstack.common.rpc.proxy.RpcProxy):
|
||||||
|
@ -42,7 +44,7 @@ class BackupAPI(cinder.openstack.common.rpc.proxy.RpcProxy):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(BackupAPI, self).__init__(
|
super(BackupAPI, self).__init__(
|
||||||
topic=FLAGS.backup_topic,
|
topic=CONF.backup_topic,
|
||||||
default_version=self.BASE_RPC_API_VERSION)
|
default_version=self.BASE_RPC_API_VERSION)
|
||||||
|
|
||||||
def create_backup(self, ctxt, host, backup_id, volume_id):
|
def create_backup(self, ctxt, host, backup_id, volume_id):
|
||||||
|
|
|
@ -42,11 +42,11 @@ from oslo.config import cfg
|
||||||
|
|
||||||
from cinder.db import base
|
from cinder.db import base
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder.openstack.common import timeutils
|
from cinder.openstack.common import timeutils
|
||||||
from swiftclient import client as swift
|
from swiftclient import client as swift
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
swiftbackup_service_opts = [
|
swiftbackup_service_opts = [
|
||||||
|
@ -70,8 +70,8 @@ swiftbackup_service_opts = [
|
||||||
help='Compression algorithm (None to disable)'),
|
help='Compression algorithm (None to disable)'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(swiftbackup_service_opts)
|
CONF.register_opts(swiftbackup_service_opts)
|
||||||
|
|
||||||
|
|
||||||
class SwiftBackupService(base.Base):
|
class SwiftBackupService(base.Base):
|
||||||
|
@ -98,14 +98,14 @@ class SwiftBackupService(base.Base):
|
||||||
|
|
||||||
def __init__(self, context, db_driver=None):
|
def __init__(self, context, db_driver=None):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.swift_url = '%s%s' % (FLAGS.backup_swift_url,
|
self.swift_url = '%s%s' % (CONF.backup_swift_url,
|
||||||
self.context.project_id)
|
self.context.project_id)
|
||||||
self.az = FLAGS.storage_availability_zone
|
self.az = CONF.storage_availability_zone
|
||||||
self.data_block_size_bytes = FLAGS.backup_swift_object_size
|
self.data_block_size_bytes = CONF.backup_swift_object_size
|
||||||
self.swift_attempts = FLAGS.backup_swift_retry_attempts
|
self.swift_attempts = CONF.backup_swift_retry_attempts
|
||||||
self.swift_backoff = FLAGS.backup_swift_retry_backoff
|
self.swift_backoff = CONF.backup_swift_retry_backoff
|
||||||
self.compressor = \
|
self.compressor = \
|
||||||
self._get_compressor(FLAGS.backup_compression_algorithm)
|
self._get_compressor(CONF.backup_compression_algorithm)
|
||||||
self.conn = swift.Connection(None, None, None,
|
self.conn = swift.Connection(None, None, None,
|
||||||
retries=self.swift_attempts,
|
retries=self.swift_attempts,
|
||||||
preauthurl=self.swift_url,
|
preauthurl=self.swift_url,
|
||||||
|
@ -133,7 +133,7 @@ class SwiftBackupService(base.Base):
|
||||||
LOG.debug(_('_create_container started, container: %(container)s,'
|
LOG.debug(_('_create_container started, container: %(container)s,'
|
||||||
'backup: %(backup_id)s') % locals())
|
'backup: %(backup_id)s') % locals())
|
||||||
if container is None:
|
if container is None:
|
||||||
container = FLAGS.backup_swift_container
|
container = CONF.backup_swift_container
|
||||||
self.db.backup_update(context, backup_id, {'container': container})
|
self.db.backup_update(context, backup_id, {'container': container})
|
||||||
if not self._check_container_exists(container):
|
if not self._check_container_exists(container):
|
||||||
self.conn.put_container(container)
|
self.conn.put_container(container)
|
||||||
|
@ -236,7 +236,7 @@ class SwiftBackupService(base.Base):
|
||||||
break
|
break
|
||||||
LOG.debug(_('reading chunk of data from volume'))
|
LOG.debug(_('reading chunk of data from volume'))
|
||||||
if self.compressor is not None:
|
if self.compressor is not None:
|
||||||
algorithm = FLAGS.backup_compression_algorithm.lower()
|
algorithm = CONF.backup_compression_algorithm.lower()
|
||||||
obj[object_name]['compression'] = algorithm
|
obj[object_name]['compression'] = algorithm
|
||||||
data_size_bytes = len(data)
|
data_size_bytes = len(data)
|
||||||
data = self.compressor.compress(data)
|
data = self.compressor.compress(data)
|
||||||
|
|
|
@ -19,18 +19,20 @@
|
||||||
Helper code for the iSCSI volume driver.
|
Helper code for the iSCSI volume driver.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import fileutils
|
from cinder.openstack.common import fileutils
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume import utils as volume_utils
|
from cinder.volume import utils as volume_utils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
iscsi_helper_opt = [cfg.StrOpt('iscsi_helper',
|
iscsi_helper_opt = [cfg.StrOpt('iscsi_helper',
|
||||||
|
@ -59,9 +61,9 @@ iscsi_helper_opt = [cfg.StrOpt('iscsi_helper',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(iscsi_helper_opt)
|
CONF.register_opts(iscsi_helper_opt)
|
||||||
FLAGS.import_opt('volume_name_template', 'cinder.db')
|
CONF.import_opt('volume_name_template', 'cinder.db')
|
||||||
|
|
||||||
|
|
||||||
class TargetAdmin(object):
|
class TargetAdmin(object):
|
||||||
|
@ -133,7 +135,7 @@ class TgtAdm(TargetAdmin):
|
||||||
# Note(jdg) tid and lun aren't used by TgtAdm but remain for
|
# Note(jdg) tid and lun aren't used by TgtAdm but remain for
|
||||||
# compatibility
|
# compatibility
|
||||||
|
|
||||||
fileutils.ensure_tree(FLAGS.volumes_dir)
|
fileutils.ensure_tree(CONF.volumes_dir)
|
||||||
|
|
||||||
vol_id = name.split(':')[1]
|
vol_id = name.split(':')[1]
|
||||||
if chap_auth is None:
|
if chap_auth is None:
|
||||||
|
@ -151,7 +153,7 @@ class TgtAdm(TargetAdmin):
|
||||||
""" % (name, path, chap_auth)
|
""" % (name, path, chap_auth)
|
||||||
|
|
||||||
LOG.info(_('Creating iscsi_target for: %s') % vol_id)
|
LOG.info(_('Creating iscsi_target for: %s') % vol_id)
|
||||||
volumes_dir = FLAGS.volumes_dir
|
volumes_dir = CONF.volumes_dir
|
||||||
volume_path = os.path.join(volumes_dir, vol_id)
|
volume_path = os.path.join(volumes_dir, vol_id)
|
||||||
|
|
||||||
f = open(volume_path, 'w+')
|
f = open(volume_path, 'w+')
|
||||||
|
@ -177,7 +179,7 @@ class TgtAdm(TargetAdmin):
|
||||||
os.unlink(volume_path)
|
os.unlink(volume_path)
|
||||||
raise exception.ISCSITargetCreateFailed(volume_id=vol_id)
|
raise exception.ISCSITargetCreateFailed(volume_id=vol_id)
|
||||||
|
|
||||||
iqn = '%s%s' % (FLAGS.iscsi_target_prefix, vol_id)
|
iqn = '%s%s' % (CONF.iscsi_target_prefix, vol_id)
|
||||||
tid = self._get_target(iqn)
|
tid = self._get_target(iqn)
|
||||||
if tid is None:
|
if tid is None:
|
||||||
LOG.error(_("Failed to create iscsi target for volume "
|
LOG.error(_("Failed to create iscsi target for volume "
|
||||||
|
@ -192,10 +194,10 @@ class TgtAdm(TargetAdmin):
|
||||||
|
|
||||||
def remove_iscsi_target(self, tid, lun, vol_id, **kwargs):
|
def remove_iscsi_target(self, tid, lun, vol_id, **kwargs):
|
||||||
LOG.info(_('Removing iscsi_target for: %s') % vol_id)
|
LOG.info(_('Removing iscsi_target for: %s') % vol_id)
|
||||||
vol_uuid_file = FLAGS.volume_name_template % vol_id
|
vol_uuid_file = CONF.volume_name_template % vol_id
|
||||||
volume_path = os.path.join(FLAGS.volumes_dir, vol_uuid_file)
|
volume_path = os.path.join(CONF.volumes_dir, vol_uuid_file)
|
||||||
if os.path.isfile(volume_path):
|
if os.path.isfile(volume_path):
|
||||||
iqn = '%s%s' % (FLAGS.iscsi_target_prefix,
|
iqn = '%s%s' % (CONF.iscsi_target_prefix,
|
||||||
vol_uuid_file)
|
vol_uuid_file)
|
||||||
else:
|
else:
|
||||||
raise exception.ISCSITargetRemoveFailed(volume_id=vol_id)
|
raise exception.ISCSITargetRemoveFailed(volume_id=vol_id)
|
||||||
|
@ -232,10 +234,10 @@ class IetAdm(TargetAdmin):
|
||||||
super(IetAdm, self).__init__('ietadm', execute)
|
super(IetAdm, self).__init__('ietadm', execute)
|
||||||
|
|
||||||
def _iotype(self, path):
|
def _iotype(self, path):
|
||||||
if FLAGS.iscsi_iotype == 'auto':
|
if CONF.iscsi_iotype == 'auto':
|
||||||
return 'blockio' if volume_utils.is_block(path) else 'fileio'
|
return 'blockio' if volume_utils.is_block(path) else 'fileio'
|
||||||
else:
|
else:
|
||||||
return FLAGS.iscsi_iotype
|
return CONF.iscsi_iotype
|
||||||
|
|
||||||
def create_iscsi_target(self, name, tid, lun, path,
|
def create_iscsi_target(self, name, tid, lun, path,
|
||||||
chap_auth=None, **kwargs):
|
chap_auth=None, **kwargs):
|
||||||
|
@ -249,7 +251,7 @@ class IetAdm(TargetAdmin):
|
||||||
(type, username, password) = chap_auth.split()
|
(type, username, password) = chap_auth.split()
|
||||||
self._new_auth(tid, type, username, password, **kwargs)
|
self._new_auth(tid, type, username, password, **kwargs)
|
||||||
|
|
||||||
conf_file = FLAGS.iet_conf
|
conf_file = CONF.iet_conf
|
||||||
if os.path.exists(conf_file):
|
if os.path.exists(conf_file):
|
||||||
try:
|
try:
|
||||||
volume_conf = """
|
volume_conf = """
|
||||||
|
@ -274,8 +276,8 @@ class IetAdm(TargetAdmin):
|
||||||
LOG.info(_('Removing iscsi_target for volume: %s') % vol_id)
|
LOG.info(_('Removing iscsi_target for volume: %s') % vol_id)
|
||||||
self._delete_logicalunit(tid, lun, **kwargs)
|
self._delete_logicalunit(tid, lun, **kwargs)
|
||||||
self._delete_target(tid, **kwargs)
|
self._delete_target(tid, **kwargs)
|
||||||
vol_uuid_file = FLAGS.volume_name_template % vol_id
|
vol_uuid_file = CONF.volume_name_template % vol_id
|
||||||
conf_file = FLAGS.iet_conf
|
conf_file = CONF.iet_conf
|
||||||
if os.path.exists(conf_file):
|
if os.path.exists(conf_file):
|
||||||
with utils.temporary_chown(conf_file):
|
with utils.temporary_chown(conf_file):
|
||||||
try:
|
try:
|
||||||
|
@ -387,8 +389,8 @@ class LioAdm(TargetAdmin):
|
||||||
(chap_auth_userid, chap_auth_password) = chap_auth.split(' ')[1:]
|
(chap_auth_userid, chap_auth_password) = chap_auth.split(' ')[1:]
|
||||||
|
|
||||||
extra_args = []
|
extra_args = []
|
||||||
if FLAGS.lio_initiator_iqns:
|
if CONF.lio_initiator_iqns:
|
||||||
extra_args.append(FLAGS.lio_initiator_iqns)
|
extra_args.append(CONF.lio_initiator_iqns)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
command_args = ['rtstool',
|
command_args = ['rtstool',
|
||||||
|
@ -407,7 +409,7 @@ class LioAdm(TargetAdmin):
|
||||||
|
|
||||||
raise exception.ISCSITargetCreateFailed(volume_id=vol_id)
|
raise exception.ISCSITargetCreateFailed(volume_id=vol_id)
|
||||||
|
|
||||||
iqn = '%s%s' % (FLAGS.iscsi_target_prefix, vol_id)
|
iqn = '%s%s' % (CONF.iscsi_target_prefix, vol_id)
|
||||||
tid = self._get_target(iqn)
|
tid = self._get_target(iqn)
|
||||||
if tid is None:
|
if tid is None:
|
||||||
LOG.error(_("Failed to create iscsi target for volume "
|
LOG.error(_("Failed to create iscsi target for volume "
|
||||||
|
@ -419,7 +421,7 @@ class LioAdm(TargetAdmin):
|
||||||
def remove_iscsi_target(self, tid, lun, vol_id, **kwargs):
|
def remove_iscsi_target(self, tid, lun, vol_id, **kwargs):
|
||||||
LOG.info(_('Removing iscsi_target: %s') % vol_id)
|
LOG.info(_('Removing iscsi_target: %s') % vol_id)
|
||||||
vol_uuid_name = 'volume-%s' % vol_id
|
vol_uuid_name = 'volume-%s' % vol_id
|
||||||
iqn = '%s%s' % (FLAGS.iscsi_target_prefix, vol_uuid_name)
|
iqn = '%s%s' % (CONF.iscsi_target_prefix, vol_uuid_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._execute('rtstool',
|
self._execute('rtstool',
|
||||||
|
@ -462,11 +464,11 @@ class LioAdm(TargetAdmin):
|
||||||
|
|
||||||
|
|
||||||
def get_target_admin():
|
def get_target_admin():
|
||||||
if FLAGS.iscsi_helper == 'tgtadm':
|
if CONF.iscsi_helper == 'tgtadm':
|
||||||
return TgtAdm()
|
return TgtAdm()
|
||||||
elif FLAGS.iscsi_helper == 'fake':
|
elif CONF.iscsi_helper == 'fake':
|
||||||
return FakeIscsiHelper()
|
return FakeIscsiHelper()
|
||||||
elif FLAGS.iscsi_helper == 'lioadm':
|
elif CONF.iscsi_helper == 'lioadm':
|
||||||
return LioAdm()
|
return LioAdm()
|
||||||
else:
|
else:
|
||||||
return IetAdm()
|
return IetAdm()
|
||||||
|
|
|
@ -27,10 +27,10 @@ SHOULD include dedicated exception logging.
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import exception as com_exception
|
from cinder.openstack.common import exception as com_exception
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
exc_log_opts = [
|
exc_log_opts = [
|
||||||
|
@ -39,8 +39,8 @@ exc_log_opts = [
|
||||||
help='make exception message format errors fatal'),
|
help='make exception message format errors fatal'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(exc_log_opts)
|
CONF.register_opts(exc_log_opts)
|
||||||
|
|
||||||
|
|
||||||
class ConvertedException(webob.exc.WSGIHTTPException):
|
class ConvertedException(webob.exc.WSGIHTTPException):
|
||||||
|
@ -105,7 +105,7 @@ class CinderException(Exception):
|
||||||
LOG.exception(_('Exception in string format operation'))
|
LOG.exception(_('Exception in string format operation'))
|
||||||
for name, value in kwargs.iteritems():
|
for name, value in kwargs.iteritems():
|
||||||
LOG.error("%s: %s" % (name, value))
|
LOG.error("%s: %s" % (name, value))
|
||||||
if FLAGS.fatal_exception_format_errors:
|
if CONF.fatal_exception_format_errors:
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
# at least get the core message out if something happened
|
# at least get the core message out if something happened
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
"""Implementation of an image service that uses Glance as the backend"""
|
"""Implementation of an image service that uses Glance as the backend"""
|
||||||
|
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
@ -28,16 +29,17 @@ import urlparse
|
||||||
|
|
||||||
import glanceclient
|
import glanceclient
|
||||||
import glanceclient.exc
|
import glanceclient.exc
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import jsonutils
|
from cinder.openstack.common import jsonutils
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder.openstack.common import timeutils
|
from cinder.openstack.common import timeutils
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
FLAGS = flags.FLAGS
|
|
||||||
|
|
||||||
|
|
||||||
def _parse_image_ref(image_href):
|
def _parse_image_ref(image_href):
|
||||||
|
@ -56,19 +58,19 @@ def _parse_image_ref(image_href):
|
||||||
|
|
||||||
|
|
||||||
def _create_glance_client(context, netloc, use_ssl,
|
def _create_glance_client(context, netloc, use_ssl,
|
||||||
version=FLAGS.glance_api_version):
|
version=CONF.glance_api_version):
|
||||||
"""Instantiate a new glanceclient.Client object."""
|
"""Instantiate a new glanceclient.Client object."""
|
||||||
if version is None:
|
if version is None:
|
||||||
version = FLAGS.glance_api_version
|
version = CONF.glance_api_version
|
||||||
params = {}
|
params = {}
|
||||||
if use_ssl:
|
if use_ssl:
|
||||||
scheme = 'https'
|
scheme = 'https'
|
||||||
# https specific params
|
# https specific params
|
||||||
params['insecure'] = FLAGS.glance_api_insecure
|
params['insecure'] = CONF.glance_api_insecure
|
||||||
params['ssl_compression'] = FLAGS.glance_api_ssl_compression
|
params['ssl_compression'] = CONF.glance_api_ssl_compression
|
||||||
else:
|
else:
|
||||||
scheme = 'http'
|
scheme = 'http'
|
||||||
if FLAGS.auth_strategy == 'keystone':
|
if CONF.auth_strategy == 'keystone':
|
||||||
params['token'] = context.auth_token
|
params['token'] = context.auth_token
|
||||||
endpoint = '%s://%s' % (scheme, netloc)
|
endpoint = '%s://%s' % (scheme, netloc)
|
||||||
return glanceclient.Client(str(version), endpoint, **params)
|
return glanceclient.Client(str(version), endpoint, **params)
|
||||||
|
@ -77,12 +79,12 @@ def _create_glance_client(context, netloc, use_ssl,
|
||||||
def get_api_servers():
|
def get_api_servers():
|
||||||
"""Return Iterable over shuffled api servers.
|
"""Return Iterable over shuffled api servers.
|
||||||
|
|
||||||
Shuffle a list of FLAGS.glance_api_servers and return an iterator
|
Shuffle a list of CONF.glance_api_servers and return an iterator
|
||||||
that will cycle through the list, looping around to the beginning
|
that will cycle through the list, looping around to the beginning
|
||||||
if necessary.
|
if necessary.
|
||||||
"""
|
"""
|
||||||
api_servers = []
|
api_servers = []
|
||||||
for api_server in FLAGS.glance_api_servers:
|
for api_server in CONF.glance_api_servers:
|
||||||
if '//' not in api_server:
|
if '//' not in api_server:
|
||||||
api_server = 'http://' + api_server
|
api_server = 'http://' + api_server
|
||||||
url = urlparse.urlparse(api_server)
|
url = urlparse.urlparse(api_server)
|
||||||
|
@ -129,7 +131,7 @@ class GlanceClientWrapper(object):
|
||||||
"""Call a glance client method.
|
"""Call a glance client method.
|
||||||
|
|
||||||
If we get a connection error,
|
If we get a connection error,
|
||||||
retry the request according to FLAGS.glance_num_retries.
|
retry the request according to CONF.glance_num_retries.
|
||||||
"""
|
"""
|
||||||
version = self.version
|
version = self.version
|
||||||
if version in kwargs:
|
if version in kwargs:
|
||||||
|
@ -138,7 +140,7 @@ class GlanceClientWrapper(object):
|
||||||
retry_excs = (glanceclient.exc.ServiceUnavailable,
|
retry_excs = (glanceclient.exc.ServiceUnavailable,
|
||||||
glanceclient.exc.InvalidEndpoint,
|
glanceclient.exc.InvalidEndpoint,
|
||||||
glanceclient.exc.CommunicationError)
|
glanceclient.exc.CommunicationError)
|
||||||
num_attempts = 1 + FLAGS.glance_num_retries
|
num_attempts = 1 + CONF.glance_num_retries
|
||||||
|
|
||||||
for attempt in xrange(1, num_attempts + 1):
|
for attempt in xrange(1, num_attempts + 1):
|
||||||
client = self.client or self._create_onetime_client(context,
|
client = self.client or self._create_onetime_client(context,
|
||||||
|
|
|
@ -25,6 +25,7 @@ Some slight modifications, but at some point
|
||||||
we should look at maybe pushign this up to OSLO
|
we should look at maybe pushign this up to OSLO
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -32,19 +33,19 @@ import tempfile
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import fileutils
|
from cinder.openstack.common import fileutils
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
image_helper_opt = [cfg.StrOpt('image_conversion_dir',
|
image_helper_opt = [cfg.StrOpt('image_conversion_dir',
|
||||||
default='/tmp',
|
default='/tmp',
|
||||||
help='parent dir for tempdir used for image conversion'), ]
|
help='parent dir for tempdir used for image conversion'), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(image_helper_opt)
|
CONF.register_opts(image_helper_opt)
|
||||||
|
|
||||||
|
|
||||||
class QemuImgInfo(object):
|
class QemuImgInfo(object):
|
||||||
|
@ -211,15 +212,15 @@ def fetch(context, image_service, image_id, path, _user_id, _project_id):
|
||||||
def fetch_to_raw(context, image_service,
|
def fetch_to_raw(context, image_service,
|
||||||
image_id, dest,
|
image_id, dest,
|
||||||
user_id=None, project_id=None):
|
user_id=None, project_id=None):
|
||||||
if (FLAGS.image_conversion_dir and not
|
if (CONF.image_conversion_dir and not
|
||||||
os.path.exists(FLAGS.image_conversion_dir)):
|
os.path.exists(CONF.image_conversion_dir)):
|
||||||
os.makedirs(FLAGS.image_conversion_dir)
|
os.makedirs(CONF.image_conversion_dir)
|
||||||
|
|
||||||
# NOTE(avishay): I'm not crazy about creating temp files which may be
|
# NOTE(avishay): I'm not crazy about creating temp files which may be
|
||||||
# large and cause disk full errors which would confuse users.
|
# large and cause disk full errors which would confuse users.
|
||||||
# Unfortunately it seems that you can't pipe to 'qemu-img convert' because
|
# Unfortunately it seems that you can't pipe to 'qemu-img convert' because
|
||||||
# it seeks. Maybe we can think of something for a future version.
|
# it seeks. Maybe we can think of something for a future version.
|
||||||
fd, tmp = tempfile.mkstemp(dir=FLAGS.image_conversion_dir)
|
fd, tmp = tempfile.mkstemp(dir=CONF.image_conversion_dir)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
with fileutils.remove_path_on_error(tmp):
|
with fileutils.remove_path_on_error(tmp):
|
||||||
fetch(context, image_service, image_id, tmp, user_id, project_id)
|
fetch(context, image_service, image_id, tmp, user_id, project_id)
|
||||||
|
@ -267,11 +268,11 @@ def upload_volume(context, image_service, image_meta, volume_path):
|
||||||
image_service.update(context, image_id, {}, image_file)
|
image_service.update(context, image_id, {}, image_file)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (FLAGS.image_conversion_dir and not
|
if (CONF.image_conversion_dir and not
|
||||||
os.path.exists(FLAGS.image_conversion_dir)):
|
os.path.exists(CONF.image_conversion_dir)):
|
||||||
os.makedirs(FLAGS.image_conversion_dir)
|
os.makedirs(CONF.image_conversion_dir)
|
||||||
|
|
||||||
fd, tmp = tempfile.mkstemp(dir=FLAGS.image_conversion_dir)
|
fd, tmp = tempfile.mkstemp(dir=CONF.image_conversion_dir)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
with fileutils.remove_path_on_error(tmp):
|
with fileutils.remove_path_on_error(tmp):
|
||||||
LOG.debug("%s was raw, converting to %s" %
|
LOG.debug("%s was raw, converting to %s" %
|
||||||
|
|
|
@ -53,8 +53,10 @@ This module provides Manager, a base class for managers.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from cinder.db import base
|
from cinder.db import base
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder.openstack.common import periodic_task
|
from cinder.openstack.common import periodic_task
|
||||||
from cinder.openstack.common.rpc import dispatcher as rpc_dispatcher
|
from cinder.openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||||
|
@ -62,9 +64,7 @@ from cinder.scheduler import rpcapi as scheduler_rpcapi
|
||||||
from cinder import version
|
from cinder import version
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class Manager(base.Base, periodic_task.PeriodicTasks):
|
||||||
|
|
||||||
def __init__(self, host=None, db_driver=None):
|
def __init__(self, host=None, db_driver=None):
|
||||||
if not host:
|
if not host:
|
||||||
host = FLAGS.host
|
host = CONF.host
|
||||||
self.host = host
|
self.host = host
|
||||||
super(Manager, self).__init__(db_driver)
|
super(Manager, self).__init__(db_driver)
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ class Manager(base.Base, periodic_task.PeriodicTasks):
|
||||||
|
|
||||||
def service_config(self, context):
|
def service_config(self, context):
|
||||||
config = {}
|
config = {}
|
||||||
for key in FLAGS:
|
for key in CONF:
|
||||||
config[key] = FLAGS.get(key, None)
|
config[key] = CONF.get(key, None)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,14 @@
|
||||||
|
|
||||||
"""Policy Engine For Cinder"""
|
"""Policy Engine For Cinder"""
|
||||||
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import policy
|
from cinder.openstack.common import policy
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
|
|
||||||
|
|
||||||
policy_opts = [
|
policy_opts = [
|
||||||
cfg.StrOpt('policy_file',
|
cfg.StrOpt('policy_file',
|
||||||
default='policy.json',
|
default='policy.json',
|
||||||
|
@ -32,8 +33,8 @@ policy_opts = [
|
||||||
default='default',
|
default='default',
|
||||||
help=_('Rule checked when requested rule is not found')), ]
|
help=_('Rule checked when requested rule is not found')), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(policy_opts)
|
CONF.register_opts(policy_opts)
|
||||||
|
|
||||||
_POLICY_PATH = None
|
_POLICY_PATH = None
|
||||||
_POLICY_CACHE = {}
|
_POLICY_CACHE = {}
|
||||||
|
@ -51,13 +52,13 @@ def init():
|
||||||
global _POLICY_PATH
|
global _POLICY_PATH
|
||||||
global _POLICY_CACHE
|
global _POLICY_CACHE
|
||||||
if not _POLICY_PATH:
|
if not _POLICY_PATH:
|
||||||
_POLICY_PATH = utils.find_config(FLAGS.policy_file)
|
_POLICY_PATH = utils.find_config(CONF.policy_file)
|
||||||
utils.read_cached_file(_POLICY_PATH, _POLICY_CACHE,
|
utils.read_cached_file(_POLICY_PATH, _POLICY_CACHE,
|
||||||
reload_func=_set_brain)
|
reload_func=_set_brain)
|
||||||
|
|
||||||
|
|
||||||
def _set_brain(data):
|
def _set_brain(data):
|
||||||
default_rule = FLAGS.policy_default_rule
|
default_rule = CONF.policy_default_rule
|
||||||
policy.set_brain(policy.Brain.load_json(data, default_rule))
|
policy.set_brain(policy.Brain.load_json(data, default_rule))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,17 +18,18 @@
|
||||||
|
|
||||||
"""Quotas for volumes."""
|
"""Quotas for volumes."""
|
||||||
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from cinder import db
|
from cinder import db
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import importutils
|
from cinder.openstack.common import importutils
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder.openstack.common import timeutils
|
from cinder.openstack.common import timeutils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
quota_opts = [
|
quota_opts = [
|
||||||
|
@ -55,8 +56,8 @@ quota_opts = [
|
||||||
default='cinder.quota.DbQuotaDriver',
|
default='cinder.quota.DbQuotaDriver',
|
||||||
help='default driver to use for quota checks'), ]
|
help='default driver to use for quota checks'), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(quota_opts)
|
CONF.register_opts(quota_opts)
|
||||||
|
|
||||||
|
|
||||||
class DbQuotaDriver(object):
|
class DbQuotaDriver(object):
|
||||||
|
@ -296,7 +297,7 @@ class DbQuotaDriver(object):
|
||||||
|
|
||||||
# Set up the reservation expiration
|
# Set up the reservation expiration
|
||||||
if expire is None:
|
if expire is None:
|
||||||
expire = FLAGS.reservation_expire
|
expire = CONF.reservation_expire
|
||||||
if isinstance(expire, (int, long)):
|
if isinstance(expire, (int, long)):
|
||||||
expire = datetime.timedelta(seconds=expire)
|
expire = datetime.timedelta(seconds=expire)
|
||||||
if isinstance(expire, datetime.timedelta):
|
if isinstance(expire, datetime.timedelta):
|
||||||
|
@ -321,7 +322,7 @@ class DbQuotaDriver(object):
|
||||||
# session isn't available outside the DBAPI, we
|
# session isn't available outside the DBAPI, we
|
||||||
# have to do the work there.
|
# have to do the work there.
|
||||||
return db.quota_reserve(context, resources, quotas, deltas, expire,
|
return db.quota_reserve(context, resources, quotas, deltas, expire,
|
||||||
FLAGS.until_refresh, FLAGS.max_age,
|
CONF.until_refresh, CONF.max_age,
|
||||||
project_id=project_id)
|
project_id=project_id)
|
||||||
|
|
||||||
def commit(self, context, reservations, project_id=None):
|
def commit(self, context, reservations, project_id=None):
|
||||||
|
@ -446,7 +447,7 @@ class BaseResource(object):
|
||||||
def default(self):
|
def default(self):
|
||||||
"""Return the default value of the quota."""
|
"""Return the default value of the quota."""
|
||||||
|
|
||||||
return FLAGS[self.flag] if self.flag else -1
|
return CONF[self.flag] if self.flag else -1
|
||||||
|
|
||||||
|
|
||||||
class ReservableResource(BaseResource):
|
class ReservableResource(BaseResource):
|
||||||
|
@ -538,7 +539,7 @@ class QuotaEngine(object):
|
||||||
"""Initialize a Quota object."""
|
"""Initialize a Quota object."""
|
||||||
|
|
||||||
if not quota_driver_class:
|
if not quota_driver_class:
|
||||||
quota_driver_class = FLAGS.quota_driver
|
quota_driver_class = CONF.quota_driver
|
||||||
|
|
||||||
if isinstance(quota_driver_class, basestring):
|
if isinstance(quota_driver_class, basestring):
|
||||||
quota_driver_class = importutils.import_object(quota_driver_class)
|
quota_driver_class = importutils.import_object(quota_driver_class)
|
||||||
|
@ -792,7 +793,7 @@ def _sync_gigabytes(context, project_id, session):
|
||||||
(_junk, vol_gigs) = db.volume_data_get_for_project(context,
|
(_junk, vol_gigs) = db.volume_data_get_for_project(context,
|
||||||
project_id,
|
project_id,
|
||||||
session=session)
|
session=session)
|
||||||
if FLAGS.no_snapshot_gb_quota:
|
if CONF.no_snapshot_gb_quota:
|
||||||
return {'gigabytes': vol_gigs}
|
return {'gigabytes': vol_gigs}
|
||||||
|
|
||||||
(_junk, snap_gigs) = db.snapshot_data_get_for_project(context,
|
(_junk, snap_gigs) = db.snapshot_data_get_for_project(context,
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
"""Generic Node base class for all workers that run on hosts."""
|
"""Generic Node base class for all workers that run on hosts."""
|
||||||
|
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
|
@ -34,7 +35,6 @@ from oslo.config import cfg
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import db
|
from cinder import db
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import importutils
|
from cinder.openstack.common import importutils
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder.openstack.common import rpc
|
from cinder.openstack.common import rpc
|
||||||
|
@ -42,6 +42,7 @@ from cinder import utils
|
||||||
from cinder import version
|
from cinder import version
|
||||||
from cinder import wsgi
|
from cinder import wsgi
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
service_opts = [
|
service_opts = [
|
||||||
|
@ -63,8 +64,8 @@ service_opts = [
|
||||||
default=8776,
|
default=8776,
|
||||||
help='port for os volume api to listen'), ]
|
help='port for os volume api to listen'), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(service_opts)
|
CONF.register_opts(service_opts)
|
||||||
|
|
||||||
|
|
||||||
class SignalExit(SystemExit):
|
class SignalExit(SystemExit):
|
||||||
|
@ -398,7 +399,7 @@ class Service(object):
|
||||||
self.timers.append(periodic)
|
self.timers.append(periodic)
|
||||||
|
|
||||||
def _create_service_ref(self, context):
|
def _create_service_ref(self, context):
|
||||||
zone = FLAGS.storage_availability_zone
|
zone = CONF.storage_availability_zone
|
||||||
service_ref = db.service_create(context,
|
service_ref = db.service_create(context,
|
||||||
{'host': self.host,
|
{'host': self.host,
|
||||||
'binary': self.binary,
|
'binary': self.binary,
|
||||||
|
@ -417,30 +418,30 @@ class Service(object):
|
||||||
periodic_fuzzy_delay=None, service_name=None):
|
periodic_fuzzy_delay=None, service_name=None):
|
||||||
"""Instantiates class and passes back application object.
|
"""Instantiates class and passes back application object.
|
||||||
|
|
||||||
:param host: defaults to FLAGS.host
|
:param host: defaults to CONF.host
|
||||||
:param binary: defaults to basename of executable
|
:param binary: defaults to basename of executable
|
||||||
:param topic: defaults to bin_name - 'cinder-' part
|
:param topic: defaults to bin_name - 'cinder-' part
|
||||||
:param manager: defaults to FLAGS.<topic>_manager
|
:param manager: defaults to CONF.<topic>_manager
|
||||||
:param report_interval: defaults to FLAGS.report_interval
|
:param report_interval: defaults to CONF.report_interval
|
||||||
:param periodic_interval: defaults to FLAGS.periodic_interval
|
:param periodic_interval: defaults to CONF.periodic_interval
|
||||||
:param periodic_fuzzy_delay: defaults to FLAGS.periodic_fuzzy_delay
|
:param periodic_fuzzy_delay: defaults to CONF.periodic_fuzzy_delay
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not host:
|
if not host:
|
||||||
host = FLAGS.host
|
host = CONF.host
|
||||||
if not binary:
|
if not binary:
|
||||||
binary = os.path.basename(inspect.stack()[-1][1])
|
binary = os.path.basename(inspect.stack()[-1][1])
|
||||||
if not topic:
|
if not topic:
|
||||||
topic = binary
|
topic = binary
|
||||||
if not manager:
|
if not manager:
|
||||||
subtopic = topic.rpartition('cinder-')[2]
|
subtopic = topic.rpartition('cinder-')[2]
|
||||||
manager = FLAGS.get('%s_manager' % subtopic, None)
|
manager = CONF.get('%s_manager' % subtopic, None)
|
||||||
if report_interval is None:
|
if report_interval is None:
|
||||||
report_interval = FLAGS.report_interval
|
report_interval = CONF.report_interval
|
||||||
if periodic_interval is None:
|
if periodic_interval is None:
|
||||||
periodic_interval = FLAGS.periodic_interval
|
periodic_interval = CONF.periodic_interval
|
||||||
if periodic_fuzzy_delay is None:
|
if periodic_fuzzy_delay is None:
|
||||||
periodic_fuzzy_delay = FLAGS.periodic_fuzzy_delay
|
periodic_fuzzy_delay = CONF.periodic_fuzzy_delay
|
||||||
service_obj = cls(host, binary, topic, manager,
|
service_obj = cls(host, binary, topic, manager,
|
||||||
report_interval=report_interval,
|
report_interval=report_interval,
|
||||||
periodic_interval=periodic_interval,
|
periodic_interval=periodic_interval,
|
||||||
|
@ -486,7 +487,7 @@ class Service(object):
|
||||||
def report_state(self):
|
def report_state(self):
|
||||||
"""Update the state of this service in the datastore."""
|
"""Update the state of this service in the datastore."""
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
zone = FLAGS.storage_availability_zone
|
zone = CONF.storage_availability_zone
|
||||||
state_catalog = {}
|
state_catalog = {}
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
@ -531,8 +532,8 @@ class WSGIService(object):
|
||||||
self.manager = self._get_manager()
|
self.manager = self._get_manager()
|
||||||
self.loader = loader or wsgi.Loader()
|
self.loader = loader or wsgi.Loader()
|
||||||
self.app = self.loader.load_app(name)
|
self.app = self.loader.load_app(name)
|
||||||
self.host = getattr(FLAGS, '%s_listen' % name, "0.0.0.0")
|
self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
|
||||||
self.port = getattr(FLAGS, '%s_listen_port' % name, 0)
|
self.port = getattr(CONF, '%s_listen_port' % name, 0)
|
||||||
self.server = wsgi.Server(name,
|
self.server = wsgi.Server(name,
|
||||||
self.app,
|
self.app,
|
||||||
host=self.host,
|
host=self.host,
|
||||||
|
@ -549,10 +550,10 @@ class WSGIService(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
fl = '%s_manager' % self.name
|
fl = '%s_manager' % self.name
|
||||||
if fl not in FLAGS:
|
if fl not in CONF:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
manager_class_name = FLAGS.get(fl, None)
|
manager_class_name = CONF.get(fl, None)
|
||||||
if not manager_class_name:
|
if not manager_class_name:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -605,9 +606,9 @@ def serve(*servers):
|
||||||
|
|
||||||
|
|
||||||
def wait():
|
def wait():
|
||||||
LOG.debug(_('Full set of FLAGS:'))
|
LOG.debug(_('Full set of CONF:'))
|
||||||
for flag in FLAGS:
|
for flag in CONF:
|
||||||
flag_get = FLAGS.get(flag, None)
|
flag_get = CONF.get(flag, None)
|
||||||
# hide flag contents from log if contains a password
|
# hide flag contents from log if contains a password
|
||||||
# should use secret flag when switch over to openstack-common
|
# should use secret flag when switch over to openstack-common
|
||||||
if ("_password" in flag or "_key" in flag or
|
if ("_password" in flag or "_key" in flag or
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
Handles all requests relating to transferring ownership of volumes.
|
Handles all requests relating to transferring ownership of volumes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
|
@ -26,11 +27,11 @@ from oslo.config import cfg
|
||||||
|
|
||||||
from cinder.db import base
|
from cinder.db import base
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder import quota
|
from cinder import quota
|
||||||
from cinder.volume import api as volume_api
|
from cinder.volume import api as volume_api
|
||||||
|
|
||||||
|
|
||||||
volume_transfer_opts = [
|
volume_transfer_opts = [
|
||||||
cfg.IntOpt('volume_transfer_salt_length', default=8,
|
cfg.IntOpt('volume_transfer_salt_length', default=8,
|
||||||
help='The number of characters in the salt.'),
|
help='The number of characters in the salt.'),
|
||||||
|
@ -38,8 +39,8 @@ volume_transfer_opts = [
|
||||||
help='The number of characters in the '
|
help='The number of characters in the '
|
||||||
'autogenerated auth key.'), ]
|
'autogenerated auth key.'), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(volume_transfer_opts)
|
CONF.register_opts(volume_transfer_opts)
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
QUOTAS = quota.QUOTAS
|
QUOTAS = quota.QUOTAS
|
||||||
|
@ -102,8 +103,8 @@ class API(base.Base):
|
||||||
raise exception.InvalidVolume(reason=_("status must be available"))
|
raise exception.InvalidVolume(reason=_("status must be available"))
|
||||||
|
|
||||||
# The salt is just a short random string.
|
# The salt is just a short random string.
|
||||||
salt = self._get_random_string(FLAGS.volume_transfer_salt_length)
|
salt = self._get_random_string(CONF.volume_transfer_salt_length)
|
||||||
auth_key = self._get_random_string(FLAGS.volume_transfer_key_length)
|
auth_key = self._get_random_string(CONF.volume_transfer_key_length)
|
||||||
crypt_hash = self._get_crypt_hash(salt, auth_key)
|
crypt_hash = self._get_crypt_hash(salt, auth_key)
|
||||||
|
|
||||||
# TODO(ollie): Transfer expiry needs to be implemented.
|
# TODO(ollie): Transfer expiry needs to be implemented.
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
"""Utilities and helper functions."""
|
"""Utilities and helper functions."""
|
||||||
|
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import errno
|
import errno
|
||||||
import functools
|
import functools
|
||||||
import hashlib
|
import hashlib
|
||||||
import inspect
|
import inspect
|
||||||
import itertools
|
|
||||||
import os
|
import os
|
||||||
import paramiko
|
import paramiko
|
||||||
import pyclbr
|
import pyclbr
|
||||||
|
@ -34,13 +34,9 @@ import re
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import signal
|
import signal
|
||||||
import socket
|
|
||||||
import struct
|
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import types
|
|
||||||
import warnings
|
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
from xml.parsers import expat
|
from xml.parsers import expat
|
||||||
from xml import sax
|
from xml import sax
|
||||||
|
@ -52,8 +48,9 @@ from eventlet.green import subprocess
|
||||||
from eventlet import greenthread
|
from eventlet import greenthread
|
||||||
from eventlet import pools
|
from eventlet import pools
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import excutils
|
from cinder.openstack.common import excutils
|
||||||
from cinder.openstack.common import importutils
|
from cinder.openstack.common import importutils
|
||||||
from cinder.openstack.common import lockutils
|
from cinder.openstack.common import lockutils
|
||||||
|
@ -61,10 +58,10 @@ from cinder.openstack.common import log as logging
|
||||||
from cinder.openstack.common import timeutils
|
from cinder.openstack.common import timeutils
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
|
ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
|
||||||
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
||||||
FLAGS = flags.FLAGS
|
|
||||||
|
|
||||||
synchronized = lockutils.synchronized_with_prefix('cinder-')
|
synchronized = lockutils.synchronized_with_prefix('cinder-')
|
||||||
|
|
||||||
|
@ -79,9 +76,9 @@ def find_config(config_path):
|
||||||
"""
|
"""
|
||||||
possible_locations = [
|
possible_locations = [
|
||||||
config_path,
|
config_path,
|
||||||
os.path.join(FLAGS.state_path, "etc", "cinder", config_path),
|
os.path.join(CONF.state_path, "etc", "cinder", config_path),
|
||||||
os.path.join(FLAGS.state_path, "etc", config_path),
|
os.path.join(CONF.state_path, "etc", config_path),
|
||||||
os.path.join(FLAGS.state_path, config_path),
|
os.path.join(CONF.state_path, config_path),
|
||||||
"/etc/cinder/%s" % config_path,
|
"/etc/cinder/%s" % config_path,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -121,7 +118,7 @@ def execute(*cmd, **kwargs):
|
||||||
:param attempts: How many times to retry cmd.
|
:param attempts: How many times to retry cmd.
|
||||||
:param run_as_root: True | False. Defaults to False. If set to True,
|
:param run_as_root: True | False. Defaults to False. If set to True,
|
||||||
the command is prefixed by the command specified
|
the command is prefixed by the command specified
|
||||||
in the root_helper FLAG.
|
in the root_helper CONF.
|
||||||
|
|
||||||
:raises exception.Error: on receiving unknown arguments
|
:raises exception.Error: on receiving unknown arguments
|
||||||
:raises exception.ProcessExecutionError:
|
:raises exception.ProcessExecutionError:
|
||||||
|
@ -149,18 +146,18 @@ def execute(*cmd, **kwargs):
|
||||||
|
|
||||||
if run_as_root:
|
if run_as_root:
|
||||||
|
|
||||||
if FLAGS.rootwrap_config is None or FLAGS.root_helper != 'sudo':
|
if CONF.rootwrap_config is None or CONF.root_helper != 'sudo':
|
||||||
LOG.deprecated(_('The root_helper option (which lets you specify '
|
LOG.deprecated(_('The root_helper option (which lets you specify '
|
||||||
'a root wrapper different from cinder-rootwrap, '
|
'a root wrapper different from cinder-rootwrap, '
|
||||||
'and defaults to using sudo) is now deprecated. '
|
'and defaults to using sudo) is now deprecated. '
|
||||||
'You should use the rootwrap_config option '
|
'You should use the rootwrap_config option '
|
||||||
'instead.'))
|
'instead.'))
|
||||||
|
|
||||||
if (FLAGS.rootwrap_config is not None):
|
if (CONF.rootwrap_config is not None):
|
||||||
cmd = ['sudo', 'cinder-rootwrap',
|
cmd = ['sudo', 'cinder-rootwrap',
|
||||||
FLAGS.rootwrap_config] + list(cmd)
|
CONF.rootwrap_config] + list(cmd)
|
||||||
else:
|
else:
|
||||||
cmd = shlex.split(FLAGS.root_helper) + list(cmd)
|
cmd = shlex.split(CONF.root_helper) + list(cmd)
|
||||||
cmd = map(str, cmd)
|
cmd = map(str, cmd)
|
||||||
|
|
||||||
while attempts > 0:
|
while attempts > 0:
|
||||||
|
@ -410,7 +407,7 @@ def last_completed_audit_period(unit=None):
|
||||||
The begin timestamp of this audit period is the same as the
|
The begin timestamp of this audit period is the same as the
|
||||||
end of the previous."""
|
end of the previous."""
|
||||||
if not unit:
|
if not unit:
|
||||||
unit = FLAGS.volume_usage_audit_period
|
unit = CONF.volume_usage_audit_period
|
||||||
|
|
||||||
offset = 0
|
offset = 0
|
||||||
if '@' in unit:
|
if '@' in unit:
|
||||||
|
@ -564,7 +561,7 @@ class LazyPluggable(object):
|
||||||
|
|
||||||
def __get_backend(self):
|
def __get_backend(self):
|
||||||
if not self.__backend:
|
if not self.__backend:
|
||||||
backend_name = FLAGS[self.__pivot]
|
backend_name = CONF[self.__pivot]
|
||||||
if backend_name not in self.__backends:
|
if backend_name not in self.__backends:
|
||||||
raise exception.Error(_('Invalid backend: %s') % backend_name)
|
raise exception.Error(_('Invalid backend: %s') % backend_name)
|
||||||
|
|
||||||
|
@ -829,11 +826,11 @@ def is_valid_ipv4(address):
|
||||||
|
|
||||||
|
|
||||||
def monkey_patch():
|
def monkey_patch():
|
||||||
""" If the Flags.monkey_patch set as True,
|
""" If the CONF.monkey_patch set as True,
|
||||||
this function patches a decorator
|
this function patches a decorator
|
||||||
for all functions in specified modules.
|
for all functions in specified modules.
|
||||||
You can set decorators for each modules
|
You can set decorators for each modules
|
||||||
using FLAGS.monkey_patch_modules.
|
using CONF.monkey_patch_modules.
|
||||||
The format is "Module path:Decorator function".
|
The format is "Module path:Decorator function".
|
||||||
Example: 'cinder.api.ec2.cloud:' \
|
Example: 'cinder.api.ec2.cloud:' \
|
||||||
cinder.openstack.common.notifier.api.notify_decorator'
|
cinder.openstack.common.notifier.api.notify_decorator'
|
||||||
|
@ -844,11 +841,11 @@ def monkey_patch():
|
||||||
name - name of the function
|
name - name of the function
|
||||||
function - object of the function
|
function - object of the function
|
||||||
"""
|
"""
|
||||||
# If FLAGS.monkey_patch is not True, this function do nothing.
|
# If CONF.monkey_patch is not True, this function do nothing.
|
||||||
if not FLAGS.monkey_patch:
|
if not CONF.monkey_patch:
|
||||||
return
|
return
|
||||||
# Get list of modules and decorators
|
# Get list of modules and decorators
|
||||||
for module_and_decorator in FLAGS.monkey_patch_modules:
|
for module_and_decorator in CONF.monkey_patch_modules:
|
||||||
module, decorator_name = module_and_decorator.split(':')
|
module, decorator_name = module_and_decorator.split(':')
|
||||||
# import decorator function
|
# import decorator function
|
||||||
decorator = importutils.import_class(decorator_name)
|
decorator = importutils.import_class(decorator_name)
|
||||||
|
@ -897,7 +894,7 @@ def generate_glance_url():
|
||||||
"""Generate the URL to glance."""
|
"""Generate the URL to glance."""
|
||||||
# TODO(jk0): This will eventually need to take SSL into consideration
|
# TODO(jk0): This will eventually need to take SSL into consideration
|
||||||
# when supported in glance.
|
# when supported in glance.
|
||||||
return "http://%s:%d" % (FLAGS.glance_host, FLAGS.glance_port)
|
return "http://%s:%d" % (CONF.glance_host, CONF.glance_port)
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
@ -1010,7 +1007,7 @@ def service_is_up(service):
|
||||||
last_heartbeat = service['updated_at'] or service['created_at']
|
last_heartbeat = service['updated_at'] or service['created_at']
|
||||||
# Timestamps in DB are UTC.
|
# Timestamps in DB are UTC.
|
||||||
elapsed = total_seconds(timeutils.utcnow() - last_heartbeat)
|
elapsed = total_seconds(timeutils.utcnow() - last_heartbeat)
|
||||||
return abs(elapsed) <= FLAGS.service_down_time
|
return abs(elapsed) <= CONF.service_down_time
|
||||||
|
|
||||||
|
|
||||||
def generate_mac_address():
|
def generate_mac_address():
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
"""Utility methods for working with WSGI servers."""
|
"""Utility methods for working with WSGI servers."""
|
||||||
|
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
@ -36,10 +37,10 @@ import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flags
|
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
|
|
||||||
|
|
||||||
socket_opts = [
|
socket_opts = [
|
||||||
cfg.IntOpt('backlog',
|
cfg.IntOpt('backlog',
|
||||||
default=4096,
|
default=4096,
|
||||||
|
@ -65,7 +66,6 @@ socket_opts = [
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONF.register_opts(socket_opts)
|
CONF.register_opts(socket_opts)
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ class Loader(object):
|
||||||
:returns: None
|
:returns: None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
config_path = config_path or FLAGS.api_paste_config
|
config_path = config_path or CONF.api_paste_config
|
||||||
self.config_path = utils.find_config(config_path)
|
self.config_path = utils.find_config(config_path)
|
||||||
|
|
||||||
def load_app(self, name):
|
def load_app(self, name):
|
||||||
|
|
Loading…
Reference in New Issue