system.chown(osd_keyring)
-def get_journal_size(lv_format=True):
- """
- Helper to retrieve the size (defined in megabytes in ceph.conf) to create
- the journal logical volume, it "translates" the string into a float value,
- then converts that into gigabytes, and finally (optionally) it formats it
- back as a string so that it can be used for creating the LV.
-
- :param lv_format: Return a string to be used for ``lv_create``. A 5 GB size
- would result in '5G', otherwise it will return a ``Size`` object.
- """
- conf_journal_size = conf.ceph.get_safe('osd', 'osd_journal_size', '5120')
- logger.debug('osd_journal_size set to %s' % conf_journal_size)
- journal_size = disk.Size(mb=str_to_int(conf_journal_size))
-
- if journal_size < disk.Size(gb=2):
- mlogger.error('Refusing to continue with configured size for journal')
- raise RuntimeError('journal sizes must be larger than 2GB, detected: %s' % journal_size)
- if lv_format:
- return '%sG' % journal_size.gb.as_int()
- return journal_size
-
-
def get_block_db_size(lv_format=True):
"""
Helper to retrieve the size (defined in megabytes in ceph.conf) to create
terminal.error('device %s is used by another osd %s as %s, should be %s'% (device, current_osd_uuid, current_device_type, osd_uuid))
raise SystemExit(1)
-def link_journal(journal_device, osd_id):
- _link_device(journal_device, 'journal', osd_id)
-
def link_block(block_device, osd_id):
_link_device(block_device, 'block', osd_id)
else:
raise RuntimeError('Command failed with exit code %s: %s' % (returncode, ' '.join(command)))
-
-def osd_mkfs_filestore(osd_id, fsid, keyring):
- """
- Create the files for the OSD to function. A normal call will look like:
-
- ceph-osd --cluster ceph --mkfs --mkkey -i 0 \
- --monmap /var/lib/ceph/osd/ceph-0/activate.monmap \
- --osd-data /var/lib/ceph/osd/ceph-0 \
- --osd-journal /var/lib/ceph/osd/ceph-0/journal \
- --osd-uuid 8d208665-89ae-4733-8888-5d3bfbeeec6c \
- --keyring /var/lib/ceph/osd/ceph-0/keyring \
- --setuser ceph --setgroup ceph
-
- """
- path = '/var/lib/ceph/osd/%s-%s/' % (conf.cluster, osd_id)
- monmap = os.path.join(path, 'activate.monmap')
- journal = os.path.join(path, 'journal')
-
- system.chown(journal)
- system.chown(path)
-
- command = [
- 'ceph-osd',
- '--cluster', conf.cluster,
- '--osd-objectstore', 'filestore',
- '--mkfs',
- '-i', osd_id,
- '--monmap', monmap,
- ]
-
- if get_osdspec_affinity():
- command.extend(['--osdspec-affinity', get_osdspec_affinity()])
-
- command.extend([
- '--keyfile', '-',
- '--osd-data', path,
- '--osd-journal', journal,
- '--osd-uuid', fsid,
- '--setuser', 'ceph',
- '--setgroup', 'ceph'
- ])
-
- _, _, returncode = process.call(
- command, stdin=keyring, terminal_verbose=True, show_command=True
- )
- if returncode != 0:
- raise RuntimeError('Command failed with exit code %s: %s' % (returncode, ' '.join(command)))