def prepare_bluestore(block, wal, db, secrets, id_=None, fsid=None): """ :param block: The name of the logical volume for the bluestore data :param wal: a regular/plain disk or logical volume, to be used for block.wal :param db: a regular/plain disk or logical volume, to be used for block.db :param secrets: A dict with the secrets needed to create the osd (e.g. cephx) :param id_: The OSD id :param fsid: The OSD fsid, also known as the OSD UUID """ cephx_secret = secrets.get('cephx_secret', prepare_utils.create_key()) json_secrets = json.dumps(secrets) # allow re-using an existing fsid, in case prepare failed fsid = fsid or system.generate_uuid() # allow re-using an id, in case a prepare failed osd_id = id_ or prepare_utils.create_id(fsid, json_secrets) # create the directory prepare_utils.create_osd_path(osd_id, tmpfs=True) # symlink the block prepare_utils.link_block(block, osd_id) # get the latest monmap prepare_utils.get_monmap(osd_id) # write the OSD keyring if it doesn't exist already prepare_utils.write_keyring(osd_id, cephx_secret) # prepare the osd filesystem prepare_utils.osd_mkfs_bluestore( osd_id, fsid, keyring=cephx_secret, wal=wal, db=db )
def prepare_bluestore(block, wal, db, secrets, id_=None, fsid=None): """ :param block: The name of the logical volume for the bluestore data :param wal: a regular/plain disk or logical volume, to be used for block.wal :param db: a regular/plain disk or logical volume, to be used for block.db :param secrets: A dict with the secrets needed to create the osd (e.g. cephx) :param id_: The OSD id :param fsid: The OSD fsid, also known as the OSD UUID """ cephx_secret = secrets.get('cephx_secret', prepare_utils.create_key()) json_secrets = json.dumps(secrets) # allow re-using an existing fsid, in case prepare failed fsid = fsid or system.generate_uuid() # allow re-using an id, in case a prepare failed osd_id = id_ or prepare_utils.create_id(fsid, json_secrets) # create the directory prepare_utils.create_osd_path(osd_id, tmpfs=True) # symlink the block prepare_utils.link_block(block, osd_id) # get the latest monmap prepare_utils.get_monmap(osd_id) # write the OSD keyring if it doesn't exist already prepare_utils.write_keyring(osd_id, cephx_secret) # prepare the osd filesystem prepare_utils.osd_mkfs_bluestore(osd_id, fsid, keyring=cephx_secret, wal=wal, db=db)
def test_non_zero_exit_status(self, stub_call, monkeypatch): conf.cluster = 'ceph' monkeypatch.setattr('ceph_volume.util.prepare.system.chown', lambda x: True) stub_call(([], [], 1)) with pytest.raises(RuntimeError) as error: prepare.osd_mkfs_bluestore('1', 'asdf-1234', keyring='keyring') assert "Command failed with exit code 1" in str(error)
def prepare_bluestore(block, secrets, osd_id, fsid, tmpfs): """ :param block: The name of the logical volume for the bluestore data :param wal: a regular/plain disk or logical volume, to be used for block.wal :param db: a regular/plain disk or logical volume, to be used for block.db :param secrets: A dict with the secrets needed to create the osd (e.g. cephx) :param id_: The OSD id :param fsid: The OSD fsid, also known as the OSD UUID """ cephx_secret = secrets.get('cephx_secret', prepare_utils.create_key()) # create the directory prepare_utils.create_osd_path(osd_id, tmpfs=tmpfs) # symlink the block prepare_utils.link_block(block, osd_id) # get the latest monmap prepare_utils.get_monmap(osd_id) # write the OSD keyring if it doesn't exist already prepare_utils.write_keyring(osd_id, cephx_secret) # prepare the osd filesystem prepare_utils.osd_mkfs_bluestore( osd_id, fsid, keyring=cephx_secret, )
def test_non_zero_exit_formats_command_correctly(self, stub_call, monkeypatch): conf.cluster = 'ceph' monkeypatch.setattr('ceph_volume.util.prepare.system.chown', lambda x: True) stub_call(([], [], 1)) with pytest.raises(RuntimeError) as error: prepare.osd_mkfs_bluestore('1', 'asdf-1234', keyring='keyring') expected = ' '.join([ 'ceph-osd', '--cluster', 'ceph', '--osd-objectstore', 'bluestore', '--mkfs', '-i', '1', '--monmap', '/var/lib/ceph/osd/ceph-1/activate.monmap', '--keyfile', '-', '--osd-data', '/var/lib/ceph/osd/ceph-1/', '--osd-uuid', 'asdf-1234', '--setuser', 'ceph', '--setgroup', 'ceph' ]) assert expected in str(error)
def test_non_zero_exit_formats_command_correctly(self, stub_call, monkeypatch): conf.cluster = 'ceph' monkeypatch.setattr('ceph_volume.util.prepare.system.chown', lambda x: True) stub_call(([], [], 1)) with pytest.raises(RuntimeError) as error: prepare.osd_mkfs_bluestore('1', 'asdf-1234', keyring='keyring') expected = ' '.join([ 'ceph-osd', '--cluster', 'ceph', '--osd-objectstore', 'bluestore', '--mkfs', '-i', '1', '--monmap', '/var/lib/ceph/osd/ceph-1/activate.monmap', '--keyfile', '-', '--osd-data', '/var/lib/ceph/osd/ceph-1/', '--osd-uuid', 'asdf-1234', '--setuser', 'ceph', '--setgroup', 'ceph']) assert expected in str(error)
def prepare_bluestore(block, wal, db, secrets, tags, id_=None, fsid=None): """ :param block: The name of the logical volume for the bluestore data :param wal: a regular/plain disk or logical volume, to be used for block.wal :param db: a regular/plain disk or logical volume, to be used for block.db :param secrets: A dict with the secrets needed to create the osd (e.g. cephx) :param id_: The OSD id :param fsid: The OSD fsid, also known as the OSD UUID """ cephx_secret = secrets.get('cephx_secret', prepare_utils.create_key()) json_secrets = json.dumps(secrets) # encryption-only operations if secrets.get('dmcrypt_key'): # If encrypted, there is no need to create the lockbox keyring file because # bluestore re-creates the files and does not have support for other files # like the custom lockbox one. This will need to be done on activation. # format and open ('decrypt' devices) and re-assign the device and journal # variables so that the rest of the process can use the mapper paths key = secrets['dmcrypt_key'] block = prepare_dmcrypt(key, block, 'block', tags) wal = prepare_dmcrypt(key, wal, 'wal', tags) db = prepare_dmcrypt(key, db, 'db', tags) # allow re-using an existing fsid, in case prepare failed fsid = fsid or system.generate_uuid() # allow re-using an id, in case a prepare failed osd_id = id_ or prepare_utils.create_id(fsid, json_secrets) # create the directory prepare_utils.create_osd_path(osd_id, tmpfs=True) # symlink the block prepare_utils.link_block(block, osd_id) # get the latest monmap prepare_utils.get_monmap(osd_id) # write the OSD keyring if it doesn't exist already prepare_utils.write_keyring(osd_id, cephx_secret) # prepare the osd filesystem prepare_utils.osd_mkfs_bluestore(osd_id, fsid, keyring=cephx_secret, wal=wal, db=db)
def prepare_bluestore(block, wal, db, secrets, tags, osd_id, fsid): """ :param block: The name of the logical volume for the bluestore data :param wal: a regular/plain disk or logical volume, to be used for block.wal :param db: a regular/plain disk or logical volume, to be used for block.db :param secrets: A dict with the secrets needed to create the osd (e.g. cephx) :param id_: The OSD id :param fsid: The OSD fsid, also known as the OSD UUID """ cephx_secret = secrets.get('cephx_secret', prepare_utils.create_key()) # encryption-only operations if secrets.get('dmcrypt_key'): # If encrypted, there is no need to create the lockbox keyring file because # bluestore re-creates the files and does not have support for other files # like the custom lockbox one. This will need to be done on activation. # format and open ('decrypt' devices) and re-assign the device and journal # variables so that the rest of the process can use the mapper paths key = secrets['dmcrypt_key'] block = prepare_dmcrypt(key, block, 'block', tags) wal = prepare_dmcrypt(key, wal, 'wal', tags) db = prepare_dmcrypt(key, db, 'db', tags) # create the directory prepare_utils.create_osd_path(osd_id, tmpfs=True) # symlink the block prepare_utils.link_block(block, osd_id) # get the latest monmap prepare_utils.get_monmap(osd_id) # write the OSD keyring if it doesn't exist already prepare_utils.write_keyring(osd_id, cephx_secret) # prepare the osd filesystem prepare_utils.osd_mkfs_bluestore( osd_id, fsid, keyring=cephx_secret, wal=wal, db=db )
def test_db_is_added(self, fake_call, monkeypatch): monkeypatch.setattr(system, 'chown', lambda path: True) prepare.osd_mkfs_bluestore(1, 'asdf', db='/dev/smm2') assert '--bluestore-block-db-path' in fake_call.calls[0]['args'][0] assert '/dev/smm2' in fake_call.calls[0]['args'][0]
def test_keyring_is_not_added(self, fake_call, monkeypatch): monkeypatch.setattr(system, 'chown', lambda path: True) prepare.osd_mkfs_bluestore(1, 'asdf') assert '--keyfile' not in fake_call.calls[0]['args'][0]