container_path = None
-class CDError(Exception):
+class Error(Exception):
pass
##################################
return func()
if len(fsid_list) > 1:
- raise CDError('cannot infer fsid, must specify --fsid')
+ raise Error('cannot infer fsid, must specify --fsid')
logger.info('Inferring fsid %s' % fsid_list[0])
args.fsid = fsid_list[0]
with open(args.keyring, 'r') as f:
keyring = f.read()
else:
- raise CDError('no keyring provided')
+ raise Error('no keyring provided')
with open(args.config, 'r') as f:
config = f.read()
return (config, keyring)
with open(args.keyring, 'r') as f:
keyring = f.read()
else:
- raise CDError('no keyring provided')
+ raise Error('no keyring provided')
crash_keyring = None
if args.crash_keyring:
with open(args.crash_keyring, 'r') as f:
if not args.allow_overwrite:
for f in [args.output_config, args.output_keyring, args.output_pub_ssh_key]:
if os.path.exists(f):
- raise CDError('%s already exists; delete or pass '
+ raise Error('%s already exists; delete or pass '
'--allow-overwrite to overwrite' % f)
# initial vars
addr_arg = args.mon_addrv
mon_ip = args.mon_addrv.split(':')[1]
else:
- raise CDError('must specify --mon-ip or --mon-addrv')
+ raise Error('must specify --mon-ip or --mon-addrv')
if not cp.has_section('global'):
cp.add_section('global')
cp.set('global', 'fsid', fsid);
logger.info('Verifying we can ping mon IP %s...' % mon_ip)
_, _, ret = call(['timeout', '5', 'ping', mon_ip, '-c', '1'], 'ping')
if ret:
- raise CDError('failed to ping %s' % mon_ip)
+ raise Error('failed to ping %s' % mon_ip)
if not args.skip_pull:
logger.info('Pulling latest %s container...' % args.image)
# type: () -> None
(daemon_type, daemon_id) = args.name.split('.', 1)
if daemon_type not in ['mon', 'mgr', 'mds', 'osd', 'rgw', 'rbd-mirror']:
- raise CDError('daemon type %s not recognized' % daemon_type)
+ raise Error('daemon type %s not recognized' % daemon_type)
(config, keyring, crash_keyring) = get_config_and_both_keyrings()
if daemon_type == 'mon':
if args.mon_ip:
config += '[mon.%s]\n\tpublic_network = %s\n' % (daemon_id,
args.mon_network)
else:
- raise CDError('must specify --mon-ip or --mon-network')
+ raise Error('must specify --mon-ip or --mon-network')
(uid, gid) = extract_uid_gid()
c = get_container(args.fsid, daemon_type, daemon_id)
deploy_daemon(args.fsid, daemon_type, daemon_id, c, uid, gid,
def command_enter():
# type: () -> int
if not args.fsid:
- raise CDError('must pass --fsid to specify cluster')
+ raise Error('must pass --fsid to specify cluster')
(daemon_type, daemon_id) = args.name.split('.', 1)
container_args = [] # type: List[str]
if args.command:
def command_unit():
# type: () -> None
if not args.fsid:
- raise CDError('must pass --fsid to specify cluster')
+ raise Error('must pass --fsid to specify cluster')
(daemon_type, daemon_id) = args.name.split('.', 1)
unit_name = get_unit_name(args.fsid, daemon_type, daemon_id)
call_throws([
def command_logs():
# type: () -> None
if not args.fsid:
- raise CDError('must pass --fsid to specify cluster')
+ raise Error('must pass --fsid to specify cluster')
cmd = [str(container_path), 'logs'] # type: List[str]
if args.follow:
cmd.append('-f')
daemon_id,
legacy_dir=args.legacy_dir)
if not fsid:
- raise CDError('could not detect legacy fsid; set fsid in ceph.conf')
+ raise Error('could not detect legacy fsid; set fsid in ceph.conf')
# NOTE: implicit assumption here that the units correspond to the
# cluster we are adopting based on the /etc/{defaults,sysconfig}/ceph
enable=True, # unconditionally enable the new unit
start=(state == 'running'))
else:
- raise RuntimeError('adoption of style %s not implemented' % args.style)
+ raise Error('adoption of style %s not implemented' % args.style)
##################################
# type: () -> None
(daemon_type, daemon_id) = args.name.split('.', 1)
if daemon_type in ['mon', 'osd'] and not args.force:
- raise CDError('must pass --force to proceed: '
+ raise Error('must pass --force to proceed: '
'this command may destroy precious data!')
unit_name = get_unit_name(args.fsid, daemon_type, daemon_id)
call(['systemctl', 'stop', unit_name],
def command_rm_cluster():
# type: () -> None
if not args.force:
- raise CDError('must pass --force to proceed: '
+ raise Error('must pass --force to proceed: '
'this command may destroy precious data!')
# stop + disable individual daemon units
container_path = find_program(i)
break
except Exception as e:
- logger.debug('could not locate %s: %s' % (i, e))
+ logger.debug('Could not locate %s: %s' % (i, e))
if not container_path:
- raise CDError('unable to locate any of %s' % CONTAINER_PREFERENCE)
+ sys.stderr.write('Unable to locate any of %s\n' % CONTAINER_PREFERENCE)
+ sys.exit(1)
if 'func' not in args:
sys.stderr.write('No command specified; pass -h or --help for usage\n')
sys.exit(1)
try:
r = args.func()
- except CDError as e:
- sys.stderr.write('ERROR: %s' % e)
+ except Error as e:
+ if args.verbose:
+ raise
+ sys.stderr.write('ERROR: %s\n' % e)
sys.exit(1)
if not r:
r = 0