Code cleanup, remove useless import

This is a massive removal of all useless import that are all over the code
and unit tests. There's also some simple dead code removal or move.

Change-Id: Ida1208b47f38e552219e3b909f8d7c4f22ba3273
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2013-02-11 17:29:31 +01:00
parent 3340461656
commit c885f33c31
24 changed files with 24 additions and 80 deletions

View File

@ -23,8 +23,6 @@ Based on pecan.middleware.errordocument
import json
from webob import exc
class ParsableErrorMiddleware(object):
"""Replace error body with something the client can parse.

View File

@ -20,7 +20,6 @@ import requests
from ceilometer import counter
from ceilometer.central import plugin
from ceilometer.openstack.common import cfg
class KwapiClient(object):

View File

@ -21,7 +21,6 @@ import os
from stevedore import extension
import yaml
from ceilometer import extension_manager
from ceilometer.openstack.common import cfg
from ceilometer.openstack.common import log

View File

@ -21,10 +21,9 @@
import abc
from collections import namedtuple
from ceilometer.openstack.common import cfg
# Import rabbit_notifier to register notification_topics flag so that
# Import rpc_notifier to register notification_topics flag so that
# plugins can use it
import ceilometer.openstack.common.notifier.rabbit_notifier
import ceilometer.openstack.common.notifier.rpc_notifier
ExchangeTopics = namedtuple('ExchangeTopics', ['exchange', 'topics'])

View File

@ -16,14 +16,16 @@
"""SQLAlchemy storage backend
"""
from __future__ import absolute_import
import copy
import datetime
from sqlalchemy import func
from ceilometer.openstack.common import log
from ceilometer.storage import base
from ceilometer.storage.sqlalchemy.models import Meter, Project, Resource
from ceilometer.storage.sqlalchemy.models import Source, User
from ceilometer.storage.sqlalchemy.session import func
import ceilometer.storage.sqlalchemy.session as sqlalchemy_session
from ceilometer.storage.sqlalchemy import migration

View File

@ -15,7 +15,6 @@
# under the License.
from sqlalchemy import *
from ceilometer.openstack.common import timeutils
meta = MetaData()

View File

@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from sqlalchemy import MetaData
def upgrade(migrate_engine):

View File

@ -22,7 +22,7 @@ import json
from sqlalchemy import Column, Integer, String, Table
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import ForeignKey, DateTime
from sqlalchemy.orm import relationship, backref
from sqlalchemy.orm import relationship
from sqlalchemy.types import TypeDecorator, VARCHAR
from urlparse import urlparse

View File

@ -22,7 +22,6 @@ import re
import time
import sqlalchemy
from sqlalchemy import func
from sqlalchemy.exc import DisconnectionError, OperationalError
import sqlalchemy.orm
from sqlalchemy.pool import NullPool, StaticPool

View File

@ -26,13 +26,9 @@ import flask
from pecan import set_config
from pecan.testing import load_test_app
import mox
import stubout
from ceilometer import storage
from ceilometer.api.v1 import app as v1_app
from ceilometer.api.v1 import blueprint as v1_blueprint
from ceilometer.api.controllers import v2
from ceilometer.openstack.common import cfg
from ceilometer.tests import db as db_test_base
from ceilometer.tests import base

View File

@ -24,7 +24,6 @@ inline callbacks.
"""
import functools
import unittest
import nose.plugins.skip

View File

@ -18,12 +18,6 @@
"""Test listing users.
"""
import datetime
import logging
from ceilometer.collector import meter
from ceilometer import counter
from ceilometer.tests import api as tests_api

View File

@ -24,7 +24,6 @@ from stevedore import extension
from ceilometer.central import manager
from ceilometer import counter
from ceilometer import pipeline
from ceilometer.tests import base
from ceilometer.openstack.common import cfg

View File

@ -29,7 +29,6 @@ from stevedore.tests import manager as test_manager
from ceilometer.collector import meter
from ceilometer.collector import service
from ceilometer.openstack.common import cfg
from ceilometer import pipeline
from ceilometer.storage import base
from ceilometer.tests import base as tests_base
from ceilometer.compute import notifications

View File

@ -25,7 +25,6 @@ from stevedore import extension
from ceilometer import nova_client
from ceilometer.compute import manager
from ceilometer import counter
from ceilometer import pipeline
from ceilometer.tests import base
from ceilometer.openstack.common import cfg

View File

@ -28,8 +28,6 @@ from ceilometer.compute import manager
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.tests import base as test_base
import mox
class TestPollsterBase(test_base.TestCase):

View File

@ -19,13 +19,9 @@
"""Tests for libvirt inspector.
"""
import time
from ceilometer.compute.virt.libvirt import inspector as libvirt_inspector
from ceilometer.tests import base as test_base
import mox
class TestLibvirtInspection(test_base.TestCase):

View File

