Files
5a8cfd6e06d4ee7f47c5926c3859cbd6161c0d1a
swift /bin /swift-recon-cron

77 lines
2.7 KiB
Plaintext
Raw Normal View History

# 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.
swift-recon-cron.py
"""
import os
import sys
lock_path
for i in os.listdir(device_dir):
continue
# skip stuff like "accounts", "containers", etc.
if not (asyncdir == ASYNCDIR_BASE or
asyncdir.startswith(ASYNCDIR_BASE + '-')):
continue
async_pending = os.path.join(device, asyncdir)
if os.path.isdir(async_pending):
for entry in os.listdir(async_pending):
if os.path.isdir(os.path.join(async_pending, entry)):
async_hdir = os.path.join(async_pending, entry)
async_count += len(os.listdir(async_hdir))
def main():
try:
conf_path = sys.argv[1]
except Exception:
print("ex: swift-recon-cron /etc/swift/object-server.conf")
conf = readconf(conf_path, 'filter:recon')
recon_cache_path = conf.get('recon_cache_path', '/var/cache/swift')
cache_file = os.path.join(recon_cache_path, "object.recon")
conf['log_name'] = conf.get('log_name', 'recon-cron')
logger = get_logger(conf, log_route='recon-cron')
try:
asyncs = get_async_count(device_dir, logger)
dump_recon_cache({'async_pending': asyncs}, cache_file, logger)
except (Exception, Timeout) as err:
msg = 'Exception during recon-cron while accessing devices'
logger.exception(msg)
print('%s: %s' % (msg, err))
if __name__ == '__main__':
main()