diff --git a/swift/account/auditor.py b/swift/account/auditor.py index e93e8a9ca6..f38e475c19 100644 --- a/swift/account/auditor.py +++ b/swift/account/auditor.py @@ -19,8 +19,7 @@ from random import random import swift.common.db -from swift.account import server as account_server -from swift.account.backend import AccountBroker +from swift.account.backend import AccountBroker, DATADIR from swift.common.utils import get_logger, audit_location_generator, \ config_true_value, dump_recon_cache, ratelimit_sleep from swift.common.daemon import Daemon @@ -49,8 +48,7 @@ def __init__(self, conf): self.rcache = os.path.join(self.recon_cache_path, "account.recon") def _one_audit_pass(self, reported): - all_locs = audit_location_generator(self.devices, - account_server.DATADIR, '.db', + all_locs = audit_location_generator(self.devices, DATADIR, '.db', mount_check=self.mount_check, logger=self.logger) for path, device, partition in all_locs: diff --git a/swift/account/backend.py b/swift/account/backend.py index 5de41ef2b7..f29e64d93b 100644 --- a/swift/account/backend.py +++ b/swift/account/backend.py @@ -28,6 +28,8 @@ from swift.common.db import DatabaseBroker, DatabaseConnectionError, \ PENDING_CAP, PICKLE_PROTOCOL, utf8encode +DATADIR = 'accounts' + class AccountBroker(DatabaseBroker): """Encapsulates working with an account database.""" diff --git a/swift/account/reaper.py b/swift/account/reaper.py index eb7084ffd6..dbb95891e6 100644 --- a/swift/account/reaper.py +++ b/swift/account/reaper.py @@ -23,8 +23,7 @@ from eventlet import GreenPool, sleep, Timeout import swift.common.db -from swift.account.server import DATADIR -from swift.account.backend import AccountBroker +from swift.account.backend import AccountBroker, DATADIR from swift.common.direct_client import direct_delete_container, \ direct_delete_object, direct_get_container from swift.common.exceptions import ClientException diff --git a/swift/account/replicator.py b/swift/account/replicator.py index 52205b632f..ad9ad9fd5b 100644 --- a/swift/account/replicator.py +++ b/swift/account/replicator.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from swift.account import server as account_server -from swift.account.backend import AccountBroker +from swift.account.backend import AccountBroker, DATADIR from swift.common import db_replicator class AccountReplicator(db_replicator.Replicator): server_type = 'account' brokerclass = AccountBroker - datadir = account_server.DATADIR + datadir = DATADIR default_port = 6002 diff --git a/swift/account/server.py b/swift/account/server.py index 575014bd13..53889a16f1 100644 --- a/swift/account/server.py +++ b/swift/account/server.py @@ -21,7 +21,7 @@ from eventlet import Timeout import swift.common.db -from swift.account.backend import AccountBroker +from swift.account.backend import AccountBroker, DATADIR from swift.account.utils import account_listing_response from swift.common.db import DatabaseConnectionError, DatabaseAlreadyExists from swift.common.request_helpers import get_param, get_listing_content_type, \ @@ -40,9 +40,6 @@ from swift.common.request_helpers import is_sys_or_user_meta -DATADIR = 'accounts' - - class AccountController(object): """WSGI controller for the account server.""" diff --git a/swift/container/auditor.py b/swift/container/auditor.py index 62491a3976..0cd8594906 100644 --- a/swift/container/auditor.py +++ b/swift/container/auditor.py @@ -21,8 +21,7 @@ from eventlet import Timeout import swift.common.db -from swift.container import server as container_server -from swift.container.backend import ContainerBroker +from swift.container.backend import ContainerBroker, DATADIR from swift.common.utils import get_logger, audit_location_generator, \ config_true_value, dump_recon_cache, ratelimit_sleep from swift.common.daemon import Daemon @@ -49,8 +48,7 @@ def __init__(self, conf): self.rcache = os.path.join(self.recon_cache_path, "container.recon") def _one_audit_pass(self, reported): - all_locs = audit_location_generator(self.devices, - container_server.DATADIR, '.db', + all_locs = audit_location_generator(self.devices, DATADIR, '.db', mount_check=self.mount_check, logger=self.logger) for path, device, partition in all_locs: diff --git a/swift/container/backend.py b/swift/container/backend.py index 04ae9bcb67..a72da20aae 100644 --- a/swift/container/backend.py +++ b/swift/container/backend.py @@ -28,6 +28,8 @@ from swift.common.db import DatabaseBroker, DatabaseConnectionError, \ PENDING_CAP, PICKLE_PROTOCOL, utf8encode +DATADIR = 'containers' + class ContainerBroker(DatabaseBroker): """Encapsulates working with a container database.""" diff --git a/swift/container/replicator.py b/swift/container/replicator.py index 116a4a760a..f69edba01f 100644 --- a/swift/container/replicator.py +++ b/swift/container/replicator.py @@ -13,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from swift.container import server as container_server -from swift.container.backend import ContainerBroker +from swift.container.backend import ContainerBroker, DATADIR from swift.common import db_replicator class ContainerReplicator(db_replicator.Replicator): server_type = 'container' brokerclass = ContainerBroker - datadir = container_server.DATADIR + datadir = DATADIR default_port = 6001 def report_up_to_date(self, full_info): diff --git a/swift/container/server.py b/swift/container/server.py index 4242465bf6..ebf729597a 100644 --- a/swift/container/server.py +++ b/swift/container/server.py @@ -23,7 +23,7 @@ from eventlet import Timeout import swift.common.db -from swift.container.backend import ContainerBroker +from swift.container.backend import ContainerBroker, DATADIR from swift.common.db import DatabaseAlreadyExists from swift.common.container_sync_realms import ContainerSyncRealms from swift.common.request_helpers import get_param, get_listing_content_type, \ @@ -43,8 +43,6 @@ HTTPPreconditionFailed, HTTPMethodNotAllowed, Request, Response, \ HTTPInsufficientStorage, HTTPException, HeaderKeyDict -DATADIR = 'containers' - class ContainerController(object): """WSGI Controller for the container server.""" diff --git a/swift/container/sync.py b/swift/container/sync.py index 87ca387b76..0f31bbe433 100644 --- a/swift/container/sync.py +++ b/swift/container/sync.py @@ -23,8 +23,7 @@ from eventlet import sleep, Timeout import swift.common.db -from swift.container import server as container_server -from swift.container.backend import ContainerBroker +from swift.container.backend import ContainerBroker, DATADIR from swift.common.container_sync_realms import ContainerSyncRealms from swift.common.direct_client import direct_get_object from swift.common.internal_client import delete_object, put_object @@ -168,9 +167,7 @@ def run_forever(self, *args, **kwargs): sleep(random() * self.interval) while True: begin = time() - all_locs = audit_location_generator(self.devices, - container_server.DATADIR, - '.db', + all_locs = audit_location_generator(self.devices, DATADIR, '.db', mount_check=self.mount_check, logger=self.logger) for path, device, partition in all_locs: @@ -187,8 +184,7 @@ def run_once(self, *args, **kwargs): """ self.logger.info(_('Begin container sync "once" mode')) begin = time() - all_locs = audit_location_generator(self.devices, - container_server.DATADIR, '.db', + all_locs = audit_location_generator(self.devices, DATADIR, '.db', mount_check=self.mount_check, logger=self.logger) for path, device, partition in all_locs: diff --git a/swift/container/updater.py b/swift/container/updater.py index 2c2e74660f..fdc01e3fad 100644 --- a/swift/container/updater.py +++ b/swift/container/updater.py @@ -25,8 +25,7 @@ from eventlet import spawn, patcher, Timeout import swift.common.db -from swift.container.backend import ContainerBroker -from swift.container.server import DATADIR +from swift.container.backend import ContainerBroker, DATADIR from swift.common.bufferedhttp import http_connect from swift.common.exceptions import ConnectionTimeout from swift.common.ring import Ring diff --git a/test/unit/account/test_reaper.py b/test/unit/account/test_reaper.py index 7af3865827..e122fdb612 100644 --- a/test/unit/account/test_reaper.py +++ b/test/unit/account/test_reaper.py @@ -24,7 +24,7 @@ from contextlib import nested from swift.account import reaper -from swift.account.server import DATADIR +from swift.account.backend import DATADIR from swift.common.exceptions import ClientException from swift.common.utils import normalize_timestamp diff --git a/test/unit/common/test_db_replicator.py b/test/unit/common/test_db_replicator.py index 0faeaca7f7..7c061e6dd5 100644 --- a/test/unit/common/test_db_replicator.py +++ b/test/unit/common/test_db_replicator.py @@ -26,9 +26,9 @@ import mock import simplejson +from swift.container.backend import DATADIR from swift.common import db_replicator from swift.common.utils import normalize_timestamp -from swift.container import server as container_server from swift.common.exceptions import DriveNotMounted from swift.common.swob import HTTPException @@ -247,7 +247,7 @@ class TestReplicator(db_replicator.Replicator): server_type = 'container' ring_file = 'container.ring.gz' brokerclass = FakeBroker - datadir = container_server.DATADIR + datadir = DATADIR default_port = 1000 diff --git a/test/unit/container/test_updater.py b/test/unit/container/test_updater.py index c5a14e36be..5c32dfa3b0 100644 --- a/test/unit/container/test_updater.py +++ b/test/unit/container/test_updater.py @@ -25,8 +25,7 @@ from swift.common import utils from swift.container import updater as container_updater -from swift.container import server as container_server -from swift.container.backend import ContainerBroker +from swift.container.backend import ContainerBroker, DATADIR from swift.common.ring import RingData from swift.common.utils import normalize_timestamp @@ -84,7 +83,7 @@ def test_run_once(self): 'account_suppression_time': 0 }) cu.run_once() - containers_dir = os.path.join(self.sda1, container_server.DATADIR) + containers_dir = os.path.join(self.sda1, DATADIR) os.mkdir(containers_dir) cu.run_once() self.assert_(os.path.exists(containers_dir)) @@ -167,7 +166,7 @@ def test_unicode(self): 'concurrency': '1', 'node_timeout': '15', }) - containers_dir = os.path.join(self.sda1, container_server.DATADIR) + containers_dir = os.path.join(self.sda1, DATADIR) os.mkdir(containers_dir) subdir = os.path.join(containers_dir, 'subdir') os.mkdir(subdir)