Pull swift-*-info scripts into swift.cli.info
Related-Change: Ifcc8138e7b55d5b82bea0d411ec6bfcca2c77c83 Change-Id: I2718d8b96193d13f913824fc1091d72737d755ea
This commit is contained in:
parent
da12a55bc5
commit
2c5dc64d25
@ -11,42 +11,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sqlite3
|
from swift.cli import info
|
||||||
import sys
|
|
||||||
from optparse import OptionParser
|
|
||||||
|
|
||||||
from swift.cli.info import print_info, InfoSystemExit
|
|
||||||
from swift.common.exceptions import LockTimeout
|
|
||||||
|
|
||||||
|
|
||||||
def run_print_info(args, opts):
|
|
||||||
try:
|
|
||||||
print_info('account', *args, **opts)
|
|
||||||
except InfoSystemExit:
|
|
||||||
sys.exit(1)
|
|
||||||
except (sqlite3.OperationalError, LockTimeout) as e:
|
|
||||||
if not opts.get('stale_reads_ok'):
|
|
||||||
opts['stale_reads_ok'] = True
|
|
||||||
print('Warning: Possibly Stale Data')
|
|
||||||
run_print_info(args, opts)
|
|
||||||
sys.exit(2)
|
|
||||||
else:
|
|
||||||
print('Account info failed: %s' % e)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = OptionParser('%prog [options] ACCOUNT_DB_FILE')
|
info.account_main()
|
||||||
parser.add_option(
|
|
||||||
'-d', '--swift-dir', default='/etc/swift',
|
|
||||||
help="Pass location of swift directory")
|
|
||||||
parser.add_option(
|
|
||||||
'--drop-prefixes', default=False, action="store_true",
|
|
||||||
help="When outputting metadata, drop the per-section common prefixes")
|
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
|
||||||
|
|
||||||
if len(args) != 1:
|
|
||||||
sys.exit(parser.print_help())
|
|
||||||
|
|
||||||
run_print_info(args, vars(options))
|
|
||||||
|
@ -11,49 +11,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sqlite3
|
from swift.cli import info
|
||||||
import sys
|
|
||||||
from optparse import OptionParser
|
|
||||||
|
|
||||||
from swift.cli.info import print_info, InfoSystemExit
|
|
||||||
from swift.common.exceptions import LockTimeout
|
|
||||||
|
|
||||||
|
|
||||||
def run_print_info(args, opts):
|
|
||||||
try:
|
|
||||||
print_info('container', *args, **opts)
|
|
||||||
except InfoSystemExit:
|
|
||||||
sys.exit(1)
|
|
||||||
except (sqlite3.OperationalError, LockTimeout) as e:
|
|
||||||
if not opts.get('stale_reads_ok'):
|
|
||||||
opts['stale_reads_ok'] = True
|
|
||||||
print('Warning: Possibly Stale Data')
|
|
||||||
run_print_info(args, opts)
|
|
||||||
sys.exit(2)
|
|
||||||
else:
|
|
||||||
print('Container info failed: %s' % e)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = OptionParser('%prog [options] CONTAINER_DB_FILE')
|
info.container_main()
|
||||||
parser.add_option(
|
|
||||||
'-d', '--swift-dir', default='/etc/swift',
|
|
||||||
help="Pass location of swift directory")
|
|
||||||
parser.add_option(
|
|
||||||
'--drop-prefixes', default=False, action="store_true",
|
|
||||||
help="When outputting metadata, drop the per-section common prefixes")
|
|
||||||
parser.add_option(
|
|
||||||
'-v', '--verbose', default=False, action="store_true",
|
|
||||||
help="Show all shard ranges. By default, only the number of shard "
|
|
||||||
"ranges is displayed if there are many shards.")
|
|
||||||
parser.add_option(
|
|
||||||
'--sync', '-s', default=False, action="store_true",
|
|
||||||
help="Output the contents of the incoming/outging sync tables")
|
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
|
||||||
|
|
||||||
if len(args) != 1:
|
|
||||||
sys.exit(parser.print_help())
|
|
||||||
|
|
||||||
run_print_info(args, vars(options))
|
|
||||||
|
@ -14,47 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import codecs
|
from swift.cli import info
|
||||||
import sys
|
|
||||||
from optparse import OptionParser
|
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from swift.common.storage_policy import reload_storage_policies
|
|
||||||
from swift.common.utils import set_swift_dir
|
|
||||||
from swift.cli.info import print_obj, InfoSystemExit
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if not six.PY2:
|
info.obj_main()
|
||||||
# Make stdout able to write escaped bytes
|
|
||||||
sys.stdout = codecs.getwriter("utf-8")(
|
|
||||||
sys.stdout.detach(), errors='surrogateescape')
|
|
||||||
|
|
||||||
parser = OptionParser('%prog [options] OBJECT_FILE')
|
|
||||||
parser.add_option(
|
|
||||||
'-n', '--no-check-etag', default=True,
|
|
||||||
action="store_false", dest="check_etag",
|
|
||||||
help="Don't verify file contents against stored etag")
|
|
||||||
parser.add_option(
|
|
||||||
'-d', '--swift-dir', default='/etc/swift', dest='swift_dir',
|
|
||||||
help="Pass location of swift directory")
|
|
||||||
parser.add_option(
|
|
||||||
'--drop-prefixes', default=False, action="store_true",
|
|
||||||
help="When outputting metadata, drop the per-section common prefixes")
|
|
||||||
parser.add_option(
|
|
||||||
'-P', '--policy-name', dest='policy_name',
|
|
||||||
help="Specify storage policy name")
|
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
|
||||||
|
|
||||||
if len(args) != 1:
|
|
||||||
sys.exit(parser.print_help())
|
|
||||||
|
|
||||||
if set_swift_dir(options.swift_dir):
|
|
||||||
reload_storage_policies()
|
|
||||||
|
|
||||||
try:
|
|
||||||
print_obj(*args, **vars(options))
|
|
||||||
except InfoSystemExit:
|
|
||||||
sys.exit(1)
|
|
||||||
|
@ -43,13 +43,10 @@ packages =
|
|||||||
[files]
|
[files]
|
||||||
scripts =
|
scripts =
|
||||||
bin/swift-account-audit
|
bin/swift-account-audit
|
||||||
bin/swift-account-info
|
|
||||||
bin/swift-config
|
bin/swift-config
|
||||||
bin/swift-container-info
|
|
||||||
bin/swift-reconciler-enqueue
|
bin/swift-reconciler-enqueue
|
||||||
bin/swift-drive-audit
|
bin/swift-drive-audit
|
||||||
bin/swift-get-nodes
|
bin/swift-get-nodes
|
||||||
bin/swift-object-info
|
|
||||||
bin/swift-oldies
|
bin/swift-oldies
|
||||||
bin/swift-orphans
|
bin/swift-orphans
|
||||||
|
|
||||||
@ -67,11 +64,13 @@ keystone =
|
|||||||
[entry_points]
|
[entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
swift-account-auditor = swift.account.auditor:main
|
swift-account-auditor = swift.account.auditor:main
|
||||||
|
swift-account-info = swift.cli.info:account_main
|
||||||
swift-account-reaper = swift.account.reaper:main
|
swift-account-reaper = swift.account.reaper:main
|
||||||
swift-account-replicator = swift.account.replicator:main
|
swift-account-replicator = swift.account.replicator:main
|
||||||
swift-account-server = swift.account.server:main
|
swift-account-server = swift.account.server:main
|
||||||
swift-container-auditor = swift.container.auditor:main
|
swift-container-auditor = swift.container.auditor:main
|
||||||
swift-container-deleter = swift.cli.container_deleter:main
|
swift-container-deleter = swift.cli.container_deleter:main
|
||||||
|
swift-container-info = swift.cli.info:container_main
|
||||||
swift-container-replicator = swift.container.replicator:main
|
swift-container-replicator = swift.container.replicator:main
|
||||||
swift-container-reconciler = swift.container.reconciler:main
|
swift-container-reconciler = swift.container.reconciler:main
|
||||||
swift-container-server = swift.container.server:main
|
swift-container-server = swift.container.server:main
|
||||||
@ -85,6 +84,7 @@ console_scripts =
|
|||||||
swift-manage-shard-ranges = swift.cli.manage_shard_ranges:main
|
swift-manage-shard-ranges = swift.cli.manage_shard_ranges:main
|
||||||
swift-object-auditor = swift.obj.auditor:main
|
swift-object-auditor = swift.obj.auditor:main
|
||||||
swift-object-expirer = swift.obj.expirer:main
|
swift-object-expirer = swift.obj.expirer:main
|
||||||
|
swift-object-info = swift.cli.info:obj_main
|
||||||
swift-object-reconstructor = swift.obj.reconstructor:main
|
swift-object-reconstructor = swift.obj.reconstructor:main
|
||||||
swift-object-relinker = swift.cli.relinker:main
|
swift-object-relinker = swift.cli.relinker:main
|
||||||
swift-object-replicator = swift.obj.replicator:main
|
swift-object-replicator = swift.obj.replicator:main
|
||||||
|
@ -10,15 +10,21 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
import codecs
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import sys
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
import six
|
||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
|
|
||||||
|
from swift.common.exceptions import LockTimeout
|
||||||
from swift.common.utils import hash_path, storage_directory, \
|
from swift.common.utils import hash_path, storage_directory, \
|
||||||
Timestamp, is_valid_ipv6
|
Timestamp, is_valid_ipv6
|
||||||
from swift.common.ring import Ring
|
from swift.common.ring import Ring
|
||||||
@ -29,10 +35,10 @@ from swift.account.backend import AccountBroker, DATADIR as ABDATADIR
|
|||||||
from swift.container.backend import ContainerBroker, DATADIR as CBDATADIR
|
from swift.container.backend import ContainerBroker, DATADIR as CBDATADIR
|
||||||
from swift.obj.diskfile import get_data_dir, read_metadata, DATADIR_BASE, \
|
from swift.obj.diskfile import get_data_dir, read_metadata, DATADIR_BASE, \
|
||||||
extract_policy
|
extract_policy
|
||||||
from swift.common.storage_policy import POLICIES
|
from swift.common.storage_policy import POLICIES, reload_storage_policies
|
||||||
from swift.common.swob import wsgi_to_str
|
from swift.common.swob import wsgi_to_str
|
||||||
from swift.common.middleware.crypto.crypto_utils import load_crypto_meta
|
from swift.common.middleware.crypto.crypto_utils import load_crypto_meta
|
||||||
from swift.common.utils import md5
|
from swift.common.utils import md5, set_swift_dir
|
||||||
|
|
||||||
|
|
||||||
class InfoSystemExit(Exception):
|
class InfoSystemExit(Exception):
|
||||||
@ -713,3 +719,95 @@ def print_item_locations(ring, ring_name=None, account=None, container=None,
|
|||||||
print('Object \t%s\n\n' % urllib.parse.quote(obj))
|
print('Object \t%s\n\n' % urllib.parse.quote(obj))
|
||||||
print_ring_locations(ring, loc, account, container, obj, part, all_nodes,
|
print_ring_locations(ring, loc, account, container, obj, part, all_nodes,
|
||||||
policy_index=policy_index)
|
policy_index=policy_index)
|
||||||
|
|
||||||
|
|
||||||
|
def obj_main():
|
||||||
|
if not six.PY2:
|
||||||
|
# Make stdout able to write escaped bytes
|
||||||
|
sys.stdout = codecs.getwriter("utf-8")(
|
||||||
|
sys.stdout.detach(), errors='surrogateescape')
|
||||||
|
|
||||||
|
parser = OptionParser('%prog [options] OBJECT_FILE')
|
||||||
|
parser.add_option(
|
||||||
|
'-n', '--no-check-etag', default=True,
|
||||||
|
action="store_false", dest="check_etag",
|
||||||
|
help="Don't verify file contents against stored etag")
|
||||||
|
parser.add_option(
|
||||||
|
'-d', '--swift-dir', default='/etc/swift', dest='swift_dir',
|
||||||
|
help="Pass location of swift directory")
|
||||||
|
parser.add_option(
|
||||||
|
'--drop-prefixes', default=False, action="store_true",
|
||||||
|
help="When outputting metadata, drop the per-section common prefixes")
|
||||||
|
parser.add_option(
|
||||||
|
'-P', '--policy-name', dest='policy_name',
|
||||||
|
help="Specify storage policy name")
|
||||||
|
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
if len(args) != 1:
|
||||||
|
sys.exit(parser.print_help())
|
||||||
|
|
||||||
|
if set_swift_dir(options.swift_dir):
|
||||||
|
reload_storage_policies()
|
||||||
|
|
||||||
|
try:
|
||||||
|
print_obj(*args, **vars(options))
|
||||||
|
except InfoSystemExit:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def run_print_info(db_type, args, opts):
|
||||||
|
try:
|
||||||
|
print_info(db_type, *args, **opts)
|
||||||
|
except InfoSystemExit:
|
||||||
|
sys.exit(1)
|
||||||
|
except (sqlite3.OperationalError, LockTimeout) as e:
|
||||||
|
if not opts.get('stale_reads_ok'):
|
||||||
|
opts['stale_reads_ok'] = True
|
||||||
|
print('Warning: Possibly Stale Data')
|
||||||
|
run_print_info(db_type, args, opts)
|
||||||
|
sys.exit(2)
|
||||||
|
else:
|
||||||
|
print('%s info failed: %s' % (db_type.title(), e))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def container_main():
|
||||||
|
parser = OptionParser('%prog [options] CONTAINER_DB_FILE')
|
||||||
|
parser.add_option(
|
||||||
|
'-d', '--swift-dir', default='/etc/swift',
|
||||||
|
help="Pass location of swift directory")
|
||||||
|
parser.add_option(
|
||||||
|
'--drop-prefixes', default=False, action="store_true",
|
||||||
|
help="When outputting metadata, drop the per-section common prefixes")
|
||||||
|
parser.add_option(
|
||||||
|
'-v', '--verbose', default=False, action="store_true",
|
||||||
|
help="Show all shard ranges. By default, only the number of shard "
|
||||||
|
"ranges is displayed if there are many shards.")
|
||||||
|
parser.add_option(
|
||||||
|
'--sync', '-s', default=False, action="store_true",
|
||||||
|
help="Output the contents of the incoming/outging sync tables")
|
||||||
|
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
if len(args) != 1:
|
||||||
|
sys.exit(parser.print_help())
|
||||||
|
|
||||||
|
run_print_info('container', args, vars(options))
|
||||||
|
|
||||||
|
|
||||||
|
def account_main():
|
||||||
|
parser = OptionParser('%prog [options] ACCOUNT_DB_FILE')
|
||||||
|
parser.add_option(
|
||||||
|
'-d', '--swift-dir', default='/etc/swift',
|
||||||
|
help="Pass location of swift directory")
|
||||||
|
parser.add_option(
|
||||||
|
'--drop-prefixes', default=False, action="store_true",
|
||||||
|
help="When outputting metadata, drop the per-section common prefixes")
|
||||||
|
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
if len(args) != 1:
|
||||||
|
sys.exit(parser.print_help())
|
||||||
|
|
||||||
|
run_print_info('account', args, vars(options))
|
||||||
|
Loading…
Reference in New Issue
Block a user