From 843bb0cd53f6cc3caa9beeb8f07a374943d01889 Mon Sep 17 00:00:00 2001 From: Sushil Kumar Date: Wed, 20 May 2015 19:53:12 +0000 Subject: [PATCH] Fixes hacking rules This patchset helps reducing the ignored pep8 errors. Fixed some ignored hacking rules, as listed follows: - E111 indentation is not a multiple of four - E122 continuation line missing indentation or outdented - E123 closing bracket does not match indentation of opening bracket's line - E128 continuation line under-indented for visual indent - E251 unexpected spaces around keyword / parameter equals - E265 block comment should start with '# ' - E713 test for membership should be 'not in' - H105 Don't use author tags - H306 imports not in alphabetical order Change-Id: Iadf2af4f6ec90420153ad63b5a41650392ef2cbd --- contrib/trove-guestagent | 2 +- generate_examples.py | 3 +- run_tests.py | 79 ++++++++-------- tox.ini | 4 +- trove/__init__.py | 1 - trove/backup/models.py | 30 +++--- trove/backup/service.py | 4 +- trove/cluster/models.py | 2 +- trove/cluster/service.py | 6 +- trove/cmd/fakemode.py | 3 +- trove/cmd/manage.py | 2 +- trove/common/api.py | 6 +- trove/common/auth.py | 6 +- trove/common/base_exception.py | 2 - trove/common/base_wsgi.py | 7 +- trove/common/exception.py | 2 +- trove/common/extensions.py | 10 +- trove/common/limits.py | 10 +- trove/common/models.py | 3 +- trove/common/pagination.py | 6 +- .../cluster/experimental/mongodb/api.py | 2 +- .../experimental/mongodb/guestagent.py | 8 +- .../experimental/mongodb/taskmanager.py | 2 +- .../cluster/experimental/vertica/api.py | 20 ++-- .../experimental/vertica/guestagent.py | 20 ++-- .../experimental/vertica/taskmanager.py | 22 ++--- trove/common/template.py | 2 +- trove/common/utils.py | 17 ++-- trove/common/wsgi.py | 18 ++-- trove/conductor/api.py | 3 +- trove/conductor/manager.py | 2 +- trove/conductor/models.py | 20 ++-- trove/configuration/models.py | 6 +- trove/configuration/service.py | 9 +- trove/datastore/models.py | 14 +-- trove/datastore/service.py | 4 +- trove/datastore/views.py | 2 +- trove/db/__init__.py | 2 +- trove/db/models.py | 6 +- trove/db/sqlalchemy/mappers.py | 2 +- trove/db/sqlalchemy/migrate_repo/schema.py | 3 +- .../migrate_repo/versions/006_dns_records.py | 2 +- .../migrate_repo/versions/011_quota.py | 20 ++-- .../migrate_repo/versions/012_backup.py | 22 ++--- .../013_add_security_group_artifacts.py | 6 +- .../versions/014_update_instance_flavor_id.py | 2 +- .../versions/016_add_datastore_type.py | 2 +- .../versions/018_datastore_versions_fix.py | 2 +- .../versions/019_datastore_fix.py | 7 +- .../versions/020_configurations.py | 6 +- .../versions/021_conductor_last_seen.py | 4 +- .../versions/023_add_instance_indexes.py | 4 +- .../versions/024_add_backup_indexes.py | 4 +- .../025_add_service_statuses_indexes.py | 4 +- .../027_add_datastore_capabilities.py | 2 +- .../versions/030_add_master_slave.py | 2 +- .../031_add_timestamps_to_configurations.py | 2 +- .../migrate_repo/versions/032_clusters.py | 2 +- .../versions/033_datastore_parameters.py | 6 +- trove/db/sqlalchemy/migration.py | 2 +- trove/db/sqlalchemy/session.py | 17 ++-- trove/dns/designate/driver.py | 12 ++- trove/dns/driver.py | 8 +- trove/dns/manager.py | 4 +- trove/dns/models.py | 6 +- trove/extensions/account/models.py | 2 +- trove/extensions/account/service.py | 9 +- trove/extensions/mgmt/clusters/service.py | 8 +- .../extensions/mgmt/configuration/service.py | 8 +- .../extensions/mgmt/host/instance/service.py | 2 +- trove/extensions/mgmt/host/models.py | 10 +- trove/extensions/mgmt/host/service.py | 4 +- trove/extensions/mgmt/instances/models.py | 8 +- trove/extensions/mgmt/instances/service.py | 10 +- trove/extensions/mgmt/quota/service.py | 6 +- trove/extensions/mgmt/upgrade/service.py | 6 +- trove/extensions/mgmt/volume/service.py | 4 +- trove/extensions/mysql/models.py | 2 +- trove/extensions/mysql/service.py | 11 +-- trove/extensions/routes/mgmt.py | 11 +-- trove/extensions/routes/security_group.py | 4 +- trove/extensions/security_group/models.py | 6 +- trove/extensions/security_group/service.py | 4 +- trove/extensions/security_group/views.py | 3 +- trove/flavor/views.py | 2 +- trove/guestagent/api.py | 2 +- trove/guestagent/backup/backupagent.py | 5 +- trove/guestagent/common/operating_system.py | 5 +- trove/guestagent/common/sql_query.py | 2 +- trove/guestagent/common/timeutils.py | 3 +- .../experimental/cassandra/manager.py | 13 +-- .../experimental/cassandra/service.py | 10 +- .../experimental/couchbase/manager.py | 6 +- .../experimental/couchbase/service.py | 9 +- .../datastore/experimental/couchdb/manager.py | 8 +- .../datastore/experimental/couchdb/service.py | 6 +- .../datastore/experimental/db2/manager.py | 6 +- .../datastore/experimental/db2/service.py | 4 +- .../datastore/experimental/mongodb/manager.py | 7 +- .../datastore/experimental/mongodb/service.py | 19 ++-- .../experimental/postgresql/manager.py | 11 ++- .../experimental/postgresql/service/access.py | 8 +- .../experimental/postgresql/service/config.py | 3 +- .../postgresql/service/database.py | 3 +- .../postgresql/service/install.py | 4 +- .../experimental/postgresql/service/root.py | 1 + .../experimental/postgresql/service/status.py | 5 +- .../experimental/postgresql/service/users.py | 3 +- .../datastore/experimental/redis/manager.py | 10 +- .../datastore/experimental/redis/service.py | 14 +-- .../datastore/experimental/vertica/manager.py | 29 +++--- .../datastore/experimental/vertica/service.py | 29 +++--- .../datastore/experimental/vertica/system.py | 32 +++---- trove/guestagent/datastore/mysql/manager.py | 15 +-- trove/guestagent/datastore/mysql/service.py | 16 ++-- trove/guestagent/datastore/service.py | 2 +- trove/guestagent/db/models.py | 2 +- trove/guestagent/dbaas.py | 4 +- trove/guestagent/models.py | 2 +- trove/guestagent/pkg.py | 7 +- .../backup/experimental/couchbase_impl.py | 4 +- .../strategies/replication/mysql_base.py | 3 +- .../guestagent/strategies/restore/__init__.py | 20 ++-- trove/guestagent/strategies/restore/base.py | 6 +- .../restore/experimental/couchbase_impl.py | 2 +- .../restore/experimental/postgresql_impl.py | 6 +- .../strategies/restore/mysql_impl.py | 11 ++- trove/guestagent/strategies/storage/swift.py | 6 +- trove/guestagent/volume.py | 7 +- trove/instance/models.py | 65 +++++++------ trove/instance/service.py | 19 ++-- trove/instance/tasks.py | 4 +- trove/instance/views.py | 2 +- trove/network/neutron.py | 5 +- trove/network/nova.py | 3 +- trove/quota/quota.py | 14 +-- trove/rpc.py | 2 +- trove/taskmanager/api.py | 5 +- trove/taskmanager/manager.py | 7 +- trove/taskmanager/models.py | 92 ++++++++++--------- trove/tests/api/backups.py | 25 ++--- trove/tests/api/configurations.py | 27 +++--- trove/tests/api/databases.py | 12 +-- trove/tests/api/datastores.py | 9 +- trove/tests/api/flavors.py | 11 +-- trove/tests/api/header.py | 5 +- trove/tests/api/instances.py | 74 ++++++++------- trove/tests/api/instances_actions.py | 34 +++---- trove/tests/api/instances_delete.py | 14 +-- trove/tests/api/instances_mysql_down.py | 17 ++-- trove/tests/api/instances_resize.py | 9 +- trove/tests/api/limits.py | 11 +-- trove/tests/api/mgmt/accounts.py | 20 ++-- trove/tests/api/mgmt/admin_required.py | 5 +- trove/tests/api/mgmt/configurations.py | 7 +- trove/tests/api/mgmt/hosts.py | 13 ++- trove/tests/api/mgmt/instances.py | 30 +++--- trove/tests/api/mgmt/instances_actions.py | 29 +++--- trove/tests/api/mgmt/malformed_json.py | 13 +-- trove/tests/api/mgmt/quotas.py | 17 ++-- trove/tests/api/mgmt/storage.py | 5 +- trove/tests/api/replication.py | 8 +- trove/tests/api/root.py | 11 +-- trove/tests/api/root_on_create.py | 12 +-- trove/tests/api/user_access.py | 9 +- trove/tests/api/users.py | 21 ++--- trove/tests/api/versions.py | 8 +- trove/tests/config.py | 6 +- trove/tests/db/migrations.py | 13 +-- trove/tests/examples/client.py | 1 + trove/tests/examples/snippets.py | 30 +++--- trove/tests/fakes/dns.py | 5 +- trove/tests/fakes/guestagent.py | 7 +- trove/tests/fakes/taskmanager.py | 3 +- .../tests/unittests/api/common/test_limits.py | 9 +- trove/tests/unittests/api/test_versions.py | 3 +- .../unittests/backup/test_backup_models.py | 20 ++-- .../unittests/backup/test_backupagent.py | 38 ++++---- trove/tests/unittests/backup/test_storage.py | 35 +++---- trove/tests/unittests/cluster/test_cluster.py | 4 +- .../test_cluster_vertica_controller.py | 20 ++-- .../unittests/cluster/test_cluster_views.py | 3 +- .../unittests/cluster/test_vertica_cluster.py | 20 ++-- trove/tests/unittests/common/test_remote.py | 18 ++-- trove/tests/unittests/common/test_template.py | 4 +- trove/tests/unittests/conductor/test_conf.py | 8 +- .../tests/unittests/conductor/test_methods.py | 2 +- .../test_configuration_controller.py | 3 +- trove/tests/unittests/datastore/base.py | 5 +- .../unittests/datastore/test_capability.py | 6 +- .../unittests/datastore/test_datastore.py | 2 +- .../unittests/db/test_migration_utils.py | 17 ++-- .../unittests/dns/test_designate_driver.py | 12 ++- .../test_agent_heartbeats_models.py | 4 +- trove/tests/unittests/guestagent/test_api.py | 4 +- .../guestagent/test_cassandra_manager.py | 9 +- .../guestagent/test_couchbase_manager.py | 26 +++--- .../guestagent/test_couchdb_manager.py | 17 ++-- .../unittests/guestagent/test_db2_manager.py | 13 +-- .../tests/unittests/guestagent/test_dbaas.py | 74 +++++++-------- .../unittests/guestagent/test_dbmodels.py | 5 +- .../tests/unittests/guestagent/test_models.py | 14 +-- .../test_mongodb_cluster_manager.py | 8 +- .../guestagent/test_mongodb_manager.py | 11 ++- .../guestagent/test_mysql_manager.py | 13 +-- .../guestagent/test_operating_system.py | 8 +- trove/tests/unittests/guestagent/test_pkg.py | 7 +- .../guestagent/test_redis_manager.py | 11 ++- .../guestagent/test_vertica_manager.py | 39 ++++---- .../tests/unittests/guestagent/test_volume.py | 10 +- .../instance/test_instance_controller.py | 3 +- .../instance/test_instance_models.py | 11 ++- trove/tests/unittests/mgmt/test_clusters.py | 20 ++-- trove/tests/unittests/mgmt/test_models.py | 15 ++- .../unittests/mysql/test_user_controller.py | 43 ++++----- .../unittests/network/test_neutron_driver.py | 5 +- trove/tests/unittests/quota/test_quota.py | 15 +-- trove/tests/unittests/router/test_router.py | 3 +- .../secgroups/test_security_group.py | 27 +++--- .../unittests/taskmanager/test_clusters.py | 12 +-- .../unittests/taskmanager/test_models.py | 41 +++++---- .../taskmanager/test_vertica_clusters.py | 29 +++--- .../unittests/upgrade/test_controller.py | 3 +- trove/tests/util/__init__.py | 22 ++--- trove/tests/util/check.py | 3 +- trove/tests/util/client.py | 2 - trove/tests/util/event_simulator.py | 4 +- trove/tests/util/mysql.py | 8 +- trove/tests/util/usage.py | 7 +- 229 files changed, 1282 insertions(+), 1242 deletions(-) diff --git a/contrib/trove-guestagent b/contrib/trove-guestagent index c9c8ebb12b..18d7e142a9 100755 --- a/contrib/trove-guestagent +++ b/contrib/trove-guestagent @@ -19,8 +19,8 @@ When the guest is moved out of the application, this will no longer be needed in the project.""" -import sys import os +import sys possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, diff --git a/generate_examples.py b/generate_examples.py index afe14e6c12..f26c385ed8 100755 --- a/generate_examples.py +++ b/generate_examples.py @@ -15,11 +15,12 @@ # under the License. # -import run_tests import argparse import os import sys +import run_tests + def import_tests(): from trove.tests.examples import snippets diff --git a/run_tests.py b/run_tests.py index 64dbacdd25..7b89a8e1b4 100644 --- a/run_tests.py +++ b/run_tests.py @@ -19,22 +19,23 @@ import functools import gettext import os -import urllib import sys import traceback - -from trove.common import cfg -from trove.common import utils -from trove.common.rpc import service as rpc_service -from trove.common.rpc import version as rpc_version -from trove.openstack.common import log as logging -from trove.tests.config import CONFIG -from trove import rpc -from wsgi_intercept.httplib2_intercept import install as wsgi_install -import proboscis -import wsgi_intercept +import urllib import eventlet +import proboscis +import wsgi_intercept +from wsgi_intercept.httplib2_intercept import install as wsgi_install + +from trove.common import cfg +from trove.common.rpc import service as rpc_service +from trove.common.rpc import version as rpc_version +from trove.common import utils +from trove.openstack.common import log as logging +from trove import rpc +from trove.tests.config import CONFIG + eventlet.monkey_patch(thread=False) CONF = cfg.CONF @@ -77,13 +78,12 @@ def initialize_trove(config_file): def datastore_init(): # Adds the datastore for mysql (needed to make most calls work). - from trove.datastore import models from trove.configuration.models import DatastoreConfigurationParameters + from trove.datastore import models - models.DBDatastore.create(id=CONFIG.dbaas_datastore_id, - name=CONFIG.dbaas_datastore, - default_version_id= - CONFIG.dbaas_datastore_version_id) + models.DBDatastore.create( + id=CONFIG.dbaas_datastore_id, name=CONFIG.dbaas_datastore, + default_version_id=CONFIG.dbaas_datastore_version_id) models.DBDatastore.create(id=utils.generate_uuid(), name=CONFIG.dbaas_datastore_name_no_versions, @@ -91,22 +91,18 @@ def datastore_init(): main_dsv = models.DBDatastoreVersion.create( id=CONFIG.dbaas_datastore_version_id, - datastore_id= - CONFIG.dbaas_datastore_id, + datastore_id=CONFIG.dbaas_datastore_id, name=CONFIG.dbaas_datastore_version, manager="mysql", - image_id= - 'c00000c0-00c0-0c00-00c0-000c000000cc', + image_id='c00000c0-00c0-0c00-00c0-000c000000cc', packages='test packages', active=1) - models.DBDatastoreVersion.create(id="d00000d0-00d0-0d00-00d0-000d000000dd", - datastore_id= - CONFIG.dbaas_datastore_id, - name='mysql_inactive_version', - manager="mysql", - image_id= - 'c00000c0-00c0-0c00-00c0-000c000000cc', - packages=None, active=0) + models.DBDatastoreVersion.create( + id="d00000d0-00d0-0d00-00d0-000d000000dd", + datastore_id=CONFIG.dbaas_datastore_id, + name='mysql_inactive_version', manager="mysql", + image_id='c00000c0-00c0-0c00-00c0-000c000000cc', + packages=None, active=0) def add_parm(name, data_type, max_size, min_size=0, restart_required=0): DatastoreConfigurationParameters.create( @@ -148,7 +144,6 @@ def initialize_fakes(app): path_info = env.get('PATH_INFO') if path_info: env['PATH_INFO'] = urllib.unquote(path_info) - #print("%s %s" % (args, kwargs)) return app.__call__(env, start_response) return call_back @@ -200,30 +195,30 @@ def run_tests(repl): def import_tests(): # F401 unused imports needed for tox tests from trove.tests.api import backups # noqa - from trove.tests.api import header # noqa - from trove.tests.api import limits # noqa + from trove.tests.api import configurations # noqa + from trove.tests.api import databases # noqa + from trove.tests.api import datastores # noqa from trove.tests.api import flavors # noqa - from trove.tests.api import versions # noqa + from trove.tests.api import header # noqa from trove.tests.api import instances as rd_instances # noqa from trove.tests.api import instances_actions as rd_actions # noqa from trove.tests.api import instances_delete # noqa from trove.tests.api import instances_mysql_down # noqa from trove.tests.api import instances_resize # noqa - from trove.tests.api import configurations # noqa - from trove.tests.api import databases # noqa - from trove.tests.api import datastores # noqa - from trove.tests.api import replication # noqa - from trove.tests.api import root # noqa - from trove.tests.api import root_on_create # noqa - from trove.tests.api import users # noqa - from trove.tests.api import user_access # noqa + from trove.tests.api import limits # noqa from trove.tests.api.mgmt import accounts # noqa from trove.tests.api.mgmt import admin_required # noqa from trove.tests.api.mgmt import hosts # noqa from trove.tests.api.mgmt import instances as mgmt_instances # noqa from trove.tests.api.mgmt import instances_actions as mgmt_actions # noqa - from trove.tests.api.mgmt import storage # noqa from trove.tests.api.mgmt import malformed_json # noqa + from trove.tests.api.mgmt import storage # noqa + from trove.tests.api import replication # noqa + from trove.tests.api import root # noqa + from trove.tests.api import root_on_create # noqa + from trove.tests.api import user_access # noqa + from trove.tests.api import users # noqa + from trove.tests.api import versions # noqa from trove.tests.db import migrations # noqa diff --git a/tox.ini b/tox.ini index b65a3fb5d2..4ff380ccb7 100644 --- a/tox.ini +++ b/tox.ini @@ -41,9 +41,9 @@ commands = {posargs} [flake8] show-source = True -# H301 and H306 are ignored on purpose. +# H301 is ignored on purpose. # The rest of the ignores are TODOs. -ignore = E111,E122,E123,E128,E251,E265,E713,F821,H105,H237,H238,H301,H305,H306,H307,H402,H404,H405,H407,H501,H904 +ignore = F821,H237,H238,H301,H305,H307,H402,H404,H405,H407,H501,H904 builtins = _ exclude=.venv,.tox,dist,doc,openstack,*egg,rsdns,tools,etc,build,*.po,*.pot filename=*.py,trove-* diff --git a/trove/__init__.py b/trove/__init__.py index 932f8f730b..7faa682566 100644 --- a/trove/__init__.py +++ b/trove/__init__.py @@ -19,7 +19,6 @@ .. automodule:: trove :platform: Unix :synopsis: Platform-As-A-Service Database Cloud -.. moduleauthor:: Michael Basnight """ __all__ = ['__version__'] diff --git a/trove/backup/models.py b/trove/backup/models.py index 3dd90695f0..d2d0b151c7 100644 --- a/trove/backup/models.py +++ b/trove/backup/models.py @@ -1,16 +1,16 @@ -#Copyright [2013] Hewlett-Packard Development Company, L.P. +# Copyright [2013] Hewlett-Packard Development Company, L.P. -#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 +# 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 +# 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. +# 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. """Model classes that form the core of snapshots functionality.""" @@ -20,14 +20,14 @@ from swiftclient.client import ClientException from trove.backup.state import BackupState from trove.common import cfg from trove.common import exception -from trove.db.models import DatabaseModelBase -from trove.datastore import models as datastore_models -from trove.openstack.common import log as logging -from trove.taskmanager import api +from trove.common.i18n import _ from trove.common.remote import create_swift_client from trove.common import utils +from trove.datastore import models as datastore_models +from trove.db.models import DatabaseModelBase +from trove.openstack.common import log as logging from trove.quota.quota import run_with_quotas -from trove.common.i18n import _ +from trove.taskmanager import api CONF = cfg.CONF diff --git a/trove/backup/service.py b/trove/backup/service.py index b5d2bb3683..0116ec3836 100644 --- a/trove/backup/service.py +++ b/trove/backup/service.py @@ -13,14 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.backup import views from trove.backup.models import Backup +from trove.backup import views from trove.common import apischema from trove.common import cfg +from trove.common.i18n import _ from trove.common import pagination from trove.common import wsgi from trove.openstack.common import log as logging -from trove.common.i18n import _ CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/trove/cluster/models.py b/trove/cluster/models.py index 9f0643df1b..0c4cabe39a 100644 --- a/trove/cluster/models.py +++ b/trove/cluster/models.py @@ -17,12 +17,12 @@ from trove.cluster.tasks import ClusterTask from trove.cluster.tasks import ClusterTasks from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common.strategies.cluster import strategy from trove.datastore import models as datastore_models from trove.db import models as dbmodels from trove.instance import models as inst_models from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.taskmanager import api as task_api diff --git a/trove/cluster/service.py b/trove/cluster/service.py index 91539ea107..c9c5b6d0ae 100644 --- a/trove/cluster/service.py +++ b/trove/cluster/service.py @@ -17,16 +17,16 @@ from oslo_config.cfg import NoSuchOptError from trove.cluster import models from trove.cluster import views +from trove.common import apischema from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import pagination -from trove.common import apischema +from trove.common.strategies.cluster import strategy from trove.common import utils from trove.common import wsgi -from trove.common.strategies.cluster import strategy from trove.datastore import models as datastore_models from trove.openstack.common import log as logging -from trove.common.i18n import _ CONF = cfg.CONF diff --git a/trove/cmd/fakemode.py b/trove/cmd/fakemode.py index 87a1574e71..ec02a1c656 100755 --- a/trove/cmd/fakemode.py +++ b/trove/cmd/fakemode.py @@ -12,8 +12,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_config import cfg as openstack_cfg from oslo_concurrency import processutils +from oslo_config import cfg as openstack_cfg + from trove.cmd.common import with_initialize diff --git a/trove/cmd/manage.py b/trove/cmd/manage.py index d4d5531db5..6de42b343a 100755 --- a/trove/cmd/manage.py +++ b/trove/cmd/manage.py @@ -25,9 +25,9 @@ from trove.common import cfg from trove.common import exception from trove.common import utils from trove.configuration import models as config_models +from trove.datastore import models as datastore_models from trove.db import get_db_api from trove.openstack.common import log as logging -from trove.datastore import models as datastore_models CONF = cfg.CONF diff --git a/trove/common/api.py b/trove/common/api.py index 60222e580a..853272de0b 100644 --- a/trove/common/api.py +++ b/trove/common/api.py @@ -14,16 +14,16 @@ import routes -from trove.common import wsgi +from trove.backup.service import BackupController from trove.cluster.service import ClusterController +from trove.common import wsgi from trove.configuration.service import ConfigurationsController from trove.configuration.service import ParametersController +from trove.datastore.service import DatastoreController from trove.flavor.service import FlavorController from trove.instance.service import InstanceController from trove.limits.service import LimitsController -from trove.backup.service import BackupController from trove.versions import VersionsController -from trove.datastore.service import DatastoreController class API(wsgi.Router): diff --git a/trove/common/auth.py b/trove/common/auth.py index c8dd7d2e37..ffa345b6ed 100644 --- a/trove/common/auth.py +++ b/trove/common/auth.py @@ -14,14 +14,14 @@ # under the License. import re + +from oslo_utils import strutils import webob.exc import wsgi -from oslo_utils import strutils - from trove.common import exception -from trove.openstack.common import log as logging from trove.common.i18n import _ +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/common/base_exception.py b/trove/common/base_exception.py index debe7afaf1..a806ee3a75 100644 --- a/trove/common/base_exception.py +++ b/trove/common/base_exception.py @@ -98,9 +98,7 @@ def wrap_exception(f): return f(*args, **kw) except Exception as e: if not isinstance(e, Error): - #exc_type, exc_value, exc_traceback = sys.exc_info() logging.exception(_('Uncaught exception')) - #logging.error(traceback.extract_stack(exc_traceback)) raise Error(str(e)) raise _wrap.func_name = f.func_name diff --git a/trove/common/base_wsgi.py b/trove/common/base_wsgi.py index e84706cc41..997b543971 100644 --- a/trove/common/base_wsgi.py +++ b/trove/common/base_wsgi.py @@ -30,7 +30,6 @@ import eventlet.wsgi from oslo_config import cfg import routes import routes.middleware -#import six import webob.dec import webob.exc from xml.dom import minidom @@ -481,7 +480,7 @@ class XMLDictSerializer(DictSerializer): self._add_xmlns(node, has_atom) return node.toprettyxml(indent=' ', encoding='UTF-8') - #NOTE (ameade): the has_atom should be removed after all of the + # NOTE (ameade): the has_atom should be removed after all of the # xml serializers and view builders have been updated to the current # spec that required all responses include the xmlns:atom, the has_atom # flag is to prevent current tests from breaking @@ -501,7 +500,7 @@ class XMLDictSerializer(DictSerializer): if xmlns: result.setAttribute('xmlns', xmlns) - #TODO(bcwaldon): accomplish this without a type-check + # TODO(bcwaldon): accomplish this without a type-check if type(data) is list: collections = metadata.get('list_collections', {}) if nodename in collections: @@ -520,7 +519,7 @@ class XMLDictSerializer(DictSerializer): for item in data: node = self._to_xml_node(doc, metadata, singular, item) result.appendChild(node) - #TODO(bcwaldon): accomplish this without a type-check + # TODO(bcwaldon): accomplish this without a type-check elif type(data) is dict: collections = metadata.get('dict_collections', {}) if nodename in collections: diff --git a/trove/common/exception.py b/trove/common/exception.py index af0873109a..ff1b53794a 100644 --- a/trove/common/exception.py +++ b/trove/common/exception.py @@ -19,9 +19,9 @@ import re from oslo_concurrency import processutils -from trove.openstack.common import log as logging from trove.common import base_exception as openstack_exception from trove.common.i18n import _ +from trove.openstack.common import log as logging ClientConnectionError = openstack_exception.ClientConnectionError diff --git a/trove/common/extensions.py b/trove/common/extensions.py index 32d7edad9a..0c53c0a93e 100644 --- a/trove/common/extensions.py +++ b/trove/common/extensions.py @@ -14,20 +14,20 @@ # under the License. import abc + +from lxml import etree import routes import six import stevedore import webob.dec import webob.exc -from trove.common import base_wsgi - -from lxml import etree -from trove.openstack.common import log as logging from trove.common import base_exception as exception +from trove.common import base_wsgi from trove.common import cfg +from trove.common.i18n import _ from trove.common import wsgi -from trove.common.i18n import _ # noqa +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/common/limits.py b/trove/common/limits.py index 30a4bb950e..1785a085f5 100644 --- a/trove/common/limits.py +++ b/trove/common/limits.py @@ -23,16 +23,16 @@ import httplib import math import re import time + +from oslo_serialization import jsonutils +from oslo_utils import importutils import webob.dec import webob.exc -from oslo_utils import importutils -from oslo_serialization import jsonutils - -from trove.common import cfg -from trove.common import wsgi from trove.common import base_wsgi +from trove.common import cfg from trove.common.i18n import _ +from trove.common import wsgi CONF = cfg.CONF diff --git a/trove/common/models.py b/trove/common/models.py index 6b0d040129..84fbcc9579 100644 --- a/trove/common/models.py +++ b/trove/common/models.py @@ -16,8 +16,9 @@ """Model classes that form the core of instances functionality.""" from oslo_utils.importutils import import_class -from trove.common import remote + from trove.common import cfg +from trove.common import remote CONF = cfg.CONF diff --git a/trove/common/pagination.py b/trove/common/pagination.py index b587b7f3c7..94a6a13fcb 100644 --- a/trove/common/pagination.py +++ b/trove/common/pagination.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. -import urllib -import six.moves.urllib.parse as urlparse - try: from collections import OrderedDict except ImportError: from ordereddict import OrderedDict +import urllib + +import six.moves.urllib.parse as urlparse def url_quote(s): diff --git a/trove/common/strategies/cluster/experimental/mongodb/api.py b/trove/common/strategies/cluster/experimental/mongodb/api.py index fa34c95d77..83f3af998f 100644 --- a/trove/common/strategies/cluster/experimental/mongodb/api.py +++ b/trove/common/strategies/cluster/experimental/mongodb/api.py @@ -20,6 +20,7 @@ from trove.cluster.tasks import ClusterTasks from trove.cluster.views import ClusterView from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import remote from trove.common.strategies.cluster import base from trove.common import utils @@ -27,7 +28,6 @@ from trove.common import wsgi from trove.datastore import models as datastore_models from trove.extensions.mgmt.clusters.views import MgmtClusterView from trove.instance import models as inst_models -from trove.common.i18n import _ from trove.openstack.common import log as logging from trove.quota.quota import check_quotas from trove.taskmanager import api as task_api diff --git a/trove/common/strategies/cluster/experimental/mongodb/guestagent.py b/trove/common/strategies/cluster/experimental/mongodb/guestagent.py index e15805564e..1ab7bdbbdb 100644 --- a/trove/common/strategies/cluster/experimental/mongodb/guestagent.py +++ b/trove/common/strategies/cluster/experimental/mongodb/guestagent.py @@ -34,10 +34,10 @@ class MongoDbGuestAgentAPI(guest_api.API): def add_shard(self, replica_set_name, replica_set_member): LOG.debug("Adding shard with replSet %(replica_set_name)s and member " - "%(replica_set_member)s for instance %(id)s" % { - 'replica_set_name': replica_set_name, - 'replica_set_member': replica_set_member, - 'id': self.id}) + "%(replica_set_member)s for instance " + "%(id)s" % {'replica_set_name': replica_set_name, + 'replica_set_member': replica_set_member, + 'id': self.id}) return self._call("add_shard", guest_api.AGENT_HIGH_TIMEOUT, self.version_cap, replica_set_name=replica_set_name, diff --git a/trove/common/strategies/cluster/experimental/mongodb/taskmanager.py b/trove/common/strategies/cluster/experimental/mongodb/taskmanager.py index e2aee3f23c..56de1cd3ef 100644 --- a/trove/common/strategies/cluster/experimental/mongodb/taskmanager.py +++ b/trove/common/strategies/cluster/experimental/mongodb/taskmanager.py @@ -16,10 +16,10 @@ from eventlet.timeout import Timeout from trove.common import cfg +from trove.common.i18n import _ from trove.common.strategies.cluster import base from trove.instance.models import DBInstance from trove.instance.models import Instance -from trove.common.i18n import _ from trove.openstack.common import log as logging from trove.taskmanager import api as task_api import trove.taskmanager.models as task_models diff --git a/trove/common/strategies/cluster/experimental/vertica/api.py b/trove/common/strategies/cluster/experimental/vertica/api.py index 3bcd73aada..d5eadf3b89 100644 --- a/trove/common/strategies/cluster/experimental/vertica/api.py +++ b/trove/common/strategies/cluster/experimental/vertica/api.py @@ -1,15 +1,15 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. from novaclient import exceptions as nova_exceptions diff --git a/trove/common/strategies/cluster/experimental/vertica/guestagent.py b/trove/common/strategies/cluster/experimental/vertica/guestagent.py index 14b35df982..f5047b5f6e 100644 --- a/trove/common/strategies/cluster/experimental/vertica/guestagent.py +++ b/trove/common/strategies/cluster/experimental/vertica/guestagent.py @@ -1,15 +1,15 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. from trove.common import cfg from trove.common.strategies.cluster import base diff --git a/trove/common/strategies/cluster/experimental/vertica/taskmanager.py b/trove/common/strategies/cluster/experimental/vertica/taskmanager.py index 1271611a80..e1db2cb437 100644 --- a/trove/common/strategies/cluster/experimental/vertica/taskmanager.py +++ b/trove/common/strategies/cluster/experimental/vertica/taskmanager.py @@ -1,23 +1,23 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. from eventlet.timeout import Timeout from trove.common import cfg +from trove.common.i18n import _ from trove.common.strategies.cluster import base from trove.instance.models import DBInstance from trove.instance.models import Instance -from trove.common.i18n import _ from trove.openstack.common import log as logging from trove.taskmanager import api as task_api import trove.taskmanager.models as task_models diff --git a/trove/common/template.py b/trove/common/template.py index 803484d989..74130f8dae 100644 --- a/trove/common/template.py +++ b/trove/common/template.py @@ -20,9 +20,9 @@ from oslo_config import cfg as oslo_config from trove.common import cfg from trove.common import configurations from trove.common import exception +from trove.common.i18n import _ from trove.common import utils from trove.openstack.common import log as logging -from trove.common.i18n import _ CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/trove/common/utils.py b/trove/common/utils.py index 208d2b2c79..fc43cc010c 100644 --- a/trove/common/utils.py +++ b/trove/common/utils.py @@ -16,20 +16,19 @@ import datetime import inspect -import jinja2 -import time -import six.moves.urllib.parse as urlparse -import uuid import os import shutil +import time +import uuid from eventlet.timeout import Timeout -from passlib import utils as passlib_utils - -from oslo_utils import importutils -from oslo_utils import timeutils -from oslo_utils import strutils +import jinja2 from oslo_concurrency import processutils +from oslo_utils import importutils +from oslo_utils import strutils +from oslo_utils import timeutils +from passlib import utils as passlib_utils +import six.moves.urllib.parse as urlparse from trove.common import cfg from trove.common import exception diff --git a/trove/common/wsgi.py b/trove/common/wsgi.py index 8725252946..cd1d420025 100644 --- a/trove/common/wsgi.py +++ b/trove/common/wsgi.py @@ -14,29 +14,29 @@ # under the License. """Wsgi helper utilities for trove""" -import eventlet.wsgi import math -import jsonschema -import paste.urlmap import re import time import traceback import uuid + +import eventlet.wsgi +import jsonschema +from oslo_serialization import jsonutils +import paste.urlmap import webob import webob.dec import webob.exc +from trove.common import base_wsgi +from trove.common import cfg from trove.common import context as rd_context from trove.common import exception -from trove.common import utils from trove.common.i18n import _ -from oslo_serialization import jsonutils - +from trove.common import utils +from trove.openstack.common import log as logging from trove.openstack.common import pastedeploy from trove.openstack.common import service -from trove.common import base_wsgi -from trove.openstack.common import log as logging -from trove.common import cfg CONTEXT_KEY = 'trove.context' Router = base_wsgi.Router diff --git a/trove/conductor/api.py b/trove/conductor/api.py index affbf6c050..d89691c76d 100644 --- a/trove/conductor/api.py +++ b/trove/conductor/api.py @@ -13,10 +13,11 @@ # under the License. import oslo_messaging as messaging -from trove import rpc + from trove.common import cfg from trove.common.rpc import version as rpc_version from trove.openstack.common import log as logging +from trove import rpc CONF = cfg.CONF diff --git a/trove/conductor/manager.py b/trove/conductor/manager.py index bb38d1178f..f50cc868ee 100644 --- a/trove/conductor/manager.py +++ b/trove/conductor/manager.py @@ -17,6 +17,7 @@ import oslo_messaging as messaging from trove.backup import models as bkup_models from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common.instance import ServiceStatus from trove.common.rpc import version as rpc_version from trove.conductor.models import LastSeen @@ -24,7 +25,6 @@ from trove.extensions.mysql import models as mysql_models from trove.instance import models as t_models from trove.openstack.common import log as logging from trove.openstack.common import periodic_task -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/conductor/models.py b/trove/conductor/models.py index 4cee86b7e2..c7df8c2b63 100644 --- a/trove/conductor/models.py +++ b/trove/conductor/models.py @@ -1,16 +1,16 @@ -#Copyright 2014 OpenStack Foundation +# Copyright 2014 OpenStack Foundation -#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 +# 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 +# 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. +# 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. from trove.db import get_db_api from trove.openstack.common import log as logging diff --git a/trove/configuration/models.py b/trove/configuration/models.py index 1bcfb66692..30a95bb7bd 100644 --- a/trove/configuration/models.py +++ b/trove/configuration/models.py @@ -13,18 +13,18 @@ # License for the specific language governing permissions and limitations # under the License. -import json from datetime import datetime +import json from trove.common import cfg from trove.common import exception -from trove.common import utils from trove.common.exception import ModelNotFoundError +from trove.common.i18n import _ +from trove.common import utils from trove.datastore import models as dstore_models from trove.db import get_db_api from trove.db import models as dbmodels from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.taskmanager import api as task_api diff --git a/trove/configuration/service.py b/trove/configuration/service.py index 28f9677cf8..336a8b14d6 100644 --- a/trove/configuration/service.py +++ b/trove/configuration/service.py @@ -14,18 +14,19 @@ # under the License. from datetime import datetime + +import trove.common.apischema as apischema from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import pagination from trove.common import wsgi from trove.configuration import models -from trove.configuration import views from trove.configuration.models import DBConfigurationParameter +from trove.configuration import views from trove.datastore import models as ds_models -from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.instance import models as instances_models -import trove.common.apischema as apischema +from trove.openstack.common import log as logging CONF = cfg.CONF diff --git a/trove/datastore/models.py b/trove/datastore/models.py index eb8a5c9253..642eccc95e 100644 --- a/trove/datastore/models.py +++ b/trove/datastore/models.py @@ -19,8 +19,8 @@ from trove.common import cfg from trove.common import exception from trove.common import utils -from trove.db import models as dbmodels from trove.db import get_db_api +from trove.db import models as dbmodels from trove.openstack.common import log as logging @@ -412,8 +412,8 @@ class DatastoreVersion(object): self._datastore_name = Datastore.load(self.datastore_id).name return self._datastore_name - #TODO(tim.simpson): This would be less confusing if it was called "version" - # and datastore_name was called "name". + # TODO(tim.simpson): This would be less confusing if it was called + # "version" and datastore_name was called "name". @property def name(self): return self.db_info.name @@ -475,15 +475,15 @@ def get_datastore_version(type=None, version=None, return_inactive=False): datastore = Datastore.load(datastore) version = version or datastore.default_version_id if not version: - raise exception.DatastoreDefaultVersionNotFound(datastore= - datastore.name) + raise exception.DatastoreDefaultVersionNotFound( + datastore=datastore.name) datastore_version = DatastoreVersion.load(datastore, version) if datastore_version.datastore_id != datastore.id: raise exception.DatastoreNoVersion(datastore=datastore.name, version=datastore_version.name) if not datastore_version.active and not return_inactive: - raise exception.DatastoreVersionInactive(version= - datastore_version.name) + raise exception.DatastoreVersionInactive( + version=datastore_version.name) return (datastore, datastore_version) diff --git a/trove/datastore/service.py b/trove/datastore/service.py index 9cfda748a5..376bdb5661 100644 --- a/trove/datastore/service.py +++ b/trove/datastore/service.py @@ -27,7 +27,7 @@ class DatastoreController(wsgi.Controller): datastore_versions = (models.DatastoreVersions.load(datastore.id)) return wsgi.Result(views. DatastoreView(datastore, datastore_versions, - req).data(), 200) + req).data(), 200) def index(self, req, tenant_id): context = req.environ[wsgi.CONTEXT_KEY] @@ -38,7 +38,7 @@ class DatastoreController(wsgi.Controller): datastores_versions = models.DatastoreVersions.load_all(only_active) return wsgi.Result(views. DatastoresView(datastores, datastores_versions, - req).data(), 200) + req).data(), 200) def version_show(self, req, tenant_id, datastore, id): datastore = models.Datastore.load(datastore) diff --git a/trove/datastore/views.py b/trove/datastore/views.py index 2ac779facb..6b4ebb6c5f 100644 --- a/trove/datastore/views.py +++ b/trove/datastore/views.py @@ -16,8 +16,8 @@ # under the License. # -from trove.common import wsgi from trove.common.views import create_links +from trove.common import wsgi class DatastoreView(object): diff --git a/trove/db/__init__.py b/trove/db/__init__.py index 1f3698e1fb..b8f27b3f23 100644 --- a/trove/db/__init__.py +++ b/trove/db/__init__.py @@ -15,8 +15,8 @@ import optparse -from trove.common import utils from trove.common import cfg +from trove.common import utils CONF = cfg.CONF diff --git a/trove/db/models.py b/trove/db/models.py index e25a94b599..b419c1d3c4 100644 --- a/trove/db/models.py +++ b/trove/db/models.py @@ -12,14 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.db import get_db_api -from trove.db import db_query from trove.common import exception +from trove.common.i18n import _ from trove.common import models from trove.common import pagination from trove.common import utils +from trove.db import db_query +from trove.db import get_db_api from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) diff --git a/trove/db/sqlalchemy/mappers.py b/trove/db/sqlalchemy/mappers.py index 8e1b67cf23..7965253262 100644 --- a/trove/db/sqlalchemy/mappers.py +++ b/trove/db/sqlalchemy/mappers.py @@ -14,9 +14,9 @@ # under the License. from sqlalchemy import MetaData -from sqlalchemy import Table from sqlalchemy import orm from sqlalchemy.orm import exc as orm_exc +from sqlalchemy import Table def map(engine, models): diff --git a/trove/db/sqlalchemy/migrate_repo/schema.py b/trove/db/sqlalchemy/migrate_repo/schema.py index 3b7bd18f40..48d4a30b04 100644 --- a/trove/db/sqlalchemy/migrate_repo/schema.py +++ b/trove/db/sqlalchemy/migrate_repo/schema.py @@ -15,9 +15,10 @@ """Various conveniences used for migration scripts.""" -from trove.openstack.common import log as logging import sqlalchemy.types +from trove.openstack.common import log as logging + logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') diff --git a/trove/db/sqlalchemy/migrate_repo/versions/006_dns_records.py b/trove/db/sqlalchemy/migrate_repo/versions/006_dns_records.py index 0afd5a8d32..79d554e60d 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/006_dns_records.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/006_dns_records.py @@ -16,10 +16,10 @@ from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData -from trove.db.sqlalchemy.migrate_repo.schema import Table from trove.db.sqlalchemy.migrate_repo.schema import create_tables from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import String +from trove.db.sqlalchemy.migrate_repo.schema import Table meta = MetaData() diff --git a/trove/db/sqlalchemy/migrate_repo/versions/011_quota.py b/trove/db/sqlalchemy/migrate_repo/versions/011_quota.py index 0a189181c5..3cd4d3d626 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/011_quota.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/011_quota.py @@ -1,16 +1,16 @@ -#Copyright [2013] Hewlett-Packard Development Company, L.P. +# Copyright [2013] Hewlett-Packard Development Company, L.P. -#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 +# 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 +# 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. +# 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. from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData diff --git a/trove/db/sqlalchemy/migrate_repo/versions/012_backup.py b/trove/db/sqlalchemy/migrate_repo/versions/012_backup.py index 8a04400105..5b32724cce 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/012_backup.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/012_backup.py @@ -1,27 +1,27 @@ -#Copyright [2013] Hewlett-Packard Development Company, L.P. +# Copyright [2013] Hewlett-Packard Development Company, L.P. -#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 +# 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 +# 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. +# 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. from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData +from trove.db.sqlalchemy.migrate_repo.schema import Boolean from trove.db.sqlalchemy.migrate_repo.schema import create_tables from trove.db.sqlalchemy.migrate_repo.schema import DateTime from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import Float from trove.db.sqlalchemy.migrate_repo.schema import String from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy.migrate_repo.schema import Boolean meta = MetaData() diff --git a/trove/db/sqlalchemy/migrate_repo/versions/013_add_security_group_artifacts.py b/trove/db/sqlalchemy/migrate_repo/versions/013_add_security_group_artifacts.py index 41214032b6..65679e2331 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/013_add_security_group_artifacts.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/013_add_security_group_artifacts.py @@ -17,12 +17,12 @@ from sqlalchemy import ForeignKey from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import Boolean +from trove.db.sqlalchemy.migrate_repo.schema import create_tables +from trove.db.sqlalchemy.migrate_repo.schema import DateTime +from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import Integer from trove.db.sqlalchemy.migrate_repo.schema import String -from trove.db.sqlalchemy.migrate_repo.schema import DateTime from trove.db.sqlalchemy.migrate_repo.schema import Table diff --git a/trove/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py b/trove/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py index c662d78d8a..66b118f363 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/014_update_instance_flavor_id.py @@ -31,7 +31,7 @@ def upgrade(migrate_engine): 'TYPE INTEGER USING flavor_id::integer') else: instances = Table('instances', meta, autoload=True) - #modify column + # modify column instances.c.flavor_id.alter(type=Integer()) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/016_add_datastore_type.py b/trove/db/sqlalchemy/migrate_repo/versions/016_add_datastore_type.py index 4f90e8f02d..cec628a75a 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/016_add_datastore_type.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/016_add_datastore_type.py @@ -61,7 +61,7 @@ def upgrade(migrate_engine): instances.drop_column('service_type') # Table 'service_images' is deprecated since this version. # Leave it for few releases. - #drop_tables([service_images]) + # drop_tables([service_images]) def downgrade(migrate_engine): diff --git a/trove/db/sqlalchemy/migrate_repo/versions/018_datastore_versions_fix.py b/trove/db/sqlalchemy/migrate_repo/versions/018_datastore_versions_fix.py index 3aebcf983b..dbb5ebaaf8 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/018_datastore_versions_fix.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/018_datastore_versions_fix.py @@ -21,7 +21,7 @@ def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine datastore_versions = Table('datastore_versions', meta, autoload=True) - #modify column + # modify column datastore_versions.c.name.alter(unique=False) diff --git a/trove/db/sqlalchemy/migrate_repo/versions/019_datastore_fix.py b/trove/db/sqlalchemy/migrate_repo/versions/019_datastore_fix.py index dcf03d4595..1b51ee911a 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/019_datastore_fix.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/019_datastore_fix.py @@ -13,10 +13,11 @@ # under the License. from sqlalchemy.schema import MetaData -from sqlalchemy.sql.expression import select -from sqlalchemy.sql.expression import insert -from sqlalchemy.sql.expression import update from sqlalchemy.sql.expression import delete +from sqlalchemy.sql.expression import insert +from sqlalchemy.sql.expression import select +from sqlalchemy.sql.expression import update + from trove.common import cfg from trove.db.sqlalchemy.migrate_repo.schema import Table diff --git a/trove/db/sqlalchemy/migrate_repo/versions/020_configurations.py b/trove/db/sqlalchemy/migrate_repo/versions/020_configurations.py index 279180d9bf..4a433c48ff 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/020_configurations.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/020_configurations.py @@ -17,10 +17,10 @@ from sqlalchemy import ForeignKey from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import drop_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime from trove.db.sqlalchemy.migrate_repo.schema import Boolean +from trove.db.sqlalchemy.migrate_repo.schema import create_tables +from trove.db.sqlalchemy.migrate_repo.schema import DateTime +from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import String from trove.db.sqlalchemy.migrate_repo.schema import Table from trove.db.sqlalchemy import utils as db_utils diff --git a/trove/db/sqlalchemy/migrate_repo/versions/021_conductor_last_seen.py b/trove/db/sqlalchemy/migrate_repo/versions/021_conductor_last_seen.py index d93b847f1f..bfd52fdcd8 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/021_conductor_last_seen.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/021_conductor_last_seen.py @@ -15,11 +15,11 @@ from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData +from trove.db.sqlalchemy.migrate_repo.schema import create_tables +from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import Float from trove.db.sqlalchemy.migrate_repo.schema import String from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import drop_tables meta = MetaData() diff --git a/trove/db/sqlalchemy/migrate_repo/versions/023_add_instance_indexes.py b/trove/db/sqlalchemy/migrate_repo/versions/023_add_instance_indexes.py index 29ffcaf6a6..b35471315e 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/023_add_instance_indexes.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/023_add_instance_indexes.py @@ -13,11 +13,11 @@ # under the License. from sqlalchemy.exc import OperationalError -from sqlalchemy.schema import MetaData from sqlalchemy.schema import Index -from trove.openstack.common import log as logging +from sqlalchemy.schema import MetaData from trove.db.sqlalchemy.migrate_repo.schema import Table +from trove.openstack.common import log as logging logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') diff --git a/trove/db/sqlalchemy/migrate_repo/versions/024_add_backup_indexes.py b/trove/db/sqlalchemy/migrate_repo/versions/024_add_backup_indexes.py index 61216dba4f..75df838337 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/024_add_backup_indexes.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/024_add_backup_indexes.py @@ -13,11 +13,11 @@ # under the License. from sqlalchemy.exc import OperationalError -from sqlalchemy.schema import MetaData from sqlalchemy.schema import Index -from trove.openstack.common import log as logging +from sqlalchemy.schema import MetaData from trove.db.sqlalchemy.migrate_repo.schema import Table +from trove.openstack.common import log as logging logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') diff --git a/trove/db/sqlalchemy/migrate_repo/versions/025_add_service_statuses_indexes.py b/trove/db/sqlalchemy/migrate_repo/versions/025_add_service_statuses_indexes.py index 4cd216c1ba..dcc226b2b2 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/025_add_service_statuses_indexes.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/025_add_service_statuses_indexes.py @@ -13,11 +13,11 @@ # under the License. from sqlalchemy.exc import OperationalError -from sqlalchemy.schema import MetaData from sqlalchemy.schema import Index -from trove.openstack.common import log as logging +from sqlalchemy.schema import MetaData from trove.db.sqlalchemy.migrate_repo.schema import Table +from trove.openstack.common import log as logging logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema') diff --git a/trove/db/sqlalchemy/migrate_repo/versions/027_add_datastore_capabilities.py b/trove/db/sqlalchemy/migrate_repo/versions/027_add_datastore_capabilities.py index 9f9642538d..233ad3c874 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/027_add_datastore_capabilities.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/027_add_datastore_capabilities.py @@ -17,11 +17,11 @@ from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData from sqlalchemy.schema import UniqueConstraint +from trove.db.sqlalchemy.migrate_repo.schema import Boolean from trove.db.sqlalchemy.migrate_repo.schema import create_tables from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import String from trove.db.sqlalchemy.migrate_repo.schema import Table -from trove.db.sqlalchemy.migrate_repo.schema import Boolean meta = MetaData() diff --git a/trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py b/trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py index 2a7491eda6..d031d167d5 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py @@ -13,8 +13,8 @@ # under the License. from sqlalchemy.schema import Column -from sqlalchemy.schema import MetaData from sqlalchemy.schema import ForeignKey +from sqlalchemy.schema import MetaData from trove.db.sqlalchemy.migrate_repo.schema import String from trove.db.sqlalchemy.migrate_repo.schema import Table diff --git a/trove/db/sqlalchemy/migrate_repo/versions/031_add_timestamps_to_configurations.py b/trove/db/sqlalchemy/migrate_repo/versions/031_add_timestamps_to_configurations.py index 8ca717a48b..4afd19f0a1 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/031_add_timestamps_to_configurations.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/031_add_timestamps_to_configurations.py @@ -15,8 +15,8 @@ from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData -from trove.db.sqlalchemy.migrate_repo.schema import Table from trove.db.sqlalchemy.migrate_repo.schema import DateTime +from trove.db.sqlalchemy.migrate_repo.schema import Table def upgrade(migrate_engine): diff --git a/trove/db/sqlalchemy/migrate_repo/versions/032_clusters.py b/trove/db/sqlalchemy/migrate_repo/versions/032_clusters.py index 21c96e395d..590077d490 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/032_clusters.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/032_clusters.py @@ -20,8 +20,8 @@ from sqlalchemy.schema import MetaData from trove.db.sqlalchemy.migrate_repo.schema import Boolean from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import DateTime +from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import Integer from trove.db.sqlalchemy.migrate_repo.schema import String from trove.db.sqlalchemy.migrate_repo.schema import Table diff --git a/trove/db/sqlalchemy/migrate_repo/versions/033_datastore_parameters.py b/trove/db/sqlalchemy/migrate_repo/versions/033_datastore_parameters.py index 078558d8a7..c88d807c34 100644 --- a/trove/db/sqlalchemy/migrate_repo/versions/033_datastore_parameters.py +++ b/trove/db/sqlalchemy/migrate_repo/versions/033_datastore_parameters.py @@ -18,10 +18,10 @@ from sqlalchemy.schema import Column from sqlalchemy.schema import MetaData from sqlalchemy.schema import UniqueConstraint -from trove.db.sqlalchemy.migrate_repo.schema import create_tables -from trove.db.sqlalchemy.migrate_repo.schema import drop_tables -from trove.db.sqlalchemy.migrate_repo.schema import DateTime from trove.db.sqlalchemy.migrate_repo.schema import Boolean +from trove.db.sqlalchemy.migrate_repo.schema import create_tables +from trove.db.sqlalchemy.migrate_repo.schema import DateTime +from trove.db.sqlalchemy.migrate_repo.schema import drop_tables from trove.db.sqlalchemy.migrate_repo.schema import String from trove.db.sqlalchemy.migrate_repo.schema import Table diff --git a/trove/db/sqlalchemy/migration.py b/trove/db/sqlalchemy/migration.py index ca311dd655..c1798da933 100644 --- a/trove/db/sqlalchemy/migration.py +++ b/trove/db/sqlalchemy/migration.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.openstack.common import log as logging import os from migrate.versioning import api as versioning_api @@ -25,6 +24,7 @@ except ImportError: from migrate import exceptions as versioning_exceptions from trove.common import exception +from trove.openstack.common import log as logging logger = logging.getLogger('trove.db.sqlalchemy.migration') diff --git a/trove/db/sqlalchemy/session.py b/trove/db/sqlalchemy/session.py index 6d8fcc5319..3bb4db0ec8 100644 --- a/trove/db/sqlalchemy/session.py +++ b/trove/db/sqlalchemy/session.py @@ -14,6 +14,7 @@ # under the License. import contextlib + import osprofiler.sqlalchemy import sqlalchemy from sqlalchemy import create_engine @@ -21,9 +22,9 @@ from sqlalchemy import MetaData from sqlalchemy.orm import sessionmaker from trove.common import cfg -from trove.openstack.common import log as logging from trove.common.i18n import _ from trove.db.sqlalchemy import mappers +from trove.openstack.common import log as logging _ENGINE = None _MAKER = None @@ -41,17 +42,17 @@ def configure_db(options, models_mapper=None): if models_mapper: models_mapper.map(_ENGINE) else: - from trove.instance import models as base_models + from trove.backup import models as backup_models + from trove.cluster import models as cluster_models + from trove.conductor import models as conductor_models + from trove.configuration import models as configurations_models from trove.datastore import models as datastores_models from trove.dns import models as dns_models from trove.extensions.mysql import models as mysql_models - from trove.guestagent import models as agent_models - from trove.quota import models as quota_models - from trove.backup import models as backup_models from trove.extensions.security_group import models as secgrp_models - from trove.configuration import models as configurations_models - from trove.conductor import models as conductor_models - from trove.cluster import models as cluster_models + from trove.guestagent import models as agent_models + from trove.instance import models as base_models + from trove.quota import models as quota_models model_modules = [ base_models, diff --git a/trove/dns/designate/driver.py b/trove/dns/designate/driver.py index d4ebd7a4f1..e35cb7377d 100644 --- a/trove/dns/designate/driver.py +++ b/trove/dns/designate/driver.py @@ -17,14 +17,16 @@ Dns Driver that uses Designate DNSaaS. """ +import base64 +import hashlib + +from designateclient.v1 import Client +from designateclient.v1.records import Record + from trove.common import cfg from trove.common import exception from trove.dns import driver from trove.openstack.common import log as logging -from designateclient.v1 import Client -from designateclient.v1.records import Record -import base64 -import hashlib CONF = cfg.CONF @@ -142,7 +144,7 @@ class DesignateInstanceEntryFactory(driver.DnsInstanceEntryFactory): # Constructing the hostname by hashing the instance ID. name = base64.b32encode(hashlib.md5(instance_id).digest())[:11].lower() hostname = ("%s.%s" % (name, zone.name)) - #Removing the leading dot if present + # Removing the leading dot if present if hostname.endswith('.'): hostname = hostname[:-1] diff --git a/trove/dns/driver.py b/trove/dns/driver.py index 359545bf19..86f0aca194 100644 --- a/trove/dns/driver.py +++ b/trove/dns/driver.py @@ -45,13 +45,13 @@ class DnsDriver(object): pass def modify_content(self, name, content, dns_zone): - #TODO(tim.simpson) I've found no use for this in RS impl of DNS w/ - # instances. Check to see its really needed. + # TODO(tim.simpson) I've found no use for this in RS impl of DNS w/ + # instances. Check to see its really needed. pass def rename_entry(self, content, name, dns_zone): - #TODO(tim.simpson) I've found no use for this in RS impl of DNS w/ - # instances. Check to see its really needed. + # TODO(tim.simpson) I've found no use for this in RS impl of DNS w/ + # instances. Check to see its really needed. pass diff --git a/trove/dns/manager.py b/trove/dns/manager.py index bf632e40ba..c7dab51d46 100644 --- a/trove/dns/manager.py +++ b/trove/dns/manager.py @@ -16,10 +16,10 @@ """ Dns manager. """ -from trove.openstack.common import log as logging -from trove.common import utils from trove.common import cfg +from trove.common import utils +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/dns/models.py b/trove/dns/models.py index d596ce1134..eb64b5cabc 100644 --- a/trove/dns/models.py +++ b/trove/dns/models.py @@ -18,11 +18,11 @@ Model classes that map instance Ip to dns record. """ -from trove.db import get_db_api from trove.common import exception -from trove.common.models import ModelBase -from trove.openstack.common import log as logging from trove.common.i18n import _ +from trove.common.models import ModelBase +from trove.db import get_db_api +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/extensions/account/models.py b/trove/extensions/account/models.py index e70fd95827..25858812e1 100644 --- a/trove/extensions/account/models.py +++ b/trove/extensions/account/models.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.openstack.common import log as logging from trove.instance.models import DBInstance +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/extensions/account/service.py b/trove/extensions/account/service.py index ad5096bff9..92d3dcfc40 100644 --- a/trove/extensions/account/service.py +++ b/trove/extensions/account/service.py @@ -13,14 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.openstack.common import log as logging - -from trove.common import wsgi +import trove.common.apischema as apischema from trove.common.auth import admin_context +from trove.common.i18n import _ +from trove.common import wsgi from trove.extensions.account import models from trove.extensions.account import views -from trove.common.i18n import _ -import trove.common.apischema as apischema +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/clusters/service.py b/trove/extensions/mgmt/clusters/service.py index ab22e6406b..b9d9e3f9c6 100644 --- a/trove/extensions/mgmt/clusters/service.py +++ b/trove/extensions/mgmt/clusters/service.py @@ -15,14 +15,14 @@ from trove.cluster.service import ClusterController -from trove.common import exception -from trove.common import wsgi +import trove.common.apischema as apischema from trove.common.auth import admin_context +from trove.common import exception +from trove.common.i18n import _ +from trove.common import wsgi from trove.extensions.mgmt.clusters import models from trove.extensions.mgmt.clusters import views from trove.openstack.common import log as logging -from trove.common.i18n import _ -import trove.common.apischema as apischema LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/configuration/service.py b/trove/extensions/mgmt/configuration/service.py index 4ffceed9bf..88a8b598ee 100644 --- a/trove/extensions/mgmt/configuration/service.py +++ b/trove/extensions/mgmt/configuration/service.py @@ -14,15 +14,15 @@ # under the License. -from trove.common import exception -from trove.common import wsgi +import trove.common.apischema as apischema from trove.common.auth import admin_context +from trove.common import exception +from trove.common.i18n import _ +from trove.common import wsgi from trove.configuration import models as config_models from trove.datastore import models as ds_models from trove.extensions.mgmt.configuration import views from trove.openstack.common import log as logging -from trove.common.i18n import _ -import trove.common.apischema as apischema LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/host/instance/service.py b/trove/extensions/mgmt/host/instance/service.py index 68617eb0a5..9945d58bc4 100644 --- a/trove/extensions/mgmt/host/instance/service.py +++ b/trove/extensions/mgmt/host/instance/service.py @@ -15,10 +15,10 @@ from trove.common import exception +from trove.common.i18n import _ from trove.common import wsgi from trove.extensions.mgmt.host import models from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/host/models.py b/trove/extensions/mgmt/host/models.py index feef310e03..86e6b0c5c0 100644 --- a/trove/extensions/mgmt/host/models.py +++ b/trove/extensions/mgmt/host/models.py @@ -17,16 +17,16 @@ Model classes that extend the instances functionality for MySQL instances. """ -from trove.openstack.common import log as logging -from trove.common.i18n import _ +from novaclient import exceptions as nova_exceptions from trove.common import exception +from trove.common.i18n import _ +from trove.common.remote import create_guest_client +from trove.common.remote import create_nova_client from trove.instance.models import DBInstance from trove.instance.models import InstanceServiceStatus from trove.instance.models import SimpleInstance -from trove.common.remote import create_guest_client -from trove.common.remote import create_nova_client -from novaclient import exceptions as nova_exceptions +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/host/service.py b/trove/extensions/mgmt/host/service.py index 348b691013..71fab7818c 100644 --- a/trove/extensions/mgmt/host/service.py +++ b/trove/extensions/mgmt/host/service.py @@ -14,13 +14,13 @@ # under the License. -from trove.common import wsgi from trove.common.auth import admin_context +from trove.common.i18n import _ +from trove.common import wsgi from trove.extensions.mgmt.host import models from trove.extensions.mgmt.host import views from trove.instance.service import InstanceController from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/instances/models.py b/trove/extensions/mgmt/instances/models.py index a9232193a8..e1fbc424ad 100644 --- a/trove/extensions/mgmt/instances/models.py +++ b/trove/extensions/mgmt/instances/models.py @@ -17,11 +17,11 @@ from trove.common import cfg from trove.common import exception from trove.common import remote from trove.common import utils -from trove.openstack.common import log as logging -from trove.instance import models as imodels -from trove.instance.models import load_instance, InstanceServiceStatus -from trove.instance import models as instance_models from trove.extensions.mysql import models as mysql_models +from trove.instance import models as imodels +from trove.instance import models as instance_models +from trove.instance.models import load_instance, InstanceServiceStatus +from trove.openstack.common import log as logging from trove import rpc LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/instances/service.py b/trove/extensions/mgmt/instances/service.py index d8c2c87988..22e25bdc69 100644 --- a/trove/extensions/mgmt/instances/service.py +++ b/trove/extensions/mgmt/instances/service.py @@ -17,19 +17,19 @@ from novaclient import exceptions as nova_exceptions from trove.backup.models import Backup -from trove.common import exception -from trove.common import wsgi +import trove.common.apischema as apischema from trove.common.auth import admin_context -from trove.instance import models as instance_models +from trove.common import exception +from trove.common.i18n import _ +from trove.common import wsgi from trove.extensions.mgmt.instances import models from trove.extensions.mgmt.instances import views from trove.extensions.mgmt.instances.views import DiagnosticsView from trove.extensions.mgmt.instances.views import HwInfoView from trove.extensions.mysql import models as mysql_models +from trove.instance import models as instance_models from trove.instance.service import InstanceController from trove.openstack.common import log as logging -from trove.common.i18n import _ -import trove.common.apischema as apischema LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/quota/service.py b/trove/extensions/mgmt/quota/service.py index ef2c4ee92f..d1417237cc 100644 --- a/trove/extensions/mgmt/quota/service.py +++ b/trove/extensions/mgmt/quota/service.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.common import wsgi -from trove.common import exception from trove.common.auth import admin_context +from trove.common import exception +from trove.common import wsgi from trove.extensions.mgmt.quota import views from trove.openstack.common import log as logging -from trove.quota.quota import QUOTAS as quota_engine from trove.quota.models import Quota +from trove.quota.quota import QUOTAS as quota_engine LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/upgrade/service.py b/trove/extensions/mgmt/upgrade/service.py index 6ce6020bb9..7c6687d441 100644 --- a/trove/extensions/mgmt/upgrade/service.py +++ b/trove/extensions/mgmt/upgrade/service.py @@ -13,12 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.common import wsgi +import trove.common.apischema as apischema from trove.common.auth import admin_context +from trove.common.i18n import _ +from trove.common import wsgi from trove.extensions.mgmt.upgrade.models import UpgradeMessageSender from trove.openstack.common import log as logging -from trove.common.i18n import _ -import trove.common.apischema as apischema LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mgmt/volume/service.py b/trove/extensions/mgmt/volume/service.py index 3359871f3d..a5c55a4e90 100644 --- a/trove/extensions/mgmt/volume/service.py +++ b/trove/extensions/mgmt/volume/service.py @@ -14,12 +14,12 @@ # under the License. -from trove.common import wsgi from trove.common.auth import admin_context +from trove.common.i18n import _ +from trove.common import wsgi from trove.extensions.mgmt.volume import models from trove.extensions.mgmt.volume import views from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) diff --git a/trove/extensions/mysql/models.py b/trove/extensions/mysql/models.py index b0c7dee609..abaf7011b6 100644 --- a/trove/extensions/mysql/models.py +++ b/trove/extensions/mysql/models.py @@ -19,8 +19,8 @@ Model classes that extend the instances functionality for MySQL instances. from trove.common import cfg from trove.common import exception -from trove.common import utils from trove.common.remote import create_guest_client +from trove.common import utils from trove.db import get_db_api from trove.guestagent.db import models as guest_models from trove.instance import models as base_models diff --git a/trove/extensions/mysql/service.py b/trove/extensions/mysql/service.py index ba875677dc..67651819ec 100644 --- a/trove/extensions/mysql/service.py +++ b/trove/extensions/mysql/service.py @@ -13,23 +13,22 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_utils import strutils import webob.exc -from oslo_utils import strutils - +import trove.common.apischema as apischema from trove.common import exception +from trove.common.i18n import _ from trove.common import pagination -from trove.common import wsgi from trove.common.utils import correct_id_with_req -from trove.extensions.mysql.common import populate_validated_databases +from trove.common import wsgi from trove.extensions.mysql.common import populate_users +from trove.extensions.mysql.common import populate_validated_databases from trove.extensions.mysql.common import unquote_user_host from trove.extensions.mysql import models from trove.extensions.mysql import views from trove.guestagent.db import models as guest_models from trove.openstack.common import log as logging -from trove.common.i18n import _ -import trove.common.apischema as apischema LOG = logging.getLogger(__name__) diff --git a/trove/extensions/routes/mgmt.py b/trove/extensions/routes/mgmt.py index cd7132479e..90ee509bc4 100644 --- a/trove/extensions/routes/mgmt.py +++ b/trove/extensions/routes/mgmt.py @@ -13,17 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.openstack.common import log as logging - from trove.common import extensions from trove.extensions.mgmt.clusters.service import MgmtClusterController from trove.extensions.mgmt.configuration import service as conf_service -from trove.extensions.mgmt.instances.service import MgmtInstanceController -from trove.extensions.mgmt.host.service import HostController -from trove.extensions.mgmt.quota.service import QuotaController from trove.extensions.mgmt.host.instance import service as hostservice -from trove.extensions.mgmt.volume.service import StorageController +from trove.extensions.mgmt.host.service import HostController +from trove.extensions.mgmt.instances.service import MgmtInstanceController +from trove.extensions.mgmt.quota.service import QuotaController from trove.extensions.mgmt.upgrade.service import UpgradeController +from trove.extensions.mgmt.volume.service import StorageController +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/extensions/routes/security_group.py b/trove/extensions/routes/security_group.py index 522fd799f0..f93b303db7 100644 --- a/trove/extensions/routes/security_group.py +++ b/trove/extensions/routes/security_group.py @@ -14,11 +14,11 @@ # under the License. # -from trove.openstack.common import log as logging -from trove.common import extensions from trove.common import cfg +from trove.common import extensions from trove.extensions.security_group import service +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/extensions/security_group/models.py b/trove/extensions/security_group/models.py index 2cdd3ace73..74d87285fe 100644 --- a/trove/extensions/security_group/models.py +++ b/trove/extensions/security_group/models.py @@ -19,10 +19,10 @@ Model classes for Security Groups and Security Group Rules on instances. """ from trove.common import cfg from trove.common import exception -from trove.db.models import DatabaseModelBase -from trove.common.models import NetworkRemoteModelBase -from trove.openstack.common import log as logging from trove.common.i18n import _ +from trove.common.models import NetworkRemoteModelBase +from trove.db.models import DatabaseModelBase +from trove.openstack.common import log as logging CONF = cfg.CONF diff --git a/trove/extensions/security_group/service.py b/trove/extensions/security_group/service.py index 60803699b1..d3ad264944 100644 --- a/trove/extensions/security_group/service.py +++ b/trove/extensions/security_group/service.py @@ -15,14 +15,14 @@ # from trove.common import cfg from trove.common import exception -from trove.common import wsgi +from trove.common.i18n import _ from trove.common import utils +from trove.common import wsgi from trove.datastore.models import DatastoreVersion from trove.extensions.security_group import models from trove.extensions.security_group import views from trove.instance import models as instance_models from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/extensions/security_group/views.py b/trove/extensions/security_group/views.py index 8591f4955e..12e208bba1 100644 --- a/trove/extensions/security_group/views.py +++ b/trove/extensions/security_group/views.py @@ -14,9 +14,10 @@ # under the License. # -from trove.openstack.common import log as logging import os +from trove.openstack.common import log as logging + LOG = logging.getLogger(__name__) diff --git a/trove/flavor/views.py b/trove/flavor/views.py index 943ca84f6f..b5be2494e0 100644 --- a/trove/flavor/views.py +++ b/trove/flavor/views.py @@ -14,8 +14,8 @@ # under the License. -from trove.common.views import create_links from trove.common import cfg +from trove.common.views import create_links CONF = cfg.CONF diff --git a/trove/guestagent/api.py b/trove/guestagent/api.py index d87523fe1d..77f67de87c 100644 --- a/trove/guestagent/api.py +++ b/trove/guestagent/api.py @@ -18,8 +18,8 @@ Handles all request to the Platform or Guest VM """ from eventlet import Timeout -from oslo_messaging.rpc.client import RemoteError import oslo_messaging as messaging +from oslo_messaging.rpc.client import RemoteError from trove.common import cfg from trove.common import exception diff --git a/trove/guestagent/backup/backupagent.py b/trove/guestagent/backup/backupagent.py index 3c005bf6f7..2bba1c70c1 100644 --- a/trove/guestagent/backup/backupagent.py +++ b/trove/guestagent/backup/backupagent.py @@ -15,18 +15,19 @@ # import logging + from trove.backup.state import BackupState from trove.common import cfg from trove.common import context as trove_context +from trove.common.i18n import _ from trove.conductor import api as conductor_api from trove.guestagent.common import timeutils from trove.guestagent.dbaas import get_filesystem_volume_stats from trove.guestagent.strategies.backup.base import BackupError from trove.guestagent.strategies.backup.base import UnknownBackupType -from trove.guestagent.strategies.storage import get_storage_strategy from trove.guestagent.strategies.backup import get_backup_strategy from trove.guestagent.strategies.restore import get_restore_strategy -from trove.common.i18n import _ # noqa +from trove.guestagent.strategies.storage import get_storage_strategy LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/common/operating_system.py b/trove/guestagent/common/operating_system.py index bb867ede77..4901115bfb 100644 --- a/trove/guestagent/common/operating_system.py +++ b/trove/guestagent/common/operating_system.py @@ -14,14 +14,15 @@ # under the License. import inspect +import operator import os import stat -import operator from oslo_concurrency.processutils import UnknownArgumentError + from trove.common import exception -from trove.common import utils from trove.common.i18n import _ +from trove.common import utils REDHAT = 'redhat' DEBIAN = 'debian' diff --git a/trove/guestagent/common/sql_query.py b/trove/guestagent/common/sql_query.py index 66e1833a43..25fdd4d190 100644 --- a/trove/guestagent/common/sql_query.py +++ b/trove/guestagent/common/sql_query.py @@ -442,7 +442,7 @@ class SetServerVariable(object): else: return "SET GLOBAL %s=%s" % (self.key, self.value) -### Miscellaneous queries that need no parameters. +# Miscellaneous queries that need no parameters. FLUSH = "FLUSH PRIVILEGES;" ROOT_ENABLED = ("SELECT User FROM mysql.user " diff --git a/trove/guestagent/common/timeutils.py b/trove/guestagent/common/timeutils.py index 5d4f8bdce8..4ffd73d0f2 100644 --- a/trove/guestagent/common/timeutils.py +++ b/trove/guestagent/common/timeutils.py @@ -1,6 +1,7 @@ -from oslo_utils import timeutils from datetime import datetime +from oslo_utils import timeutils + def float_utcnow(): return float(datetime.strftime(timeutils.utcnow(), "%s.%f")) diff --git a/trove/guestagent/datastore/experimental/cassandra/manager.py b/trove/guestagent/datastore/experimental/cassandra/manager.py index 29a7e01a81..c918605768 100644 --- a/trove/guestagent/datastore/experimental/cassandra/manager.py +++ b/trove/guestagent/datastore/experimental/cassandra/manager.py @@ -15,14 +15,15 @@ # import os + from trove.common import cfg from trove.common import exception -from trove.guestagent import volume -from trove.guestagent.datastore.experimental.cassandra import service -from trove.openstack.common import periodic_task -from trove.openstack.common import log as logging from trove.common.i18n import _ +from trove.guestagent.datastore.experimental.cassandra import service from trove.guestagent import dbaas +from trove.guestagent import volume +from trove.openstack.common import log as logging +from trove.openstack.common import periodic_task CONF = cfg.CONF LOG = logging.getLogger(__name__) @@ -91,9 +92,9 @@ class Manager(periodic_task.PeriodicTasks): device.unmount_device(device_path) device.format() if os.path.exists(mount_point): - #rsync exiting data + # rsync exiting data device.migrate_data(mount_point) - #mount the volume + # mount the volume device.mount(mount_point) LOG.debug("Mounting new volume.") diff --git a/trove/guestagent/datastore/experimental/cassandra/service.py b/trove/guestagent/datastore/experimental/cassandra/service.py index f434cb3199..d9db8506fc 100644 --- a/trove/guestagent/datastore/experimental/cassandra/service.py +++ b/trove/guestagent/datastore/experimental/cassandra/service.py @@ -15,19 +15,21 @@ import os import tempfile -import yaml + from oslo_utils import netutils +import yaml + from trove.common import cfg -from trove.common import utils from trove.common import exception +from trove.common.i18n import _ from trove.common import instance as rd_instance +from trove.common import utils from trove.guestagent.common import operating_system from trove.guestagent.common.operating_system import FileMode from trove.guestagent.datastore.experimental.cassandra import system from trove.guestagent.datastore import service from trove.guestagent import pkg from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) @@ -138,7 +140,7 @@ class CassandraApp(object): os.write(conf_fd, config_contents) operating_system.move(conf_path, system.CASSANDRA_CONF, as_root=True) - #TODO(denis_makogon): figure out the dynamic way to discover + # TODO(denis_makogon): figure out the dynamic way to discover # configs owner since it can cause errors if there is # no cassandra user in operating system operating_system.chown(system.CASSANDRA_CONF, diff --git a/trove/guestagent/datastore/experimental/couchbase/manager.py b/trove/guestagent/datastore/experimental/couchbase/manager.py index 9ac8705b5d..5c19565805 100644 --- a/trove/guestagent/datastore/experimental/couchbase/manager.py +++ b/trove/guestagent/datastore/experimental/couchbase/manager.py @@ -17,15 +17,15 @@ import os from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import instance as rd_instance from trove.guestagent import backup -from trove.guestagent import dbaas -from trove.guestagent import volume from trove.guestagent.datastore.experimental.couchbase import service from trove.guestagent.datastore.experimental.couchbase import system +from trove.guestagent import dbaas +from trove.guestagent import volume from trove.openstack.common import log as logging from trove.openstack.common import periodic_task -from trove.common.i18n import _ LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/datastore/experimental/couchbase/service.py b/trove/guestagent/datastore/experimental/couchbase/service.py index b6b0e19b02..fb202f3b4d 100644 --- a/trove/guestagent/datastore/experimental/couchbase/service.py +++ b/trove/guestagent/datastore/experimental/couchbase/service.py @@ -14,24 +14,25 @@ # under the License. import json -import pexpect import os import stat import subprocess import tempfile from oslo_utils import netutils +import pexpect + from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import instance as rd_instance from trove.common import utils as utils -from trove.guestagent import pkg from trove.guestagent.common import operating_system -from trove.guestagent.datastore import service from trove.guestagent.datastore.experimental.couchbase import system +from trove.guestagent.datastore import service from trove.guestagent.db import models +from trove.guestagent import pkg from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/datastore/experimental/couchdb/manager.py b/trove/guestagent/datastore/experimental/couchdb/manager.py index 33e20ef1ed..d1d7fe690c 100644 --- a/trove/guestagent/datastore/experimental/couchdb/manager.py +++ b/trove/guestagent/datastore/experimental/couchdb/manager.py @@ -17,12 +17,12 @@ import os from trove.common import cfg from trove.common import exception -from trove.openstack.common import log as logging -from trove.openstack.common import periodic_task +from trove.common.i18n import _ +from trove.guestagent.datastore.experimental.couchdb import service from trove.guestagent import dbaas from trove.guestagent import volume -from trove.guestagent.datastore.experimental.couchdb import service -from trove.common.i18n import _ +from trove.openstack.common import log as logging +from trove.openstack.common import periodic_task LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/datastore/experimental/couchdb/service.py b/trove/guestagent/datastore/experimental/couchdb/service.py index 3301693b54..39c7949f54 100644 --- a/trove/guestagent/datastore/experimental/couchdb/service.py +++ b/trove/guestagent/datastore/experimental/couchdb/service.py @@ -17,15 +17,15 @@ import json from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import instance as rd_instance from trove.common import utils as utils -from trove.guestagent import pkg from trove.guestagent.common import operating_system from trove.guestagent.common.operating_system import FileMode -from trove.guestagent.datastore import service from trove.guestagent.datastore.experimental.couchdb import system +from trove.guestagent.datastore import service +from trove.guestagent import pkg from trove.openstack.common import log as logging -from trove.common.i18n import _ CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/datastore/experimental/db2/manager.py b/trove/guestagent/datastore/experimental/db2/manager.py index fdb7fe8074..e85eca60a5 100644 --- a/trove/guestagent/datastore/experimental/db2/manager.py +++ b/trove/guestagent/datastore/experimental/db2/manager.py @@ -15,12 +15,12 @@ from trove.common import cfg from trove.common import exception -from trove.openstack.common import log as logging -from trove.openstack.common import periodic_task +from trove.guestagent.datastore.experimental.db2 import service from trove.guestagent import dbaas from trove.guestagent import volume -from trove.guestagent.datastore.experimental.db2 import service from trove.openstack.common.gettextutils import _ +from trove.openstack.common import log as logging +from trove.openstack.common import periodic_task LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/datastore/experimental/db2/service.py b/trove/guestagent/datastore/experimental/db2/service.py index f65362a4c9..eefed32100 100644 --- a/trove/guestagent/datastore/experimental/db2/service.py +++ b/trove/guestagent/datastore/experimental/db2/service.py @@ -18,11 +18,11 @@ from trove.common import exception from trove.common import instance as rd_instance from trove.common import utils as utils from trove.guestagent.common import operating_system -from trove.guestagent.datastore import service from trove.guestagent.datastore.experimental.db2 import system +from trove.guestagent.datastore import service from trove.guestagent.db import models -from trove.openstack.common import log as logging from trove.openstack.common.gettextutils import _ +from trove.openstack.common import log as logging CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/datastore/experimental/mongodb/manager.py b/trove/guestagent/datastore/experimental/mongodb/manager.py index 3b85522371..7b515d15e0 100644 --- a/trove/guestagent/datastore/experimental/mongodb/manager.py +++ b/trove/guestagent/datastore/experimental/mongodb/manager.py @@ -16,17 +16,18 @@ import os from oslo_utils import netutils + from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import instance as ds_instance -from trove.guestagent import dbaas -from trove.guestagent import volume from trove.guestagent.common import operating_system from trove.guestagent.datastore.experimental.mongodb import ( service as mongo_service) from trove.guestagent.datastore.experimental.mongodb import system +from trove.guestagent import dbaas +from trove.guestagent import volume from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.openstack.common import periodic_task diff --git a/trove/guestagent/datastore/experimental/mongodb/service.py b/trove/guestagent/datastore/experimental/mongodb/service.py index 310128199b..0a81d82d6e 100644 --- a/trove/guestagent/datastore/experimental/mongodb/service.py +++ b/trove/guestagent/datastore/experimental/mongodb/service.py @@ -14,20 +14,21 @@ # under the License. import json +import os import re -import os from oslo_utils import netutils + from trove.common import cfg -from trove.common import utils as utils from trove.common import exception -from trove.common import instance as ds_instance from trove.common.exception import ProcessExecutionError -from trove.guestagent.datastore import service -from trove.guestagent.datastore.experimental.mongodb import system -from trove.openstack.common import log as logging -from trove.guestagent.common import operating_system from trove.common.i18n import _ +from trove.common import instance as ds_instance +from trove.common import utils as utils +from trove.guestagent.common import operating_system +from trove.guestagent.datastore.experimental.mongodb import system +from trove.guestagent.datastore import service +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) CONF = cfg.CONF @@ -323,7 +324,7 @@ class MongoDBApp(object): # add replica-set members for member in members: self.do_mongo('rs.add("' + member + '")') - # TODO(ramashri) see if hardcoded values can be removed + # TODO(ramashri) see if hardcoded values can be removed utils.poll_until(check_rs_status, sleep_time=60, time_out=100) @@ -359,7 +360,7 @@ class MongoDbAppStatus(service.BaseDbStatus): if self._is_config_server() is True: status_check = (system.CMD_STATUS % (netutils.get_my_ipv4() + - ' --port 27019')) + ' --port 27019')) else: status_check = (system.CMD_STATUS % netutils.get_my_ipv4()) diff --git a/trove/guestagent/datastore/experimental/postgresql/manager.py b/trove/guestagent/datastore/experimental/postgresql/manager.py index cab8d998dc..0a930e19b3 100644 --- a/trove/guestagent/datastore/experimental/postgresql/manager.py +++ b/trove/guestagent/datastore/experimental/postgresql/manager.py @@ -15,16 +15,17 @@ import os -from trove.common import cfg -from trove.guestagent import dbaas -from trove.guestagent import backup -from trove.guestagent import volume + from .service.config import PgSqlConfig from .service.database import PgSqlDatabase from .service.install import PgSqlInstall from .service.root import PgSqlRoot -from .service.users import PgSqlUsers from .service.status import PgSqlAppStatus +from .service.users import PgSqlUsers +from trove.common import cfg +from trove.guestagent import backup +from trove.guestagent import dbaas +from trove.guestagent import volume from trove.openstack.common import log as logging from trove.openstack.common import periodic_task diff --git a/trove/guestagent/datastore/experimental/postgresql/service/access.py b/trove/guestagent/datastore/experimental/postgresql/service/access.py index 734f29ed9b..787eff93d9 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/access.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/access.py @@ -14,9 +14,9 @@ # under the License. from trove.common import cfg +from trove.common.i18n import _ from trove.guestagent.datastore.experimental.postgresql import pgutil from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF @@ -38,8 +38,7 @@ class PgSqlAccess(object): "({database}).").format( guest_id=CONF.guest_id, user=username, - database=database, - ) + database=database,) ) pgutil.psql( pgutil.AccessQuery.grant( @@ -61,8 +60,7 @@ class PgSqlAccess(object): "({database}).").format( guest_id=CONF.guest_id, user=username, - database=database, - ) + database=database,) ) pgutil.psql( pgutil.AccessQuery.revoke( diff --git a/trove/guestagent/datastore/experimental/postgresql/service/config.py b/trove/guestagent/datastore/experimental/postgresql/service/config.py index db37b59869..42221695dd 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/config.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/config.py @@ -14,7 +14,9 @@ # under the License. import re + from trove.common import cfg +from trove.common.i18n import _ from trove.common import utils from trove.guestagent.common import operating_system from trove.guestagent.datastore.experimental.postgresql import pgutil @@ -23,7 +25,6 @@ from trove.guestagent.datastore.experimental.postgresql.service.process import( from trove.guestagent.datastore.experimental.postgresql.service.status import( PgSqlAppStatus) from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/datastore/experimental/postgresql/service/database.py b/trove/guestagent/datastore/experimental/postgresql/service/database.py index d5cfb37f2d..9443b535fe 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/database.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/database.py @@ -14,10 +14,11 @@ # under the License. import itertools + from trove.common import cfg +from trove.common.i18n import _ from trove.guestagent.datastore.experimental.postgresql import pgutil from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/datastore/experimental/postgresql/service/install.py b/trove/guestagent/datastore/experimental/postgresql/service/install.py index 1053bf4fc0..d928961fc8 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/install.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/install.py @@ -14,14 +14,14 @@ # under the License. from trove.common import cfg +from trove.common.i18n import _ from trove.common import instance -from trove.guestagent import pkg from trove.guestagent.datastore.experimental.postgresql.service.process import( PgSqlProcess) from trove.guestagent.datastore.experimental.postgresql.service.status import( PgSqlAppStatus) +from trove.guestagent import pkg from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/datastore/experimental/postgresql/service/root.py b/trove/guestagent/datastore/experimental/postgresql/service/root.py index e99decce85..33e107479d 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/root.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/root.py @@ -14,6 +14,7 @@ # under the License. import uuid + from trove.common import cfg from trove.guestagent.datastore.experimental.postgresql import pgutil from trove.openstack.common import log as logging diff --git a/trove/guestagent/datastore/experimental/postgresql/service/status.py b/trove/guestagent/datastore/experimental/postgresql/service/status.py index 0e35997565..d8f860d1b5 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/status.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/status.py @@ -14,11 +14,12 @@ # under the License. import os -from trove.common import utils + from trove.common import exception from trove.common import instance -from trove.guestagent.datastore import service +from trove.common import utils from trove.guestagent.datastore.experimental.postgresql import pgutil +from trove.guestagent.datastore import service from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/datastore/experimental/postgresql/service/users.py b/trove/guestagent/datastore/experimental/postgresql/service/users.py index c280db3572..c3972d7a32 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/users.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/users.py @@ -14,12 +14,13 @@ # under the License. import itertools + from trove.common import cfg +from trove.common.i18n import _ from trove.guestagent.datastore.experimental.postgresql import pgutil from trove.guestagent.datastore.experimental.postgresql.service.access import ( PgSqlAccess) from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/datastore/experimental/redis/manager.py b/trove/guestagent/datastore/experimental/redis/manager.py index f24f9f21a6..7d68100d0a 100644 --- a/trove/guestagent/datastore/experimental/redis/manager.py +++ b/trove/guestagent/datastore/experimental/redis/manager.py @@ -15,16 +15,16 @@ from trove.common import cfg from trove.common import exception -from trove.guestagent import dbaas -from trove.guestagent import volume +from trove.common.i18n import _ from trove.common import instance as rd_instance from trove.guestagent.common import operating_system -from trove.guestagent.datastore.experimental.redis.service import ( - RedisAppStatus) from trove.guestagent.datastore.experimental.redis.service import ( RedisApp) +from trove.guestagent.datastore.experimental.redis.service import ( + RedisAppStatus) +from trove.guestagent import dbaas +from trove.guestagent import volume from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.openstack.common import periodic_task diff --git a/trove/guestagent/datastore/experimental/redis/service.py b/trove/guestagent/datastore/experimental/redis/service.py index 63e378526b..4881ae74c3 100644 --- a/trove/guestagent/datastore/experimental/redis/service.py +++ b/trove/guestagent/datastore/experimental/redis/service.py @@ -16,15 +16,15 @@ import os from trove.common import cfg -from trove.common import utils as utils from trove.common import exception -from trove.common import instance as rd_instance -from trove.guestagent import pkg -from trove.guestagent.common import operating_system -from trove.guestagent.datastore import service -from trove.guestagent.datastore.experimental.redis import system -from trove.openstack.common import log as logging from trove.common.i18n import _ +from trove.common import instance as rd_instance +from trove.common import utils as utils +from trove.guestagent.common import operating_system +from trove.guestagent.datastore.experimental.redis import system +from trove.guestagent.datastore import service +from trove.guestagent import pkg +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) TMP_REDIS_CONF = '/tmp/redis.conf.tmp' diff --git a/trove/guestagent/datastore/experimental/vertica/manager.py b/trove/guestagent/datastore/experimental/vertica/manager.py index 2c159d4a0e..e9dee34565 100644 --- a/trove/guestagent/datastore/experimental/vertica/manager.py +++ b/trove/guestagent/datastore/experimental/vertica/manager.py @@ -1,27 +1,28 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. import os + from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import instance as rd_ins -from trove.guestagent import volume -from trove.guestagent import dbaas from trove.guestagent.datastore.experimental.vertica.service import ( VerticaAppStatus) from trove.guestagent.datastore.experimental.vertica.service import VerticaApp +from trove.guestagent import dbaas +from trove.guestagent import volume from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.openstack.common import periodic_task LOG = logging.getLogger(__name__) @@ -59,7 +60,7 @@ class Manager(periodic_task.PeriodicTasks): device.unmount_device(device_path) device.format() if path_exists_function(mount_point): - #rsync any existing data + # rsync any existing data device.migrate_data(mount_point) # mount the volume device.mount(mount_point) diff --git a/trove/guestagent/datastore/experimental/vertica/service.py b/trove/guestagent/datastore/experimental/vertica/service.py index e939f64e4f..137f2e6d2d 100644 --- a/trove/guestagent/datastore/experimental/vertica/service.py +++ b/trove/guestagent/datastore/experimental/vertica/service.py @@ -1,15 +1,15 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. import ConfigParser import os @@ -17,16 +17,17 @@ import subprocess import tempfile from oslo_utils import netutils + from trove.common import cfg from trove.common import exception -from trove.common import utils as utils +from trove.common.i18n import _ from trove.common import instance as rd_instance +from trove.common import utils as utils +from trove.guestagent.datastore.experimental.vertica import system from trove.guestagent.datastore import service from trove.guestagent import pkg from trove.guestagent import volume -from trove.guestagent.datastore.experimental.vertica import system from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF @@ -43,7 +44,7 @@ class VerticaAppStatus(service.BaseDbStatus): out, err = system.shell_execute(system.STATUS_ACTIVE_DB, "dbadmin") if out.strip() == DB_NAME: - #UP status is confirmed + # UP status is confirmed LOG.info(_("Service Status is RUNNING.")) return rd_instance.ServiceStatuses.RUNNING else: diff --git a/trove/guestagent/datastore/experimental/vertica/system.py b/trove/guestagent/datastore/experimental/vertica/system.py index 4de914c3c9..e64d7ae0be 100644 --- a/trove/guestagent/datastore/experimental/vertica/system.py +++ b/trove/guestagent/datastore/experimental/vertica/system.py @@ -1,15 +1,15 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. from trove.common import utils @@ -35,11 +35,11 @@ INSTALL_TIMEOUT = 1000 def shell_execute(command, command_executor="root"): - #This method encapsulates utils.execute for 2 purpose: - #1. Helps in safe testing. - #2. Helps in executing commands as other user, using their environment. + # This method encapsulates utils.execute for 2 purpose: + # 1. Helps in safe testing. + # 2. Helps in executing commands as other user, using their environment. - #Note: This method uses su because using sudo -i -u - #does not works with vertica installer - #and it has problems while executing remote commands. + # Note: This method uses su because using sudo -i -u + # does not works with vertica installer + # and it has problems while executing remote commands. return utils.execute("sudo", "su", "-", command_executor, "-c", command) diff --git a/trove/guestagent/datastore/mysql/manager.py b/trove/guestagent/datastore/mysql/manager.py index 4527cf3f5d..c116987423 100644 --- a/trove/guestagent/datastore/mysql/manager.py +++ b/trove/guestagent/datastore/mysql/manager.py @@ -17,18 +17,19 @@ # import os + from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import instance as rd_instance -from trove.guestagent import dbaas from trove.guestagent import backup -from trove.guestagent import volume -from trove.guestagent.datastore.mysql.service import MySqlAppStatus from trove.guestagent.datastore.mysql.service import MySqlAdmin from trove.guestagent.datastore.mysql.service import MySqlApp +from trove.guestagent.datastore.mysql.service import MySqlAppStatus +from trove.guestagent import dbaas from trove.guestagent.strategies.replication import get_replication_strategy +from trove.guestagent import volume from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.openstack.common import periodic_task @@ -122,16 +123,16 @@ class Manager(periodic_task.PeriodicTasks): app = MySqlApp(MySqlAppStatus.get()) app.install_if_needed(packages) if device_path: - #stop and do not update database + # stop and do not update database app.stop_db() device = volume.VolumeDevice(device_path) # unmount if device is already mounted device.unmount_device(device_path) device.format() if os.path.exists(mount_point): - #rsync exiting data + # rsync exiting data device.migrate_data(mount_point) - #mount the volume + # mount the volume device.mount(mount_point) LOG.debug("Mounted the volume.") app.start_mysql() diff --git a/trove/guestagent/datastore/mysql/service.py b/trove/guestagent/datastore/mysql/service.py index 0f66256495..4dbc007ebc 100644 --- a/trove/guestagent/datastore/mysql/service.py +++ b/trove/guestagent/datastore/mysql/service.py @@ -16,10 +16,10 @@ # under the License. # +from collections import defaultdict import os import re import uuid -from collections import defaultdict import sqlalchemy from sqlalchemy import exc @@ -27,18 +27,18 @@ from sqlalchemy import interfaces from sqlalchemy.sql.expression import text from trove.common import cfg -from trove.common import utils as utils from trove.common import exception -from trove.common import instance as rd_instance from trove.common.exception import PollTimeOut +from trove.common.i18n import _ +from trove.common import instance as rd_instance +from trove.common import utils as utils from trove.guestagent.common import operating_system from trove.guestagent.common.operating_system import FileMode from trove.guestagent.common import sql_query +from trove.guestagent.datastore import service from trove.guestagent.db import models from trove.guestagent import pkg -from trove.guestagent.datastore import service from trove.openstack.common import log as logging -from trove.common.i18n import _ ADMIN_USER_NAME = "os_admin" LOG = logging.getLogger(__name__) @@ -117,8 +117,8 @@ def get_auth_password(): def get_engine(): """Create the default engine with the updated admin user.""" - #TODO(rnirmal):Based on permissions issues being resolved we may revert - #url = URL(drivername='mysql', host='localhost', + # TODO(rnirmal):Based on permissions issues being resolved we may revert + # url = URL(drivername='mysql', host='localhost', # query={'read_default_file': '/etc/mysql/my.cnf'}) global ENGINE if ENGINE: @@ -133,7 +133,7 @@ def get_engine(): def load_mysqld_options(): - #find mysqld bin + # find mysqld bin for bin in MYSQL_BIN_CANDIDATES: if os.path.isfile(bin): mysqld_bin = bin diff --git a/trove/guestagent/datastore/service.py b/trove/guestagent/datastore/service.py index fe940abf3e..ad297e4ae7 100644 --- a/trove/guestagent/datastore/service.py +++ b/trove/guestagent/datastore/service.py @@ -18,11 +18,11 @@ import time from trove.common import cfg from trove.common import context +from trove.common.i18n import _ from trove.common import instance from trove.conductor import api as conductor_api from trove.guestagent.common import timeutils from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/db/models.py b/trove/guestagent/db/models.py index d7de1c09d2..f3290208ff 100644 --- a/trove/guestagent/db/models.py +++ b/trove/guestagent/db/models.py @@ -328,7 +328,7 @@ class MySQLDatabase(Base): """Validate the character set and set it.""" if not value: pass - elif not value in self.charset: + elif value not in self.charset: raise ValueError(_("'%s' not a valid character set.") % value) else: self._character_set = value diff --git a/trove/guestagent/dbaas.py b/trove/guestagent/dbaas.py index 4d68a3a6b4..f38914eb36 100644 --- a/trove/guestagent/dbaas.py +++ b/trove/guestagent/dbaas.py @@ -23,12 +23,12 @@ handles RPC calls relating to Platform specific operations. """ +from itertools import chain import os -from trove.openstack.common import log -from itertools import chain from trove.common import cfg from trove.common.i18n import _ +from trove.openstack.common import log LOG = log.getLogger(__name__) diff --git a/trove/guestagent/models.py b/trove/guestagent/models.py index 95f45172af..85ffe86e6e 100644 --- a/trove/guestagent/models.py +++ b/trove/guestagent/models.py @@ -17,11 +17,11 @@ from datetime import timedelta from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common import utils from trove.db import get_db_api from trove.db import models as dbmodels from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/pkg.py b/trove/guestagent/pkg.py index ea8613c2cb..c26e233ad2 100644 --- a/trove/guestagent/pkg.py +++ b/trove/guestagent/pkg.py @@ -17,19 +17,20 @@ Manages packages on the Guest VM. """ import commands +import os import re import subprocess from tempfile import NamedTemporaryFile -import os + import pexpect import six from trove.common import exception -from trove.common import utils from trove.common.exception import ProcessExecutionError +from trove.common.i18n import _ +from trove.common import utils from trove.guestagent.common import operating_system from trove.openstack.common import log as logging -from trove.common.i18n import _ LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/strategies/backup/experimental/couchbase_impl.py b/trove/guestagent/strategies/backup/experimental/couchbase_impl.py index b9686a0dab..5a761f89a2 100644 --- a/trove/guestagent/strategies/backup/experimental/couchbase_impl.py +++ b/trove/guestagent/strategies/backup/experimental/couchbase_impl.py @@ -17,13 +17,13 @@ import json from trove.common import exception +from trove.common.i18n import _ from trove.common import utils +from trove.guestagent.common import operating_system from trove.guestagent.datastore.experimental.couchbase import service from trove.guestagent.datastore.experimental.couchbase import system from trove.guestagent.strategies.backup import base -from trove.common.i18n import _ from trove.openstack.common import log as logging -from trove.guestagent.common import operating_system LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/strategies/replication/mysql_base.py b/trove/guestagent/strategies/replication/mysql_base.py index ecb74d2b8e..31be261355 100644 --- a/trove/guestagent/strategies/replication/mysql_base.py +++ b/trove/guestagent/strategies/replication/mysql_base.py @@ -18,6 +18,7 @@ import abc import uuid from oslo_utils import netutils + from trove.common import cfg from trove.common import utils from trove.guestagent.backup.backupagent import BackupAgent @@ -25,8 +26,8 @@ from trove.guestagent.datastore.mysql.service import MySqlAdmin from trove.guestagent.db import models from trove.guestagent.strategies import backup from trove.guestagent.strategies.replication import base -from trove.openstack.common import log as logging from trove.openstack.common.gettextutils import _ +from trove.openstack.common import log as logging AGENT = BackupAgent() CONF = cfg.CONF diff --git a/trove/guestagent/strategies/restore/__init__.py b/trove/guestagent/strategies/restore/__init__.py index 5441fa6360..d6a368ec8e 100644 --- a/trove/guestagent/strategies/restore/__init__.py +++ b/trove/guestagent/strategies/restore/__init__.py @@ -1,16 +1,16 @@ -#Copyright 2013 Hewlett-Packard Development Company, L.P. +# Copyright 2013 Hewlett-Packard Development Company, L.P. -#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 +# 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 +# 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. +# 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. from trove.guestagent.strategy import Strategy from trove.openstack.common import log as logging diff --git a/trove/guestagent/strategies/restore/base.py b/trove/guestagent/strategies/restore/base.py index b7fa58a0fe..e2e305a3d7 100644 --- a/trove/guestagent/strategies/restore/base.py +++ b/trove/guestagent/strategies/restore/base.py @@ -13,12 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. # -from trove.guestagent.strategy import Strategy +from eventlet.green import subprocess + from trove.common import cfg from trove.common import utils +from trove.guestagent.strategy import Strategy from trove.openstack.common import log as logging -from trove.common.i18n import _ # noqa -from eventlet.green import subprocess LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/strategies/restore/experimental/couchbase_impl.py b/trove/guestagent/strategies/restore/experimental/couchbase_impl.py index 9380274eca..436b155acc 100644 --- a/trove/guestagent/strategies/restore/experimental/couchbase_impl.py +++ b/trove/guestagent/strategies/restore/experimental/couchbase_impl.py @@ -21,9 +21,9 @@ import time from trove.common import exception from trove.common import utils from trove.guestagent.common import operating_system -from trove.guestagent import dbaas from trove.guestagent.datastore.experimental.couchbase import service from trove.guestagent.datastore.experimental.couchbase import system +from trove.guestagent import dbaas from trove.guestagent.strategies.restore import base from trove.openstack.common import log as logging diff --git a/trove/guestagent/strategies/restore/experimental/postgresql_impl.py b/trove/guestagent/strategies/restore/experimental/postgresql_impl.py index 796bc8d7c5..b4821e474f 100644 --- a/trove/guestagent/strategies/restore/experimental/postgresql_impl.py +++ b/trove/guestagent/strategies/restore/experimental/postgresql_impl.py @@ -14,10 +14,12 @@ # under the License. import re + +from eventlet.green import subprocess + +from trove.common import exception from trove.guestagent.strategies.restore import base from trove.openstack.common import log as logging -from trove.common import exception -from eventlet.green import subprocess LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/strategies/restore/mysql_impl.py b/trove/guestagent/strategies/restore/mysql_impl.py index 06145d5352..3bc00add68 100644 --- a/trove/guestagent/strategies/restore/mysql_impl.py +++ b/trove/guestagent/strategies/restore/mysql_impl.py @@ -16,18 +16,19 @@ import glob import os -import pexpect import re import tempfile +import pexpect + +from trove.common import exception +from trove.common.i18n import _ +from trove.common import utils from trove.guestagent.common import operating_system from trove.guestagent.common.operating_system import FileMode +import trove.guestagent.datastore.mysql.service as dbaas from trove.guestagent.strategies.restore import base from trove.openstack.common import log as logging -from trove.common import exception -from trove.common import utils -import trove.guestagent.datastore.mysql.service as dbaas -from trove.common.i18n import _ # noqa LOG = logging.getLogger(__name__) diff --git a/trove/guestagent/strategies/storage/swift.py b/trove/guestagent/strategies/storage/swift.py index ce4dfa42c2..62798b2645 100644 --- a/trove/guestagent/strategies/storage/swift.py +++ b/trove/guestagent/strategies/storage/swift.py @@ -16,11 +16,11 @@ import hashlib +from trove.common import cfg +from trove.common.i18n import _ +from trove.common.remote import create_swift_client from trove.guestagent.strategies.storage import base from trove.openstack.common import log as logging -from trove.common.i18n import _ # noqa -from trove.common.remote import create_swift_client -from trove.common import cfg LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/guestagent/volume.py b/trove/guestagent/volume.py index 61c3913005..94a6dcae3d 100644 --- a/trove/guestagent/volume.py +++ b/trove/guestagent/volume.py @@ -14,16 +14,17 @@ # under the License. import os -import pexpect from tempfile import NamedTemporaryFile +import pexpect + from trove.common import cfg -from trove.common import utils from trove.common.exception import GuestError from trove.common.exception import ProcessExecutionError -from trove.openstack.common import log as logging from trove.common.i18n import _ +from trove.common import utils from trove.guestagent.common import operating_system +from trove.openstack.common import log as logging TMP_MOUNT_POINT = "/mnt/volume" diff --git a/trove/instance/models.py b/trove/instance/models.py index 794e9f45f5..9a002a0696 100644 --- a/trove/instance/models.py +++ b/trove/instance/models.py @@ -13,35 +13,37 @@ # 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 __builtin__ import setattr """Model classes that form the core of instances functionality.""" -import re +from __builtin__ import setattr from datetime import datetime from datetime import timedelta +import re + from novaclient import exceptions as nova_exceptions from oslo_config.cfg import NoSuchOptError + +from trove.backup.models import Backup from trove.common import cfg from trove.common import exception -from trove.common import template +from trove.common import i18n as i18n import trove.common.instance as tr_instance +from trove.common.remote import create_cinder_client from trove.common.remote import create_dns_client from trove.common.remote import create_guest_client from trove.common.remote import create_nova_client -from trove.common.remote import create_cinder_client +from trove.common import template from trove.common import utils from trove.configuration.models import Configuration -from trove.extensions.security_group.models import SecurityGroup +from trove.datastore import models as datastore_models from trove.db import get_db_api from trove.db import models as dbmodels -from trove.datastore import models as datastore_models -from trove.backup.models import Backup -from trove.quota.quota import run_with_quotas +from trove.extensions.security_group.models import SecurityGroup from trove.instance.tasks import InstanceTask from trove.instance.tasks import InstanceTasks -from trove.taskmanager import api as task_api from trove.openstack.common import log as logging -from trove.common import i18n as i18n +from trove.quota.quota import run_with_quotas +from trove.taskmanager import api as task_api (_, _LE, _LI, _LW) = (i18n._, i18n._LE, i18n._LI, i18n._LW) @@ -169,7 +171,7 @@ class SimpleInstance(object): @property def addresses(self): - #TODO(tim.simpson): This code attaches two parts of the Nova server to + # TODO(tim.simpson): This code attaches two parts of the Nova server to # db_info: "status" and "addresses". The idea # originally was to listen to events to update this # data and store it in the Trove database. @@ -274,11 +276,11 @@ class SimpleInstance(object): @property def status(self): - ### Check for taskmanager errors. + # Check for taskmanager errors. if self.db_info.task_status.is_error: return InstanceStatus.ERROR - ### Check for taskmanager status. + # Check for taskmanager status. action = self.db_info.task_status.action if 'BUILDING' == action: if 'ERROR' == self.db_info.server_status: @@ -295,7 +297,7 @@ class SimpleInstance(object): if InstanceTasks.EJECTING.action == action: return InstanceStatus.EJECT - ### Check for server status. + # Check for server status. if self.db_info.server_status in ["BUILD", "ERROR", "REBOOT", "RESIZE"]: return self.db_info.server_status @@ -305,11 +307,11 @@ class SimpleInstance(object): if self.db_info.server_status in ["VERIFY_RESIZE"]: return InstanceStatus.RESIZE - ### Check if there is a backup running for this instance + # Check if there is a backup running for this instance if Backup.running(self.id): return InstanceStatus.BACKUP - ### Report as Shutdown while deleting, unless there's an error. + # Report as Shutdown while deleting, unless there's an error. if 'DELETING' == action: if self.db_info.server_status in ["ACTIVE", "SHUTDOWN", "DELETED"]: return InstanceStatus.SHUTDOWN @@ -320,7 +322,7 @@ class SimpleInstance(object): 'status': self.db_info.server_status}) return InstanceStatus.ERROR - ### Check against the service status. + # Check against the service status. # The service is only paused during a reboot. if tr_instance.ServiceStatuses.PAUSED == self.datastore_status.status: return InstanceStatus.REBOOT @@ -470,7 +472,7 @@ def load_instance(cls, context, id, needs_server=False, try: server = load_server(context, db_info.id, db_info.compute_instance_id) - #TODO(tim.simpson): Remove this hack when we have notifications! + # TODO(tim.simpson): Remove this hack when we have notifications! db_info.server_status = server.status db_info.addresses = server.addresses except exception.ComputeInstanceNotFound: @@ -774,17 +776,14 @@ class Instance(BuiltInstance): root_passwords = [] root_password = None for instance_index in range(0, instance_count): - db_info = DBInstance.create(name=name, flavor_id=flavor_id, - tenant_id=context.tenant, - volume_size=volume_size, - datastore_version_id= - datastore_version.id, - task_status=InstanceTasks.BUILDING, - configuration_id=configuration_id, - slave_of_id=slave_of_id, - cluster_id=cluster_id, - shard_id=shard_id, - type=instance_type) + db_info = DBInstance.create( + name=name, flavor_id=flavor_id, tenant_id=context.tenant, + volume_size=volume_size, + datastore_version_id=datastore_version.id, + task_status=InstanceTasks.BUILDING, + configuration_id=configuration_id, + slave_of_id=slave_of_id, cluster_id=cluster_id, + shard_id=shard_id, type=instance_type) LOG.debug("Tenant %(tenant)s created new Trove instance " "%(db)s.", {'tenant': context.tenant, 'db': db_info.id}) @@ -926,7 +925,7 @@ class Instance(BuiltInstance): if self.db_info.cluster_id is not None and not self.context.is_admin: raise exception.ClusterInstanceOperationNotSupported() # Set our local status since Nova might not change it quick enough. - #TODO(tim.simpson): Possible bad stuff can happen if this service + # TODO(tim.simpson): Possible bad stuff can happen if this service # shuts down before it can set status to NONE. # We need a last updated time to mitigate this; # after some period of tolerance, we'll assume the @@ -1161,7 +1160,7 @@ class Instances(object): for db in db_items: server = None try: - #TODO(tim.simpson): Delete when we get notifications working! + # TODO(tim.simpson): Delete when we get notifications working! if InstanceTasks.BUILDING == db.task_status: db.server_status = "BUILD" db.addresses = {} @@ -1173,9 +1172,9 @@ class Instances(object): except exception.ComputeInstanceNotFound: db.server_status = "SHUTDOWN" # Fake it... db.addresses = {} - #TODO(tim.simpson): End of hack. + # TODO(tim.simpson): End of hack. - #volumes = find_volumes(server.id) + # volumes = find_volumes(server.id) datastore_status = InstanceServiceStatus.find_by( instance_id=db.id) if not datastore_status.status: # This should never happen. diff --git a/trove/instance/service.py b/trove/instance/service.py index 12f73e691f..911df79b6d 100644 --- a/trove/instance/service.py +++ b/trove/instance/service.py @@ -13,25 +13,24 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_utils import strutils import webob.exc -from oslo_utils import strutils - +from trove.backup.models import Backup as backup_model +from trove.backup import views as backup_views +import trove.common.apischema as apischema from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ +from trove.common.i18n import _LI from trove.common import pagination from trove.common import utils from trove.common import wsgi -from trove.extensions.mysql.common import populate_validated_databases -from trove.extensions.mysql.common import populate_users -from trove.instance import models, views from trove.datastore import models as datastore_models -from trove.backup.models import Backup as backup_model -from trove.backup import views as backup_views +from trove.extensions.mysql.common import populate_users +from trove.extensions.mysql.common import populate_validated_databases +from trove.instance import models, views from trove.openstack.common import log as logging -from trove.common.i18n import _ -from trove.common.i18n import _LI -import trove.common.apischema as apischema CONF = cfg.CONF diff --git a/trove/instance/tasks.py b/trove/instance/tasks.py index c6b2f9369f..885500f6b9 100644 --- a/trove/instance/tasks.py +++ b/trove/instance/tasks.py @@ -21,8 +21,8 @@ class InstanceTask(object): """ Stores the different kind of tasks being performed by an instance. """ - #TODO(tim.simpson): Figure out someway to migrate this to the TaskManager - # once that revs up. + # TODO(tim.simpson): Figure out someway to migrate this to the TaskManager + # once that revs up. _lookup = {} def __init__(self, code, action, db_text, is_error=False): diff --git a/trove/instance/views.py b/trove/instance/views.py index c03b3f9e11..24555f9a98 100644 --- a/trove/instance/views.py +++ b/trove/instance/views.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.openstack.common import log as logging from trove.common import cfg from trove.common.views import create_links from trove.instance import models +from trove.openstack.common import log as logging LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/trove/network/neutron.py b/trove/network/neutron.py index b14e94fcda..7739602762 100644 --- a/trove/network/neutron.py +++ b/trove/network/neutron.py @@ -14,11 +14,12 @@ # under the License. # +from neutronclient.common import exceptions as neutron_exceptions + from trove.common import exception from trove.common import remote from trove.network import base from trove.openstack.common import log as logging -from neutronclient.common import exceptions as neutron_exceptions LOG = logging.getLogger(__name__) @@ -92,7 +93,7 @@ class NeutronDriver(base.NetworkDriver): return self._convert_to_nova_security_group_rule_format( secgroup_rule.get('security_group_rule', secgroup_rule)) except neutron_exceptions.NeutronClientException as e: - # ignore error if rule already exists + # ignore error if rule already exists if e.status_code == 409: LOG.exception("secgroup rule already exists") else: diff --git a/trove/network/nova.py b/trove/network/nova.py index b6f27653b4..d6baf479b2 100644 --- a/trove/network/nova.py +++ b/trove/network/nova.py @@ -14,11 +14,12 @@ # under the License. # +from novaclient import exceptions as nova_exceptions + from trove.common import exception from trove.common import remote from trove.network import base from trove.openstack.common import log as logging -from novaclient import exceptions as nova_exceptions LOG = logging.getLogger(__name__) diff --git a/trove/quota/quota.py b/trove/quota/quota.py index e7f6125895..9c01ddb45a 100644 --- a/trove/quota/quota.py +++ b/trove/quota/quota.py @@ -18,9 +18,9 @@ from oslo_config import cfg from oslo_utils import importutils -from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.common import exception +from trove.common.i18n import _ +from trove.openstack.common import log as logging from trove.quota.models import Quota from trove.quota.models import QuotaUsage from trove.quota.models import Reservation @@ -137,8 +137,8 @@ class DbQuotaDriver(object): unregistered_resources = [delta for delta in deltas if delta not in resources] if unregistered_resources: - raise exception.QuotaResourceUnknown(unknown= - unregistered_resources) + raise exception.QuotaResourceUnknown( + unknown=unregistered_resources) quotas = self.get_all_quotas_by_tenant(tenant_id, deltas.keys()) quota_usages = self.get_all_quota_usages_by_tenant(tenant_id, @@ -146,9 +146,9 @@ class DbQuotaDriver(object): overs = [resource for resource in deltas if (int(deltas[resource]) > 0 and - (quota_usages[resource].in_use + - quota_usages[resource].reserved + - int(deltas[resource])) > quotas[resource].hard_limit)] + (quota_usages[resource].in_use + + quota_usages[resource].reserved + + int(deltas[resource])) > quotas[resource].hard_limit)] if overs: raise exception.QuotaExceeded(overs=sorted(overs)) diff --git a/trove/rpc.py b/trove/rpc.py index 7e02b6242b..310a034cf5 100644 --- a/trove/rpc.py +++ b/trove/rpc.py @@ -68,7 +68,7 @@ def init(conf): allowed_remote_exmods=exmods, aliases=TRANSPORT_ALIASES) - #serializer = RequestContextSerializer(JsonPayloadSerializer()) + # serializer = RequestContextSerializer(JsonPayloadSerializer()) # https://review.openstack.org/#/c/71532/1/nova/rpc.py NOTIFIER = messaging.Notifier(TRANSPORT, serializer=None) diff --git a/trove/taskmanager/api.py b/trove/taskmanager/api.py index 2d5142c771..7cfcace75c 100644 --- a/trove/taskmanager/api.py +++ b/trove/taskmanager/api.py @@ -19,13 +19,14 @@ Routes all the requests to the task manager. """ import oslo_messaging as messaging + from trove.common import cfg from trove.common import exception -from trove.common.strategies.cluster import strategy import trove.common.rpc.version as rpc_version +from trove.common.strategies.cluster import strategy from trove.guestagent import models as agent_models -from trove import rpc from trove.openstack.common import log as logging +from trove import rpc CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/trove/taskmanager/manager.py b/trove/taskmanager/manager.py index 18817ea70b..39e93f5ad6 100644 --- a/trove/taskmanager/manager.py +++ b/trove/taskmanager/manager.py @@ -16,17 +16,16 @@ from sets import Set import oslo_messaging as messaging -from trove.common.context import TroveContext - from oslo_utils import importutils from trove.backup.models import Backup import trove.common.cfg as cfg -from trove.common.i18n import _ -import trove.common.rpc.version as rpc_version +from trove.common.context import TroveContext from trove.common import exception from trove.common.exception import ReplicationSlaveAttachError from trove.common.exception import TroveError +from trove.common.i18n import _ +import trove.common.rpc.version as rpc_version from trove.common.strategies.cluster import strategy import trove.extensions.mgmt.instances.models as mgmtmodels from trove.instance.tasks import InstanceTasks diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py index fb72ce5228..1d3519f9a2 100755 --- a/trove/taskmanager/models.py +++ b/trove/taskmanager/models.py @@ -12,16 +12,16 @@ # License for the specific language governing permissions and limitations # under the License. +import os.path import re import traceback -import os.path -from heatclient import exc as heat_exceptions from cinderclient import exceptions as cinder_exceptions from eventlet import greenthread +from heatclient import exc as heat_exceptions from novaclient import exceptions as nova_exceptions - from oslo_utils import timeutils +from swiftclient.client import ClientException from trove.backup import models as bkup_models from trove.backup.models import Backup @@ -32,9 +32,6 @@ from trove.cluster.models import DBCluster from trove.cluster import tasks from trove.common import cfg from trove.common import exception -from trove.common import template -from trove.common import utils -from trove.common.utils import try_recover from trove.common.exception import BackupCreationError from trove.common.exception import GuestError from trove.common.exception import GuestTimeout @@ -43,30 +40,32 @@ from trove.common.exception import MalformedSecurityGroupRuleError from trove.common.exception import PollTimeOut from trove.common.exception import TroveError from trove.common.exception import VolumeCreationFailure -from trove.common.instance import ServiceStatuses +from trove.common.i18n import _ from trove.common import instance as rd_instance -from trove.common.strategies.cluster import strategy +from trove.common.instance import ServiceStatuses +import trove.common.remote as remote +from trove.common.remote import create_cinder_client from trove.common.remote import create_dns_client from trove.common.remote import create_heat_client -from trove.common.remote import create_cinder_client -from trove.extensions.mysql import models as mysql_models +from trove.common.strategies.cluster import strategy +from trove.common import template +from trove.common import utils +from trove.common.utils import try_recover from trove.configuration.models import Configuration -from trove.extensions.security_group.models import SecurityGroup -from trove.extensions.security_group.models import SecurityGroupRule +from trove.extensions.mysql import models as mysql_models from trove.extensions.security_group.models import ( SecurityGroupInstanceAssociation) -from swiftclient.client import ClientException +from trove.extensions.security_group.models import SecurityGroup +from trove.extensions.security_group.models import SecurityGroupRule from trove.instance import models as inst_models from trove.instance.models import BuiltInstance from trove.instance.models import DBInstance from trove.instance.models import FreshInstance -from trove.instance.tasks import InstanceTasks -from trove.instance.models import InstanceStatus from trove.instance.models import InstanceServiceStatus +from trove.instance.models import InstanceStatus +from trove.instance.tasks import InstanceTasks from trove.openstack.common import log as logging -from trove.common.i18n import _ from trove.quota.quota import run_with_quotas -import trove.common.remote as remote from trove import rpc LOG = logging.getLogger(__name__) @@ -1410,7 +1409,7 @@ class BackupTasks(object): @classmethod def delete_backup(cls, context, backup_id): - #delete backup from swift + """Delete backup from swift.""" LOG.info(_("Deleting backup %s.") % backup_id) backup = bkup_models.Backup.get_by_id(context, backup_id) try: @@ -1452,37 +1451,39 @@ class ResizeVolumeAction(object): return self.instance.device_path def _fail(self, orig_func): - LOG.exception(_("%(func)s encountered an error when attempting to " - "resize the volume for instance %(id)s. Setting service " - "status to failed.") % {'func': orig_func.__name__, - 'id': self.instance.id}) + LOG.exception(_("%(func)s encountered an error when " + "attempting to resize the volume for " + "instance %(id)s. Setting service " + "status to failed.") % {'func': orig_func.__name__, + 'id': self.instance.id}) service = InstanceServiceStatus.find_by(instance_id=self.instance.id) service.set_status(ServiceStatuses.FAILED) service.save() def _recover_restart(self, orig_func): LOG.exception(_("%(func)s encountered an error when attempting to " - "resize the volume for instance %(id)s. Trying to " - "recover by restarting the guest.") % { - 'func': orig_func.__name__, - 'id': self.instance.id}) + "resize the volume for instance %(id)s. Trying to " + "recover by restarting the " + "guest.") % {'func': orig_func.__name__, + 'id': self.instance.id}) self.instance.restart() def _recover_mount_restart(self, orig_func): LOG.exception(_("%(func)s encountered an error when attempting to " - "resize the volume for instance %(id)s. Trying to " - "recover by mounting the volume and then restarting the " - "guest.") % {'func': orig_func.__name__, - 'id': self.instance.id}) + "resize the volume for instance %(id)s. Trying to " + "recover by mounting the volume and then restarting " + "the guest.") % {'func': orig_func.__name__, + 'id': self.instance.id}) self._mount_volume() self.instance.restart() def _recover_full(self, orig_func): LOG.exception(_("%(func)s encountered an error when attempting to " - "resize the volume for instance %(id)s. Trying to " - "recover by attaching and mounting the volume and then " - "restarting the guest.") % {'func': orig_func.__name__, - 'id': self.instance.id}) + "resize the volume for instance %(id)s. Trying to " + "recover by attaching and" + " mounting the volume and then restarting the " + "guest.") % {'func': orig_func.__name__, + 'id': self.instance.id}) self._attach_volume() self._mount_volume() self.instance.restart() @@ -1501,7 +1502,7 @@ class ResizeVolumeAction(object): mount_point=mount_point) LOG.debug("Successfully unmounted the volume %(vol_id)s for " "instance %(id)s" % {'vol_id': self.instance.volume_id, - 'id': self.instance.id}) + 'id': self.instance.id}) @try_recover def _detach_volume(self): @@ -1528,7 +1529,7 @@ class ResizeVolumeAction(object): device_path = self.get_device_path() LOG.debug("Attach volume %(vol_id)s to instance %(id)s at " "%(dev)s" % {'vol_id': self.instance.volume_id, - 'id': self.instance.id, 'dev': device_path}) + 'id': self.instance.id, 'dev': device_path}) self.instance.nova_client.volumes.create_server_volume( self.instance.server.id, self.instance.volume_id, device_path) @@ -1542,7 +1543,7 @@ class ResizeVolumeAction(object): LOG.debug("Successfully attached volume %(vol_id)s to instance " "%(id)s" % {'vol_id': self.instance.volume_id, - 'id': self.instance.id}) + 'id': self.instance.id}) @try_recover def _resize_fs(self): @@ -1554,7 +1555,7 @@ class ResizeVolumeAction(object): mount_point=mount_point) LOG.debug("Successfully resized volume %(vol_id)s filesystem for " "instance %(id)s" % {'vol_id': self.instance.volume_id, - 'id': self.instance.id}) + 'id': self.instance.id}) @try_recover def _mount_volume(self): @@ -1566,18 +1567,19 @@ class ResizeVolumeAction(object): mount_point=mount_point) LOG.debug("Successfully mounted the volume %(vol_id)s on instance " "%(id)s" % {'vol_id': self.instance.volume_id, - 'id': self.instance.id}) + 'id': self.instance.id}) @try_recover def _extend(self): LOG.debug("Extending volume %(vol_id)s for instance %(id)s to " "size %(size)s" % {'vol_id': self.instance.volume_id, - 'id': self.instance.id, 'size': self.new_size}) + 'id': self.instance.id, + 'size': self.new_size}) self.instance.volume_client.volumes.extend(self.instance.volume_id, self.new_size) LOG.debug("Successfully extended the volume %(vol_id)s for instance " "%(id)s" % {'vol_id': self.instance.volume_id, - 'id': self.instance.id}) + 'id': self.instance.id}) def _verify_extend(self): try: @@ -1638,10 +1640,10 @@ class ResizeVolumeAction(object): LOG.debug("%(gt)s: Resizing instance %(id)s volume for server " "%(server_id)s from %(old_volume_size)s to " "%(new_size)r GB" % {'gt': greenthread.getcurrent(), - 'id': self.instance.id, - 'server_id': self.instance.server.id, - 'old_volume_size': self.old_size, - 'new_size': self.new_size}) + 'id': self.instance.id, + 'server_id': self.instance.server.id, + 'old_volume_size': self.old_size, + 'new_size': self.new_size}) if self.instance.server.status == InstanceStatus.ACTIVE: self._resize_active_volume() diff --git a/trove/tests/api/backups.py b/trove/tests/api/backups.py index 654d5e718a..db1154715d 100644 --- a/trove/tests/api/backups.py +++ b/trove/tests/api/backups.py @@ -16,23 +16,24 @@ from proboscis.asserts import assert_equal from proboscis.asserts import assert_not_equal from proboscis.asserts import assert_raises from proboscis.asserts import fail -from proboscis import test -from proboscis import SkipTest from proboscis.decorators import time_out -from trove.common import cfg -from trove.common.utils import poll_until -from trove.common.utils import generate_uuid -from trove.common import exception -from trove.tests.util import create_dbaas_client -from trove.tests.util.users import Requirements -from trove.tests.config import CONFIG +from proboscis import SkipTest +from proboscis import test from troveclient.compat import exceptions -from trove.tests.api.instances import WaitForGuestInstallationToFinish + +from trove.common import cfg +from trove.common import exception +from trove.common.utils import generate_uuid +from trove.common.utils import poll_until +from trove import tests +from trove.tests.api.instances import assert_unprocessable from trove.tests.api.instances import instance_info from trove.tests.api.instances import TIMEOUT_INSTANCE_CREATE from trove.tests.api.instances import TIMEOUT_INSTANCE_DELETE -from trove.tests.api.instances import assert_unprocessable -from trove import tests +from trove.tests.api.instances import WaitForGuestInstallationToFinish +from trove.tests.config import CONFIG +from trove.tests.util import create_dbaas_client +from trove.tests.util.users import Requirements GROUP = "dbaas.api.backups" diff --git a/trove/tests/api/configurations.py b/trove/tests/api/configurations.py index 5ab77e899c..c0543d5eeb 100644 --- a/trove/tests/api/configurations.py +++ b/trove/tests/api/configurations.py @@ -14,34 +14,36 @@ # under the License. +from datetime import datetime import json from time import sleep -from datetime import datetime + from proboscis import after_class -from proboscis import before_class -from proboscis import SkipTest -from proboscis import test from proboscis.asserts import assert_equal +from proboscis.asserts import assert_not_equal from proboscis.asserts import assert_raises from proboscis.asserts import assert_true -from proboscis.asserts import assert_not_equal +from proboscis import before_class from proboscis.decorators import time_out +from proboscis import SkipTest +from proboscis import test +from troveclient.compat import exceptions + from trove.common.utils import poll_until from trove.tests.api.backups import RestoreUsingBackup from trove.tests.api.instances import assert_unprocessable -from trove.tests.api.instances import InstanceTestInfo from trove.tests.api.instances import instance_info +from trove.tests.api.instances import InstanceTestInfo from trove.tests.api.instances import TIMEOUT_INSTANCE_CREATE from trove.tests.api.instances import TIMEOUT_INSTANCE_DELETE from trove.tests.api.instances import WaitForGuestInstallationToFinish from trove.tests.config import CONFIG -from trove.tests.util import create_dbaas_client from trove.tests.util.check import AttrCheck from trove.tests.util.check import CollectionCheck from trove.tests.util.check import TypeCheck +from trove.tests.util import create_dbaas_client from trove.tests.util.mysql import create_mysql_connection from trove.tests.util.users import Requirements -from troveclient.compat import exceptions GROUP = "dbaas.api.configurations" @@ -433,10 +435,9 @@ class AfterConfigurationsCreation(ConfigurationsTestBase): other_user_tenant_id = other_user.tenant_id client_tenant_id = instance_info.user.tenant_id if other_user_tenant_id == client_tenant_id: - other_user = CONFIG.users.find_user(reqs, - black_list=[ - instance_info.user.auth_user, - other_user]) + other_user = CONFIG.users.find_user( + reqs, black_list=[instance_info.user.auth_user, + other_user]) print(other_user) print(other_user.__dict__) other_client = create_dbaas_client(other_user) @@ -705,7 +706,7 @@ class DeleteConfigurations(ConfigurationsTestBase): resp, body = instance_info.dbaas.client.last_response assert_equal(resp.status, 202) instance_info.dbaas.instances.get(configuration_instance.id) - #test that config group is not removed + # test that config group is not removed instance_info.dbaas.instances.modify(instance_info.id, configuration=None) resp, body = instance_info.dbaas.client.last_response diff --git a/trove/tests/api/databases.py b/trove/tests/api/databases.py index 5fd9b604bd..ece7d0e6cc 100644 --- a/trove/tests/api/databases.py +++ b/trove/tests/api/databases.py @@ -14,21 +14,19 @@ import time -from troveclient.compat import exceptions - -from proboscis import before_class -from proboscis import test from proboscis.asserts import assert_equal from proboscis.asserts import assert_false from proboscis.asserts import assert_raises from proboscis.asserts import assert_true +from proboscis import before_class from proboscis.decorators import time_out +from proboscis import test +from troveclient.compat import exceptions from trove import tests - -from trove.tests import util from trove.tests.api.instances import GROUP_START from trove.tests.api.instances import instance_info +from trove.tests import util from trove.tests.util import test_config GROUP = "dbaas.api.databases" @@ -123,7 +121,7 @@ class TestDatabases(object): @test def test_create_database_list_system(self): - #Databases that should not be returned in the list + # Databases that should not be returned in the list databases = self.dbaas.databases.list(instance_info.id) assert_equal(200, self.dbaas.last_http_code) found = False diff --git a/trove/tests/api/datastores.py b/trove/tests/api/datastores.py index 8b261e74af..39afbaa1a0 100644 --- a/trove/tests/api/datastores.py +++ b/trove/tests/api/datastores.py @@ -15,18 +15,17 @@ from nose.tools import assert_equal -from troveclient.compat import exceptions - -from proboscis import before_class -from proboscis import test from proboscis.asserts import assert_raises from proboscis.asserts import assert_true +from proboscis import before_class +from proboscis import test +from troveclient.compat import exceptions from trove import tests +from trove.tests.util.check import TypeCheck from trove.tests.util import create_dbaas_client from trove.tests.util import test_config from trove.tests.util.users import Requirements -from trove.tests.util.check import TypeCheck GROUP = "dbaas.api.datastores" NAME = "nonexistent" diff --git a/trove/tests/api/flavors.py b/trove/tests/api/flavors.py index f66151b60c..407b193ee9 100644 --- a/trove/tests/api/flavors.py +++ b/trove/tests/api/flavors.py @@ -18,19 +18,18 @@ import os from nose.tools import assert_equal from nose.tools import assert_false from nose.tools import assert_true +from proboscis.asserts import assert_raises +from proboscis import before_class +from proboscis import test from troveclient.compat import exceptions from troveclient.v1.flavors import Flavor -from proboscis import before_class -from proboscis import test -from proboscis.asserts import assert_raises - from trove import tests +from trove.tests.util.check import AttrCheck from trove.tests.util import create_dbaas_client from trove.tests.util import create_nova_client from trove.tests.util import test_config from trove.tests.util.users import Requirements -from trove.tests.util.check import AttrCheck GROUP = "dbaas.api.flavors" @@ -127,7 +126,7 @@ class Flavors(object): print(os_flavors) print("DBaaS Flavors:") print(dbaas_flavors) - #Length of both flavors list should be identical. + # Length of both flavors list should be identical. assert_equal(len(os_flavors), len(dbaas_flavors)) for os_flavor in os_flavors: found_index = None diff --git a/trove/tests/api/header.py b/trove/tests/api/header.py index 3b952f9d80..86719b517d 100644 --- a/trove/tests/api/header.py +++ b/trove/tests/api/header.py @@ -16,11 +16,12 @@ # under the License. # -from proboscis import test -from proboscis import SkipTest from functools import wraps +from proboscis import SkipTest +from proboscis import test from troveclient.compat.client import TroveHTTPClient + from trove.tests.api.versions import Versions diff --git a/trove/tests/api/instances.py b/trove/tests/api/instances.py index 2c6c3bc5d4..9994e2b3de 100644 --- a/trove/tests/api/instances.py +++ b/trove/tests/api/instances.py @@ -13,12 +13,46 @@ # License for the specific language governing permissions and limitations # under the License. +from datetime import datetime import os import re import time +from time import sleep import unittest +from proboscis import after_class +from proboscis.asserts import assert_equal +from proboscis.asserts import assert_false +from proboscis.asserts import assert_is_not_none +from proboscis.asserts import assert_not_equal +from proboscis.asserts import assert_raises +from proboscis.asserts import assert_true +from proboscis.asserts import fail +from proboscis import before_class +from proboscis.decorators import time_out +from proboscis import SkipTest +from proboscis import test +from troveclient.compat import exceptions + +from trove.common import exception as rd_exceptions +from trove.common.utils import poll_until +from trove.datastore import models as datastore_models +from trove import tests +from trove.tests.config import CONFIG +from trove.tests.util.check import AttrCheck +from trove.tests.util.check import TypeCheck +from trove.tests.util import create_dbaas_client +from trove.tests.util import create_nova_client +from trove.tests.util import dns_checker +from trove.tests.util import event_simulator +from trove.tests.util import iso_time +from trove.tests.util import test_config +from trove.tests.util.usage import create_usage_verifier +from trove.tests.util.users import Requirements + +FAKE = test_config.values['fake_mode'] + GROUP = "dbaas.guest" GROUP_NEUTRON = "dbaas.neutron" GROUP_START = "dbaas.guest.initialize" @@ -36,42 +70,6 @@ GROUP_QUOTAS = "dbaas.quotas" TIMEOUT_INSTANCE_CREATE = 60 * 32 TIMEOUT_INSTANCE_DELETE = 120 -from datetime import datetime -from time import sleep - -from trove.datastore import models as datastore_models -from trove.common import exception as rd_exceptions -from troveclient.compat import exceptions - -from proboscis.decorators import time_out -from proboscis import before_class -from proboscis import after_class -from proboscis import test -from proboscis import SkipTest -from proboscis.asserts import assert_equal -from proboscis.asserts import assert_false -from proboscis.asserts import assert_not_equal -from proboscis.asserts import assert_raises -from proboscis.asserts import assert_is_not_none -from proboscis.asserts import assert_true -from proboscis.asserts import fail - -from trove import tests -from trove.tests.config import CONFIG -from trove.tests.util import create_dbaas_client -from trove.tests.util import create_nova_client -from trove.tests.util.usage import create_usage_verifier -from trove.tests.util import dns_checker -from trove.tests.util import iso_time -from trove.tests.util.users import Requirements -from trove.common.utils import poll_until -from trove.tests.util.check import AttrCheck -from trove.tests.util.check import TypeCheck -from trove.tests.util import test_config -from trove.tests.util import event_simulator - -FAKE = test_config.values['fake_mode'] - class InstanceTestInfo(object): """Stores new instance information used by dependent tests.""" @@ -1365,7 +1363,7 @@ class DeleteInstance(object): except Exception as ex: fail("Failure: %s" % str(ex)) - #TODO(tim-simpson): make sure that the actual instance, volume, + # TODO(tim-simpson): make sure that the actual instance, volume, # guest status, and DNS entries are deleted. @@ -1451,7 +1449,7 @@ class VerifyInstanceMgmtInfo(object): 'name': ir.name, 'account_id': info.user.auth_user, # TODO(hub-cap): fix this since its a flavor object now - #'flavorRef': info.dbaas_flavor_href, + # 'flavorRef': info.dbaas_flavor_href, 'databases': [ { 'name': 'db2', diff --git a/trove/tests/api/instances_actions.py b/trove/tests/api/instances_actions.py index 19f9ba56c7..f27ae099cf 100644 --- a/trove/tests/api/instances_actions.py +++ b/trove/tests/api/instances_actions.py @@ -16,30 +16,30 @@ import time from proboscis import after_class -from proboscis import before_class -from proboscis import test from proboscis import asserts +from proboscis import before_class from proboscis.decorators import time_out from proboscis import SkipTest - -from trove import tests -from trove.tests.util.check import Checker +from proboscis import test +from sqlalchemy import exc as sqlalchemy_exc +from sqlalchemy.sql.expression import text from troveclient.compat.exceptions import BadRequest from troveclient.compat.exceptions import HTTPNotImplemented -from trove.tests.api.instances import GROUP as INSTANCE_GROUP -from trove.tests.api.instances import instance_info -from trove.tests.api.instances import GROUP_START -from trove.tests.api.instances import assert_unprocessable -from trove.tests.api.instances import VOLUME_SUPPORT -from trove.tests.api.instances import EPHEMERAL_SUPPORT -from trove.tests.util.server_connection import create_server_connection + from trove.common.utils import poll_until -import trove.tests.util as testsutil +from trove import tests +from trove.tests.api.instances import assert_unprocessable +from trove.tests.api.instances import EPHEMERAL_SUPPORT +from trove.tests.api.instances import GROUP as INSTANCE_GROUP +from trove.tests.api.instances import GROUP_START +from trove.tests.api.instances import instance_info +from trove.tests.api.instances import VOLUME_SUPPORT from trove.tests.config import CONFIG -from trove.tests.util import LocalSqlClient -from sqlalchemy import exc as sqlalchemy_exc +import trove.tests.util as testsutil +from trove.tests.util.check import Checker from trove.tests.util.check import TypeCheck -from sqlalchemy.sql.expression import text +from trove.tests.util import LocalSqlClient +from trove.tests.util.server_connection import create_server_connection GROUP = "dbaas.api.instances.actions" GROUP_REBOOT = "dbaas.api.instances.actions.reboot" @@ -491,7 +491,7 @@ class ResizeInstanceTest(ActionTestBase): self.get_flavor_href(flavor_id=self.expected_new_flavor_id)) asserts.assert_equal(202, self.dbaas.last_http_code) - #(WARNING) IF THE RESIZE IS WAY TOO FAST THIS WILL FAIL + # (WARNING) IF THE RESIZE IS WAY TOO FAST THIS WILL FAIL assert_unprocessable( self.dbaas.instances.resize_instance, self.instance_id, diff --git a/trove/tests/api/instances_delete.py b/trove/tests/api/instances_delete.py index da2de8ac4f..63e000de8e 100644 --- a/trove/tests/api/instances_delete.py +++ b/trove/tests/api/instances_delete.py @@ -19,19 +19,19 @@ import time from proboscis import after_class -from proboscis import before_class -from proboscis import test from proboscis import asserts +from proboscis import before_class from proboscis.decorators import time_out +from proboscis import test +from troveclient.compat import exceptions from trove.common import cfg -from troveclient.compat import exceptions -from trove.tests.util import create_dbaas_client from trove.common.utils import poll_until -from trove.tests.util import test_config -from trove.tests.util.users import Requirements from trove.tests.api.instances import instance_info from trove.tests.api.instances import VOLUME_SUPPORT +from trove.tests.util import create_dbaas_client +from trove.tests.util import test_config +from trove.tests.util.users import Requirements CONF = cfg.CONF @@ -122,7 +122,7 @@ class ErroredInstanceDelete(TestBase): else: self.volume_error = None # Create an instance that fails during DNS prov. - #self.dns_error = self.create_instance('test_DNS_ERROR') + # self.dns_error = self.create_instance('test_DNS_ERROR') # Create an instance that fails while it's been deleted the first time. self.delete_error = self.create_instance('test_ERROR_ON_DELETE') diff --git a/trove/tests/api/instances_mysql_down.py b/trove/tests/api/instances_mysql_down.py index f7e87a8736..e108052ae8 100644 --- a/trove/tests/api/instances_mysql_down.py +++ b/trove/tests/api/instances_mysql_down.py @@ -16,19 +16,20 @@ Extra tests to create an instance, shut down MySQL, and delete it. """ -from proboscis.decorators import time_out -from proboscis import before_class -from proboscis import test -from proboscis import asserts +from datetime import datetime import time -from datetime import datetime +from proboscis import asserts +from proboscis import before_class +from proboscis.decorators import time_out +from proboscis import test from troveclient.compat import exceptions -from trove.tests.util import create_client + from trove.common.utils import poll_until -from trove.tests.util import test_config -from trove.tests.api.instances import VOLUME_SUPPORT from trove.tests.api.instances import EPHEMERAL_SUPPORT +from trove.tests.api.instances import VOLUME_SUPPORT +from trove.tests.util import create_client +from trove.tests.util import test_config @test(groups=["dbaas.api.instances.down"]) diff --git a/trove/tests/api/instances_resize.py b/trove/tests/api/instances_resize.py index bf67b1729c..558fbecc4b 100644 --- a/trove/tests/api/instances_resize.py +++ b/trove/tests/api/instances_resize.py @@ -15,18 +15,17 @@ from mock import Mock from mox3 import mox -from testtools import TestCase -from proboscis import test - from novaclient.exceptions import BadRequest from novaclient.v2.servers import Server from oslo_messaging._drivers.common import RPCException +from proboscis import test +from testtools import TestCase +from trove.common.context import TroveContext from trove.common.exception import PollTimeOut +from trove.common import instance as rd_instance from trove.common import template from trove.common import utils -from trove.common.context import TroveContext -from trove.common import instance as rd_instance from trove.datastore.models import DatastoreVersion from trove.guestagent import api as guest from trove.instance.models import DBInstance diff --git a/trove/tests/api/limits.py b/trove/tests/api/limits.py index 30681b93ae..8cd115b10d 100644 --- a/trove/tests/api/limits.py +++ b/trove/tests/api/limits.py @@ -16,20 +16,19 @@ # under the License. # +from datetime import datetime + from nose.tools import assert_equal from nose.tools import assert_true - from oslo_utils import timeutils - from proboscis import before_class from proboscis import test +from troveclient.compat import exceptions from trove.common import cfg -from trove.tests.util import create_dbaas_client -from troveclient.compat import exceptions -from datetime import datetime -from trove.tests.util.users import Users from trove.tests.fakes import limits as fake_limits +from trove.tests.util import create_dbaas_client +from trove.tests.util.users import Users CONF = cfg.CONF diff --git a/trove/tests/api/mgmt/accounts.py b/trove/tests/api/mgmt/accounts.py index 4e91f0e0fc..9cdd29e339 100644 --- a/trove/tests/api/mgmt/accounts.py +++ b/trove/tests/api/mgmt/accounts.py @@ -12,22 +12,20 @@ # License for the specific language governing permissions and limitations # under the License. +from nose.plugins.skip import SkipTest +from proboscis import after_class +from proboscis import asserts +from proboscis import before_class +from proboscis.decorators import time_out +from proboscis import test from troveclient.compat import exceptions -from nose.plugins.skip import SkipTest - -from proboscis import after_class -from proboscis import before_class -from proboscis import test -from proboscis import asserts -from proboscis.decorators import time_out - +from trove.common.utils import poll_until from trove import tests from trove.tests.api.instances import instance_info -from trove.tests.util import test_config -from trove.tests.util import create_dbaas_client -from trove.common.utils import poll_until from trove.tests.config import CONFIG +from trove.tests.util import create_dbaas_client +from trove.tests.util import test_config from trove.tests.util.users import Requirements diff --git a/trove/tests/api/mgmt/admin_required.py b/trove/tests/api/mgmt/admin_required.py index c2a7ce7f15..c0f34cee3e 100644 --- a/trove/tests/api/mgmt/admin_required.py +++ b/trove/tests/api/mgmt/admin_required.py @@ -12,11 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -from troveclient.compat.exceptions import Unauthorized - +from proboscis.asserts import assert_raises from proboscis import before_class from proboscis import test -from proboscis.asserts import assert_raises +from troveclient.compat.exceptions import Unauthorized from trove import tests from trove.tests.util import create_dbaas_client diff --git a/trove/tests/api/mgmt/configurations.py b/trove/tests/api/mgmt/configurations.py index 994a3357c5..700280dfd0 100644 --- a/trove/tests/api/mgmt/configurations.py +++ b/trove/tests/api/mgmt/configurations.py @@ -13,15 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. -from troveclient.compat import exceptions - +from proboscis import asserts from proboscis import before_class from proboscis import test -from proboscis import asserts +from troveclient.compat import exceptions from trove import tests -from trove.tests.util import test_config from trove.tests.util import create_dbaas_client +from trove.tests.util import test_config from trove.tests.util.users import Requirements GROUP = "dbaas.api.mgmt.configurations" diff --git a/trove/tests/api/mgmt/hosts.py b/trove/tests/api/mgmt/hosts.py index 0b46e8c47b..cf053388ba 100644 --- a/trove/tests/api/mgmt/hosts.py +++ b/trove/tests/api/mgmt/hosts.py @@ -12,23 +12,22 @@ # License for the specific language governing permissions and limitations # under the License. -from troveclient.compat import exceptions - -from proboscis import before_class -from proboscis import test from proboscis.asserts import assert_not_equal from proboscis.asserts import assert_raises from proboscis.asserts import assert_true +from proboscis import before_class from proboscis.check import Check +from proboscis import test +from troveclient.compat import exceptions from trove.tests.api.instances import create_new_instance from trove.tests.api.instances import CreateInstance from trove.tests.config import CONFIG +from trove.tests import DBAAS_API +from trove.tests import INSTANCES +from trove.tests import PRE_INSTANCES from trove.tests.util import create_dbaas_client from trove.tests.util.users import Requirements -from trove.tests import DBAAS_API -from trove.tests import PRE_INSTANCES -from trove.tests import INSTANCES GROUP = "dbaas.api.mgmt.hosts" diff --git a/trove/tests/api/mgmt/instances.py b/trove/tests/api/mgmt/instances.py index aac5e91bf7..92d1dfc395 100644 --- a/trove/tests/api/mgmt/instances.py +++ b/trove/tests/api/mgmt/instances.py @@ -12,27 +12,25 @@ # License for the specific language governing permissions and limitations # under the License. -from troveclient.compat import exceptions - -from proboscis import before_class -from proboscis import test from proboscis.asserts import assert_equal from proboscis.asserts import assert_raises +from proboscis import before_class from proboscis.check import Check from proboscis import SkipTest +from proboscis import test +from troveclient.compat import exceptions +from trove.common.utils import poll_until +from trove.tests.api.instances import CreateInstance +from trove.tests.api.instances import GROUP_START +from trove.tests.api.instances import GROUP_TEST +from trove.tests.api.instances import instance_info from trove.tests.config import CONFIG +from trove.tests.util.check import CollectionCheck +from trove.tests.util.check import TypeCheck from trove.tests.util import create_client from trove.tests.util import create_dbaas_client from trove.tests.util.users import Requirements -from trove.tests.util.check import CollectionCheck -from trove.tests.util.check import TypeCheck - -from trove.tests.api.instances import CreateInstance -from trove.tests.api.instances import instance_info -from trove.tests.api.instances import GROUP_START -from trove.tests.api.instances import GROUP_TEST -from trove.common.utils import poll_until GROUP = "dbaas.api.mgmt.instances" @@ -99,7 +97,7 @@ def mgmt_instance_get(): instance.has_field('id', basestring) instance.has_field('links', list) instance.has_field('name', basestring) - #instance.has_field('server_status', basestring) + # instance.has_field('server_status', basestring) instance.has_field('status', basestring) instance.has_field('tenant_id', basestring) instance.has_field('updated', basestring) @@ -109,7 +107,7 @@ def mgmt_instance_get(): instance.has_field('volume', dict, volume_check) else: instance.has_field('volume', None) - #TODO(tim-simpson): Validate additional fields, assert + # TODO(tim-simpson): Validate additional fields, assert # no extra fields exist. if api_instance.server is not None: print("the real content of server: %s" % dir(api_instance.server)) @@ -191,14 +189,14 @@ class WhenMgmtInstanceGetIsCalledButServerIsNotReady(object): instance.has_field('id', basestring) instance.has_field('links', list) instance.has_field('name', basestring) - #instance.has_field('server_status', basestring) + # instance.has_field('server_status', basestring) instance.has_field('status', basestring) instance.has_field('tenant_id', basestring) instance.has_field('updated', basestring) # Can be None if no volume is given on this instance. instance.has_field('server', None) instance.has_field('volume', None) - #TODO(tim-simpson): Validate additional fields, + # TODO(tim-simpson): Validate additional fields, # assert no extra fields exist. diff --git a/trove/tests/api/mgmt/instances_actions.py b/trove/tests/api/mgmt/instances_actions.py index 334e420fe9..42c5230f70 100644 --- a/trove/tests/api/mgmt/instances_actions.py +++ b/trove/tests/api/mgmt/instances_actions.py @@ -13,27 +13,26 @@ # under the License. from mox3 import mox -import trove.common.instance as tr_instance -from trove.backup import models as backup_models -from trove.backup import state -from trove.common.context import TroveContext -from trove.instance.tasks import InstanceTasks -from trove.instance import models as imodels -from trove.instance.models import DBInstance -from trove.extensions.mgmt.instances.models import MgmtInstance -from trove.tests.util import create_dbaas_client -from trove.tests.util import test_config -from trove.tests.util.users import Requirements - from novaclient.v2.servers import Server - -from proboscis import test -from proboscis import before_class from proboscis import after_class from proboscis.asserts import assert_equal from proboscis.asserts import assert_raises +from proboscis import before_class +from proboscis import test + +from trove.backup import models as backup_models +from trove.backup import state +from trove.common.context import TroveContext from trove.common import exception +import trove.common.instance as tr_instance +from trove.extensions.mgmt.instances.models import MgmtInstance from trove.extensions.mgmt.instances.service import MgmtInstanceController +from trove.instance import models as imodels +from trove.instance.models import DBInstance +from trove.instance.tasks import InstanceTasks +from trove.tests.util import create_dbaas_client +from trove.tests.util import test_config +from trove.tests.util.users import Requirements GROUP = "dbaas.api.mgmt.action.reset-task-status" diff --git a/trove/tests/api/mgmt/malformed_json.py b/trove/tests/api/mgmt/malformed_json.py index 36f5c3ca07..3eeaf62c01 100644 --- a/trove/tests/api/mgmt/malformed_json.py +++ b/trove/tests/api/mgmt/malformed_json.py @@ -17,18 +17,19 @@ # from collections import deque -from proboscis import test -from proboscis import asserts + from proboscis import after_class +from proboscis import asserts from proboscis import before_class -from trove.tests.config import CONFIG +from proboscis import test + +from trove.common.utils import poll_until from trove.tests.api.instances import instance_info from trove.tests.api.instances import VOLUME_SUPPORT - -from trove.tests.util.users import Requirements +from trove.tests.config import CONFIG from trove.tests.util import assert_contains from trove.tests.util import create_dbaas_client -from trove.common.utils import poll_until +from trove.tests.util.users import Requirements @test(groups=["dbaas.api.mgmt.malformed_json"]) diff --git a/trove/tests/api/mgmt/quotas.py b/trove/tests/api/mgmt/quotas.py index b6001841f9..1699fc1ef5 100644 --- a/trove/tests/api/mgmt/quotas.py +++ b/trove/tests/api/mgmt/quotas.py @@ -16,17 +16,18 @@ # under the License. # -from proboscis import test -from proboscis import asserts from proboscis import after_class -from proboscis import before_class +from proboscis import asserts from proboscis.asserts import Check -from trove.tests.util import create_dbaas_client +from proboscis import before_class +from proboscis import test +from troveclient.compat import exceptions + +from trove.tests.config import CONFIG from trove.tests.util import create_client +from trove.tests.util import create_dbaas_client from trove.tests.util import get_standby_instance_flavor from trove.tests.util.users import Requirements -from trove.tests.config import CONFIG -from troveclient.compat import exceptions class QuotasBase(object): @@ -169,5 +170,5 @@ class ChangeVolumesQuota(QuotasBase): + 1}) asserts.assert_equal(413, self.client1.last_http_code) - #create an instance when I set the limit back to - #multiple updates to the quota and it should do what you expect + # create an instance when I set the limit back to + # multiple updates to the quota and it should do what you expect diff --git a/trove/tests/api/mgmt/storage.py b/trove/tests/api/mgmt/storage.py index c1646fcc66..212f1d123d 100644 --- a/trove/tests/api/mgmt/storage.py +++ b/trove/tests/api/mgmt/storage.py @@ -14,16 +14,15 @@ from nose.plugins.skip import SkipTest - +from proboscis import asserts from proboscis import before_class from proboscis import test -from proboscis import asserts from trove import tests from trove.tests.api.instances import CheckInstance from trove.tests.api.instances import instance_info -from trove.tests.util import test_config from trove.tests.util import create_dbaas_client +from trove.tests.util import test_config from trove.tests.util.users import Requirements FAKE_MODE = test_config.values['fake_mode'] diff --git a/trove/tests/api/replication.py b/trove/tests/api/replication.py index 9b57c4f7cb..59f8ed12db 100644 --- a/trove/tests/api/replication.py +++ b/trove/tests/api/replication.py @@ -12,12 +12,16 @@ # 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 proboscis import test +from time import sleep + from proboscis.asserts import assert_equal from proboscis.asserts import assert_raises from proboscis.asserts import assert_true from proboscis.decorators import time_out from proboscis import SkipTest +from proboscis import test +from troveclient.compat import exceptions + from trove.common.utils import generate_uuid from trove.common.utils import poll_until from trove.tests.api.instances import CheckInstance @@ -27,8 +31,6 @@ from trove.tests.api.instances import TIMEOUT_INSTANCE_DELETE from trove.tests.api.instances import WaitForGuestInstallationToFinish from trove.tests.config import CONFIG from trove.tests.util.server_connection import create_server_connection -from troveclient.compat import exceptions -from time import sleep class SlaveInstanceTestInfo(object): diff --git a/trove/tests/api/root.py b/trove/tests/api/root.py index e53ea85d39..3ab574795c 100644 --- a/trove/tests/api/root.py +++ b/trove/tests/api/root.py @@ -13,23 +13,22 @@ # under the License. -from troveclient.compat import exceptions - from nose.plugins.skip import SkipTest -from proboscis import before_class -from proboscis import test from proboscis.asserts import assert_equal from proboscis.asserts import assert_false from proboscis.asserts import assert_not_equal from proboscis.asserts import assert_raises from proboscis.asserts import assert_true +from proboscis import before_class +from proboscis import test +from troveclient.compat import exceptions from trove import tests -from trove.tests.api.users import TestUsers +from trove.tests.api.databases import TestMysqlAccess from trove.tests.api.instances import instance_info +from trove.tests.api.users import TestUsers from trove.tests import util from trove.tests.util import test_config -from trove.tests.api.databases import TestMysqlAccess GROUP = "dbaas.api.root" diff --git a/trove/tests/api/root_on_create.py b/trove/tests/api/root_on_create.py index a29a4f6b1f..be13c5e065 100644 --- a/trove/tests/api/root_on_create.py +++ b/trove/tests/api/root_on_create.py @@ -12,20 +12,20 @@ # License for the specific language governing permissions and limitations # under the License. -from proboscis import before_class from proboscis import after_class -from proboscis import test from proboscis.asserts import assert_equal from proboscis.asserts import assert_not_equal from proboscis.asserts import assert_true +from proboscis import before_class +from proboscis import test -from trove import tests from trove.common import cfg from trove.common.utils import poll_until -from trove.tests import util -from trove.tests.api.users import TestUsers -from trove.tests.api.instances import instance_info +from trove import tests from trove.tests.api.databases import TestMysqlAccess +from trove.tests.api.instances import instance_info +from trove.tests.api.users import TestUsers +from trove.tests import util CONF = cfg.CONF GROUP = "dbaas.api.root.oncreate" diff --git a/trove/tests/api/user_access.py b/trove/tests/api/user_access.py index 76782f7887..dfb4d87934 100644 --- a/trove/tests/api/user_access.py +++ b/trove/tests/api/user_access.py @@ -14,18 +14,17 @@ from random import choice -from troveclient.compat import exceptions - from proboscis import after_class +from proboscis import asserts from proboscis import before_class from proboscis import test -from proboscis import asserts +from troveclient.compat import exceptions from trove import tests from trove.tests.api.instances import instance_info +from trove.tests.api.users import TestUsers from trove.tests import util from trove.tests.util import test_config -from trove.tests.api.users import TestUsers GROUP = "dbaas.api.useraccess" GROUP_POSITIVE = GROUP + ".positive" @@ -478,7 +477,7 @@ class TestUserAccessNegative(UserAccessBase): @test def test_user_empty_with_host(self): - #self._negative_user_test("", self.databases, 400, 400, 400, 400) + # self._negative_user_test("", self.databases, 400, 400, 400, 400) # Try and fail to create the user. empty_user = {"name": "", "host": "%", "password": "password", "databases": []} diff --git a/trove/tests/api/users.py b/trove/tests/api/users.py index 24abf2bd84..ba4b919250 100644 --- a/trove/tests/api/users.py +++ b/trove/tests/api/users.py @@ -13,26 +13,24 @@ # under the License. import time - -from troveclient.compat import exceptions +import urllib from proboscis import after_class -from proboscis import before_class -from proboscis import test from proboscis.asserts import assert_equal from proboscis.asserts import assert_false from proboscis.asserts import assert_raises from proboscis.asserts import assert_true from proboscis.asserts import fail +from proboscis import before_class +from proboscis import test +from troveclient.compat import exceptions from trove import tests from trove.tests.api.databases import TestDatabases +from trove.tests.api.databases import TestMysqlAccess from trove.tests.api.instances import instance_info from trove.tests import util from trove.tests.util import test_config -from trove.tests.api.databases import TestMysqlAccess - -import urllib GROUP = "dbaas.api.users" @@ -106,7 +104,7 @@ class TestUsers(object): @test(depends_on=[test_create_users]) def test_create_users_list(self): - #tests for users that should be listed + # tests for users that should be listed users = self.dbaas.users.list(instance_info.id) assert_equal(200, self.dbaas.last_http_code) found = False @@ -149,7 +147,7 @@ class TestUsers(object): @test(depends_on=[test_create_users_list]) def test_create_users_list_system(self): - #tests for users that should not be listed + # tests for users that should not be listed users = self.dbaas.users.list(instance_info.id) assert_equal(200, self.dbaas.last_http_code) for user in self.system_users: @@ -205,7 +203,7 @@ class TestUsers(object): @test() def test_updateduser_newname_host_unique(self): - #The updated_username@hostname should not exist already + # The updated_username@hostname should not exist already users = [] old_name = "testuser1" hostname = "192.168.0.1" @@ -386,7 +384,8 @@ class TestUsers(object): assert_equal(400, self.dbaas.last_http_code) @test(enabled=False) - #TODO(hub_cap): Make this test work once python-routes is updated, if ever. + # TODO(hub_cap): Make this test work once python-routes is updated, + # if ever. def test_delete_user_with_period_in_name(self): """Attempt to create/destroy a user with a period in its name.""" users = [] diff --git a/trove/tests/api/versions.py b/trove/tests/api/versions.py index 8c55ed23b1..0d1a2d1db7 100644 --- a/trove/tests/api/versions.py +++ b/trove/tests/api/versions.py @@ -12,15 +12,15 @@ # License for the specific language governing permissions and limitations # under the License. -from proboscis import before_class -from proboscis import test from proboscis.asserts import assert_equal +from proboscis import before_class from proboscis import SkipTest - +from proboscis import test from troveclient.compat.exceptions import ClientException + from trove import tests -from trove.tests.util import test_config from trove.tests.util import create_dbaas_client +from trove.tests.util import test_config from trove.tests.util.users import Requirements GROUP = "dbaas.api.versions" diff --git a/trove/tests/config.py b/trove/tests/config.py index b5722fd77f..87af19ab3a 100644 --- a/trove/tests/config.py +++ b/trove/tests/config.py @@ -21,13 +21,13 @@ environments if we choose to. """ +from collections import Mapping import json import os -from collections import Mapping -#TODO(tim.simpson): I feel like this class already exists somewhere in core -# Python. +# TODO(tim.simpson): I feel like this class already exists somewhere in core +# Python. class FrozenDict(Mapping): def __init__(self, original): diff --git a/trove/tests/db/migrations.py b/trove/tests/db/migrations.py index 4024d7d1e5..48768e068f 100644 --- a/trove/tests/db/migrations.py +++ b/trove/tests/db/migrations.py @@ -24,23 +24,20 @@ admin rights (i.e. create/drop database) import glob import os -from migrate.versioning import repository import migrate.versioning.api as migration_api - +from migrate.versioning import repository from oslo_concurrency import processutils - from proboscis import after_class -from proboscis import before_class -from proboscis import test -from proboscis import SkipTest from proboscis.asserts import assert_equal from proboscis.asserts import assert_true - +from proboscis import before_class +from proboscis import SkipTest +from proboscis import test import sqlalchemy import sqlalchemy.exc -import trove.db.sqlalchemy.migrate_repo from trove.common.i18n import _ +import trove.db.sqlalchemy.migrate_repo from trove.openstack.common import log as logging from trove.tests.util import event_simulator diff --git a/trove/tests/examples/client.py b/trove/tests/examples/client.py index 5d4a38e10d..f8fa1a019e 100644 --- a/trove/tests/examples/client.py +++ b/trove/tests/examples/client.py @@ -20,6 +20,7 @@ from urlparse import urlparse from proboscis.asserts import fail from troveclient.compat.client import TroveHTTPClient + from trove.tests.config import CONFIG print_req = True diff --git a/trove/tests/examples/snippets.py b/trove/tests/examples/snippets.py index 3f92dead21..5ff26ce2c6 100644 --- a/trove/tests/examples/snippets.py +++ b/trove/tests/examples/snippets.py @@ -12,27 +12,25 @@ # License for the specific language governing permissions and limitations # under the License. -import json -import time -import logging import functools +import json +import logging +import time -from proboscis import before_class -from proboscis import test -from proboscis import SkipTest -from proboscis import TestProgram from proboscis.asserts import assert_equal from proboscis.asserts import assert_true from proboscis.asserts import Check - -from troveclient.compat import TroveHTTPClient +from proboscis import before_class +from proboscis import SkipTest +from proboscis import test +from proboscis import TestProgram from troveclient.compat import client as trove_client -from trove.tests.config import CONFIG - from troveclient.compat import Dbaas +from troveclient.compat import TroveHTTPClient -from trove.tests.examples.client import SnippetWriter +from trove.tests.config import CONFIG from trove.tests.examples.client import JsonClient +from trove.tests.examples.client import SnippetWriter trove_client._logger.setLevel(logging.CRITICAL) @@ -168,12 +166,10 @@ def create_client(cls, user): def make_client(user): - #snippet_writer = SnippetWriter(conf) args, kwargs = create_client_args(user) kwargs['client_cls'] = JsonClient client = Dbaas(*args, **kwargs) client.client.name = "auth" - #client.client.snippet_writer = snippet_writer client.authenticate() return client @@ -348,8 +344,7 @@ class Databases(Example): "POST", 202, "Accepted", lambda client: client.databases.create( json_instance.id, - databases= - [ + databases=[ { "name": "testingdb", "character_set": "utf8", @@ -358,8 +353,7 @@ class Databases(Example): "name": "anotherdb" }, { "name": "oneMoreDB" - } - ])) + }])) @test(depends_on=[post_create_databases]) def get_list_databases(self): diff --git a/trove/tests/fakes/dns.py b/trove/tests/fakes/dns.py index 6d1f3b31d3..9c88ee3b23 100644 --- a/trove/tests/fakes/dns.py +++ b/trove/tests/fakes/dns.py @@ -12,10 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.dns import driver -from proboscis.asserts import fail from proboscis.asserts import assert_equal from proboscis.asserts import assert_true +from proboscis.asserts import fail + +from trove.dns import driver from trove.openstack.common import log as logging diff --git a/trove/tests/fakes/guestagent.py b/trove/tests/fakes/guestagent.py index d3d102d355..61a80eb766 100644 --- a/trove/tests/fakes/guestagent.py +++ b/trove/tests/fakes/guestagent.py @@ -13,13 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.openstack.common import log as logging -import time import re +import time import eventlet + from trove.common import exception as rd_exception from trove.common import instance as rd_instance +from trove.openstack.common import log as logging from trove.tests.util import unquote_user_host DB = {} @@ -208,9 +209,9 @@ class FakeGuest(object): mount_point=None, backup_info=None, config_contents=None, root_password=None, overrides=None, cluster_config=None, snapshot=None): + from trove.guestagent.models import AgentHeartBeat from trove.instance.models import DBInstance from trove.instance.models import InstanceServiceStatus - from trove.guestagent.models import AgentHeartBeat LOG.debug("users... %s" % users) LOG.debug("databases... %s" % databases) instance_name = DBInstance.find_by(id=self.id).name diff --git a/trove/tests/fakes/taskmanager.py b/trove/tests/fakes/taskmanager.py index 1caa522579..8198472817 100644 --- a/trove/tests/fakes/taskmanager.py +++ b/trove/tests/fakes/taskmanager.py @@ -15,13 +15,14 @@ # from collections import defaultdict + import eventlet import trove.openstack.common.log as logging +from trove import rpc from trove.taskmanager.api import API from trove.taskmanager.manager import Manager import trove.tests.util.usage as usage -from trove import rpc LOG = logging.getLogger(__name__) MESSAGE_QUEUE = defaultdict(list) diff --git a/trove/tests/unittests/api/common/test_limits.py b/trove/tests/unittests/api/common/test_limits.py index 4baae9c1d1..dd2b4e063f 100644 --- a/trove/tests/unittests/api/common/test_limits.py +++ b/trove/tests/unittests/api/common/test_limits.py @@ -18,17 +18,18 @@ Tests dealing with HTTP rate-limiting. """ import httplib -from trove.quota.models import Quota -import webob + from mock import Mock, MagicMock +from oslo_serialization import jsonutils import six +import webob from trove.common import limits from trove.common.limits import Limit -from trove.limits import views from trove.limits.service import LimitsController -from oslo_serialization import jsonutils +from trove.limits import views +from trove.quota.models import Quota from trove.quota.quota import QUOTAS from trove.tests.unittests import trove_testtools diff --git a/trove/tests/unittests/api/test_versions.py b/trove/tests/unittests/api/test_versions.py index fd03a71724..e9c31ffb87 100644 --- a/trove/tests/unittests/api/test_versions.py +++ b/trove/tests/unittests/api/test_versions.py @@ -14,14 +14,15 @@ # under the License. from mock import Mock + from trove.tests.unittests import trove_testtools from trove.versions import BaseVersion from trove.versions import Version from trove.versions import VersionDataView +from trove.versions import VERSIONS from trove.versions import VersionsAPI from trove.versions import VersionsController from trove.versions import VersionsDataView -from trove.versions import VERSIONS BASE_URL = 'http://localhost' diff --git a/trove/tests/unittests/backup/test_backup_models.py b/trove/tests/unittests/backup/test_backup_models.py index a3d6800be7..d3bdacff39 100644 --- a/trove/tests/unittests/backup/test_backup_models.py +++ b/trove/tests/unittests/backup/test_backup_models.py @@ -1,15 +1,15 @@ -#Copyright 2013 Hewlett-Packard Development Company, L.P. -#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 +# Copyright 2013 Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. import datetime diff --git a/trove/tests/unittests/backup/test_backupagent.py b/trove/tests/unittests/backup/test_backupagent.py index f368534bab..f241ac89cf 100644 --- a/trove/tests/unittests/backup/test_backupagent.py +++ b/trove/tests/unittests/backup/test_backupagent.py @@ -1,34 +1,34 @@ -#Copyright 2013 Hewlett-Packard Development Company, L.P. +# Copyright 2013 Hewlett-Packard Development Company, L.P. -#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 +# 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 +# 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. - -from mock import Mock, MagicMock, patch, ANY -from webob.exc import HTTPNotFound +# 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. import hashlib import os +from mock import Mock, MagicMock, patch, ANY from oslo_utils import netutils -from trove.common import utils -from trove.common.context import TroveContext -from trove.conductor import api as conductor_api -from trove.guestagent.strategies.backup import mysql_impl -from trove.guestagent.strategies.backup.experimental import couchbase_impl -from trove.guestagent.strategies.restore.base import RestoreRunner +from webob.exc import HTTPNotFound + from trove.backup.state import BackupState +from trove.common.context import TroveContext +from trove.common import utils +from trove.conductor import api as conductor_api from trove.guestagent.backup import backupagent from trove.guestagent.strategies.backup.base import BackupRunner from trove.guestagent.strategies.backup.base import UnknownBackupType +from trove.guestagent.strategies.backup.experimental import couchbase_impl +from trove.guestagent.strategies.backup import mysql_impl +from trove.guestagent.strategies.restore.base import RestoreRunner from trove.guestagent.strategies.storage.base import Storage from trove.tests.unittests import trove_testtools diff --git a/trove/tests/unittests/backup/test_storage.py b/trove/tests/unittests/backup/test_storage.py index b9fe16b6b0..0e1dc0cf20 100644 --- a/trove/tests/unittests/backup/test_storage.py +++ b/trove/tests/unittests/backup/test_storage.py @@ -1,30 +1,31 @@ -#Copyright 2013 Rackspace Development Company, L.P. +# Copyright 2013 Rackspace Development Company, L.P. -#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 +# 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 +# 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. +# 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. -from mock import Mock, MagicMock, patch import hashlib +from mock import Mock, MagicMock, patch + from trove.common.context import TroveContext -from trove.tests.fakes.swift import FakeSwiftConnection -from trove.tests.unittests import trove_testtools -from trove.tests.unittests.backup.test_backupagent \ - import MockBackup as MockBackupRunner +from trove.guestagent.strategies.storage import swift +from trove.guestagent.strategies.storage.swift import StreamReader from trove.guestagent.strategies.storage.swift \ import SwiftDownloadIntegrityError -from trove.guestagent.strategies.storage import swift from trove.guestagent.strategies.storage.swift import SwiftStorage -from trove.guestagent.strategies.storage.swift import StreamReader +from trove.tests.fakes.swift import FakeSwiftConnection +from trove.tests.unittests.backup.test_backupagent \ + import MockBackup as MockBackupRunner +from trove.tests.unittests import trove_testtools class SwiftStorageSaveChecksumTests(trove_testtools.TestCase): diff --git a/trove/tests/unittests/cluster/test_cluster.py b/trove/tests/unittests/cluster/test_cluster.py index 32cee4ca8e..5d1499e309 100644 --- a/trove/tests/unittests/cluster/test_cluster.py +++ b/trove/tests/unittests/cluster/test_cluster.py @@ -207,6 +207,6 @@ class ClusterTest(trove_testtools.TestCase): mock_task_api.mongodb_add_shard_cluster.return_value = None mock_task_api_load.return_value = mock_task_api self.cluster.add_shard() - mock_update_db.assert_called_with(task_status= - ClusterTasks.ADDING_SHARD) + mock_update_db.assert_called_with( + task_status=ClusterTasks.ADDING_SHARD) mock_task_api.mongodb_add_shard_cluster.assert_called diff --git a/trove/tests/unittests/cluster/test_cluster_vertica_controller.py b/trove/tests/unittests/cluster/test_cluster_vertica_controller.py index c3f3186c96..f8ca9df773 100644 --- a/trove/tests/unittests/cluster/test_cluster_vertica_controller.py +++ b/trove/tests/unittests/cluster/test_cluster_vertica_controller.py @@ -1,15 +1,15 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. import jsonschema diff --git a/trove/tests/unittests/cluster/test_cluster_views.py b/trove/tests/unittests/cluster/test_cluster_views.py index d13637895a..939439ed0b 100644 --- a/trove/tests/unittests/cluster/test_cluster_views.py +++ b/trove/tests/unittests/cluster/test_cluster_views.py @@ -14,9 +14,10 @@ # under the License. # -from mock import Mock from mock import MagicMock +from mock import Mock from mock import patch + from trove.cluster.views import ClusterInstanceDetailView from trove.cluster.views import ClusterView from trove.cluster.views import load_view diff --git a/trove/tests/unittests/cluster/test_vertica_cluster.py b/trove/tests/unittests/cluster/test_vertica_cluster.py index 420306591c..24a0fde2ab 100644 --- a/trove/tests/unittests/cluster/test_vertica_cluster.py +++ b/trove/tests/unittests/cluster/test_vertica_cluster.py @@ -1,15 +1,15 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. import uuid diff --git a/trove/tests/unittests/common/test_remote.py b/trove/tests/unittests/common/test_remote.py index 75e4543ea6..b75b2c1a66 100644 --- a/trove/tests/unittests/common/test_remote.py +++ b/trove/tests/unittests/common/test_remote.py @@ -15,16 +15,18 @@ # License for the specific language governing permissions and limitations # under the License. # +import uuid + from mock import patch, MagicMock +import swiftclient.client from testtools import ExpectedException, matchers + from trove.common import cfg +from trove.common.context import TroveContext from trove.common import exception from trove.common import remote -from trove.common.context import TroveContext from trove.tests.fakes.swift import SwiftClientStub from trove.tests.unittests import trove_testtools -import swiftclient.client -import uuid class TestRemote(trove_testtools.TestCase): @@ -102,10 +104,12 @@ class TestRemote(trove_testtools.TestCase): # get container details cont_info = conn.get_container(cont_name) self.assertIsNotNone(cont_info) - self.assertThat(cont_info[0], matchers.KeysEqual('content-length', - 'x-container-object-count', 'accept-ranges', - 'x-container-bytes-used', 'x-timestamp', - 'x-trans-id', 'date', 'content-type')) + self.assertThat( + cont_info[0], + matchers.KeysEqual('content-length', + 'x-container-object-count', 'accept-ranges', + 'x-container-bytes-used', 'x-timestamp', + 'x-trans-id', 'date', 'content-type')) self.assertThat(len(cont_info[1]), matchers.Equals(0)) # remove container swift_stub.without_container(cont_name) diff --git a/trove/tests/unittests/common/test_template.py b/trove/tests/unittests/common/test_template.py index 19a259276f..0050aa5567 100644 --- a/trove/tests/unittests/common/test_template.py +++ b/trove/tests/unittests/common/test_template.py @@ -9,14 +9,16 @@ # 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. +import re + from mock import Mock + from trove.common import exception from trove.common import template from trove.common import utils from trove.datastore.models import DatastoreVersion from trove.tests.unittests import trove_testtools from trove.tests.unittests.util import util -import re class TemplateTest(trove_testtools.TestCase): diff --git a/trove/tests/unittests/conductor/test_conf.py b/trove/tests/unittests/conductor/test_conf.py index 7a504e71fc..680460c17d 100644 --- a/trove/tests/unittests/conductor/test_conf.py +++ b/trove/tests/unittests/conductor/test_conf.py @@ -12,14 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. -import trove.common.cfg as cfg -import trove.tests.fakes.conf as fake_conf - from mock import MagicMock from mock import patch -from trove.cmd import conductor as conductor_cmd + from trove.cmd import common as common_cmd +from trove.cmd import conductor as conductor_cmd +import trove.common.cfg as cfg from trove.openstack.common import service as os_service +import trove.tests.fakes.conf as fake_conf from trove.tests.unittests import trove_testtools CONF = cfg.CONF diff --git a/trove/tests/unittests/conductor/test_methods.py b/trove/tests/unittests/conductor/test_methods.py index 7ca42463c9..558fddb6fd 100644 --- a/trove/tests/unittests/conductor/test_methods.py +++ b/trove/tests/unittests/conductor/test_methods.py @@ -15,8 +15,8 @@ from trove.backup import models as bkup_models from trove.backup import state from trove.common import exception as t_exception -from trove.common import utils from trove.common.instance import ServiceStatuses +from trove.common import utils from trove.conductor import manager as conductor_manager from trove.guestagent.common import timeutils from trove.instance import models as t_models diff --git a/trove/tests/unittests/configuration/test_configuration_controller.py b/trove/tests/unittests/configuration/test_configuration_controller.py index 4ffcba26df..ff9fa069a7 100644 --- a/trove/tests/unittests/configuration/test_configuration_controller.py +++ b/trove/tests/unittests/configuration/test_configuration_controller.py @@ -13,13 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. # +import jsonschema from mock import MagicMock + from trove.common import configurations from trove.common.exception import UnprocessableEntity from trove.configuration.service import ConfigurationsController from trove.extensions.mgmt.configuration import service from trove.tests.unittests import trove_testtools -import jsonschema class TestConfigurationParser(trove_testtools.TestCase): diff --git a/trove/tests/unittests/datastore/base.py b/trove/tests/unittests/datastore/base.py index fb46d46af8..45b87a1abc 100644 --- a/trove/tests/unittests/datastore/base.py +++ b/trove/tests/unittests/datastore/base.py @@ -11,14 +11,15 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import uuid + from trove.datastore import models as datastore_models from trove.datastore.models import Capability -from trove.datastore.models import DBCapabilityOverrides from trove.datastore.models import Datastore from trove.datastore.models import DatastoreVersion +from trove.datastore.models import DBCapabilityOverrides from trove.tests.unittests import trove_testtools from trove.tests.unittests.util import util -import uuid class TestDatastoreBase(trove_testtools.TestCase): diff --git a/trove/tests/unittests/datastore/test_capability.py b/trove/tests/unittests/datastore/test_capability.py index a9f27a9466..194d683ad1 100644 --- a/trove/tests/unittests/datastore/test_capability.py +++ b/trove/tests/unittests/datastore/test_capability.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -from trove.tests.unittests.datastore.base import TestDatastoreBase -from trove.datastore.models import CapabilityOverride -from trove.datastore.models import Capability from trove.common.exception import CapabilityNotFound +from trove.datastore.models import Capability +from trove.datastore.models import CapabilityOverride +from trove.tests.unittests.datastore.base import TestDatastoreBase class TestCapabilities(TestDatastoreBase): diff --git a/trove/tests/unittests/datastore/test_datastore.py b/trove/tests/unittests/datastore/test_datastore.py index 53209e6f18..0a1beed3c2 100644 --- a/trove/tests/unittests/datastore/test_datastore.py +++ b/trove/tests/unittests/datastore/test_datastore.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from trove.common import exception from trove.datastore import models as datastore_models from trove.datastore.models import Datastore from trove.tests.unittests.datastore.base import TestDatastoreBase -from trove.common import exception class TestDatastore(TestDatastoreBase): diff --git a/trove/tests/unittests/db/test_migration_utils.py b/trove/tests/unittests/db/test_migration_utils.py index b8dcb6f3ce..ccc91a587c 100644 --- a/trove/tests/unittests/db/test_migration_utils.py +++ b/trove/tests/unittests/db/test_migration_utils.py @@ -13,13 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. # -from mock import Mock from mock import call +from mock import Mock from mock import patch from sqlalchemy.engine import reflection from sqlalchemy.schema import Column -from trove.db.sqlalchemy import utils as db_utils + from trove.db.sqlalchemy.migrate_repo.schema import String +from trove.db.sqlalchemy import utils as db_utils from trove.tests.unittests import trove_testtools @@ -36,13 +37,13 @@ class TestDbMigrationUtils(trove_testtools.TestCase): mock_engine = Mock() (mock_inspector.return_value. get_foreign_keys.return_value) = [{'constrained_columns': ['col1'], - 'referred_table': 'ref_table1', - 'referred_columns': ['ref_col1'], - 'name': 'constraint1'}, + 'referred_table': 'ref_table1', + 'referred_columns': ['ref_col1'], + 'name': 'constraint1'}, {'constrained_columns': ['col2'], - 'referred_table': 'ref_table2', - 'referred_columns': ['ref_col2'], - 'name': 'constraint2'}] + 'referred_table': 'ref_table2', + 'referred_columns': ['ref_col2'], + 'name': 'constraint2'}] ret_val = db_utils.get_foreign_key_constraint_names(mock_engine, 'table1', ['col1'], diff --git a/trove/tests/unittests/dns/test_designate_driver.py b/trove/tests/unittests/dns/test_designate_driver.py index 257e295dd1..24663dd206 100644 --- a/trove/tests/unittests/dns/test_designate_driver.py +++ b/trove/tests/unittests/dns/test_designate_driver.py @@ -11,13 +11,15 @@ # 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 designateclient.v1.domains import Domain -from designateclient.v1.records import Record -from trove.dns.designate import driver -from mock import MagicMock -from mock import patch import base64 import hashlib + +from designateclient.v1.domains import Domain +from designateclient.v1.records import Record +from mock import MagicMock +from mock import patch + +from trove.dns.designate import driver from trove.tests.unittests import trove_testtools diff --git a/trove/tests/unittests/guestagent/test_agent_heartbeats_models.py b/trove/tests/unittests/guestagent/test_agent_heartbeats_models.py index e224467b19..8a0ae94828 100644 --- a/trove/tests/unittests/guestagent/test_agent_heartbeats_models.py +++ b/trove/tests/unittests/guestagent/test_agent_heartbeats_models.py @@ -10,8 +10,10 @@ # 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. -import testtools import uuid + +import testtools + from trove.common import exception from trove.guestagent.models import AgentHeartBeat from trove.tests.unittests.util import util diff --git a/trove/tests/unittests/guestagent/test_api.py b/trove/tests/unittests/guestagent/test_api.py index 139c969f0f..0186f40150 100644 --- a/trove/tests/unittests/guestagent/test_api.py +++ b/trove/tests/unittests/guestagent/test_api.py @@ -13,8 +13,8 @@ # under the License. from eventlet import Timeout import mock -from oslo_messaging.rpc.client import RemoteError import oslo_messaging as messaging +from oslo_messaging.rpc.client import RemoteError from testtools.matchers import Is import trove.common.context as context @@ -41,7 +41,7 @@ def _mock_call_pwd_change(cmd, version=None, users=None): def _mock_call(cmd, timeout, version=None, username=None, hostname=None, database=None, databases=None): - #To check get_user, list_access, grant_access, revoke_access in cmd. + # To check get_user, list_access, grant_access, revoke_access in cmd. if cmd in ('get_user', 'list_access', 'grant_access', 'revoke_access'): return True else: diff --git a/trove/tests/unittests/guestagent/test_cassandra_manager.py b/trove/tests/unittests/guestagent/test_cassandra_manager.py index 117e26c0e1..c2353d97ab 100644 --- a/trove/tests/unittests/guestagent/test_cassandra_manager.py +++ b/trove/tests/unittests/guestagent/test_cassandra_manager.py @@ -14,17 +14,18 @@ import os -import testtools from mock import MagicMock from oslo_utils import netutils +import testtools + from trove.common.context import TroveContext from trove.common.instance import ServiceStatuses -from trove.guestagent import volume -from trove.guestagent.datastore.experimental.cassandra import ( - service as cass_service) from trove.guestagent.datastore.experimental.cassandra import ( manager as cass_manager) +from trove.guestagent.datastore.experimental.cassandra import ( + service as cass_service) from trove.guestagent import pkg as pkg +from trove.guestagent import volume class GuestAgentCassandraDBManagerTest(testtools.TestCase): diff --git a/trove/tests/unittests/guestagent/test_couchbase_manager.py b/trove/tests/unittests/guestagent/test_couchbase_manager.py index 60156869dc..ee33cc0ea0 100644 --- a/trove/tests/unittests/guestagent/test_couchbase_manager.py +++ b/trove/tests/unittests/guestagent/test_couchbase_manager.py @@ -12,22 +12,24 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import os import stat import tempfile -import testtools + +import mock from mock import MagicMock from mock import Mock from oslo_utils import netutils -from trove.common import utils +import testtools + from trove.common.context import TroveContext -from trove.guestagent import volume +from trove.common import utils from trove.guestagent import backup -from trove.guestagent.datastore.experimental.couchbase import ( - service as couch_service) from trove.guestagent.datastore.experimental.couchbase import ( manager as couch_manager) +from trove.guestagent.datastore.experimental.couchbase import ( + service as couch_service) +from trove.guestagent import volume class GuestAgentCouchbaseManagerTest(testtools.TestCase): @@ -99,14 +101,14 @@ class GuestAgentCouchbaseManagerTest(testtools.TestCase): return_value=None) backup.restore = MagicMock(return_value=None) - #invocation + # invocation self.manager.prepare(self.context, self.packages, None, 2048, None, device_path=device_path, mount_point='/var/lib/couchbase', backup_info=backup_info, overrides=None, cluster_config=None) - #verification/assertion + # verification/assertion mock_status.begin_install.assert_any_call() couch_service.CouchbaseApp.install_if_needed.assert_any_call( self.packages) @@ -121,18 +123,18 @@ class GuestAgentCouchbaseManagerTest(testtools.TestCase): mock_status = MagicMock() self.manager.appStatus = mock_status couch_service.CouchbaseApp.restart = MagicMock(return_value=None) - #invocation + # invocation self.manager.restart(self.context) - #verification/assertion + # verification/assertion couch_service.CouchbaseApp.restart.assert_any_call() def test_stop_db(self): mock_status = MagicMock() self.manager.appStatus = mock_status couch_service.CouchbaseApp.stop_db = MagicMock(return_value=None) - #invocation + # invocation self.manager.stop_db(self.context) - #verification/assertion + # verification/assertion couch_service.CouchbaseApp.stop_db.assert_any_call( do_not_start_on_reboot=False) diff --git a/trove/tests/unittests/guestagent/test_couchdb_manager.py b/trove/tests/unittests/guestagent/test_couchdb_manager.py index a2a217f69d..d6c2319502 100644 --- a/trove/tests/unittests/guestagent/test_couchdb_manager.py +++ b/trove/tests/unittests/guestagent/test_couchdb_manager.py @@ -14,18 +14,19 @@ import os -import testtools from mock import MagicMock from mock import patch from oslo_utils import netutils +import testtools + from trove.common.context import TroveContext from trove.common.instance import ServiceStatuses -from trove.guestagent import volume -from trove.guestagent.datastore.experimental.couchdb import ( - service as couchdb_service) from trove.guestagent.datastore.experimental.couchdb import ( manager as couchdb_manager) +from trove.guestagent.datastore.experimental.couchdb import ( + service as couchdb_service) from trove.guestagent import pkg as pkg +from trove.guestagent import volume class GuestAgentCouchDBManagerTest(testtools.TestCase): @@ -127,18 +128,18 @@ class GuestAgentCouchDBManagerTest(testtools.TestCase): self.manager.appStatus = mock_status with patch.object(couchdb_service.CouchDBApp, 'restart', return_value=None): - #invocation + # invocation self.manager.restart(self.context) - #verification/assertion + # verification/assertion couchdb_service.CouchDBApp.restart.assert_any_call() def test_stop_db(self): mock_status = MagicMock() self.manager.appStatus = mock_status couchdb_service.CouchDBApp.stop_db = MagicMock(return_value=None) - #invocation + # invocation self.manager.stop_db(self.context) - #verification/assertion + # verification/assertion couchdb_service.CouchDBApp.stop_db.assert_any_call( do_not_start_on_reboot=False) diff --git a/trove/tests/unittests/guestagent/test_db2_manager.py b/trove/tests/unittests/guestagent/test_db2_manager.py index e285565294..00d4029751 100644 --- a/trove/tests/unittests/guestagent/test_db2_manager.py +++ b/trove/tests/unittests/guestagent/test_db2_manager.py @@ -12,18 +12,19 @@ # License for the specific language governing permissions and limitations # under the License. -import testtools from mock import MagicMock from mock import patch +import testtools from testtools.matchers import Is, Equals, Not + from trove.common.context import TroveContext from trove.common.instance import ServiceStatuses -from trove.guestagent import volume -from trove.guestagent.datastore.experimental.db2 import ( - service as db2_service) from trove.guestagent.datastore.experimental.db2 import ( manager as db2_manager) +from trove.guestagent.datastore.experimental.db2 import ( + service as db2_service) from trove.guestagent import pkg as pkg +from trove.guestagent import volume class GuestAgentDB2ManagerTest(testtools.TestCase): @@ -135,9 +136,9 @@ class GuestAgentDB2ManagerTest(testtools.TestCase): self.manager.appStatus = mock_status with patch.object(db2_service.DB2App, 'restart', return_value=None) as restart_mock: - #invocation + # invocation self.manager.restart(self.context) - #verification/assertion + # verification/assertion restart_mock.assert_any_call() def test_stop_db(self): diff --git a/trove/tests/unittests/guestagent/test_dbaas.py b/trove/tests/unittests/guestagent/test_dbaas.py index 5697db9709..00384cf4d3 100644 --- a/trove/tests/unittests/guestagent/test_dbaas.py +++ b/trove/tests/unittests/guestagent/test_dbaas.py @@ -16,64 +16,66 @@ import ConfigParser import os import subprocess import tempfile -from uuid import uuid4 import time +from uuid import uuid4 + from mock import ANY from mock import DEFAULT -from mock import Mock from mock import MagicMock -from mock import PropertyMock +from mock import Mock from mock import patch +from mock import PropertyMock from oslo_utils import netutils import sqlalchemy import testtools -from testtools.matchers import Is from testtools.matchers import Equals +from testtools.matchers import Is from testtools.matchers import Not + from trove.common import cfg -from trove.common.exception import ProcessExecutionError +from trove.common.exception import BadRequest from trove.common.exception import GuestError from trove.common.exception import PollTimeOut -from trove.common.exception import BadRequest -from trove.common import utils +from trove.common.exception import ProcessExecutionError from trove.common import instance as rd_instance +from trove.common import utils from trove.conductor import api as conductor_api -import trove.guestagent.datastore.mysql.service as dbaas -from trove.guestagent import dbaas as dbaas_sr -from trove.guestagent import pkg from trove.guestagent.common import operating_system from trove.guestagent.common.operating_system import FileMode -from trove.guestagent.dbaas import to_gb -from trove.guestagent.dbaas import get_filesystem_volume_stats -from trove.guestagent.datastore.service import BaseDbStatus -from trove.guestagent.datastore.experimental.redis import service as rservice -from trove.guestagent.datastore.experimental.redis.service import RedisApp -from trove.guestagent.datastore.experimental.redis import system as RedisSystem from trove.guestagent.datastore.experimental.cassandra import ( service as cass_service) from trove.guestagent.datastore.experimental.cassandra import ( system as cass_system) -from trove.guestagent.datastore.mysql.service import MySqlAdmin -from trove.guestagent.datastore.mysql.service import MySqlRootAccess -from trove.guestagent.datastore.mysql.service import MySqlApp -from trove.guestagent.datastore.mysql.service import MySqlAppStatus -from trove.guestagent.datastore.mysql.service import KeepAliveConnection from trove.guestagent.datastore.experimental.couchbase import ( service as couchservice) from trove.guestagent.datastore.experimental.couchdb import ( service as couchdb_service) +from trove.guestagent.datastore.experimental.db2 import ( + service as db2service) from trove.guestagent.datastore.experimental.mongodb import ( service as mongo_service) from trove.guestagent.datastore.experimental.mongodb import ( system as mongo_system) -from trove.guestagent.datastore.experimental.vertica.service import VerticaApp -from trove.guestagent.datastore.experimental.vertica.service import ( - VerticaAppStatus) +from trove.guestagent.datastore.experimental.redis import service as rservice +from trove.guestagent.datastore.experimental.redis.service import RedisApp +from trove.guestagent.datastore.experimental.redis import system as RedisSystem from trove.guestagent.datastore.experimental.vertica import ( system as vertica_system) -from trove.guestagent.datastore.experimental.db2 import ( - service as db2service) +from trove.guestagent.datastore.experimental.vertica.service import ( + VerticaAppStatus) +from trove.guestagent.datastore.experimental.vertica.service import VerticaApp +import trove.guestagent.datastore.mysql.service as dbaas +from trove.guestagent.datastore.mysql.service import KeepAliveConnection +from trove.guestagent.datastore.mysql.service import MySqlAdmin +from trove.guestagent.datastore.mysql.service import MySqlApp +from trove.guestagent.datastore.mysql.service import MySqlAppStatus +from trove.guestagent.datastore.mysql.service import MySqlRootAccess +from trove.guestagent.datastore.service import BaseDbStatus from trove.guestagent.db import models +from trove.guestagent import dbaas as dbaas_sr +from trove.guestagent.dbaas import get_filesystem_volume_stats +from trove.guestagent.dbaas import to_gb +from trove.guestagent import pkg from trove.guestagent.volume import VolumeDevice from trove.instance.models import InstanceServiceStatus from trove.tests.unittests.util import util @@ -682,8 +684,8 @@ class MySqlAdminTest(testtools.TestCase): databases = ['mysql'] with patch.object(self.mySqlAdmin, '_get_user', return_value=user): self.mySqlAdmin.grant_access('test_usr', '%', databases) - #since mysql is not a database to be provided access to, - #testing that executed was not called in grant access. + # since mysql is not a database to be provided access to, + # testing that executed was not called in grant access. dbaas.LocalSqlClient.execute.assert_not_called() def test_is_root_enabled(self): @@ -742,8 +744,8 @@ class MySqlAppTest(testtools.TestCase): 'cmd_enable': Mock(), 'cmd_disable': Mock(), 'bin': Mock()} - operating_system.service_discovery = Mock(return_value= - mysql_service) + operating_system.service_discovery = Mock( + return_value=mysql_service) time.sleep = Mock() os.unlink = Mock() dbaas.get_auth_password = Mock() @@ -1586,8 +1588,8 @@ class ServiceRegistryTest(testtools.TestCase): datastore_registry_ext_test = { 'test': 'trove.guestagent.datastore.test.manager.Manager', } - dbaas_sr.get_custom_managers = Mock(return_value= - datastore_registry_ext_test) + dbaas_sr.get_custom_managers = Mock( + return_value=datastore_registry_ext_test) test_dict = dbaas_sr.datastore_registry() self.assertEqual(datastore_registry_ext_test.get('test', None), test_dict.get('test')) @@ -1621,8 +1623,8 @@ class ServiceRegistryTest(testtools.TestCase): 'mysql': 'trove.guestagent.datastore.mysql.' 'manager.Manager123', } - dbaas_sr.get_custom_managers = Mock(return_value= - datastore_registry_ext_test) + dbaas_sr.get_custom_managers = Mock( + return_value=datastore_registry_ext_test) test_dict = dbaas_sr.datastore_registry() self.assertEqual('trove.guestagent.datastore.mysql.' 'manager.Manager123', @@ -1654,8 +1656,8 @@ class ServiceRegistryTest(testtools.TestCase): def test_datastore_registry_with_blank_dict(self): datastore_registry_ext_test = dict() - dbaas_sr.get_custom_managers = Mock(return_value= - datastore_registry_ext_test) + dbaas_sr.get_custom_managers = Mock( + return_value=datastore_registry_ext_test) test_dict = dbaas_sr.datastore_registry() self.assertEqual('trove.guestagent.datastore.mysql.' 'manager.Manager', diff --git a/trove/tests/unittests/guestagent/test_dbmodels.py b/trove/tests/unittests/guestagent/test_dbmodels.py index be5fe7dde8..e31e7cc9a9 100644 --- a/trove/tests/unittests/guestagent/test_dbmodels.py +++ b/trove/tests/unittests/guestagent/test_dbmodels.py @@ -11,9 +11,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import testtools -from trove.guestagent.db import models as dbmodels from mock import MagicMock +import testtools + +from trove.guestagent.db import models as dbmodels class MySQLDatabaseTest(testtools.TestCase): diff --git a/trove/tests/unittests/guestagent/test_models.py b/trove/tests/unittests/guestagent/test_models.py index bd1178660f..cc78411a7e 100644 --- a/trove/tests/unittests/guestagent/test_models.py +++ b/trove/tests/unittests/guestagent/test_models.py @@ -12,14 +12,16 @@ # License for the specific language governing permissions and limitations # under the License. -import testtools -from mock import Mock, MagicMock -from trove.guestagent import models -from trove.common import utils -from trove.db.sqlalchemy import api as dbapi -from trove.db import models as dbmodels from datetime import datetime +from mock import Mock, MagicMock +import testtools + +from trove.common import utils +from trove.db import models as dbmodels +from trove.db.sqlalchemy import api as dbapi +from trove.guestagent import models + class AgentHeartBeatTest(testtools.TestCase): def setUp(self): diff --git a/trove/tests/unittests/guestagent/test_mongodb_cluster_manager.py b/trove/tests/unittests/guestagent/test_mongodb_cluster_manager.py index f459ebf2b6..2dbf023c7f 100644 --- a/trove/tests/unittests/guestagent/test_mongodb_cluster_manager.py +++ b/trove/tests/unittests/guestagent/test_mongodb_cluster_manager.py @@ -13,18 +13,18 @@ # License for the specific language governing permissions and limitations # under the License. -import testtools - from mock import patch from oslo_utils import netutils +import testtools + +from trove.common.context import TroveContext from trove.common import instance as ds_instance from trove.common import utils -from trove.common.context import TroveContext -from trove.guestagent import volume from trove.guestagent.datastore.experimental.mongodb import ( service as mongo_service) from trove.guestagent.datastore.experimental.mongodb.manager import Manager from trove.guestagent.datastore.experimental.mongodb.service import MongoDBApp +from trove.guestagent import volume class GuestAgentMongoDBClusterManagerTest(testtools.TestCase): diff --git a/trove/tests/unittests/guestagent/test_mongodb_manager.py b/trove/tests/unittests/guestagent/test_mongodb_manager.py index 23f27e9d28..bc31c0d164 100644 --- a/trove/tests/unittests/guestagent/test_mongodb_manager.py +++ b/trove/tests/unittests/guestagent/test_mongodb_manager.py @@ -14,16 +14,17 @@ import os -import testtools from mock import MagicMock from mock import patch -from trove.common import utils +import testtools + from trove.common.context import TroveContext -from trove.guestagent import volume -from trove.guestagent.datastore.experimental.mongodb import ( - service as mongo_service) +from trove.common import utils from trove.guestagent.datastore.experimental.mongodb import ( manager as mongo_manager) +from trove.guestagent.datastore.experimental.mongodb import ( + service as mongo_service) +from trove.guestagent import volume from trove.guestagent.volume import VolumeDevice diff --git a/trove/tests/unittests/guestagent/test_mysql_manager.py b/trove/tests/unittests/guestagent/test_mysql_manager.py index 050ac2b310..d21bf3160c 100644 --- a/trove/tests/unittests/guestagent/test_mysql_manager.py +++ b/trove/tests/unittests/guestagent/test_mysql_manager.py @@ -14,22 +14,23 @@ import os -import testtools from mock import MagicMock from mock import patch +from proboscis.asserts import assert_equal +import testtools from testtools.matchers import Is, Equals, Not + from trove.common.context import TroveContext from trove.common.exception import InsufficientSpaceForReplica from trove.common.exception import ProcessExecutionError from trove.common import instance as rd_instance -from trove.guestagent import dbaas as base_dbaas -from trove.guestagent import volume +from trove.guestagent import backup from trove.guestagent.datastore.mysql.manager import Manager import trove.guestagent.datastore.mysql.service as dbaas -from trove.guestagent import backup -from trove.guestagent.volume import VolumeDevice +from trove.guestagent import dbaas as base_dbaas from trove.guestagent import pkg as pkg -from proboscis.asserts import assert_equal +from trove.guestagent import volume +from trove.guestagent.volume import VolumeDevice class GuestAgentManagerTest(testtools.TestCase): diff --git a/trove/tests/unittests/guestagent/test_operating_system.py b/trove/tests/unittests/guestagent/test_operating_system.py index a281d618b9..4c089b9117 100644 --- a/trove/tests/unittests/guestagent/test_operating_system.py +++ b/trove/tests/unittests/guestagent/test_operating_system.py @@ -14,14 +14,16 @@ # under the License. import itertools -from mock import call, patch import os -from oslo_concurrency.processutils import UnknownArgumentError import stat + +from mock import call, patch +from oslo_concurrency.processutils import UnknownArgumentError import testtools from testtools import ExpectedException -from trove.common import utils + from trove.common import exception +from trove.common import utils from trove.guestagent.common import operating_system from trove.guestagent.common.operating_system import FileMode diff --git a/trove/tests/unittests/guestagent/test_pkg.py b/trove/tests/unittests/guestagent/test_pkg.py index 069abf5724..f429c1de53 100644 --- a/trove/tests/unittests/guestagent/test_pkg.py +++ b/trove/tests/unittests/guestagent/test_pkg.py @@ -13,13 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. +import commands import os +import re import subprocess -import testtools + from mock import Mock, MagicMock, patch import pexpect -import commands -import re +import testtools from trove.common import exception from trove.common import utils diff --git a/trove/tests/unittests/guestagent/test_redis_manager.py b/trove/tests/unittests/guestagent/test_redis_manager.py index fd626ec48d..7ad8da1043 100644 --- a/trove/tests/unittests/guestagent/test_redis_manager.py +++ b/trove/tests/unittests/guestagent/test_redis_manager.py @@ -12,15 +12,16 @@ # License for the specific language governing permissions and limitations # under the License. -import testtools from mock import MagicMock +import testtools + from trove.common.context import TroveContext -from trove.guestagent.datastore.experimental.redis.manager import ( - Manager as RedisManager) -from trove.guestagent.datastore.experimental.redis import ( - service as redis_service) from trove.guestagent import backup from trove.guestagent.common import operating_system +from trove.guestagent.datastore.experimental.redis import ( + service as redis_service) +from trove.guestagent.datastore.experimental.redis.manager import ( + Manager as RedisManager) from trove.guestagent.volume import VolumeDevice diff --git a/trove/tests/unittests/guestagent/test_vertica_manager.py b/trove/tests/unittests/guestagent/test_vertica_manager.py index 6d2cdf7172..1c781d8059 100644 --- a/trove/tests/unittests/guestagent/test_vertica_manager.py +++ b/trove/tests/unittests/guestagent/test_vertica_manager.py @@ -1,28 +1,29 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. -import testtools from mock import MagicMock from mock import patch +import testtools + +from trove.common.context import TroveContext from trove.common.exception import DatastoreOperationNotSupported from trove.common import instance as rd_instance -from trove.common.context import TroveContext -from trove.guestagent import dbaas -from trove.guestagent import volume from trove.guestagent.datastore.experimental.vertica.manager import Manager -from trove.guestagent.datastore.experimental.vertica.service import VerticaApp from trove.guestagent.datastore.experimental.vertica.service import ( VerticaAppStatus) +from trove.guestagent.datastore.experimental.vertica.service import VerticaApp +from trove.guestagent import dbaas +from trove.guestagent import volume from trove.guestagent.volume import VolumeDevice @@ -137,18 +138,18 @@ class GuestAgentManagerTest(testtools.TestCase): mock_status = MagicMock() self.manager.appStatus = mock_status VerticaApp.restart = MagicMock(return_value=None) - #invocation + # invocation self.manager.restart(self.context) - #verification/assertion + # verification/assertion VerticaApp.restart.assert_any_call() def test_stop_db(self): mock_status = MagicMock() self.manager.appStatus = mock_status VerticaApp.stop_db = MagicMock(return_value=None) - #invocation + # invocation self.manager.stop_db(self.context) - #verification/assertion + # verification/assertion VerticaApp.stop_db.assert_any_call(do_not_start_on_reboot=False) @patch.object(VerticaApp, 'install_vertica') diff --git a/trove/tests/unittests/guestagent/test_volume.py b/trove/tests/unittests/guestagent/test_volume.py index 00ecc05862..bccc003691 100644 --- a/trove/tests/unittests/guestagent/test_volume.py +++ b/trove/tests/unittests/guestagent/test_volume.py @@ -12,12 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. import os -import testtools -import pexpect + from mock import Mock, MagicMock, patch, mock_open -from trove.guestagent import volume -from trove.common import utils +import pexpect +import testtools + from trove.common.exception import GuestError, ProcessExecutionError +from trove.common import utils +from trove.guestagent import volume def _setUp_fake_spawn(return_val=0): diff --git a/trove/tests/unittests/instance/test_instance_controller.py b/trove/tests/unittests/instance/test_instance_controller.py index 4c957fb6cd..ed0ff244bc 100644 --- a/trove/tests/unittests/instance/test_instance_controller.py +++ b/trove/tests/unittests/instance/test_instance_controller.py @@ -13,13 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. # +import jsonschema from mock import Mock from testtools.matchers import Is, Equals from testtools.testcase import skip + from trove.common import apischema from trove.instance.service import InstanceController from trove.tests.unittests import trove_testtools -import jsonschema class TestInstanceController(trove_testtools.TestCase): diff --git a/trove/tests/unittests/instance/test_instance_models.py b/trove/tests/unittests/instance/test_instance_models.py index 75e9e6af7f..e3b12d2a1d 100644 --- a/trove/tests/unittests/instance/test_instance_models.py +++ b/trove/tests/unittests/instance/test_instance_models.py @@ -11,7 +11,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import uuid + from mock import Mock, patch + from trove.backup import models as backup_models from trove.common import cfg from trove.common import exception @@ -19,16 +22,15 @@ from trove.common.instance import ServiceStatuses from trove.datastore import models as datastore_models from trove.instance import models from trove.instance.models import DBInstance +from trove.instance.models import filter_ips from trove.instance.models import Instance from trove.instance.models import InstanceServiceStatus from trove.instance.models import SimpleInstance -from trove.instance.models import filter_ips from trove.instance.tasks import InstanceTasks from trove.taskmanager import api as task_api from trove.tests.fakes import nova from trove.tests.unittests import trove_testtools from trove.tests.unittests.util import util -import uuid CONF = cfg.CONF @@ -136,8 +138,7 @@ class CreateInstanceTest(trove_testtools.TestCase): name=self.name, flavor_id=self.flavor_id, tenant_id=self.tenant_id, volume_size=self.volume_size, - datastore_version_id= - self.datastore_version.id, + datastore_version_id=self.datastore_version.id, task_status=InstanceTasks.BUILDING, configuration_id=self.configuration ) @@ -200,7 +201,7 @@ class CreateInstanceTest(trove_testtools.TestCase): "given flavor or volume.", str(exc)) def test_can_restore_from_backup_with_almost_equal_size(self): - #target size equals to "1Gb" + # target size equals to "1Gb" self.backup.size = 0.99 self.backup.save() instance = models.Instance.create( diff --git a/trove/tests/unittests/mgmt/test_clusters.py b/trove/tests/unittests/mgmt/test_clusters.py index 0d481fb35b..e4a9e267d2 100644 --- a/trove/tests/unittests/mgmt/test_clusters.py +++ b/trove/tests/unittests/mgmt/test_clusters.py @@ -1,15 +1,15 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. from mock import Mock, patch diff --git a/trove/tests/unittests/mgmt/test_models.py b/trove/tests/unittests/mgmt/test_models.py index fc6854bfaf..00247428b2 100644 --- a/trove/tests/unittests/mgmt/test_models.py +++ b/trove/tests/unittests/mgmt/test_models.py @@ -14,27 +14,28 @@ # under the License. # import uuid -from mock import MagicMock, patch, ANY -from testtools.matchers import Equals, Is, Not +from mock import MagicMock, patch, ANY from novaclient.v2 import Client from novaclient.v2.flavors import FlavorManager, Flavor from novaclient.v2.servers import Server, ServerManager from oslo_config import cfg +from testtools.matchers import Equals, Is, Not + from trove.backup.models import Backup from trove.common.context import TroveContext from trove.common import exception from trove.common import instance as rd_instance from trove.common import remote from trove.datastore import models as datastore_models +import trove.extensions.mgmt.instances.models as mgmtmodels from trove.guestagent.api import API from trove.instance.models import DBInstance from trove.instance.models import InstanceServiceStatus from trove.instance.tasks import InstanceTasks -import trove.extensions.mgmt.instances.models as mgmtmodels +from trove import rpc from trove.tests.unittests import trove_testtools from trove.tests.unittests.util import util -from trove import rpc CONF = cfg.CONF @@ -87,13 +88,11 @@ class MockMgmtInstanceTest(trove_testtools.TestCase): name='test_name', id=str(uuid.uuid4()), flavor_id='flavor_1', - datastore_version_id= - version.id, + datastore_version_id=version.id, compute_instance_id='compute_id_1', server_id='server_id_1', tenant_id='tenant_id_1', - server_status= - rd_instance.ServiceStatuses. + server_status=rd_instance.ServiceStatuses. BUILDING.api_status, deleted=False) instance.save() diff --git a/trove/tests/unittests/mysql/test_user_controller.py b/trove/tests/unittests/mysql/test_user_controller.py index 870009a945..b14f508f30 100644 --- a/trove/tests/unittests/mysql/test_user_controller.py +++ b/trove/tests/unittests/mysql/test_user_controller.py @@ -13,12 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. # +import jsonschema from testtools.matchers import Is + from trove.extensions.mysql.service import SchemaController from trove.extensions.mysql.service import UserAccessController from trove.extensions.mysql.service import UserController from trove.tests.unittests import trove_testtools -import jsonschema class TestUserController(trove_testtools.TestCase): @@ -46,11 +47,11 @@ class TestUserController(trove_testtools.TestCase): schema = self.controller.get_schema('create', body) validator = jsonschema.Draft4Validator(schema) self.assertTrue(validator.is_valid(body)) - #TODO(zed): Restore after API version increment - #errors = sorted(validator.iter_errors(body), key=lambda e: e.path) - #self.assertThat(len(errors), Is(1)) - #self.assertThat(errors[0].message, Equals("[] is too short")) - #self.assertThat(errors[0].path.pop(), Equals("users")) + # TODO(zed): Restore after API version increment + # errors = sorted(validator.iter_errors(body), key=lambda e: e.path) + # self.assertThat(len(errors), Is(1)) + # self.assertThat(errors[0].message, Equals("[] is too short")) + # self.assertThat(errors[0].path.pop(), Equals("users")) def test_validate_create_short_password(self): body = {"users": [{"name": "joe", "password": ""}]} @@ -114,7 +115,7 @@ class TestUserController(trove_testtools.TestCase): "password": "123"}]} schema = self.controller.get_schema('create', body) validator = jsonschema.Draft4Validator(schema) - #TODO(zed): After API increment, this will NOT be valid. + # TODO(zed): After API increment, this will NOT be valid. self.assertTrue(validator.is_valid(body)) def test_validate_create_complete_db(self): @@ -169,11 +170,11 @@ class TestUserController(trove_testtools.TestCase): schema = self.controller.get_schema('update_all', body) validator = jsonschema.Draft4Validator(schema) self.assertTrue(validator.is_valid(body)) - #TODO(zed): Restore after API version increment - #errors = sorted(validator.iter_errors(body), key=lambda e: e.path) - #self.assertThat(len(errors), Is(1)) - #self.assertThat(errors[0].message, Equals("[] is too short")) - #self.assertThat(errors[0].path.pop(), Equals("users")) + # TODO(zed): Restore after API version increment + # errors = sorted(validator.iter_errors(body), key=lambda e: e.path) + # self.assertThat(len(errors), Is(1)) + # self.assertThat(errors[0].message, Equals("[] is too short")) + # self.assertThat(errors[0].path.pop(), Equals("users")) def test_validate_update_short_password(self): body = {"users": [{"name": "joe", "password": ""}]} @@ -236,10 +237,10 @@ class TestUserController(trove_testtools.TestCase): schema = self.controller.get_schema('update_all', body) validator = jsonschema.Draft4Validator(schema) self.assertTrue(validator.is_valid(body)) - #TODO(zed): Restore after API version increment - #errors = sorted(validator.iter_errors(body), key=lambda e: e.path) - #self.assertThat(len(errors), Is(1)) - #self.assertThat(errors[0].message, Equals('[] is too short')) + # TODO(zed): Restore after API version increment + # errors = sorted(validator.iter_errors(body), key=lambda e: e.path) + # self.assertThat(len(errors), Is(1)) + # self.assertThat(errors[0].message, Equals('[] is too short')) def test_validate_update_short_name(self): body = {"users": [{"name": ""}]} @@ -310,11 +311,11 @@ class TestUserAccessController(trove_testtools.TestCase): schema = (UserAccessController()).get_schema('update_all', body) validator = jsonschema.Draft4Validator(schema) self.assertTrue(validator.is_valid(body)) - #TODO(zed): Restore after API version increment - #errors = sorted(validator.iter_errors(body), key=lambda e: e.path) - #self.assertThat(len(errors), Is(1)) - #self.assertThat(errors[0].message, Equals("[] is too short")) - #self.assertThat(errors[0].path.pop(), Equals("databases")) + # TODO(zed): Restore after API version increment + # errors = sorted(validator.iter_errors(body), key=lambda e: e.path) + # self.assertThat(len(errors), Is(1)) + # self.assertThat(errors[0].message, Equals("[] is too short")) + # self.assertThat(errors[0].path.pop(), Equals("databases")) class TestSchemaController(trove_testtools.TestCase): diff --git a/trove/tests/unittests/network/test_neutron_driver.py b/trove/tests/unittests/network/test_neutron_driver.py index 5ddb5d3ede..0060012b23 100644 --- a/trove/tests/unittests/network/test_neutron_driver.py +++ b/trove/tests/unittests/network/test_neutron_driver.py @@ -18,12 +18,13 @@ from mock import MagicMock from mock import Mock from neutronclient.common import exceptions as neutron_exceptions from neutronclient.v2_0 import client as NeutronClient + from trove.common import exception -from trove.common import remote from trove.common.models import NetworkRemoteModelBase +from trove.common import remote +from trove.extensions.security_group.models import RemoteSecurityGroup from trove.network import neutron from trove.network.neutron import NeutronDriver as driver -from trove.extensions.security_group.models import RemoteSecurityGroup from trove.tests.unittests import trove_testtools diff --git a/trove/tests/unittests/quota/test_quota.py b/trove/tests/unittests/quota/test_quota.py index 251562669c..4db734d195 100644 --- a/trove/tests/unittests/quota/test_quota.py +++ b/trove/tests/unittests/quota/test_quota.py @@ -14,17 +14,18 @@ from mock import Mock, MagicMock, patch from testtools import skipIf -from trove.quota.quota import DbQuotaDriver -from trove.quota.models import Resource + +from trove.common import cfg +from trove.common import exception +from trove.db.models import DatabaseModelBase +from trove.extensions.mgmt.quota.service import QuotaController from trove.quota.models import Quota from trove.quota.models import QuotaUsage from trove.quota.models import Reservation -from trove.db.models import DatabaseModelBase -from trove.extensions.mgmt.quota.service import QuotaController -from trove.common import exception -from trove.common import cfg -from trove.quota.quota import run_with_quotas +from trove.quota.models import Resource +from trove.quota.quota import DbQuotaDriver from trove.quota.quota import QUOTAS +from trove.quota.quota import run_with_quotas from trove.tests.unittests import trove_testtools """ Unit tests for the classes and functions in DbQuotaDriver.py. diff --git a/trove/tests/unittests/router/test_router.py b/trove/tests/unittests/router/test_router.py index 2cc5ea6931..34e527061d 100644 --- a/trove/tests/unittests/router/test_router.py +++ b/trove/tests/unittests/router/test_router.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +from routes import Mapper + from trove.common.wsgi import Router, Fault from trove.tests.unittests import trove_testtools -from routes import Mapper class FakeRequst(object): diff --git a/trove/tests/unittests/secgroups/test_security_group.py b/trove/tests/unittests/secgroups/test_security_group.py index 69ccfebe6d..021a430889 100644 --- a/trove/tests/unittests/secgroups/test_security_group.py +++ b/trove/tests/unittests/secgroups/test_security_group.py @@ -13,14 +13,16 @@ # under the License. import uuid -import trove.common.remote + from mock import Mock from mock import patch +from novaclient import exceptions as nova_exceptions + from trove.common import exception -from trove.tests.fakes import nova +import trove.common.remote from trove.extensions.security_group import models as sec_mod from trove.instance import models as inst_model -from novaclient import exceptions as nova_exceptions +from trove.tests.fakes import nova from trove.tests.unittests import trove_testtools @@ -37,9 +39,9 @@ class Security_Group_Exceptions_Test(trove_testtools.TestCase): self.context = Mock() self.FakeClient = nova.fake_create_nova_client(self.context) - fException = Mock(side_effect= - lambda *args, **kwargs: - self._raise(nova_exceptions.ClientException("Test"))) + fException = Mock( + side_effect=lambda *args, **kwargs: self._raise( + nova_exceptions.ClientException("Test"))) self.FakeClient.security_groups.create = fException self.FakeClient.security_groups.delete = fException @@ -110,9 +112,9 @@ class SecurityGroupDeleteTest(trove_testtools.TestCase): self.original_find_by = ( sec_mod.SecurityGroupInstanceAssociation.find_by) self.original_delete = sec_mod.SecurityGroupInstanceAssociation.delete - self.fException = Mock(side_effect= - lambda *args, **kwargs: - self._raise(exception.ModelNotFoundError())) + self.fException = Mock( + side_effect=lambda *args, **kwargs: self._raise( + exception.ModelNotFoundError())) def tearDown(self): super(SecurityGroupDeleteTest, self).tearDown() @@ -133,10 +135,9 @@ class SecurityGroupDeleteTest(trove_testtools.TestCase): def test_get_security_group_from_assoc_with_db_exception(self): - fException = Mock(side_effect= - lambda *args, **kwargs: - self._raise(nova_exceptions. - ClientException('TEST'))) + fException = Mock( + side_effect=lambda *args, **kwargs: self._raise( + nova_exceptions.ClientException('TEST'))) i_id = uuid.uuid4() class new_fake_RemoteSecGrAssoc(object): diff --git a/trove/tests/unittests/taskmanager/test_clusters.py b/trove/tests/unittests/taskmanager/test_clusters.py index 47a20ae515..9ce1b0cea1 100644 --- a/trove/tests/unittests/taskmanager/test_clusters.py +++ b/trove/tests/unittests/taskmanager/test_clusters.py @@ -50,8 +50,7 @@ class MongoDbClusterTasksTest(trove_testtools.TestCase): self.dbinst1 = DBInstance(InstanceTasks.NONE, id="1", name="member1", compute_instance_id="compute-1", task_id=InstanceTasks.NONE._code, - task_description= - InstanceTasks.NONE._db_text, + task_description=InstanceTasks.NONE._db_text, volume_id="volume-1", datastore_version_id="1", cluster_id=self.cluster_id, @@ -60,8 +59,7 @@ class MongoDbClusterTasksTest(trove_testtools.TestCase): self.dbinst2 = DBInstance(InstanceTasks.NONE, id="2", name="member2", compute_instance_id="compute-2", task_id=InstanceTasks.NONE._code, - task_description= - InstanceTasks.NONE._db_text, + task_description=InstanceTasks.NONE._db_text, volume_id="volume-2", datastore_version_id="1", cluster_id=self.cluster_id, @@ -70,8 +68,7 @@ class MongoDbClusterTasksTest(trove_testtools.TestCase): self.dbinst3 = DBInstance(InstanceTasks.NONE, id="3", name="mongos", compute_instance_id="compute-3", task_id=InstanceTasks.NONE._code, - task_description= - InstanceTasks.NONE._db_text, + task_description=InstanceTasks.NONE._db_text, volume_id="volume-3", datastore_version_id="1", cluster_id=self.cluster_id, @@ -81,8 +78,7 @@ class MongoDbClusterTasksTest(trove_testtools.TestCase): name="configserver", compute_instance_id="compute-4", task_id=InstanceTasks.NONE._code, - task_description= - InstanceTasks.NONE._db_text, + task_description=InstanceTasks.NONE._db_text, volume_id="volume-4", datastore_version_id="1", cluster_id=self.cluster_id, diff --git a/trove/tests/unittests/taskmanager/test_models.py b/trove/tests/unittests/taskmanager/test_models.py index 9fc54f4f02..2e6244a01c 100644 --- a/trove/tests/unittests/taskmanager/test_models.py +++ b/trove/tests/unittests/taskmanager/test_models.py @@ -12,44 +12,45 @@ # License for the specific language governing permissions and limitations # under the License. import datetime +import os +from tempfile import NamedTemporaryFile +import uuid -from mock import Mock, MagicMock, patch -from testtools.matchers import Equals, Is from cinderclient import exceptions as cinder_exceptions -from novaclient import exceptions as nova_exceptions -import novaclient.v2.servers -import novaclient.v2.flavors import cinderclient.v2.client as cinderclient +from mock import Mock, MagicMock, patch +from novaclient import exceptions as nova_exceptions +import novaclient.v2.flavors +import novaclient.v2.servers from oslo_utils import timeutils +from swiftclient.client import ClientException +from testtools.matchers import Equals, Is + import trove.backup.models -import trove.common.context -from trove.datastore import models as datastore_models -import trove.db.models -from trove.taskmanager import models as taskmanager_models -import trove.guestagent.api from trove.backup import models as backup_models from trove.backup import state -from trove.common import remote +import trove.common.context from trove.common.exception import GuestError +from trove.common.exception import MalformedSecurityGroupRuleError from trove.common.exception import PollTimeOut from trove.common.exception import TroveError -from trove.common.exception import MalformedSecurityGroupRuleError from trove.common.instance import ServiceStatuses +from trove.common import remote +import trove.common.template as template +from trove.common import utils +from trove.datastore import models as datastore_models +import trove.db.models from trove.extensions.mysql import models as mysql_models +import trove.guestagent.api from trove.instance.models import BaseInstance +from trove.instance.models import DBInstance from trove.instance.models import InstanceServiceStatus from trove.instance.models import InstanceStatus -from trove.instance.models import DBInstance from trove.instance.tasks import InstanceTasks +from trove import rpc +from trove.taskmanager import models as taskmanager_models from trove.tests.unittests import trove_testtools from trove.tests.unittests.util import util -from trove.common import utils -from trove import rpc -from swiftclient.client import ClientException -from tempfile import NamedTemporaryFile -import os -import trove.common.template as template -import uuid INST_ID = 'dbinst-id-1' VOLUME_ID = 'volume-id-1' diff --git a/trove/tests/unittests/taskmanager/test_vertica_clusters.py b/trove/tests/unittests/taskmanager/test_vertica_clusters.py index cc0c747079..e5790ae044 100644 --- a/trove/tests/unittests/taskmanager/test_vertica_clusters.py +++ b/trove/tests/unittests/taskmanager/test_vertica_clusters.py @@ -1,15 +1,15 @@ -#Copyright [2015] Hewlett-Packard Development Company, L.P. -#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 +# Copyright [2015] Hewlett-Packard Development Company, L.P. +# 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 +# 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. +# 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. import datetime @@ -55,8 +55,7 @@ class VerticaClusterTasksTest(trove_testtools.TestCase): self.dbinst1 = DBInstance(InstanceTasks.NONE, id="1", name="member1", compute_instance_id="compute-1", task_id=InstanceTasks.NONE._code, - task_description= - InstanceTasks.NONE._db_text, + task_description=InstanceTasks.NONE._db_text, volume_id="volume-1", datastore_version_id="1", cluster_id=self.cluster_id, @@ -64,8 +63,7 @@ class VerticaClusterTasksTest(trove_testtools.TestCase): self.dbinst2 = DBInstance(InstanceTasks.NONE, id="2", name="member2", compute_instance_id="compute-2", task_id=InstanceTasks.NONE._code, - task_description= - InstanceTasks.NONE._db_text, + task_description=InstanceTasks.NONE._db_text, volume_id="volume-2", datastore_version_id="1", cluster_id=self.cluster_id, @@ -73,8 +71,7 @@ class VerticaClusterTasksTest(trove_testtools.TestCase): self.dbinst3 = DBInstance(InstanceTasks.NONE, id="3", name="member3", compute_instance_id="compute-3", task_id=InstanceTasks.NONE._code, - task_description= - InstanceTasks.NONE._db_text, + task_description=InstanceTasks.NONE._db_text, volume_id="volume-3", datastore_version_id="1", cluster_id=self.cluster_id, diff --git a/trove/tests/unittests/upgrade/test_controller.py b/trove/tests/unittests/upgrade/test_controller.py index e21571e7ef..93d43d2f13 100644 --- a/trove/tests/unittests/upgrade/test_controller.py +++ b/trove/tests/unittests/upgrade/test_controller.py @@ -13,11 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. # +import jsonschema from mock import Mock, MagicMock, patch + from trove.extensions.mgmt.upgrade.models import UpgradeMessageSender from trove.extensions.mgmt.upgrade.service import UpgradeController from trove.tests.unittests import trove_testtools -import jsonschema class TestUpgradeController(trove_testtools.TestCase): diff --git a/trove/tests/util/__init__.py b/trove/tests/util/__init__.py index baf48131f2..f0d3b25914 100644 --- a/trove/tests/util/__init__.py +++ b/trove/tests/util/__init__.py @@ -20,13 +20,9 @@ .. automodule:: utils :platform: Unix :synopsis: Tests for Nova. -.. moduleauthor:: Nirmal Ranganathan -.. moduleauthor:: Tim Simpson """ import subprocess - -from trove.tests.config import CONFIG as test_config from urllib import unquote try: @@ -34,20 +30,20 @@ try: except ImportError: EVENT_AVAILABLE = False -from sqlalchemy import create_engine - -from troveclient.compat import exceptions - from proboscis.asserts import assert_true from proboscis.asserts import Check from proboscis.asserts import fail from proboscis import SkipTest +from sqlalchemy import create_engine from troveclient.compat import Dbaas -from trove.tests.util import test_config as CONFIG -from trove.tests.util.client import TestClient as TestClient -from trove.tests.util.users import Requirements -from trove.common.utils import import_object +from troveclient.compat import exceptions + from trove.common.utils import import_class +from trove.common.utils import import_object +from trove.tests.config import CONFIG as test_config +from trove.tests.util.client import TestClient as TestClient +from trove.tests.util import test_config as CONFIG +from trove.tests.util.users import Requirements WHITE_BOX = test_config.white_box @@ -236,7 +232,7 @@ def assert_contains(exception_message, substrings): # https://bugs.launchpad.net/trove-integration/+bug/1228306 -#TODO(cp16net): DO NOT USE needs to be removed +# TODO(cp16net): DO NOT USE needs to be removed def mysql_connection(): cls = CONFIG.get('mysql_connection', "local.MySqlConnection") diff --git a/trove/tests/util/check.py b/trove/tests/util/check.py index a371aa3ceb..5fdebbdbab 100644 --- a/trove/tests/util/check.py +++ b/trove/tests/util/check.py @@ -16,11 +16,12 @@ """Like asserts, but does not raise an exception until the end of a block.""" import traceback -from proboscis.asserts import ASSERTION_ERROR + from proboscis.asserts import assert_equal from proboscis.asserts import assert_false from proboscis.asserts import assert_not_equal from proboscis.asserts import assert_true +from proboscis.asserts import ASSERTION_ERROR from proboscis.asserts import Check diff --git a/trove/tests/util/client.py b/trove/tests/util/client.py index de5abb454c..163e62a1b2 100644 --- a/trove/tests/util/client.py +++ b/trove/tests/util/client.py @@ -20,8 +20,6 @@ .. automodule:: utils :platform: Unix :synopsis: Tests for Nova. -.. moduleauthor:: Nirmal Ranganathan -.. moduleauthor:: Tim Simpson """ diff --git a/trove/tests/util/event_simulator.py b/trove/tests/util/event_simulator.py index 05f63b2b57..bae25ba5f3 100644 --- a/trove/tests/util/event_simulator.py +++ b/trove/tests/util/event_simulator.py @@ -26,9 +26,9 @@ to sit around for the designated time, which greatly speeds up the time it takes to run the tests. """ import eventlet -from eventlet import spawn as true_spawn from eventlet.event import Event from eventlet.semaphore import Semaphore +from eventlet import spawn as true_spawn class Coroutine(object): @@ -190,7 +190,7 @@ def fake_spawn_n(func, *args, **kw): def fake_spawn(time_from_now_in_seconds, func, *args, **kw): """Fakes eventlet's spawn function by adding a fake thread.""" def thread_start(): - #fake_sleep(time_from_now_in_seconds) + # fake_sleep(time_from_now_in_seconds) return func(*args, **kw) cr = Coroutine(thread_start) diff --git a/trove/tests/util/mysql.py b/trove/tests/util/mysql.py index 5ea166cb94..bb33bd764c 100644 --- a/trove/tests/util/mysql.py +++ b/trove/tests/util/mysql.py @@ -16,17 +16,19 @@ # under the License. # -import pexpect import re + +import pexpect from sqlalchemy import create_engine -from trove import tests -from trove.tests.config import CONFIG from sqlalchemy.exc import OperationalError try: from sqlalchemy.exc import ResourceClosedError except ImportError: ResourceClosedError = Exception +from trove import tests +from trove.tests.config import CONFIG + def create_mysql_connection(host, user, password): connection = CONFIG.mysql_connection_method diff --git a/trove/tests/util/usage.py b/trove/tests/util/usage.py index ab6478aaaf..4cffd322be 100644 --- a/trove/tests/util/usage.py +++ b/trove/tests/util/usage.py @@ -15,12 +15,13 @@ from collections import defaultdict -import trove.openstack.common.log as logging -from trove.common import utils -from trove.tests.config import CONFIG import proboscis.asserts as asserts from proboscis.dependencies import SkipTest +from trove.common import utils +import trove.openstack.common.log as logging +from trove.tests.config import CONFIG + LOG = logging.getLogger(__name__) MESSAGE_QUEUE = defaultdict(list)