Switch to oslo.utils

Change-Id: Iacfcbf49864198915f8c229bc552afb412b83b79
This commit is contained in:
Julien Danjou 2014-08-19 10:19:23 +02:00
parent 3006d5a77b
commit 14b4cdbb51
78 changed files with 123 additions and 324 deletions

View File

@ -22,12 +22,12 @@ import datetime
from ceilometerclient import client as ceiloclient
from oslo.config import cfg
from oslo.utils import timeutils
import pytz
import six
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
LOG = log.getLogger(__name__)

View File

@ -19,11 +19,12 @@
import datetime
import operator
from oslo.utils import timeutils
from ceilometer.alarm import evaluator
from ceilometer.alarm.evaluator import utils
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
LOG = log.getLogger(__name__)

View File

@ -19,10 +19,11 @@ import math
import random
import uuid
from oslo.utils import timeutils
from ceilometer.alarm import rpc as rpc_alarm
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
LOG = log.getLogger(__name__)

View File

@ -21,6 +21,7 @@ import abc
from ceilometerclient import client as ceiloclient
from oslo.config import cfg
from oslo.utils import netutils
import six
from stevedore import extension
@ -29,7 +30,6 @@ from ceilometer.alarm import rpc as rpc_alarm
from ceilometer import messaging
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import network_utils
from ceilometer.openstack.common import service as os_service
@ -210,7 +210,7 @@ class AlarmNotifierService(os_service.Service):
def _handle_action(self, action, alarm_id, previous,
current, reason, reason_data):
try:
action = network_utils.urlsplit(action)
action = netutils.urlsplit(action)
except Exception:
LOG.error(
_("Unable to parse action %(action)s for alarm %(alarm_id)s"),

View File

@ -16,13 +16,13 @@ import datetime
import os
import happybase
from oslo.utils import netutils
from six.moves.urllib import parse as urlparse
from ceilometer.alarm.storage import base
from ceilometer.alarm.storage import models
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import network_utils
from ceilometer.storage.hbase import inmemory as hbase_inmemory
from ceilometer.storage.hbase import utils as hbase_utils
from ceilometer import utils
@ -140,7 +140,7 @@ class Connection(base.Connection):
database name, so we are not looking for these in the url.
"""
opts = {}
result = network_utils.urlsplit(url)
result = netutils.urlsplit(url)
opts['table_prefix'] = urlparse.parse_qs(
result.query).get('table_prefix', [None])[0]
opts['dbtype'] = result.scheme

View File

@ -37,6 +37,8 @@ import pytz
import uuid
from oslo.config import cfg
from oslo.utils import strutils
from oslo.utils import timeutils
import pecan
from pecan import rest
import six
@ -50,8 +52,6 @@ from ceilometer import messaging
from ceilometer.openstack.common import context
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import strutils
from ceilometer.openstack.common import timeutils
from ceilometer import sample
from ceilometer import storage
from ceilometer import utils

View File

@ -29,9 +29,9 @@ import eventlet
# oslo.messaging use threading.local
eventlet.monkey_patch(socket=True, select=True, thread=True)
from oslo.config import cfg
from oslo.utils import timeutils
from ceilometer.openstack.common import context
from ceilometer.openstack.common import timeutils
from ceilometer import pipeline
from ceilometer import sample
from ceilometer import service

View File

@ -15,9 +15,9 @@
# under the License.
from oslo.config import cfg
from oslo.utils import importutils
from ceilometer.alarm import service as alarm_service
from ceilometer.openstack.common import importutils
from ceilometer.openstack.common import service as os_service
from ceilometer import service

View File

@ -19,13 +19,13 @@ import socket
import msgpack
from oslo.config import cfg
from oslo.utils import units
from ceilometer import dispatcher
from ceilometer import messaging
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import service as os_service
from ceilometer.openstack.common import units
OPTS = [
cfg.StrOpt('udp_address',

View File

@ -17,11 +17,11 @@
"""Converters for producing compute CPU sample messages from notification
events.
"""
from oslo.utils import timeutils
from ceilometer.compute import notifications
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
LOG = log.getLogger(__name__)

View File

@ -18,9 +18,10 @@
"""
import abc
from oslo.utils import timeutils
import six
from ceilometer.openstack.common import timeutils
from ceilometer import plugin

View File

@ -19,12 +19,13 @@
import copy
from oslo.utils import timeutils
from ceilometer.compute import plugin
from ceilometer.compute.pollsters import util
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
LOG = log.getLogger(__name__)

View File

@ -16,9 +16,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
from ceilometer.compute import util as compute_util
from ceilometer.openstack.common import timeutils
from ceilometer import sample

View File

@ -17,11 +17,11 @@
"""Implementation of Inspector abstraction for Hyper-V"""
from oslo.config import cfg
from oslo.utils import units
from ceilometer.compute.virt.hyperv import utilsv2
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.openstack.common import log
from ceilometer.openstack.common import units
CONF = cfg.CONF
LOG = log.getLogger(__name__)

View File

@ -16,12 +16,12 @@
"""Implementation of Inspector abstraction for VMware vSphere"""
from oslo.config import cfg
from oslo.utils import units
from oslo.vmware import api
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.compute.virt.vmware import vsphere_operations
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import units
opt_group = cfg.OptGroup(name='vmware',

View File

@ -14,11 +14,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
from ceilometer import dispatcher
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer.publisher import utils as publisher_utils
from ceilometer import storage

View File

@ -20,12 +20,12 @@ import os
import jsonpath_rw
from oslo.config import cfg
from oslo.utils import timeutils
import six
import yaml
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer.storage import models
OPTS = [

View File

@ -21,13 +21,13 @@
import abc
import itertools
from oslo.utils import netutils
import six
from ceilometer.central import plugin
from ceilometer.hardware import inspector as insloader
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import network_utils
LOG = log.getLogger(__name__)
@ -54,7 +54,7 @@ class HardwarePollster(plugin.CentralPollster):
h_cache = cache.setdefault(self.CACHE_KEY, {})
sample_iters = []
for res in resources:
parsed_url = network_utils.urlsplit(res)
parsed_url = netutils.urlsplit(res)
inspector = self._get_inspector(parsed_url)
func = getattr(inspector, self.INSPECT_METHOD)

View File

@ -20,9 +20,9 @@
import copy
from oslo.utils import timeutils
from six.moves.urllib import parse as urlparse
from ceilometer.openstack.common import timeutils
from ceilometer import sample

View File

@ -22,9 +22,9 @@ import itertools
import glanceclient
from oslo.config import cfg
from oslo.utils import timeutils
from ceilometer.central import plugin
from ceilometer.openstack.common import timeutils
from ceilometer import sample

View File

@ -17,12 +17,12 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
from ceilometer.central import plugin
from ceilometer import nova_client
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
LOG = log.getLogger(__name__)

View File

@ -14,11 +14,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
from ceilometer.network.services import base
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
LOG = log.getLogger(__name__)

View File

@ -17,12 +17,13 @@
import abc
import collections
from oslo.utils import timeutils
import six
from ceilometer.network.services import base
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
LOG = log.getLogger(__name__)

View File

@ -14,11 +14,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
from ceilometer.network.services import base
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
LOG = log.getLogger(__name__)

View File

@ -15,12 +15,12 @@
import abc
from oslo.utils import netutils
import six
from six.moves.urllib import parse as urlparse
from stevedore import driver as _driver
from ceilometer.central import plugin
from ceilometer.openstack.common import network_utils
from ceilometer import sample
@ -45,7 +45,7 @@ class _Base(plugin.CentralPollster):
@staticmethod
def _parse_my_resource(resource):
parse_url = network_utils.urlsplit(resource)
parse_url = netutils.urlsplit(resource)
params = urlparse.parse_qs(parse_url.query)
parts = urlparse.ParseResult(parse_url.scheme,

View File

@ -13,13 +13,12 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
from six.moves.urllib import parse as urlparse
from ceilometer.network.statistics import driver
from ceilometer.network.statistics.opencontrail import client
from ceilometer import neutron_client
from ceilometer.openstack.common import timeutils
class OpencontrailDriver(driver.Driver):

View File

@ -12,7 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
import six
from six import moves
from six.moves.urllib import parse as urlparse
@ -21,7 +21,6 @@ from ceilometer.network.statistics import driver
from ceilometer.network.statistics.opendaylight import client
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import utils

View File

@ -21,13 +21,13 @@ from __future__ import absolute_import
from keystoneclient import exceptions
from oslo.config import cfg
from oslo.utils import timeutils
import six.moves.urllib.parse as urlparse
from swiftclient import client as swift
from ceilometer.central import plugin
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample

View File

@ -41,9 +41,10 @@ before "proxy-server" and add the following filter in the file:
from __future__ import absolute_import
from oslo.utils import timeutils
from ceilometer.openstack.common import context
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import pipeline
from ceilometer import sample
from ceilometer import service

View File

@ -1,163 +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 logging
import socket
from six.moves.urllib import parse
from ceilometer.openstack.common.gettextutils import _LW
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)
>>> parse_host_port(None)
(None, None)
"""
if not address:
return (None, None)
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'))

View File

@ -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

View File

@ -1,6 +1,6 @@
#
# Copyright 2013 Intel Corp.
# Copyright 2013 eNovance
# Copyright 2013-2014 eNovance
#
# Author: Yunhong Jiang <yunhong.jiang@intel.com>
# Julien Danjou <julien@danjou.info>
@ -19,11 +19,10 @@
import abc
from oslo.utils import netutils
import six
from stevedore import driver
from ceilometer.openstack.common import network_utils
def get_publisher(url, namespace='ceilometer.publisher'):
"""Get publisher driver and load it.
@ -31,7 +30,7 @@ def get_publisher(url, namespace='ceilometer.publisher'):
:param URL: URL for the publisher
:param namespace: Namespace to use to look for drivers.
"""
parse_result = network_utils.urlsplit(url)
parse_result = netutils.urlsplit(url)
loaded_driver = driver.DriverManager(namespace, parse_result.scheme)
return loaded_driver.driver(parse_result)

View File

@ -22,10 +22,10 @@ import socket
import msgpack
from oslo.config import cfg
from oslo.utils import netutils
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import network_utils
from ceilometer import publisher
from ceilometer.publisher import utils
@ -37,7 +37,7 @@ LOG = log.getLogger(__name__)
class UDPPublisher(publisher.PublisherBase):
def __init__(self, parsed_url):
self.host, self.port = network_utils.parse_host_port(
self.host, self.port = netutils.parse_host_port(
parsed_url.netloc,
default_port=cfg.CONF.collector.udp_port)
self.socket = socket.socket(socket.AF_INET,

View File

@ -21,11 +21,10 @@ import datetime
import inspect
import math
from oslo.utils import timeutils
import six
from six import moves
from ceilometer.openstack.common import timeutils
def iter_period(start, end, period):
"""Split a time from start to end in periods of a number of seconds.

View File

@ -28,11 +28,11 @@ import sys
import bson.code
import bson.objectid
from oslo.utils import timeutils
import pymongo
import six
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import storage
from ceilometer.storage import base
from ceilometer.storage import models

View File

@ -18,12 +18,12 @@ import os
import time
import happybase
from oslo.utils import netutils
from oslo.utils import timeutils
from six.moves.urllib import parse as urlparse
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import network_utils
from ceilometer.openstack.common import timeutils
from ceilometer.storage import base
from ceilometer.storage.hbase import inmemory as hbase_inmemory
from ceilometer.storage.hbase import utils as hbase_utils
@ -205,7 +205,7 @@ class Connection(base.Connection):
database name, so we are not looking for these in the url.
"""
opts = {}
result = network_utils.urlsplit(url)
result = netutils.urlsplit(url)
opts['table_prefix'] = urlparse.parse_qs(
result.query).get('table_prefix', [None])[0]
opts['dbtype'] = result.scheme

View File

@ -30,11 +30,11 @@ import uuid
import bson.code
import bson.objectid
from oslo.config import cfg
from oslo.utils import timeutils
import pymongo
import six
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import storage
from ceilometer.storage import base
from ceilometer.storage import models

View File

@ -22,6 +22,7 @@ import operator
import os
from oslo.config import cfg
from oslo.utils import timeutils
import six
from sqlalchemy import and_
from sqlalchemy import distinct
@ -33,7 +34,6 @@ from ceilometer.openstack.common.db.sqlalchemy import migration
import ceilometer.openstack.common.db.sqlalchemy.session as sqlalchemy_session
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import storage
from ceilometer.storage import base
from ceilometer.storage import models as api_models

View File

@ -16,8 +16,8 @@
# under the License.
"""Model classes for use in the storage API.
"""
from oslo.utils import timeutils
from ceilometer.openstack.common import timeutils
from ceilometer.storage import base

View File

@ -22,13 +22,13 @@
import time
from oslo.config import cfg
from oslo.utils import netutils
import pymongo
import six
import weakref
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import network_utils
LOG = log.getLogger(__name__)
@ -171,7 +171,7 @@ class ConnectionPool(object):
client = self._pool.get(pool_key)()
if client:
return client
splitted_url = network_utils.urlsplit(url)
splitted_url = netutils.urlsplit(url)
log_data = {'db': splitted_url.scheme,
'nodelist': connection_options['nodelist']}
LOG.info(_('Connecting to %(db)s on %(nodelist)s') % log_data)

View File

@ -14,11 +14,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
from sqlalchemy import MetaData, Table, Column, DateTime
from ceilometer.openstack.common import timeutils
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)

View File

@ -10,10 +10,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import timeutils
import sqlalchemy
from ceilometer.openstack.common import timeutils
from ceilometer.storage.sqlalchemy import models

View File

@ -19,6 +19,7 @@ SQLAlchemy models for Ceilometer data.
import json
from oslo.utils import timeutils
import six
from sqlalchemy import (Column, Integer, String, ForeignKey, Index,
UniqueConstraint, BigInteger, join)
@ -30,7 +31,6 @@ from sqlalchemy.orm import column_property
from sqlalchemy.orm import relationship
from sqlalchemy.types import TypeDecorator
from ceilometer.openstack.common import timeutils
from ceilometer.storage import models as api_models
from ceilometer import utils

View File

@ -17,11 +17,12 @@
"""class for tests in ceilometer/alarm/evaluator/__init__.py
"""
import datetime
import mock
from oslo.utils import timeutils
from oslotest import base
from ceilometer.alarm import evaluator
from ceilometer.openstack.common import timeutils
class TestEvaluatorBaseClass(base.BaseTestCase):

View File

@ -21,9 +21,10 @@ import mock
import pytz
import uuid
from oslo.utils import timeutils
from ceilometer.alarm.evaluator import combination
from ceilometer.alarm.storage import models
from ceilometer.openstack.common import timeutils
from ceilometer.tests.alarm.evaluator import base
from ceilometerclient import exc
from ceilometerclient.v2 import alarms

View File

@ -21,11 +21,11 @@ import mock
import pytz
import uuid
from oslo.utils import timeutils
from six import moves
from ceilometer.alarm.evaluator import threshold
from ceilometer.alarm.storage import models
from ceilometer.openstack.common import timeutils
from ceilometer.tests.alarm.evaluator import base
from ceilometerclient import exc
from ceilometerclient.v2 import statistics

View File

@ -22,11 +22,11 @@ import uuid
import mock
from oslo.config import fixture as fixture_config
from oslo.utils import timeutils
from six import moves
from ceilometer.alarm.partition import coordination
from ceilometer.alarm.storage import models
from ceilometer.openstack.common import timeutils
from ceilometer.tests import base as tests_base

View File

@ -211,7 +211,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
raise Exception("Evil urlsplit!")
def test_notify_alarm_invalid_url(self):
with mock.patch('ceilometer.openstack.common.network_utils.urlsplit',
with mock.patch('oslo.utils.netutils.urlsplit',
self._fake_urlsplit):
LOG = mock.MagicMock()
with mock.patch('ceilometer.alarm.service.LOG', LOG):

View File

@ -20,12 +20,12 @@ import uuid
from ceilometerclient.v2 import alarms
import eventlet
from oslo.config import fixture as fixture_config
from oslo.utils import timeutils
import six
from ceilometer.alarm import rpc as rpc_alarm
from ceilometer.alarm.storage import models
from ceilometer import messaging
from ceilometer.openstack.common import timeutils
from ceilometer.tests import base as tests_base

View File

@ -19,11 +19,11 @@
import datetime
import json
from oslo.utils import timeutils
import webtest
from ceilometer.api import app
from ceilometer.api.controllers import v2 as v2_api
from ceilometer.openstack.common import timeutils
from ceilometer.publisher import utils
from ceilometer import sample
from ceilometer.tests import api as acl

View File

@ -20,8 +20,9 @@
import datetime
from oslo.utils import timeutils
from ceilometer.alarm.storage import models
from ceilometer.openstack.common import timeutils
from ceilometer.publisher import utils
from ceilometer import sample
from ceilometer.tests.api import v2 as tests_api

View File

@ -20,8 +20,8 @@
import datetime
import mock
from oslo.utils import timeutils
from ceilometer.openstack.common import timeutils
from ceilometer.storage import models
from ceilometer.tests.api import v2
from ceilometer.tests import db as tests_db

View File

@ -16,7 +16,8 @@
import datetime
from ceilometer.openstack.common import timeutils
from oslo.utils import timeutils
from ceilometer.storage import models
from ceilometer.tests.api import v2
from ceilometer.tests import db as tests_db

View File

@ -20,10 +20,10 @@
import datetime
import mock
from oslo.utils import timeutils
import six
import webtest.app
from ceilometer.openstack.common import timeutils
from ceilometer.publisher import utils
from ceilometer import sample
from ceilometer.tests.api import v2

View File

@ -20,9 +20,9 @@
import datetime
import json
from oslo.utils import timeutils
import six
from ceilometer.openstack.common import timeutils
from ceilometer.publisher import utils
from ceilometer import sample
from ceilometer.tests.api import v2

View File

@ -21,9 +21,9 @@ import copy
import datetime
import mock
from oslo.utils import timeutils
from oslotest import mockpatch
from ceilometer.openstack.common import timeutils
from ceilometer.tests.api import v2
from ceilometer.tests import db as tests_db

View File

@ -18,12 +18,12 @@ import datetime
import fixtures
import mock
from oslo.utils import timeutils
from oslotest import base
from oslotest import mockpatch
import wsme
from ceilometer.api.controllers import v2 as api
from ceilometer.openstack.common import timeutils
from ceilometer import storage
from ceilometer.tests import base as tests_base

View File

@ -22,13 +22,13 @@ import os.path
import eventlet
import oslo.messaging.conffixture
from oslo.utils import timeutils
from oslotest import base
from oslotest import mockpatch
import six
from testtools import testcase
from ceilometer import messaging
from ceilometer.openstack.common import timeutils
class BaseTestCase(base.BaseTestCase):

View File

@ -18,10 +18,10 @@ Tests for Hyper-V inspector.
"""
import mock
from oslo.utils import units
from oslotest import base
from ceilometer.compute.virt.hyperv import inspector as hyperv_inspector
from ceilometer.openstack.common import units
class TestHyperVInspection(base.BaseTestCase):

View File

@ -546,7 +546,7 @@ class TestEventDefinition(ConverterBase):
edef = converter.EventDefinition(cfg, self.fake_plugin_mgr)
self.assertTrue(edef.is_catchall)
@mock.patch('ceilometer.openstack.common.timeutils.utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_extract_when(self, mock_utcnow):
now = datetime.datetime.utcnow()
modified = now + datetime.timedelta(minutes=1)
@ -623,7 +623,7 @@ class TestNotificationConverter(ConverterBase):
host='cydonia')
self.fake_plugin_mgr = {}
@mock.patch('ceilometer.openstack.common.timeutils.utcnow')
@mock.patch('oslo.utils.timeutils.utcnow')
def test_converter_missing_keys(self, mock_utcnow):
# test a malformed notification
now = datetime.datetime.utcnow()

View File

@ -14,20 +14,20 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.utils import netutils
from ceilometer.hardware import inspector
from ceilometer.openstack.common import network_utils
from ceilometer.tests import base
class TestHardwareInspector(base.BaseTestCase):
def test_get_inspector(self):
url = network_utils.urlsplit("snmp://")
url = netutils.urlsplit("snmp://")
driver = inspector.get_inspector(url)
self.assertTrue(driver)
def test_get_inspector_illegal(self):
url = network_utils.urlsplit("illegal://")
url = netutils.urlsplit("illegal://")
self.assertRaises(RuntimeError,
inspector.get_inspector,
url)

View File

@ -16,10 +16,10 @@
# under the License.
"""Tests for ceilometer/hardware/inspector/snmp/inspector.py
"""
from oslo.utils import netutils
from oslotest import mockpatch
from ceilometer.hardware.inspector import snmp
from ceilometer.openstack.common import network_utils
from ceilometer.tests import base as test_base
from ceilometer.tests.hardware.inspector import base
@ -250,7 +250,7 @@ class TestSNMPInspector(Base, test_base.BaseTestCase):
def setUp(self):
super(TestSNMPInspector, self).setUp()
self.inspector = snmp.SNMPInspector()
self.host = network_utils.urlsplit("snmp://localhost")
self.host = netutils.urlsplit("snmp://localhost")
self.inspector.MAPPING = self.mapping
self.useFixture(mockpatch.PatchObject(
self.inspector._cmdGen, 'getCmd', new=faux_getCmd))

View File

@ -15,11 +15,11 @@
import datetime
from oslo.utils import timeutils
from oslotest import base
from ceilometer.network import statistics
from ceilometer.network.statistics import driver
from ceilometer.openstack.common import timeutils
from ceilometer import sample

View File

@ -22,12 +22,12 @@ import datetime
import traceback
import mock
from oslo.utils import timeutils
from oslotest import base
from oslotest import mockpatch
import six
from stevedore import extension
from ceilometer.openstack.common import timeutils
from ceilometer import pipeline
from ceilometer import publisher
from ceilometer.publisher import test as test_publisher

View File

@ -1,5 +1,5 @@
#
# Copyright 2013 eNovance
# Copyright 2013-2014 eNovance
#
# Author: Julien Danjou <julien@danjou.info>
#
@ -22,9 +22,9 @@ import logging.handlers
import os
import tempfile
from oslo.utils import netutils
from oslotest import base
from ceilometer.openstack.common import network_utils as utils
from ceilometer.publisher import file
from ceilometer import sample
@ -71,8 +71,8 @@ class TestFilePublisher(base.BaseTestCase):
# Test valid configurations
tempdir = tempfile.mkdtemp()
name = '%s/log_file' % tempdir
parsed_url = utils.urlsplit('file://%s?max_bytes=50&backup_count=3'
% name)
parsed_url = netutils.urlsplit('file://%s?max_bytes=50&backup_count=3'
% name)
publisher = file.FilePublisher(parsed_url)
publisher.publish_samples(None,
self.test_data)
@ -90,7 +90,7 @@ class TestFilePublisher(base.BaseTestCase):
# Test missing max bytes, backup count configurations
tempdir = tempfile.mkdtemp()
name = '%s/log_file_plain' % tempdir
parsed_url = utils.urlsplit('file://%s' % name)
parsed_url = netutils.urlsplit('file://%s' % name)
publisher = file.FilePublisher(parsed_url)
publisher.publish_samples(None,
self.test_data)
@ -112,7 +112,7 @@ class TestFilePublisher(base.BaseTestCase):
def test_file_publisher_invalid(self):
# Test invalid max bytes, backup count configurations
tempdir = tempfile.mkdtemp()
parsed_url = utils.urlsplit(
parsed_url = netutils.urlsplit(
'file://%s/log_file_bad'
'?max_bytes=yus&backup_count=5y' % tempdir)
publisher = file.FilePublisher(parsed_url)

View File

@ -24,10 +24,10 @@ import mock
from oslo.config import fixture as fixture_config
import oslo.messaging
import oslo.messaging._drivers.common
from oslo.utils import netutils
from ceilometer import messaging
from ceilometer.openstack.common import context
from ceilometer.openstack.common import network_utils
from ceilometer.publisher import rpc
from ceilometer import sample
from ceilometer.tests import base as tests_base
@ -100,7 +100,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_published_no_mock(self):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://'))
netutils.urlsplit('rpc://'))
endpoint = mock.MagicMock(['record_metering_data'])
collector = messaging.get_rpc_server(
@ -127,7 +127,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_publish_target(self):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?target=custom_procedure_call'))
netutils.urlsplit('rpc://?target=custom_procedure_call'))
cast_context = mock.MagicMock()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
prepare.return_value = cast_context
@ -141,7 +141,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_published_with_per_meter_topic(self):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?per_meter_topic=1'))
netutils.urlsplit('rpc://?per_meter_topic=1'))
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
publisher.publish_samples(mock.MagicMock(),
self.test_data)
@ -169,7 +169,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_published_concurrency(self):
"""Test concurrent access to the local queue of the rpc publisher."""
publisher = rpc.RPCPublisher(network_utils.urlsplit('rpc://'))
publisher = rpc.RPCPublisher(netutils.urlsplit('rpc://'))
cast_context = mock.MagicMock()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
@ -199,7 +199,7 @@ class TestPublish(tests_base.BaseTestCase):
@mock.patch('ceilometer.publisher.rpc.LOG')
def test_published_with_no_policy(self, mylog):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://'))
netutils.urlsplit('rpc://'))
side_effect = oslo.messaging._drivers.common.RPCException()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
prepare.side_effect = side_effect
@ -217,7 +217,7 @@ class TestPublish(tests_base.BaseTestCase):
@mock.patch('ceilometer.publisher.rpc.LOG')
def test_published_with_policy_block(self, mylog):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?policy=default'))
netutils.urlsplit('rpc://?policy=default'))
side_effect = oslo.messaging._drivers.common.RPCException()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
prepare.side_effect = side_effect
@ -233,7 +233,7 @@ class TestPublish(tests_base.BaseTestCase):
@mock.patch('ceilometer.publisher.rpc.LOG')
def test_published_with_policy_incorrect(self, mylog):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?policy=notexist'))
netutils.urlsplit('rpc://?policy=notexist'))
side_effect = oslo.messaging._drivers.common.RPCException()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
prepare.side_effect = side_effect
@ -249,7 +249,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_published_with_policy_drop_and_rpc_down(self):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?policy=drop'))
netutils.urlsplit('rpc://?policy=drop'))
side_effect = oslo.messaging._drivers.common.RPCException()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
prepare.side_effect = side_effect
@ -261,7 +261,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_published_with_policy_queue_and_rpc_down(self):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?policy=queue'))
netutils.urlsplit('rpc://?policy=queue'))
side_effect = oslo.messaging._drivers.common.RPCException()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
prepare.side_effect = side_effect
@ -275,7 +275,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_published_with_policy_queue_and_rpc_down_up(self):
self.rpc_unreachable = True
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?policy=queue'))
netutils.urlsplit('rpc://?policy=queue'))
side_effect = oslo.messaging._drivers.common.RPCException()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
@ -299,7 +299,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_published_with_policy_sized_queue_and_rpc_down(self):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?policy=queue&max_queue_length=3'))
netutils.urlsplit('rpc://?policy=queue&max_queue_length=3'))
side_effect = oslo.messaging._drivers.common.RPCException()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:
@ -326,7 +326,7 @@ class TestPublish(tests_base.BaseTestCase):
def test_published_with_policy_default_sized_queue_and_rpc_down(self):
publisher = rpc.RPCPublisher(
network_utils.urlsplit('rpc://?policy=queue'))
netutils.urlsplit('rpc://?policy=queue'))
side_effect = oslo.messaging._drivers.common.RPCException()
with mock.patch.object(publisher.rpc_client, 'prepare') as prepare:

