Switch to oslo.utils
Change-Id: I47dc734c6d6e2ab99c25701ae3492acd5e442212
This commit is contained in:
parent
2530cfa81e
commit
874e643549
|
@ -16,12 +16,12 @@
|
|||
import re
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
from oslo.utils import units
|
||||
|
||||
from glance.common import exception
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import log as logging
|
||||
from glance.openstack.common import units
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
|
|
|
@ -23,6 +23,8 @@ import eventlet
|
|||
import glance_store as store
|
||||
import glance_store.location
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
from oslo.utils import strutils
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from webob.exc import HTTPBadRequest
|
||||
from webob.exc import HTTPConflict
|
||||
|
@ -44,10 +46,8 @@ from glance.common import utils
|
|||
from glance.common import wsgi
|
||||
from glance.i18n import _LE
|
||||
from glance import notifier
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import strutils
|
||||
import glance.registry.client.v1.api as registry
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
# under the License.
|
||||
import glance_store as store_api
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
import webob.exc
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import store_utils
|
||||
from glance.common import utils
|
||||
import glance.db
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
import glance.registry.client.v1.api as registry
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import glance_store
|
||||
from oslo.utils import excutils
|
||||
import webob.exc
|
||||
|
||||
import glance.api.policy
|
||||
|
@ -22,7 +23,6 @@ from glance.common import wsgi
|
|||
import glance.db
|
||||
import glance.gateway
|
||||
import glance.notifier
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import copy
|
||||
|
||||
import glance_store
|
||||
from oslo.utils import timeutils
|
||||
import six
|
||||
import webob
|
||||
|
||||
|
@ -27,7 +28,6 @@ import glance.db
|
|||
import glance.gateway
|
||||
import glance.notifier
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
import glance.schema
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import re
|
|||
|
||||
import glance_store
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import webob.exc
|
||||
|
@ -32,7 +33,6 @@ import glance.notifier
|
|||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import jsonutils as json
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
import glance.schema
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -35,7 +35,7 @@ class Namespace(types.Base, WSMEModelTransformer):
|
|||
owner = wsme.wsattr(types.text, mandatory=False)
|
||||
|
||||
# Not using datetime since time format has to be
|
||||
# in glance.openstack.common.timeutils.isotime() format
|
||||
# in oslo.utils.timeutils.isotime() format
|
||||
created_at = wsme.wsattr(types.text, mandatory=False)
|
||||
updated_at = wsme.wsattr(types.text, mandatory=False)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class MetadefObject(types.Base, WSMEModelTransformer):
|
|||
properties = wsme.wsattr({types.text: PropertyType}, mandatory=False)
|
||||
|
||||
# Not using datetime since time format has to be
|
||||
# in glance.openstack.common.timeutils.isotime() format
|
||||
# in oslo.utils.timeutils.isotime() format
|
||||
created_at = wsme.wsattr(types.text, mandatory=False)
|
||||
updated_at = wsme.wsattr(types.text, mandatory=False)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class ResourceTypeAssociation(types.Base, WSMEModelTransformer):
|
|||
properties_target = wsme.wsattr(types.text, mandatory=False)
|
||||
|
||||
# Not using datetime since time format has to be
|
||||
# in glance.openstack.common.timeutils.isotime() format
|
||||
# in oslo.utils.timeutils.isotime() format
|
||||
created_at = wsme.wsattr(types.text, mandatory=False)
|
||||
updated_at = wsme.wsattr(types.text, mandatory=False)
|
||||
|
||||
|
@ -46,7 +46,7 @@ class ResourceType(types.Base, WSMEModelTransformer):
|
|||
name = wsme.wsattr(types.text, mandatory=True)
|
||||
|
||||
# Not using datetime since time format has to be
|
||||
# in glance.openstack.common.timeutils.isotime() format
|
||||
# in oslo.utils.timeutils.isotime() format
|
||||
created_at = wsme.wsattr(types.text, mandatory=False)
|
||||
updated_at = wsme.wsattr(types.text, mandatory=False)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import copy
|
|||
|
||||
import glance_store
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import webob.exc
|
||||
|
@ -32,7 +33,6 @@ import glance.notifier
|
|||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.jsonutils as json
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
import glance.schema
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -26,6 +26,8 @@ import os
|
|||
import sys
|
||||
import time
|
||||
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from glance.common import utils
|
||||
|
||||
# If ../glance/__init__.py exists, add ../ to Python search path, so that
|
||||
|
@ -38,7 +40,6 @@ if os.path.exists(os.path.join(possible_topdir, 'glance', '__init__.py')):
|
|||
|
||||
from glance.common import exception
|
||||
import glance.image_cache.client
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.version import version_info as version
|
||||
|
||||
|
||||
|
|
|
@ -40,10 +40,10 @@ if os.path.exists(os.path.join(possible_topdir, 'glance', '__init__.py')):
|
|||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import units
|
||||
from six.moves import xrange
|
||||
|
||||
from glance.common import config
|
||||
from glance.openstack.common import units
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
|
|
@ -40,6 +40,7 @@ if os.path.exists(os.path.join(possible_topdir, 'glance', '__init__.py')):
|
|||
|
||||
from oslo.config import cfg
|
||||
from oslo.db.sqlalchemy import migration
|
||||
from oslo.utils import encodeutils
|
||||
|
||||
from glance.common import config
|
||||
from glance.common import exception
|
||||
|
@ -49,7 +50,6 @@ from glance.db.sqlalchemy import api as db_api
|
|||
from glance.db.sqlalchemy import metadata
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import log
|
||||
from glance.openstack.common import strutils
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -283,9 +283,9 @@ def main():
|
|||
v = getattr(CONF.command, 'action_kwarg_' + k)
|
||||
if v is None:
|
||||
continue
|
||||
func_kwargs[k] = strutils.safe_decode(v)
|
||||
func_kwargs[k] = encodeutils.safe_decode(v)
|
||||
|
||||
func_args = [strutils.safe_decode(arg)
|
||||
func_args = [encodeutils.safe_decode(arg)
|
||||
for arg in CONF.command.action_args]
|
||||
return CONF.command.action_fn(*func_args, **func_kwargs)
|
||||
except exception.GlanceException as e:
|
||||
|
|
|
@ -40,6 +40,7 @@ try:
|
|||
except ImportError:
|
||||
SENDFILE_SUPPORTED = False
|
||||
|
||||
from oslo.utils import encodeutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from six.moves import xrange
|
||||
|
@ -48,7 +49,6 @@ from glance.common import auth
|
|||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import strutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -403,7 +403,7 @@ class BaseClient(object):
|
|||
continue
|
||||
if not isinstance(value, six.string_types):
|
||||
value = str(value)
|
||||
params[key] = strutils.safe_encode(value)
|
||||
params[key] = encodeutils.safe_encode(value)
|
||||
query = urlparse.urlencode(params)
|
||||
else:
|
||||
query = None
|
||||
|
@ -424,7 +424,7 @@ class BaseClient(object):
|
|||
:returns: Dictionary with encoded headers'
|
||||
names and values
|
||||
"""
|
||||
to_str = strutils.safe_encode
|
||||
to_str = encodeutils.safe_encode
|
||||
return dict([(to_str(h), to_str(v)) for h, v in
|
||||
six.iteritems(headers)])
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import datetime
|
|||
import traceback
|
||||
|
||||
from oslo.config import cfg
|
||||
import oslo.utils.importutils as imp
|
||||
from oslo.utils import timeutils
|
||||
import six
|
||||
from webob import exc
|
||||
|
||||
|
@ -27,9 +29,7 @@ from glance.common import client
|
|||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.common import wsgi
|
||||
import glance.openstack.common.importutils as imp
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ __all__ = [
|
|||
'run',
|
||||
]
|
||||
|
||||
from oslo.utils import excutils
|
||||
import six
|
||||
|
||||
from glance.api.v2 import images as v2_api
|
||||
|
@ -24,7 +25,6 @@ from glance.common import exception
|
|||
from glance.common.scripts import utils as script_utils
|
||||
from glance.common import utils as common_utils
|
||||
from glance import i18n
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import lockutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
|
|
@ -38,14 +38,15 @@ import uuid
|
|||
import netaddr
|
||||
from OpenSSL import crypto
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import encodeutils
|
||||
from oslo.utils import excutils
|
||||
from oslo.utils import netutils
|
||||
from oslo.utils import strutils
|
||||
import six
|
||||
from webob import exc
|
||||
|
||||
from glance.common import exception
|
||||
from glance.openstack.common import excutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import network_utils
|
||||
from glance.openstack.common import strutils
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
@ -622,7 +623,7 @@ def parse_valid_host_port(host_port):
|
|||
|
||||
try:
|
||||
try:
|
||||
host, port = network_utils.parse_host_port(host_port)
|
||||
host, port = netutils.parse_host_port(host_port)
|
||||
except Exception:
|
||||
raise ValueError(_('Host and port "%s" is not valid.') % host_port)
|
||||
|
||||
|
@ -658,4 +659,4 @@ def exception_to_str(exc):
|
|||
except UnicodeError:
|
||||
error = ("Caught '%(exception)s' exception." %
|
||||
{"exception": exc.__class__.__name__})
|
||||
return strutils.safe_encode(error, errors='ignore')
|
||||
return encodeutils.safe_encode(error, errors='ignore')
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
|
||||
from datetime import datetime
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from wsme import types as wsme_types
|
||||
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
||||
class WSMEModelTransformer():
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
# under the License.
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import importutils
|
||||
from wsme.rest.json import fromjson
|
||||
from wsme.rest.json import tojson
|
||||
|
||||
|
@ -26,7 +27,6 @@ from glance.common import exception
|
|||
from glance.common import location_strategy
|
||||
import glance.domain
|
||||
import glance.domain.proxy
|
||||
from glance.openstack.common import importutils
|
||||
from glance.openstack.common import jsonutils as json
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
|
|
@ -18,11 +18,11 @@ import copy
|
|||
import functools
|
||||
import uuid
|
||||
|
||||
from oslo.utils import timeutils
|
||||
import six
|
||||
|
||||
from glance.common import exception
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -25,6 +25,7 @@ import threading
|
|||
from oslo.config import cfg
|
||||
from oslo.db import exception as db_exception
|
||||
from oslo.db.sqlalchemy import session
|
||||
from oslo.utils import timeutils
|
||||
import osprofiler.sqlalchemy
|
||||
from retrying import retry
|
||||
import six
|
||||
|
@ -44,7 +45,6 @@ from glance.db.sqlalchemy.metadef_api\
|
|||
from glance.db.sqlalchemy import models
|
||||
from glance import i18n
|
||||
import glance.openstack.common.log as os_logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
BASE = models.BASE
|
||||
sa_logger = None
|
||||
|
|
|
@ -24,6 +24,7 @@ from os.path import join
|
|||
import re
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
import six
|
||||
import sqlalchemy
|
||||
from sqlalchemy.schema import MetaData
|
||||
|
@ -31,7 +32,6 @@ from sqlalchemy.schema import MetaData
|
|||
from glance.common import utils
|
||||
from glance import i18n
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = i18n._LE
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.utils import timeutils
|
||||
import sqlalchemy
|
||||
from sqlalchemy.schema import (
|
||||
Column, ForeignKey, Index, MetaData, Table, UniqueConstraint) # noqa
|
||||
|
@ -19,7 +20,6 @@ from sqlalchemy.schema import (
|
|||
from glance.db.sqlalchemy.migrate_repo.schema import (
|
||||
Boolean, DateTime, Integer, String, Text, create_tables,
|
||||
drop_tables) # noqa
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
||||
RESOURCE_TYPES = [u'OS::Glance::Image', u'OS::Cinder::Volume',
|
||||
|
|
|
@ -21,6 +21,7 @@ SQLAlchemy models for glance data
|
|||
import uuid
|
||||
|
||||
from oslo.db.sqlalchemy import models
|
||||
from oslo.utils import timeutils
|
||||
from sqlalchemy import BigInteger
|
||||
from sqlalchemy import Boolean
|
||||
from sqlalchemy import Column
|
||||
|
@ -37,7 +38,6 @@ from sqlalchemy.types import TypeDecorator
|
|||
from sqlalchemy import UniqueConstraint
|
||||
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
||||
BASE = declarative_base()
|
||||
|
|
|
@ -17,6 +17,7 @@ SQLAlchemy models for glance metadata schema
|
|||
"""
|
||||
|
||||
from oslo.db.sqlalchemy import models
|
||||
from oslo.utils import timeutils
|
||||
from sqlalchemy import Boolean
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy import DateTime
|
||||
|
@ -28,8 +29,6 @@ from sqlalchemy.orm import relationship
|
|||
from sqlalchemy import String
|
||||
from sqlalchemy import Text
|
||||
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
||||
class DictionaryBase(models.ModelBase):
|
||||
metadata = None
|
||||
|
|
|
@ -19,14 +19,14 @@ import datetime
|
|||
import uuid
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
from oslo.utils import importutils
|
||||
from oslo.utils import timeutils
|
||||
import six
|
||||
|
||||
from glance.common import exception
|
||||
from glance import i18n
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import importutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
_LE = i18n._LE
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -20,14 +20,14 @@ LRU Cache for Image Data
|
|||
import hashlib
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
from oslo.utils import importutils
|
||||
from oslo.utils import units
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import importutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import units
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_LE = gettextutils._LE
|
||||
|
|
|
@ -27,10 +27,10 @@ import time
|
|||
from eventlet import sleep
|
||||
from eventlet import timeout
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
|
||||
from glance.common import exception
|
||||
from glance.image_cache.drivers import base
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
|
|
@ -59,12 +59,12 @@ import stat
|
|||
import time
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
import xattr
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.image_cache.drivers import base
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ import copy
|
|||
|
||||
import glance_store as store
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
import glance.domain.proxy
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
import glance_store
|
||||
from oslo.config import cfg
|
||||
from oslo import messaging
|
||||
from oslo.utils import excutils
|
||||
from oslo.utils import timeutils
|
||||
import webob
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
import glance.domain.proxy
|
||||
from glance.openstack.common import excutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
notifier_opts = [
|
||||
cfg.StrOpt('default_publisher_id', default="image.localhost",
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
# Copyright 2012 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Network-related utilities and helper functions.
|
||||
"""
|
||||
|
||||
import socket
|
||||
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from glance.openstack.common.gettextutils import _LW
|
||||
from glance.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def parse_host_port(address, default_port=None):
|
||||
"""Interpret a string as a host:port pair.
|
||||
|
||||
An IPv6 address MUST be escaped if accompanied by a port,
|
||||
because otherwise ambiguity ensues: 2001:db8:85a3::8a2e:370:7334
|
||||
means both [2001:db8:85a3::8a2e:370:7334] and
|
||||
[2001:db8:85a3::8a2e:370]:7334.
|
||||
|
||||
>>> parse_host_port('server01:80')
|
||||
('server01', 80)
|
||||
>>> parse_host_port('server01')
|
||||
('server01', None)
|
||||
>>> parse_host_port('server01', default_port=1234)
|
||||
('server01', 1234)
|
||||
>>> parse_host_port('[::1]:80')
|
||||
('::1', 80)
|
||||
>>> parse_host_port('[::1]')
|
||||
('::1', None)
|
||||
>>> parse_host_port('[::1]', default_port=1234)
|
||||
('::1', 1234)
|
||||
>>> parse_host_port('2001:db8:85a3::8a2e:370:7334', default_port=1234)
|
||||
('2001:db8:85a3::8a2e:370:7334', 1234)
|
||||
|
||||
"""
|
||||
if address[0] == '[':
|
||||
# Escaped ipv6
|
||||
_host, _port = address[1:].split(']')
|
||||
host = _host
|
||||
if ':' in _port:
|
||||
port = _port.split(':')[1]
|
||||
else:
|
||||
port = default_port
|
||||
else:
|
||||
if address.count(':') == 1:
|
||||
host, port = address.split(':')
|
||||
else:
|
||||
# 0 means ipv4, >1 means ipv6.
|
||||
# We prohibit unescaped ipv6 addresses with port.
|
||||
host = address
|
||||
port = default_port
|
||||
|
||||
return (host, None if port is None else int(port))
|
||||
|
||||
|
||||
class ModifiedSplitResult(parse.SplitResult):
|
||||
"""Split results class for urlsplit."""
|
||||
|
||||
# NOTE(dims): The functions below are needed for Python 2.6.x.
|
||||
# We can remove these when we drop support for 2.6.x.
|
||||
@property
|
||||
def hostname(self):
|
||||
netloc = self.netloc.split('@', 1)[-1]
|
||||
host, port = parse_host_port(netloc)
|
||||
return host
|
||||
|
||||
@property
|
||||
def port(self):
|
||||
netloc = self.netloc.split('@', 1)[-1]
|
||||
host, port = parse_host_port(netloc)
|
||||
return port
|
||||
|
||||
|
||||
def urlsplit(url, scheme='', allow_fragments=True):
|
||||
"""Parse a URL using urlparse.urlsplit(), splitting query and fragments.
|
||||
This function papers over Python issue9374 when needed.
|
||||
|
||||
The parameters are the same as urlparse.urlsplit.
|
||||
"""
|
||||
scheme, netloc, path, query, fragment = parse.urlsplit(
|
||||
url, scheme, allow_fragments)
|
||||
if allow_fragments and '#' in path:
|
||||
path, fragment = path.split('#', 1)
|
||||
if '?' in path:
|
||||
path, query = path.split('?', 1)
|
||||
return ModifiedSplitResult(scheme, netloc,
|
||||
path, query, fragment)
|
||||
|
||||
|
||||
def set_tcp_keepalive(sock, tcp_keepalive=True,
|
||||
tcp_keepidle=None,
|
||||
tcp_keepalive_interval=None,
|
||||
tcp_keepalive_count=None):
|
||||
"""Set values for tcp keepalive parameters
|
||||
|
||||
This function configures tcp keepalive parameters if users wish to do
|
||||
so.
|
||||
:param tcp_keepalive: Boolean, turn on or off tcp_keepalive. If users are
|
||||
not sure, this should be True, and default values will be used.
|
||||
|
||||
:param tcp_keepidle: time to wait before starting to send keepalive probes
|
||||
|
||||
:param tcp_keepalive_interval: time between successive probes, once the
|
||||
initial wait time is over
|
||||
|
||||
:param tcp_keepalive_count: number of probes to send before the connection
|
||||
is killed
|
||||
"""
|
||||
|
||||
# NOTE(praneshp): Despite keepalive being a tcp concept, the level is
|
||||
# still SOL_SOCKET. This is a quirk.
|
||||
if isinstance(tcp_keepalive, bool):
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, tcp_keepalive)
|
||||
else:
|
||||
raise TypeError("tcp_keepalive must be a boolean")
|
||||
|
||||
if not tcp_keepalive:
|
||||
return
|
||||
|
||||
# These options aren't available in the OS X version of eventlet,
|
||||
# Idle + Count * Interval effectively gives you the total timeout.
|
||||
if tcp_keepidle is not None:
|
||||
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||
sock.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_KEEPIDLE,
|
||||
tcp_keepidle)
|
||||
else:
|
||||
LOG.warning(_LW('tcp_keepidle not available on your system'))
|
||||
if tcp_keepalive_interval is not None:
|
||||
if hasattr(socket, 'TCP_KEEPINTVL'):
|
||||
sock.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_KEEPINTVL,
|
||||
tcp_keepalive_interval)
|
||||
else:
|
||||
LOG.warning(_LW('tcp_keepintvl not available on your system'))
|
||||
if tcp_keepalive_count is not None:
|
||||
if hasattr(socket, 'TCP_KEEPCNT'):
|
||||
sock.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_KEEPCNT,
|
||||
tcp_keepalive_count)
|
||||
else:
|
||||
LOG.warning(_LW('tcp_keepknt not available on your system'))
|
|
@ -1,38 +0,0 @@
|
|||
# Copyright 2013 IBM Corp
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Unit constants
|
||||
"""
|
||||
|
||||
#Binary unit constants.
|
||||
Ki = 1024
|
||||
Mi = 1024 ** 2
|
||||
Gi = 1024 ** 3
|
||||
Ti = 1024 ** 4
|
||||
Pi = 1024 ** 5
|
||||
Ei = 1024 ** 6
|
||||
Zi = 1024 ** 7
|
||||
Yi = 1024 ** 8
|
||||
|
||||
#Decimal unit constants.
|
||||
k = 1000
|
||||
M = 1000 ** 2
|
||||
G = 1000 ** 3
|
||||
T = 1000 ** 4
|
||||
P = 1000 ** 5
|
||||
E = 1000 ** 6
|
||||
Z = 1000 ** 7
|
||||
Y = 1000 ** 8
|
|
@ -16,6 +16,7 @@ import copy
|
|||
|
||||
import glance_store as store
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
import six
|
||||
|
||||
import glance.api.common
|
||||
|
@ -23,7 +24,6 @@ import glance.common.exception as exception
|
|||
from glance.common import utils
|
||||
import glance.domain
|
||||
import glance.domain.proxy
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ Reference implementation registry server WSGI controller
|
|||
"""
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import strutils
|
||||
from oslo.utils import timeutils
|
||||
from webob import exc
|
||||
|
||||
from glance.common import exception
|
||||
|
@ -26,8 +28,6 @@ from glance.common import wsgi
|
|||
import glance.db
|
||||
from glance.openstack.common import gettextutils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import strutils
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -18,9 +18,10 @@ Simple client class to speak with any RESTful service that implements
|
|||
the Glance Registry API
|
||||
"""
|
||||
|
||||
from oslo.utils import excutils
|
||||
|
||||
from glance.common.client import BaseClient
|
||||
from glance.common import crypt
|
||||
from glance.openstack.common import excutils
|
||||
from glance.openstack.common import gettextutils
|
||||
from glance.openstack.common import jsonutils
|
||||
import glance.openstack.common.log as logging
|
||||
|
|
|
@ -20,10 +20,10 @@ import datetime
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from glance.common import exception
|
||||
from glance import context
|
||||
from glance.openstack.common import timeutils
|
||||
import glance.tests.functional.db as db_tests
|
||||
from glance.tests import utils as test_utils
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ from __future__ import print_function
|
|||
import BaseHTTPServer
|
||||
import threading
|
||||
|
||||
from glance.openstack.common import units
|
||||
from oslo.utils import units
|
||||
|
||||
|
||||
FIVE_KB = 5 * units.Ki
|
||||
|
|
|
@ -21,10 +21,10 @@ import os
|
|||
import sys
|
||||
|
||||
import httplib2
|
||||
from oslo.utils import units
|
||||
from six.moves import xrange
|
||||
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import units
|
||||
from glance.tests import functional
|
||||
from glance.tests.utils import execute
|
||||
from glance.tests.utils import minimal_headers
|
||||
|
|
|
@ -27,10 +27,10 @@ import sys
|
|||
import time
|
||||
|
||||
import httplib2
|
||||
from oslo.utils import units
|
||||
from six.moves import xrange
|
||||
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import units
|
||||
from glance.tests import functional
|
||||
from glance.tests.functional.store_utils import get_http_uri
|
||||
from glance.tests.functional.store_utils import setup_http
|
||||
|
|
|
@ -19,11 +19,11 @@ import time
|
|||
|
||||
import glance_store.location
|
||||
import httplib2
|
||||
from oslo.utils import units
|
||||
from six.moves import xrange
|
||||
|
||||
from glance.common import crypt
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import units
|
||||
from glance.tests import functional
|
||||
from glance.tests.utils import execute
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
import hashlib
|
||||
|
||||
import httplib2
|
||||
from oslo.utils import units
|
||||
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import units
|
||||
from glance.tests import functional
|
||||
from glance.tests.utils import minimal_headers
|
||||
from glance.tests.utils import skip_if_disabled
|
||||
|
|
|
@ -24,10 +24,10 @@ import tempfile
|
|||
import time
|
||||
|
||||
import httplib2
|
||||
from oslo.utils import units
|
||||
from six.moves import xrange
|
||||
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import units
|
||||
from glance.tests import functional
|
||||
from glance.tests.functional.store_utils import get_http_uri
|
||||
from glance.tests.functional.store_utils import setup_http
|
||||
|
|
|
@ -16,9 +16,9 @@ import hashlib
|
|||
import os
|
||||
|
||||
import httplib2
|
||||
from oslo.utils import units
|
||||
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import units
|
||||
from glance.tests import functional
|
||||
from glance.tests.utils import execute
|
||||
from glance.tests.utils import minimal_headers
|
||||
|
|
|
@ -34,10 +34,10 @@ import tempfile
|
|||
import uuid
|
||||
|
||||
import httplib2
|
||||
from oslo.utils import timeutils
|
||||
from oslo.utils import units
|
||||
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.openstack.common import units
|
||||
from glance.tests import functional
|
||||
from glance.tests.utils import minimal_headers
|
||||
from glance.tests.utils import skip_if_disabled
|
||||
|
|
|
@ -15,11 +15,11 @@ import hashlib
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
from oslo.utils import timeutils
|
||||
from oslo.utils import units
|
||||
import testtools
|
||||
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.openstack.common import units
|
||||
from glance.tests.integration.legacy_functional import base
|
||||
from glance.tests.utils import minimal_headers
|
||||
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
|
||||
import time
|
||||
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from glance.api.v2 import tasks
|
||||
import glance.openstack.common.jsonutils as json
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.tests.integration.v2 import base
|
||||
|
||||
TENANT1 = '6838eb7b-6ded-434a-882c-b344c77fe8df'
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.utils import timeutils
|
||||
import stubout
|
||||
import webob
|
||||
|
||||
|
@ -22,7 +23,6 @@ from glance.common import auth
|
|||
from glance.common import exception
|
||||
import glance.domain
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.tests.unit import utils as unittest_utils
|
||||
from glance.tests import utils
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ CONF = cfg.CONF
|
|||
CONF.import_opt('metadata_encryption_key', 'glance.common.config')
|
||||
|
||||
|
||||
@mock.patch('glance.openstack.common.importutils.import_module')
|
||||
@mock.patch('oslo.utils.importutils.import_module')
|
||||
class TestDbUtilities(test_utils.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestDbUtilities, self).setUp()
|
||||
|
|
|
@ -19,11 +19,12 @@ import uuid
|
|||
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
import oslo.utils.importutils
|
||||
from oslo.utils import timeutils
|
||||
|
||||
import glance.async
|
||||
from glance.common import exception
|
||||
from glance import domain
|
||||
from glance.openstack.common import timeutils
|
||||
import glance.tests.utils as test_utils
|
||||
|
||||
|
||||
|
@ -518,7 +519,7 @@ class TestTaskExecutorFactory(test_utils.BaseTestCase):
|
|||
self.image_repo,
|
||||
self.image_factory)
|
||||
context = mock.Mock()
|
||||
with mock.patch.object(glance.openstack.common.importutils,
|
||||
with mock.patch.object(oslo.utils.importutils,
|
||||
'import_class') as mock_import_class:
|
||||
mock_executor = mock.Mock()
|
||||
mock_import_class.return_value = mock_executor
|
||||
|
@ -534,7 +535,7 @@ class TestTaskExecutorFactory(test_utils.BaseTestCase):
|
|||
self.image_repo,
|
||||
self.image_factory)
|
||||
context = mock.Mock()
|
||||
with mock.patch.object(glance.openstack.common.importutils,
|
||||
with mock.patch.object(oslo.utils.importutils,
|
||||
'import_class') as mock_import_class:
|
||||
mock_import_class.side_effect = ImportError
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ import os
|
|||
import time
|
||||
|
||||
import fixtures
|
||||
from oslo.utils import units
|
||||
import six
|
||||
from six.moves import xrange
|
||||
import stubout
|
||||
|
||||
from glance.common import exception
|
||||
from glance import image_cache
|
||||
from glance.openstack.common import units
|
||||
# NOTE(bcwaldon): This is imported to load the registry config options
|
||||
import glance.registry # noqa
|
||||
from glance.tests import utils as test_utils
|
||||
|
|
|
@ -37,6 +37,7 @@ from oslo.config import cfg
|
|||
from oslo.db.sqlalchemy import test_base
|
||||
from oslo.db.sqlalchemy import test_migrations
|
||||
from oslo.db.sqlalchemy import utils as db_utils
|
||||
from oslo.utils import timeutils
|
||||
import sqlalchemy
|
||||
|
||||
from glance.common import crypt
|
||||
|
@ -47,7 +48,6 @@ from glance.db.sqlalchemy import migrate_repo
|
|||
from glance.db.sqlalchemy.migrate_repo.schema import from_migration_import
|
||||
from glance.db.sqlalchemy import models
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
|
|
@ -20,13 +20,13 @@ import glance_store
|
|||
import mock
|
||||
from oslo.config import cfg
|
||||
from oslo import messaging
|
||||
from oslo.utils import timeutils
|
||||
import webob
|
||||
|
||||
import glance.async
|
||||
from glance.common import exception
|
||||
import glance.context
|
||||
from glance import notifier
|
||||
from glance.openstack.common import timeutils
|
||||
import glance.tests.unit.utils as unit_test_utils
|
||||
from glance.tests import utils
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ import uuid
|
|||
|
||||
import mock
|
||||
from mock import patch
|
||||
from oslo.utils import units
|
||||
import six
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import store_utils
|
||||
from glance.openstack.common import units
|
||||
import glance.quota
|
||||
from glance.tests.unit import utils as unit_test_utils
|
||||
from glance.tests import utils as test_utils
|
||||
|
|
|
@ -23,6 +23,7 @@ import uuid
|
|||
import glance_store as store
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
import routes
|
||||
import six
|
||||
import webob
|
||||
|
@ -37,7 +38,6 @@ import glance.context
|
|||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.db.sqlalchemy import models as db_models
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
import glance.registry.client.v1.api as registry
|
||||
from glance.tests.unit import base
|
||||
import glance.tests.unit.utils as unit_test_utils
|
||||
|
|
|
@ -20,6 +20,7 @@ import uuid
|
|||
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
import routes
|
||||
import six
|
||||
import webob
|
||||
|
@ -31,7 +32,6 @@ from glance import context
|
|||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.db.sqlalchemy import models as db_models
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.registry.api import v1 as rserver
|
||||
from glance.tests.unit import base
|
||||
from glance.tests import utils as test_utils
|
||||
|
|
|
@ -19,6 +19,7 @@ import os
|
|||
import uuid
|
||||
|
||||
from mock import patch
|
||||
from oslo.utils import timeutils
|
||||
import testtools
|
||||
|
||||
from glance.common import client as test_client
|
||||
|
@ -26,7 +27,6 @@ from glance.common import config
|
|||
from glance.common import exception
|
||||
from glance import context
|
||||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.registry.api.v1.images import Controller as rcontroller
|
||||
import glance.registry.client.v1.api as rapi
|
||||
from glance.registry.client.v1.api import client as rclient
|
||||
|
|
|
@ -19,6 +19,7 @@ import datetime
|
|||
import uuid
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
import routes
|
||||
import six
|
||||
import webob
|
||||
|
@ -29,7 +30,6 @@ import glance.context
|
|||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.db.sqlalchemy import models as db_models
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.registry.api import v2 as rserver
|
||||
from glance.tests.unit import base
|
||||
from glance.tests import utils as test_utils
|
||||
|
|
|
@ -25,12 +25,12 @@ import os
|
|||
import uuid
|
||||
|
||||
from mock import patch
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from glance.common import config
|
||||
from glance.common import exception
|
||||
from glance import context
|
||||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.registry.api import v2 as rserver
|
||||
import glance.registry.client.v2.api as rapi
|
||||
from glance.registry.client.v2.api import client as rclient
|
||||
|
|
|
@ -18,13 +18,13 @@ import datetime
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo.utils import timeutils
|
||||
import webob
|
||||
|
||||
import glance.api.v2.tasks
|
||||
import glance.domain
|
||||
import glance.gateway
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.tests.unit import base
|
||||
import glance.tests.unit.utils as unit_test_utils
|
||||
import glance.tests.utils as test_utils
|
||||
|
|
|
@ -25,6 +25,7 @@ import subprocess
|
|||
|
||||
import fixtures
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
import six
|
||||
import stubout
|
||||
import testtools
|
||||
|
@ -38,7 +39,6 @@ from glance import context
|
|||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.db.sqlalchemy import models as db_models
|
||||
from glance.openstack.common import jsonutils
|
||||
from glance.openstack.common import timeutils
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
[DEFAULT]
|
||||
|
||||
# The list of modules to copy from oslo-incubator
|
||||
module=excutils
|
||||
module=fileutils
|
||||
module=gettextutils
|
||||
module=importutils
|
||||
module=install_venv_common
|
||||
module=jsonutils
|
||||
module=local
|
||||
module=lockutils
|
||||
module=log
|
||||
module=network_utils
|
||||
module=policy
|
||||
module=processutils
|
||||
module=strutils
|
||||
module=test
|
||||
module=timeutils
|
||||
module=units
|
||||
|
||||
# The base module to hold the copy of openstack.common
|
||||
base=glance
|
||||
|
|
|
@ -25,6 +25,7 @@ pycrypto>=2.6
|
|||
iso8601>=0.1.9
|
||||
ordereddict
|
||||
oslo.config>=1.4.0 # Apache-2.0
|
||||
oslo.utils>=1.0.0 # Apache-2.0
|
||||
stevedore>=1.0.0 # Apache-2.0
|
||||
netaddr>=0.7.12
|
||||
keystonemiddleware>=1.0.0
|
||||
|
|
Loading…
Reference in New Issue