from oslo.config import cfg
from cinder import exception
-from cinder import flags
from cinder.openstack.common.db import api as db_api
default='backup-%s',
help='Template string to be used to generate backup names'), ]
-FLAGS = flags.FLAGS
-FLAGS.register_opts(db_opts)
-
+CONF = cfg.CONF
+CONF.register_opts(db_opts)
_BACKEND_MAPPING = {'sqlalchemy': 'cinder.db.sqlalchemy.api'}
-
IMPL = db_api.DBAPI(backend_mapping=_BACKEND_MAPPING)
"""Base class for classes that need modular database access."""
+
from oslo.config import cfg
-from cinder import flags
from cinder.openstack.common import importutils
+
db_driver_opt = cfg.StrOpt('db_driver',
default='cinder.db',
help='driver to use for database access')
-FLAGS = flags.FLAGS
-FLAGS.register_opt(db_driver_opt)
+CONF = cfg.CONF
+CONF.register_opt(db_driver_opt)
class Base(object):
def __init__(self, db_driver=None):
if not db_driver:
- db_driver = FLAGS.db_driver
+ db_driver = CONF.db_driver
self.db = importutils.import_module(db_driver) # pylint: disable=C0103
"""Implementation of SQLAlchemy backend."""
+
import datetime
import sys
import uuid
import warnings
+from oslo.config import cfg
from sqlalchemy.exc import IntegrityError
from sqlalchemy import or_
from sqlalchemy.orm import joinedload
from cinder import db
from cinder.db.sqlalchemy import models
from cinder import exception
-from cinder import flags
from cinder.openstack.common.db import exception as db_exc
from cinder.openstack.common.db.sqlalchemy import session as db_session
from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
-FLAGS = flags.FLAGS
-
+CONF = cfg.CONF
LOG = logging.getLogger(__name__)
get_engine = db_session.get_engine
def service_get_all_volume_sorted(context):
session = get_session()
with session.begin():
- topic = FLAGS.volume_topic
+ topic = CONF.volume_topic
label = 'volume_gigabytes'
subq = model_query(context, models.Volume.host,
func.sum(models.Volume.size).label(label),
def service_create(context, values):
service_ref = models.Service()
service_ref.update(values)
- if not FLAGS.enable_new_services:
+ if not CONF.enable_new_services:
service_ref.disabled = True
service_ref.save()
return service_ref
# License for the specific language governing permissions and limitations
# under the License.
+
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
from sqlalchemy import Integer, MetaData, String, Table
-from cinder import flags
from cinder.openstack.common import log as logging
-FLAGS = flags.FLAGS
LOG = logging.getLogger(__name__)
# License for the specific language governing permissions and limitations
# under the License.
-import distutils.version as dist_version
+
import os
+import distutils.version as dist_version
+import migrate
+from migrate.versioning import util as migrate_util
+import sqlalchemy
+
from cinder.db import migration
from cinder.db.sqlalchemy.api import get_engine
from cinder import exception
-from cinder import flags
from cinder.openstack.common import log as logging
-import migrate
-from migrate.versioning import util as migrate_util
-import sqlalchemy
-
-
LOG = logging.getLogger(__name__)
from migrate.versioning import api as versioning_api
from migrate.versioning.repository import Repository
-FLAGS = flags.FLAGS
_REPOSITORY = None
SQLAlchemy models for cinder data.
"""
+
from sqlalchemy import Column, Integer, String, Text, schema
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import ForeignKey, DateTime, Boolean
from sqlalchemy.orm import relationship, backref
-from cinder import flags
+from oslo.config import cfg
+
from cinder.openstack.common.db.sqlalchemy import models
from cinder.openstack.common import timeutils
-FLAGS = flags.FLAGS
+CONF = cfg.CONF
BASE = declarative_base()
@property
def name(self):
- return FLAGS.volume_name_template % self.id
+ return CONF.volume_name_template % self.id
ec2_id = Column(Integer)
user_id = Column(String(255))
@property
def name(self):
- return FLAGS.snapshot_name_template % self.id
+ return CONF.snapshot_name_template % self.id
@property
def volume_name(self):
- return FLAGS.volume_name_template % self.volume_id
+ return CONF.volume_name_template % self.volume_id
user_id = Column(String(255))
project_id = Column(String(255))
@property
def name(self):
- return FLAGS.backup_name_template % self.id
+ return CONF.backup_name_template % self.id
user_id = Column(String(255), nullable=False)
project_id = Column(String(255), nullable=False)
VolumeTypes,
VolumeGlanceMetadata,
)
- engine = create_engine(FLAGS.database.connection, echo=False)
+ engine = create_engine(CONF.database.connection, echo=False)
for model in models:
model.metadata.create_all(engine)