diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-02-25 01:24:23 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-02-25 01:24:23 +0000 |
| commit | b02cefe64631d51cebdfb5e3a83d22cdfea3b767 (patch) | |
| tree | 89c21761bde7957380500cd6696e1f3630422041 /tools | |
| parent | f7140d66c9a476a8d38fc428d4d011356cb87823 (diff) | |
| parent | 2fbccc0c693193533284330325f5803c8c6ce52a (diff) | |
Merge "Clean stale lockfiles on service startup : fixes bug 785955"
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/clean_file_locks.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/clean_file_locks.py b/tools/clean_file_locks.py new file mode 100755 index 000000000..eb21177aa --- /dev/null +++ b/tools/clean_file_locks.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +# Copyright 2012 La Honda Research Center, Inc. +# +# 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. + +"""clean_file_locks.py - Cleans stale interprocess locks + +This rountine can be used to find and delete stale lock files from +nova's interprocess synchroization. It can be used safely while services +are running. + +""" + +import logging +import optparse + +from nova import flags +from nova import utils +from nova import log + + +LOG = log.getLogger('nova.utils') +FLAGS = flags.FLAGS + + +def parse_options(): + """process command line options.""" + + parser = optparse.OptionParser('usage: %prog [options]') + parser.add_option('--verbose', action='store_true', + help='List lock files found and deleted') + + options, args = parser.parse_args() + + return options, args + + +def main(): + """Main loop.""" + options, args = parse_options() + verbose = options.verbose + + if verbose: + LOG.logger.setLevel(logging.DEBUG) + else: + LOG.logger.setLevel(logging.INFO) + LOG.info('Cleaning stale locks from %s' % FLAGS.lock_path) + utils.cleanup_file_locks() + LOG.info('Finished') + +if __name__ == '__main__': + main() |
