return (int(uid), int(gid))
def deploy_daemon(fsid, daemon_type, daemon_id, c, uid, gid,
- config, keyring):
- # type: (str, str, Union[int, str], CephContainer, int, int, Optional[str], Optional[str]) -> None
+ config, keyring,
+ osd_fsid=None):
+ # type: (str, str, Union[int, str], CephContainer, int, int, Optional[str], Optional[str], Optional[str]) -> None
if daemon_type == 'mon' and not os.path.exists(
get_data_dir(fsid, 'mon', daemon_id)):
assert config
uid, gid,
config, keyring)
- deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c)
+ deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c,
+ osd_fsid=osd_fsid)
update_firewalld(daemon_type)
def deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c,
- enable=True, start=True):
- # type: (str, int, int, str, Union[int, str], CephContainer, bool, bool) -> None
+ enable=True, start=True,
+ osd_fsid=None):
+ # type: (str, int, int, str, Union[int, str], CephContainer, bool, bool, Optional[str]) -> None
# cmd
data_dir = get_data_dir(fsid, daemon_type, daemon_id)
with open(data_dir + '/unit.run', 'w') as f:
if daemon_type == 'osd':
# osds have a pre-start step
+ assert osd_fsid
prestart = CephContainer(
image=args.image,
entrypoint='/usr/sbin/ceph-volume',
args=[
'lvm', 'activate',
- str(daemon_id), args.osd_fsid,
+ str(daemon_id), osd_fsid,
'--no-systemd'
],
container_args=['--privileged'],
os.fchmod(f.fileno(), 0o600)
with open(data_dir + '/unit.poststop', 'w') as f:
if daemon_type == 'osd':
+ assert osd_fsid
poststop = CephContainer(
image=args.image,
entrypoint='/usr/sbin/ceph-volume',
args=[
'lvm', 'deactivate',
- str(daemon_id), args.osd_fsid,
+ str(daemon_id), osd_fsid,
'--no-systemd'
],
container_args=['--privileged'],
(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,
- config, keyring)
+ config, keyring,
+ osd_fsid=args.osd_fsid)
if crash_keyring:
deploy_crash(args.fsid, uid, gid, config, crash_keyring)
if not fsid:
raise Error('could not detect legacy fsid; set fsid in ceph.conf')
+ data_dir_src = ('/var/lib/ceph/%s/%s-%s' %
+ (daemon_type, args.cluster, daemon_id))
+ data_dir_src = os.path.abspath(args.legacy_dir + data_dir_src)
+
+ osd_fsid = None
+ if daemon_type == 'osd':
+ path = os.path.join(data_dir_src, 'fsid')
+ try:
+ with open(path, 'r') as f:
+ osd_fsid = f.read().strip()
+ except IOError:
+ raise Error('unable to read OSD fsid from %s' % path)
+
# NOTE: implicit assumption here that the units correspond to the
# cluster we are adopting based on the /etc/{defaults,sysconfig}/ceph
# CLUSTER field.
# data
logger.info('Moving data...')
- data_dir_src = ('/var/lib/ceph/%s/%s-%s' %
- (daemon_type, args.cluster, daemon_id))
- data_dir_src = os.path.abspath(args.legacy_dir + data_dir_src)
data_dir_dst = make_data_dir(fsid, daemon_type, daemon_id,
uid=uid, gid=gid)
move_files(glob(os.path.join(data_dir_src, '*')),
c = get_container(fsid, daemon_type, daemon_id)
deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c,
enable=True, # unconditionally enable the new unit
- start=(state == 'running'))
+ start=(state == 'running'),
+ osd_fsid=osd_fsid)
update_firewalld(daemon_type)
else: