2410b616bb
If swift-recon/swift-get-nodes/swift-object-info is used with the swiftdir option they will read rings from the given directory; however they are still using /etc/swift/swift.conf to find the policies on the current node. This makes it impossible to maintain a local swift.conf copy (if you don't have write access to /etc/swift) or check multiple clusters from the same node. Until now swift-recon was also not usable with storage policy aliases, this patch fixes this as well. Closes-Bug: 1577582 Closes-Bug: 1604707 Closes-Bug: 1617951 Co-Authored-By: Alistair Coles <alistairncoles@gmail.com> Co-Authored-By: Thiago da Silva <thiago@redhat.com> Change-Id: I13188d42ec19e32e4420739eacd1e5b454af2ae3
50 lines
1.6 KiB
Python
Executable File
50 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# Copyright (c) 2010-2012 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
|
|
#
|
|
# 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.
|
|
|
|
import sys
|
|
from optparse import OptionParser
|
|
|
|
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__':
|
|
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(
|
|
'-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)
|