"Fossies" - the Fresh Open Source Software Archive

Member "glance-19.0.0/glance/db/metadata.py" (16 Oct 2019, 2122 Bytes) of package /linux/misc/openstack/glance-19.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "metadata.py" see the Fossies "Dox" file reference documentation.

    1 # Copyright 2010 United States Government as represented by the
    2 # Administrator of the National Aeronautics and Space Administration.
    3 # All Rights Reserved.
    4 #
    5 # Copyright 2013 OpenStack Foundation
    6 # Copyright 2013 Intel Corporation
    7 #
    8 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    9 #    not use this file except in compliance with the License. You may obtain
   10 #    a copy of the License at
   11 #
   12 #         http://www.apache.org/licenses/LICENSE-2.0
   13 #
   14 #    Unless required by applicable law or agreed to in writing, software
   15 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   16 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   17 #    License for the specific language governing permissions and limitations
   18 #    under the License.
   19 
   20 """Metadata setup commands."""
   21 
   22 import threading
   23 
   24 from oslo_config import cfg
   25 from oslo_db import options as db_options
   26 from stevedore import driver
   27 
   28 from glance.db.sqlalchemy import api as db_api
   29 
   30 
   31 _IMPL = None
   32 _LOCK = threading.Lock()
   33 
   34 db_options.set_defaults(cfg.CONF)
   35 
   36 
   37 def get_backend():
   38     global _IMPL
   39     if _IMPL is None:
   40         with _LOCK:
   41             if _IMPL is None:
   42                 _IMPL = driver.DriverManager(
   43                     "glance.database.metadata_backend",
   44                     cfg.CONF.database.backend).driver
   45     return _IMPL
   46 
   47 
   48 def load_metadefs():
   49     """Read metadefinition files and insert data into the database"""
   50     return get_backend().db_load_metadefs(engine=db_api.get_engine(),
   51                                           metadata_path=None,
   52                                           merge=False,
   53                                           prefer_new=False,
   54                                           overwrite=False)
   55 
   56 
   57 def unload_metadefs():
   58     """Unload metadefinitions from database"""
   59     return get_backend().db_unload_metadefs(engine=db_api.get_engine())
   60 
   61 
   62 def export_metadefs():
   63     """Export metadefinitions from database to files"""
   64     return get_backend().db_export_metadefs(engine=db_api.get_engine(),
   65                                             metadata_path=None)