View File

@ -1,5 +1,5 @@
#
# Copyright 2013 eNovance
# Copyright 2013-2014 eNovance
#
# Author: Julien Danjou <julien@danjou.info>
#
@ -22,9 +22,9 @@ import datetime
import mock
import msgpack
from oslo.config import fixture as fixture_config
from oslo.utils import netutils
from oslotest import base
from ceilometer.openstack.common import network_utils
from ceilometer.publisher import udp
from ceilometer.publisher import utils
from ceilometer import sample
@ -118,7 +118,7 @@ class TestUDPPublisher(base.BaseTestCase):
with mock.patch('socket.socket',
self._make_fake_socket(self.data_sent)):
publisher = udp.UDPPublisher(
network_utils.urlsplit('udp://somehost'))
netutils.urlsplit('udp://somehost'))
publisher.publish_samples(None,
self.test_data)
@ -152,6 +152,6 @@ class TestUDPPublisher(base.BaseTestCase):
with mock.patch('socket.socket',
self._make_broken_socket):
publisher = udp.UDPPublisher(
network_utils.urlsplit('udp://localhost'))
netutils.urlsplit('udp://localhost'))
publisher.publish_samples(None,
self.test_data)

View File

@ -26,9 +26,9 @@ import datetime
import repr
import mock
from oslo.utils import timeutils
from ceilometer.alarm.storage import impl_sqlalchemy as impl_sqla_alarm
from ceilometer.openstack.common import timeutils
from ceilometer.storage import impl_sqlalchemy
from ceilometer.storage import models
from ceilometer.storage.sqlalchemy import models as sql_models

