On 13-12-2017 10:36, Stefan Kooman wrote:
> Hi,
>
> The new style "ceph-volume" LVM way of provisioning OSDs introduces a
> little challange for us. In order to create the OSDs as logical,
> consistent and easily recognizable as possible, we try to name the
> Volume Groups (VG) and Logical Volumes (LV) the same as the OSD. For
> example: OSD no. 12 will be named /dev/osd.12/osd.12. So we don't use:
>
> "ceph-volume lvm create /dev/device"
>
> but use:
>
> "ceph-volume lvm prepare --bluestore --data osd.$OSD_ID/osd.$OSD_ID"
>
> and
>
> "ceph-volume lvm activate --bluestore $OSD_ID $OSD_FSID"
>
> However, this way of provisioning requires to know the OSD_ID before
> creating the VG/LV. Is there a way to ask Ceph which OSD_ID
> would be next up?
Stephan,
The ceph-disk code does something like this:
def allocate_osd_id(
cluster,
fsid,
keyring,
path,
):
"""
Allocates an OSD id on the given cluster.
:raises: Error if the call to allocate the OSD id fails.
:return: The allocated OSD id.
"""
lockbox_path = os.path.join(STATEDIR, 'osd-lockbox', fsid)
lockbox_osd_id = read_one_line(lockbox_path, 'whoami')
osd_keyring = os.path.join(path, 'keyring')
if lockbox_osd_id:
LOG.debug('Getting OSD id from Lockbox...')
osd_id = lockbox_osd_id
shutil.move(os.path.join(lockbox_path, 'osd_keyring'),
osd_keyring)
path_set_context(osd_keyring)
os.unlink(os.path.join(lockbox_path, 'whoami'))
return osd_id
LOG.debug('Allocating OSD id...')
secrets = Secrets()
try:
wanttobe = read_one_line(path, 'wanttobe')
if os.path.exists(os.path.join(path, 'wanttobe')):
os.unlink(os.path.join(path, 'wanttobe'))
id_arg = wanttobe and [wanttobe] or []
osd_id = command_with_stdin(
[
'ceph',
'--cluster', cluster,
'--name', 'client.bootstrap-osd',
'--keyring', keyring,
'-i', '-',
'osd', 'new',
fsid,
] + id_arg,
secrets.get_json()
)
except subprocess.CalledProcessError as e:
raise Error('ceph osd create failed', e, e.output)
osd_id = must_be_one_line(osd_id)
check_osd_id(osd_id)
secrets.write_osd_keyring(osd_keyring, osd_id)
return osd_id
--WjW
_______________________________________________
ceph-users mailing list
[email protected]
http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com