Added swift-account-info tool.
This is a very simple swift tool to retrieve information of an account that is located on the storage node. One can call the tool with a given account db file as it is stored on the storage node system. It will then return several information about that account. Change-Id: Ibfeee790adc000fc177b4b3c03d22ff785fda325
This commit is contained in:
90
bin/swift-account-info
Executable file
90
bin/swift-account-info
Executable file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/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 os
|
||||||
|
import sys
|
||||||
|
from datetime import datetime
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
from swift.common.ring import Ring
|
||||||
|
from swift.common.utils import hash_path, storage_directory
|
||||||
|
from swift.account.backend import AccountBroker
|
||||||
|
|
||||||
|
|
||||||
|
def print_account_info(db_file, swift_dir='/etc/swift'):
|
||||||
|
if not os.path.exists(db_file) or not db_file.endswith('.db'):
|
||||||
|
print "DB file doesn't exist"
|
||||||
|
sys.exit(1)
|
||||||
|
try:
|
||||||
|
ring = Ring(swift_dir, ring_name='account')
|
||||||
|
except Exception:
|
||||||
|
ring = None
|
||||||
|
metadata = {}
|
||||||
|
broker = AccountBroker(db_file)
|
||||||
|
for key, (value, timestamp) in broker.metadata.iteritems():
|
||||||
|
if value and key.lower().startswith('x-account-meta-'):
|
||||||
|
metadata[key] = value
|
||||||
|
info = broker.get_info()
|
||||||
|
account = info['account']
|
||||||
|
account_hash = hash_path(account)
|
||||||
|
print ' Account: %s' % info['account']
|
||||||
|
print ' Account Hash: %s' % account_hash
|
||||||
|
print (' Created at: %s (%s)' %
|
||||||
|
(datetime.fromtimestamp(float(info['created_at'])),
|
||||||
|
info['created_at']))
|
||||||
|
print (' Put Timestamp: %s (%s)' %
|
||||||
|
(datetime.fromtimestamp(float(info['put_timestamp'])),
|
||||||
|
info['put_timestamp']))
|
||||||
|
print (' Delete Timestamp: %s (%s)' %
|
||||||
|
(datetime.fromtimestamp(float(info['delete_timestamp'])),
|
||||||
|
info['delete_timestamp']))
|
||||||
|
print ' Container Count: %s' % info['container_count']
|
||||||
|
print ' Object Count: %s' % info['object_count']
|
||||||
|
print ' Bytes Used: %s' % info['bytes_used']
|
||||||
|
print ' Chexor: %s' % info['hash']
|
||||||
|
print ' ID: %s' % info['id']
|
||||||
|
if metadata:
|
||||||
|
print ' User Metadata: %s' % metadata
|
||||||
|
else:
|
||||||
|
print 'No user metadata found in db file'
|
||||||
|
print
|
||||||
|
|
||||||
|
if ring is not None:
|
||||||
|
print 'Ring locations:'
|
||||||
|
part, nodes = ring.get_nodes(account)
|
||||||
|
for node in nodes:
|
||||||
|
print (' %s:%s - /srv/node/%s/%s/%s.db' %
|
||||||
|
(node['ip'], node['port'], node['device'],
|
||||||
|
storage_directory('accounts', part, account_hash),
|
||||||
|
account_hash))
|
||||||
|
print
|
||||||
|
print 'note: /srv/node is used as default value of `devices`, '\
|
||||||
|
'the real value is set in account-server.conf '\
|
||||||
|
'on each storage node.'
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.set_defaults(swift_dir='/etc/swift')
|
||||||
|
parser.add_option(
|
||||||
|
'-d', '--swift-dir',
|
||||||
|
help="Pass location of swift directory")
|
||||||
|
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
if len(args) < 1:
|
||||||
|
print "Usage: %s [--swift-dir] ACCOUNT_DB_FILE" % sys.argv[0]
|
||||||
|
sys.exit(1)
|
||||||
|
print_account_info(args[0], swift_dir=options.swift_dir)
|
60
doc/manpages/swift-account-info.1
Normal file
60
doc/manpages/swift-account-info.1
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
.\"
|
||||||
|
.\" Author: Madhuri Kumari<madhuri.rai07@gmail.com>
|
||||||
|
.\"
|
||||||
|
.\" Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
.\" you may not use this file except in compliance with the License.
|
||||||
|
.\" You may obtain a copy of the License at
|
||||||
|
.\"
|
||||||
|
.\" http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
.\"
|
||||||
|
.\" Unless required by applicable law or agreed to in writing, software
|
||||||
|
.\" distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
.\" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
.\" implied.
|
||||||
|
.\" See the License for the specific language governing permissions and
|
||||||
|
.\" limitations under the License.
|
||||||
|
.\"
|
||||||
|
.TH swift-account-info 1 "3/22/2014" "Linux" "OpenStack Swift"
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
.LP
|
||||||
|
.B swift-account-info
|
||||||
|
\- Openstack-swift account-info tool
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.LP
|
||||||
|
.B swift-account-info
|
||||||
|
[ACCOUNT_DB_FILE] [SWIFT_DIR]
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.PP
|
||||||
|
This is a very simple swift tool that allows a swiftop engineer to retrieve
|
||||||
|
information about an account that is located on the storage node. One calls
|
||||||
|
the tool with a given db file as it is stored on the storage node system.
|
||||||
|
It will then return several information about that account such as;
|
||||||
|
|
||||||
|
.PD 0
|
||||||
|
.IP "- Account"
|
||||||
|
.IP "- Account hash "
|
||||||
|
.IP "- Created timestamp "
|
||||||
|
.IP "- Put timestamp "
|
||||||
|
.IP "- Delete timestamp "
|
||||||
|
.IP "- Container Count "
|
||||||
|
.IP "- Object count "
|
||||||
|
.IP "- Bytes used "
|
||||||
|
.IP "- Chexor "
|
||||||
|
.IP "- ID"
|
||||||
|
.IP "- User Metadata "
|
||||||
|
.IP "- Ring Location"
|
||||||
|
.PD
|
||||||
|
|
||||||
|
.SH DOCUMENTATION
|
||||||
|
.LP
|
||||||
|
More documentation about Openstack-Swift can be found at
|
||||||
|
.BI http://swift.openstack.org/index.html
|
||||||
|
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
|
||||||
|
.BR swift-container-info(1),
|
||||||
|
.BR swift-get-nodes(1),
|
||||||
|
.BR swift-object-info(1)
|
@@ -78,6 +78,8 @@ More documentation about Openstack-Swift can be found at
|
|||||||
|
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
|
|
||||||
|
.BR swift-account-info(1),
|
||||||
.BR swift-container-info(1),
|
.BR swift-container-info(1),
|
||||||
.BR swift-object-info(1),
|
.BR swift-object-info(1),
|
||||||
.BR swift-ring-builder(1)
|
.BR swift-ring-builder(1)
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.B swift-object-info
|
.B swift-object-info
|
||||||
[OBJECT_FILE] [SWIFT_DIR]
|
[OBJECT_FILE] [SWIFT_DIR]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
@@ -52,5 +52,7 @@ More documentation about Openstack-Swift can be found at
|
|||||||
.BI http://swift.openstack.org/index.html
|
.BI http://swift.openstack.org/index.html
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
|
|
||||||
|
.BR swift-account-info(1),
|
||||||
.BR swift-container-info(1),
|
.BR swift-container-info(1),
|
||||||
.BR swift-get-nodes(1)
|
.BR swift-get-nodes(1)
|
||||||
|
@@ -1033,6 +1033,10 @@ If you are looking at a container on the server and need more info,
|
|||||||
`swift-container-info` will display all the information like the account,
|
`swift-container-info` will display all the information like the account,
|
||||||
container, replica locations and metadata of the container.
|
container, replica locations and metadata of the container.
|
||||||
|
|
||||||
|
If you are looking at an account on the server and need more info,
|
||||||
|
`swift-account-info` will display the account, replica locations
|
||||||
|
and metadata of the account.
|
||||||
|
|
||||||
If you want to audit the data for an account, `swift-account-audit` can be
|
If you want to audit the data for an account, `swift-account-audit` can be
|
||||||
used to crawl the account, checking that all containers and objects can be
|
used to crawl the account, checking that all containers and objects can be
|
||||||
found.
|
found.
|
||||||
|
@@ -28,6 +28,7 @@ packages =
|
|||||||
scripts =
|
scripts =
|
||||||
bin/swift-account-audit
|
bin/swift-account-audit
|
||||||
bin/swift-account-auditor
|
bin/swift-account-auditor
|
||||||
|
bin/swift-account-info
|
||||||
bin/swift-account-reaper
|
bin/swift-account-reaper
|
||||||
bin/swift-account-replicator
|
bin/swift-account-replicator
|
||||||
bin/swift-account-server
|
bin/swift-account-server
|
||||||
|
Reference in New Issue
Block a user