"Fossies" - the Fresh Open Source Software Archive

Member "panko-8.1.0/panko/cmd/storage.py" (4 Aug 2021, 1781 Bytes) of package /linux/misc/openstack/panko-8.1.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 "storage.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 8.0.0_vs_8.1.0.

    1 # -*- encoding: utf-8 -*-
    2 #
    3 # Copyright 2014 OpenStack Foundation
    4 #
    5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    6 # not use this file except in compliance with the License. You may obtain
    7 # a copy of the License at
    8 #
    9 #      http://www.apache.org/licenses/LICENSE-2.0
   10 #
   11 # Unless required by applicable law or agreed to in writing, software
   12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   14 # License for the specific language governing permissions and limitations
   15 # under the License.
   16 
   17 from oslo_log import log
   18 
   19 from panko import service
   20 from panko import storage
   21 
   22 
   23 LOG = log.getLogger(__name__)
   24 
   25 
   26 def dbsync():
   27     conf = service.prepare_service()
   28     storage.get_connection_from_config(conf).upgrade()
   29 
   30 
   31 def expirer():
   32     conf = service.prepare_service()
   33 
   34     if conf.database.event_time_to_live > 0:
   35         LOG.debug("Clearing expired event data")
   36         conn = storage.get_connection_from_config(conf)
   37         max_count = conf.database.events_delete_batch_size
   38         try:
   39             if max_count > 0:
   40                 conn.clear_expired_data(conf.database.event_time_to_live,
   41                                         max_count)
   42             else:
   43                 deleted = max_count = 100
   44                 while deleted and deleted > 0:
   45                     deleted = conn.clear_expired_data(
   46                         conf.database.event_time_to_live,
   47                         max_count)
   48         except TypeError:
   49             LOG.warning("Storage driver does not support "
   50                         "'events_delete_batch_size' config option.")
   51     else:
   52         LOG.info("Nothing to clean, database event time to live "
   53                  "is disabled")