activate_lock.release()
+###########################
+
+def get_journal_osd_uuid(path):
+ if not os.path.exists(path):
+ raise Error('%s does not exist', path)
+
+ mode = os.stat(path).st_mode
+ if not stat.S_ISBLK(mode):
+ raise Error('%s is not a block device', path)
+
+ try:
+ out = _check_output(
+ args=[
+ 'ceph-osd',
+ '-i', '0', # this is ignored
+ '--get-journal-uuid',
+ '--osd-journal',
+ path,
+ ],
+ close_fds=True,
+ )
+ except subprocess.CalledProcessError as e:
+ raise Error(
+ 'failed to get osd uuid/fsid from journal',
+ e,
+ )
+ value = str(out).split('\n', 1)[0]
+ LOG.debug('Journal %s has OSD UUID %s', path, value)
+ return value
+
+def main_activate_journal(args):
+ if not os.path.exists(args.dev):
+ raise Error('%s does not exist', args.dev)
+
+ cluster = None
+ osd_id = None
+ osd_uuid = None
+ activate_lock.acquire()
+ try:
+ osd_uuid = get_journal_osd_uuid(args.dev)
+ path = os.path.join('/dev/disk/by-partuuid/', osd_uuid.lower())
+
+ (cluster, osd_id) = mount_activate(
+ dev=path,
+ activate_key_template=args.activate_key_template,
+ init=args.mark_init,
+ )
+
+ start_daemon(
+ cluster=cluster,
+ osd_id=osd_id,
+ )
+
+ activate_lock.release()
+
+ except:
+ activate_lock.release()
+ raise
###########################
func=main_activate,
)
+ activate_journal_parser = subparsers.add_parser('activate-journal', help='Activate an OSD via its journal device')
+ activate_journal_parser.add_argument(
+ 'dev',
+ metavar='DEV',
+ help='path to journal block device',
+ )
+ activate_journal_parser.add_argument(
+ '--activate-key',
+ metavar='PATH',
+ help='bootstrap-osd keyring path template (%(default)s)',
+ dest='activate_key_template',
+ )
+ activate_journal_parser.add_argument(
+ '--mark-init',
+ metavar='INITSYSTEM',
+ help='init system to manage this dir',
+ default='auto',
+ choices=INIT_SYSTEMS,
+ )
+ activate_journal_parser.set_defaults(
+ activate_key_template='/var/lib/ceph/bootstrap-osd/{cluster}.keyring',
+ func=main_activate_journal,
+ )
+
list_parser = subparsers.add_parser('list', help='List disks, partitions, and Ceph OSDs')
list_parser.set_defaults(
func=main_list,
ENV{ID_PART_ENTRY_TYPE}=="4fbd7e29-9d25-41b8-afd0-062c0ceff05d", \
RUN+="/usr/sbin/ceph-disk-activate --mount /dev/$name"
+# activate ceph-tagged partitions
+ACTION=="add", SUBSYSTEM=="block", \
+ ENV{DEVTYPE}=="partition", \
+ ENV{ID_PART_ENTRY_TYPE}=="45b0969e-9b03-4f30-b4c6-b4b80ceff106", \
+ RUN+="/usr/sbin/ceph-disk activate-journal /dev/$name"
+
# Map journal if using dm-crypt
ACTION=="add" SUBSYSTEM=="block", \
ENV{DEVTYPE}=="partition", \