def log_init(): import logging import os FILE = os.getcwd() #format='%(asctime)s:%(filename)s[line:%(lineno)d] %(levelname)s %(message)s', logging.basicConfig(level=logging.INFO, datefmt='[%Y %H:%M:%S]', filename=os.path.join(FILE, 'all.log'), filemode='a+') formatter = logging.Formatter( '%(levelname)s [%(asctime)s] [%(name)s]:%(pathname)s line=%(lineno)d [message="%(message)s"]' ) logging.info('log system init') ch = logging.StreamHandler() ch.setLevel(logging.INFO) ch.setFormatter(formatter)
import keystoneclient.v2_0.client from oslo_config import cfg from oslo_log import log as logging import glance.context import glance.db.sqlalchemy.api as db_api from glance import i18n import glance.registry.context _ = i18n._ _LC = i18n._LC _LE = i18n._LE _LI = i18n._LI LOG = logging.getLogger(__name__) LOG.addHandler(logging.StreamHandler()) LOG.setLevel(logging.DEBUG) def get_owner_map(ksclient, owner_is_tenant=True): if owner_is_tenant: entities = ksclient.tenants.list() else: entities = ksclient.users.list() # build mapping of (user or tenant) name to id return dict([(entity.name, entity.id) for entity in entities]) def build_image_owner_map(owner_map, db, context): image_owner_map = {} for image in db.image_get_all(context):