View File

@ -23,9 +23,9 @@ import datetime
import operator
import mock
from oslo.utils import timeutils
from ceilometer.alarm.storage import models as alarm_models
from ceilometer.openstack.common import timeutils
from ceilometer.publisher import utils
from ceilometer import sample
from ceilometer import storage

View File

@ -21,6 +21,7 @@ import mock
import msgpack
from oslo.config import fixture as fixture_config
import oslo.messaging
from oslo.utils import timeutils
from oslotest import mockpatch
from stevedore import extension
@ -28,7 +29,6 @@ from ceilometer import collector
from ceilometer import dispatcher
from ceilometer import messaging
from ceilometer.openstack.common import context
from ceilometer.openstack.common import timeutils
from ceilometer.publisher import utils
from ceilometer import sample
from ceilometer.tests import base as tests_base

View File

@ -21,6 +21,7 @@ import mock
from oslo.config import fixture as fixture_config
import oslo.messaging
import oslo.messaging.conffixture
from oslo.utils import timeutils
from stevedore import extension
import yaml
@ -29,7 +30,6 @@ from ceilometer import messaging
from ceilometer import notification
from ceilometer.openstack.common import context
from ceilometer.openstack.common import fileutils
from ceilometer.openstack.common import timeutils
from ceilometer.publisher import test as test_publisher
from ceilometer.tests import base as tests_base