@ -22,22 +22,26 @@ import unittest
from ceilometer.image import notifications
from ceilometer import counter
from tests import utils
def fake_uuid(x):
return '%s-%s-%s-%s' % (x * 8, x * 4, x * 4, x * 12)
NOW = datetime.isoformat(datetime.utcnow())
NOTIFICATION_SEND = {
u'event_type': u'image.send',
u'timestamp': NOW,
u'message_id': utils.fake_uuid('a'),
u'message_id': fake_uuid('a'),
u'priority': u'INFO',
u'publisher_id': u'images.example.com',
u'payload': {u'receiver_tenant_id': utils.fake_uuid('b'),
u'payload': {u'receiver_tenant_id': fake_uuid('b'),
u'destination_ip': u'1.2.3.4',
u'bytes_sent': 42,
u'image_id': utils.fake_uuid('c'),
u'receiver_user_id': utils.fake_uuid('d'),
u'owner_id': utils.fake_uuid('e')}
u'image_id': fake_uuid('c'),
u'receiver_user_id': fake_uuid('d'),
u'owner_id': fake_uuid('e')}
}
IMAGE_META = {u'status': u'saving',
@ -51,7 +55,7 @@ IMAGE_META = {u'status': u'saving',
u'key1': u'value1'},
u'min_disk': 0,
u'protected': False,
u'id': utils.fake_uuid('c'),
u'id': fake_uuid('c'),
u'location': None,
u'checksum': u'd990432ef91afef3ad9dbf4a975d3365',
u'owner': "fake",
@ -90,7 +94,7 @@ class TestNotification(unittest.TestCase):
def _verify_common_counter(self, c, name, volume):
self.assertFalse(c is None)
self.assertEqual(c.name, name)
self.assertEqual(c.resource_id, utils.fake_uuid('c'))
self.assertEqual(c.resource_id, fake_uuid('c'))
self.assertEqual(c.timestamp, NOW)
self.assertEqual(c.volume, volume)
metadata = c.resource_metadata
@ -102,8 +106,8 @@ class TestNotification(unittest.TestCase):
self.assertEqual(len(counters), 1)
download = counters[0]
self._verify_common_counter(download, 'image.download', 42)
self.assertEqual(download.user_id, utils.fake_uuid('d'))
self.assertEqual(download.project_id, utils.fake_uuid('b'))
self.assertEqual(download.user_id, fake_uuid('d'))
self.assertEqual(download.project_id, fake_uuid('b'))
self.assertEqual(download.type, counter.TYPE_DELTA)
def test_image_serve(self):
@ -112,11 +116,11 @@ class TestNotification(unittest.TestCase):
self.assertEqual(len(counters), 1)
serve = counters[0]
self._verify_common_counter(serve, 'image.serve', 42)
self.assertEqual(serve.project_id, utils.fake_uuid('e'))
self.assertEqual(serve.project_id, fake_uuid('e'))
self.assertEquals(serve.resource_metadata.get('receiver_user_id'),
utils.fake_uuid('d'))
fake_uuid('d'))
self.assertEquals(serve.resource_metadata.get('receiver_tenant_id'),
utils.fake_uuid('b'))
fake_uuid('b'))
self.assertEqual(serve.type, counter.TYPE_DELTA)
def test_image_crud_on_update(self):

View File

@ -22,7 +22,6 @@ from webob import Request
from ceilometer.tests import base
from ceilometer.objectstore import swift_middleware
from ceilometer.openstack.common import rpc
from ceilometer import pipeline

View File

@ -33,9 +33,6 @@ from ceilometer.tests import base as test_base
class DBEngineBase(object):
__metaclass__ = abc.ABCMeta
def __init__(self):
super(DBEngineBase, self).__init__()
@abc.abstractmethod
def get_connection(self):
"""Return an open connection to the DB
@ -75,7 +72,6 @@ class DBTestBase(test_base.TestCase):
'''Return an instance of the class which implements
the DBEngineTestBase abstract class
'''
return None
def __setup_engine(self):
if self.engine is None:

View File

@ -46,11 +46,9 @@
"""
import mox
from tests.storage import base
from ceilometer import storage
from ceilometer.tests.db import TestConnection, require_map_reduce

View File

@ -19,13 +19,11 @@
import logging
import os
import sqlalchemy
import re
from tests.storage import base
from ceilometer.openstack.common import cfg
from ceilometer import storage
from ceilometer.storage import impl_sqlalchemy
from ceilometer.storage.sqlalchemy.models import Meter, Project, Resource, User
from ceilometer.storage.sqlalchemy.models import Project, User
from ceilometer.storage.sqlalchemy.models import table_args

View File

@ -16,13 +16,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
from stevedore import dispatch
from stevedore import extension
from ceilometer import counter
from ceilometer import extension_manager as act_extension
from ceilometer.openstack.common import timeutils
from ceilometer import pipeline
from ceilometer.tests import base

View File

@ -1,21 +0,0 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 Red Hat Inc.
#
# Author: Eoghan Glynn <eglynn@redhat.com>
#
# 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.
def fake_uuid(x):
return '%s-%s-%s-%s' % (x * 8, x * 4, x * 4, x * 12)