Change exit codes, list exit codes in a doc
This commit is contained in:
parent
8ee11507c9
commit
1960efbbec
5
doc/source/exitcodes.rst
Normal file
5
doc/source/exitcodes.rst
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
==========
|
||||||
|
Exit Codes
|
||||||
|
==========
|
||||||
|
|
||||||
|
|
@ -16,6 +16,7 @@ Contents:
|
|||||||
usage
|
usage
|
||||||
cli
|
cli
|
||||||
tools
|
tools
|
||||||
|
exitcodes
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
==================
|
==================
|
||||||
|
@ -195,7 +195,7 @@ def main(argv=None):
|
|||||||
args = parser.parse_args(argv[1:])
|
args = parser.parse_args(argv[1:])
|
||||||
if args.version:
|
if args.version:
|
||||||
print(version)
|
print(version)
|
||||||
sys.exit(0)
|
return 0
|
||||||
loglevels = [logging.WARNING, logging.INFO, logging.DEBUG]
|
loglevels = [logging.WARNING, logging.INFO, logging.DEBUG]
|
||||||
if args.quiet and not args.log_file:
|
if args.quiet and not args.log_file:
|
||||||
args.verbose = 0
|
args.verbose = 0
|
||||||
@ -307,7 +307,7 @@ def main(argv=None):
|
|||||||
if not enough_space:
|
if not enough_space:
|
||||||
logger.error('Not enough space for logs in "%s", exiting.' %
|
logger.error('Not enough space for logs in "%s", exiting.' %
|
||||||
nm.conf['archive_dir'])
|
nm.conf['archive_dir'])
|
||||||
return 2
|
return 100
|
||||||
if not args.only_logs:
|
if not args.only_logs:
|
||||||
if nm.has(Node.pkey):
|
if nm.has(Node.pkey):
|
||||||
pretty_run(args.quiet, 'Uploading files', nm.put_files)
|
pretty_run(args.quiet, 'Uploading files', nm.put_files)
|
||||||
|
@ -452,7 +452,7 @@ class NodeManager(object):
|
|||||||
if (not os.path.exists(self.rqdir)):
|
if (not os.path.exists(self.rqdir)):
|
||||||
self.logger.critical(('NodeManager: directory %s does not'
|
self.logger.critical(('NodeManager: directory %s does not'
|
||||||
' exist') % self.rqdir)
|
' exist') % self.rqdir)
|
||||||
sys.exit(1)
|
sys.exit(101)
|
||||||
if self.conf['rqfile']:
|
if self.conf['rqfile']:
|
||||||
self.import_rq()
|
self.import_rq()
|
||||||
self.nodes = {}
|
self.nodes = {}
|
||||||
@ -495,7 +495,7 @@ class NodeManager(object):
|
|||||||
if (not self.get_nodes_fuelclient() and
|
if (not self.get_nodes_fuelclient() and
|
||||||
not self.get_nodes_api() and
|
not self.get_nodes_api() and
|
||||||
not self.get_nodes_cli()):
|
not self.get_nodes_cli()):
|
||||||
sys.exit(4)
|
sys.exit(105)
|
||||||
self.nodes_init()
|
self.nodes_init()
|
||||||
# apply soft-filter on all nodes
|
# apply soft-filter on all nodes
|
||||||
for node in self.nodes.values():
|
for node in self.nodes.values():
|
||||||
@ -609,7 +609,7 @@ class NodeManager(object):
|
|||||||
def fuel_init(self):
|
def fuel_init(self):
|
||||||
if not self.conf['fuel_ip']:
|
if not self.conf['fuel_ip']:
|
||||||
self.logger.critical('NodeManager: fuel_ip not set')
|
self.logger.critical('NodeManager: fuel_ip not set')
|
||||||
sys.exit(7)
|
sys.exit(106)
|
||||||
fuelnode = Node(id=0,
|
fuelnode = Node(id=0,
|
||||||
cluster=0,
|
cluster=0,
|
||||||
name='fuel',
|
name='fuel',
|
||||||
|
@ -30,6 +30,7 @@ import json
|
|||||||
from flock import FLock
|
from flock import FLock
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
from pipes import quote
|
from pipes import quote
|
||||||
|
import signal
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
slowpipe = '''
|
slowpipe = '''
|
||||||
@ -51,6 +52,7 @@ def interrupt_wrapper(f):
|
|||||||
f(*args, **kwargs)
|
f(*args, **kwargs)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.warning('Interrupted, exiting.')
|
logger.warning('Interrupted, exiting.')
|
||||||
|
sys.exit(signal.SIGINT)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('Error: %s' % e, exc_info=True)
|
logger.error('Error: %s' % e, exc_info=True)
|
||||||
for k in dir(e):
|
for k in dir(e):
|
||||||
@ -132,7 +134,7 @@ def run_batch(item_list, maxthreads, dict_result=False):
|
|||||||
if isinstance(run_item.result, Exception):
|
if isinstance(run_item.result, Exception):
|
||||||
logger.critical('%s, exiting' % run_item.result)
|
logger.critical('%s, exiting' % run_item.result)
|
||||||
cleanup()
|
cleanup()
|
||||||
sys.exit(42)
|
sys.exit(109)
|
||||||
run_item.process.join()
|
run_item.process.join()
|
||||||
run_item.process = None
|
run_item.process = None
|
||||||
if dict_result:
|
if dict_result:
|
||||||
@ -157,10 +159,10 @@ def load_json_file(filename):
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
logger.critical("I/O error(%s): file: %s; msg: %s" %
|
logger.critical("I/O error(%s): file: %s; msg: %s" %
|
||||||
(e.errno, e.filename, e.strerror))
|
(e.errno, e.filename, e.strerror))
|
||||||
sys.exit(1)
|
sys.exit(107)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.critical("Could not convert data")
|
logger.critical("Could not convert data", exc_info=True)
|
||||||
sys.exit(1)
|
sys.exit(108)
|
||||||
|
|
||||||
|
|
||||||
def load_yaml_file(filename):
|
def load_yaml_file(filename):
|
||||||
@ -173,14 +175,14 @@ def load_yaml_file(filename):
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
logger.critical("I/O error(%s): file: %s; msg: %s" %
|
logger.critical("I/O error(%s): file: %s; msg: %s" %
|
||||||
(e.errno, e.filename, e.strerror))
|
(e.errno, e.filename, e.strerror))
|
||||||
sys.exit(1)
|
sys.exit(102)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.critical("Could not convert data")
|
logger.critical("Could not convert data", exc_info=True)
|
||||||
sys.exit(1)
|
sys.exit(103)
|
||||||
except yaml.parser.ParserError as e:
|
except yaml.parser.ParserError as e:
|
||||||
logger.critical("Could not parse %s:\n%s" %
|
logger.critical("Could not parse %s:\n%s" %
|
||||||
(filename, str(e)))
|
(filename, str(e)))
|
||||||
sys.exit(1)
|
sys.exit(105)
|
||||||
|
|
||||||
|
|
||||||
def mdir(directory):
|
def mdir(directory):
|
||||||
@ -193,7 +195,7 @@ def mdir(directory):
|
|||||||
os.makedirs(directory)
|
os.makedirs(directory)
|
||||||
except:
|
except:
|
||||||
logger.critical("Can't create a directory: %s" % directory)
|
logger.critical("Can't create a directory: %s" % directory)
|
||||||
sys.exit(3)
|
sys.exit(110)
|
||||||
|
|
||||||
|
|
||||||
def launch_cmd(cmd, timeout, input=None, ok_codes=None, decode=True):
|
def launch_cmd(cmd, timeout, input=None, ok_codes=None, decode=True):
|
||||||
|
Loading…
Reference in New Issue
Block a user