View File

@ -18,11 +18,11 @@
import collections
import re
from oslo.utils import timeutils
import six
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
from ceilometer import transformer

View File

@ -24,11 +24,10 @@ import datetime
import decimal
import multiprocessing
from oslo.utils import timeutils
from oslo.utils import units
import six
from ceilometer.openstack.common import timeutils
from ceilometer.openstack.common import units
def recursive_keypairs(d, separator=':'):
"""Generator that produces sequence of keypairs for nested dictionaries."""

View File

@ -22,8 +22,10 @@ import contextlib
import datetime
import mock
from oslo.utils import importutils
from oslotest import base
from oslotest import moxstubout
from stevedore import extension
## NOTE(dhellmann): These imports are not in the generally approved
@ -40,7 +42,6 @@ from nova.objects import instance as nova_instance
from nova import config
from nova import context
from nova import db
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
# This option is used in the nova_notifier module, so make

View File

@ -6,9 +6,7 @@ module=context
module=db
module=db.sqlalchemy
module=eventlet_backdoor
module=excutils
module=gettextutils
module=importutils
module=jsonutils
module=local
module=log
@ -20,13 +18,9 @@ module=middleware.correlation_id
module=middleware.debug
module=middleware.request_id
module=middleware.sizelimit
module=network_utils
module=policy
module=service
module=strutils
module=threadgroup
module=timeutils
module=units
# The base module to hold the copy of openstack.common
base=ceilometer

View File

@ -16,6 +16,7 @@ pbr>=0.6,!=0.7,<1.0
pecan>=0.5.0
posix_ipc
oslo.messaging>=1.3.0
oslo.utils>=0.2.0
pysnmp>=4.2.1,<5.0.0
python-ceilometerclient>=1.0.6
python-glanceclient>=0.13.1

View File

@ -19,6 +19,7 @@ pbr>=0.6,!=0.7,<1.0
pecan>=0.5.0
posix_ipc
oslo.messaging>=1.3.0
oslo.utils>=0.2.0
pysnmp>=4.2.1,<5.0.0
python-ceilometerclient>=1.0.6
python-glanceclient>=0.13.1

View File

@ -34,11 +34,12 @@ import random
import sys
from oslo.config import cfg
from oslo.utils import timeutils
from ceilometer.publisher import utils
from ceilometer import sample
from ceilometer import storage
from ceilometer.openstack.common import timeutils
def make_test_data(conn, name, meter_type, unit, volume, random_min,
random_max, user_id, project_id, resource_id, start,