"Fossies" - the Fresh Open Source Software Archive

Member "cinder-13.0.7/cinder/objects/dynamic_log.py" (4 Oct 2019, 1733 Bytes) of package /linux/misc/openstack/cinder-13.0.7.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 "dynamic_log.py" see the Fossies "Dox" file reference documentation.

    1 # Copyright (c) 2017 Red Hat, Inc.
    2 # All Rights Reserved.
    3 #
    4 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    5 #    not use this file except in compliance with the License. You may obtain
    6 #    a copy of the License at
    7 #
    8 #         http://www.apache.org/licenses/LICENSE-2.0
    9 #
   10 #    Unless required by applicable law or agreed to in writing, software
   11 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   12 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   13 #    License for the specific language governing permissions and limitations
   14 #    under the License.
   15 
   16 from oslo_versionedobjects import fields
   17 
   18 from cinder.objects import base
   19 
   20 
   21 @base.CinderObjectRegistry.register
   22 class LogLevel(base.CinderObject):
   23     """Versioned Object to send log change requests."""
   24     # Version 1.0: Initial version
   25     VERSION = '1.0'
   26 
   27     fields = {
   28         'prefix': fields.StringField(nullable=True),
   29         'level': fields.StringField(nullable=True),
   30     }
   31 
   32     def __init__(self, context=None, **kwargs):
   33         super(LogLevel, self).__init__(**kwargs)
   34 
   35         # Set non initialized fields with default or None values
   36         for field_name in self.fields:
   37             if not self.obj_attr_is_set(field_name):
   38                 field = self.fields[field_name]
   39                 if field.default != fields.UnspecifiedDefault:
   40                     setattr(self, field_name, field.default)
   41                 elif field.nullable:
   42                     setattr(self, field_name, None)
   43 
   44 
   45 @base.CinderObjectRegistry.register
   46 class LogLevelList(base.ObjectListBase, base.CinderObject):
   47     VERSION = '1.0'
   48 
   49     fields = {
   50         'objects': fields.ListOfObjectsField('LogLevel'),
   51     }