Esempio n. 1
0
def test_ceph_volume_command_4():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(size='200GB:350GB',
                                                       rotational=True),
                          db_devices=DeviceSelection(size='200GB:350GB',
                                                     rotational=False),
                          wal_devices=DeviceSelection(size='10G'),
                          block_db_size='500M',
                          block_wal_size='500M',
                          osds_per_device=3,
                          encrypted=True)
    spec.validate()
    inventory = _mk_inventory(
        _mk_device(rotational=True, size="300.00 GB") * 2 +
        _mk_device(rotational=False, size="300.00 GB") * 2 +
        _mk_device(size="10.0 GB", rotational=False) * 2)
    sel = drive_selection.DriveSelection(spec, inventory)
    cmds = translate.to_ceph_volume(sel, []).run()
    assert all(cmd == (
        'lvm batch --no-auto /dev/sda /dev/sdb '
        '--db-devices /dev/sdc /dev/sdd --wal-devices /dev/sde /dev/sdf '
        '--block-wal-size 500M --block-db-size 500M --dmcrypt '
        '--osds-per-device 3 --yes --no-systemd')
               for cmd in cmds), f'Expected {cmd} in {cmds}'
Esempio n. 2
0
def test_ceph_volume_command_0():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(all=True))
    spec.validate()
    inventory = _mk_inventory(_mk_device() * 2)
    sel = drive_selection.DriveSelection(spec, inventory)
    cmd = translate.to_ceph_volume(sel, []).run()
    assert cmd == 'lvm batch --no-auto /dev/sda /dev/sdb --yes --no-systemd'
Esempio n. 3
0
def test_ceph_volume_command_7():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(all=True),
                          osd_id_claims={'host1': ['0', '1']})
    spec.validate()
    inventory = _mk_inventory(_mk_device(rotational=True) * 2)
    sel = drive_selection.DriveSelection(spec, inventory)
    cmd = translate.to_ceph_volume(sel, ['0', '1']).run()
    assert cmd == 'lvm batch --no-auto /dev/sda /dev/sdb --osd-ids 0 1 --yes --no-systemd'
Esempio n. 4
0
def test_ceph_volume_command_5():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(rotational=True),
                          objectstore='filestore')
    with pytest.raises(DriveGroupValidationError):
        spec.validate()
    inventory = _mk_inventory(_mk_device(rotational=True) * 2)
    sel = drive_selection.DriveSelection(spec, inventory)
    cmd = translate.to_ceph_volume(sel, []).run()
    assert cmd == 'lvm batch --no-auto /dev/sda /dev/sdb --filestore --yes --no-systemd'
Esempio n. 5
0
def test_ceph_volume_command_9():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(all=True),
                          data_allocate_fraction=0.8)
    spec.validate()
    inventory = _mk_inventory(_mk_device() * 2)
    sel = drive_selection.DriveSelection(spec, inventory)
    cmds = translate.to_ceph_volume(sel, []).run()
    assert all(
        cmd ==
        'lvm batch --no-auto /dev/sda /dev/sdb --data-allocate-fraction 0.8 --yes --no-systemd'
        for cmd in cmds), f'Expected {cmd} in {cmds}'
Esempio n. 6
0
def test_ceph_volume_command_1():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(rotational=True),
                          db_devices=DeviceSelection(rotational=False))
    spec.validate()
    inventory = _mk_inventory(
        _mk_device(rotational=True) * 2 + _mk_device(rotational=False) * 2)
    sel = drive_selection.DriveSelection(spec, inventory)
    cmds = translate.to_ceph_volume(sel, []).run()
    assert all(cmd == ('lvm batch --no-auto /dev/sda /dev/sdb '
                       '--db-devices /dev/sdc /dev/sdd --yes --no-systemd')
               for cmd in cmds), f'Expected {cmd} in {cmds}'
Esempio n. 7
0
    def _create_osd(self, svc_arg=None, inbuf=None):
        # type: (str, str) -> HandleCommandResult
        """Create one or more OSDs"""

        usage = """
Usage:
  ceph orchestrator osd create -i <json_file>
  ceph orchestrator osd create host:device1,device2,...
"""

        if inbuf:
            try:
                drive_group = DriveGroupSpec.from_json(json.loads(inbuf))
            except ValueError as e:
                msg = 'Failed to read JSON input: {}'.format(str(e)) + usage
                return HandleCommandResult(-errno.EINVAL, stderr=msg)

        elif svc_arg:
            try:
                node_name, block_device = svc_arg.split(":")
                block_devices = block_device.split(',')
            except (TypeError, KeyError, ValueError):
                msg = "Invalid host:device spec: '{}'".format(svc_arg) + usage
                return HandleCommandResult(-errno.EINVAL, stderr=msg)

            devs = DeviceSelection(paths=block_devices)
            drive_group = DriveGroupSpec(node_name, data_devices=devs)
        else:
            return HandleCommandResult(-errno.EINVAL, stderr=usage)

        # TODO: Remove this and make the orchestrator composable
        #   Like a future or so.
        host_completion = self.get_hosts()
        self._orchestrator_wait([host_completion])
        orchestrator.raise_if_exception(host_completion)
        all_hosts = [h.name for h in host_completion.result]

        try:
            drive_group.validate(all_hosts)
        except DriveGroupValidationError as e:
            return HandleCommandResult(-errno.EINVAL, stderr=str(e))

        completion = self.create_osds(drive_group, all_hosts)
        self._orchestrator_wait([completion])
        orchestrator.raise_if_exception(completion)
        self.log.warning(str(completion.result))
        return HandleCommandResult(stdout=completion.result_str())
Esempio n. 8
0
def test_raw_ceph_volume_command_1():
    spec = DriveGroupSpec(
        placement=PlacementSpec(host_pattern='*'),
        service_id='foobar',
        data_devices=DeviceSelection(rotational=True),
        db_devices=DeviceSelection(rotational=False),
        method='raw',
    )
    spec.validate()
    inventory = _mk_inventory(
        _mk_device(rotational=True) +  # data
        _mk_device(rotational=True) +  # data
        _mk_device(rotational=False)  # db
    )
    sel = drive_selection.DriveSelection(spec, inventory)
    with pytest.raises(ValueError):
        cmds = translate.to_ceph_volume(sel, []).run()
Esempio n. 9
0
def test_ceph_volume_command_6():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(rotational=False),
                          journal_devices=DeviceSelection(rotational=True),
                          journal_size='500M',
                          objectstore='filestore')
    with pytest.raises(DriveGroupValidationError):
        spec.validate()
    inventory = _mk_inventory(
        _mk_device(rotational=True) * 2 + _mk_device(rotational=False) * 2)
    sel = drive_selection.DriveSelection(spec, inventory)
    cmds = translate.to_ceph_volume(sel, []).run()
    assert all(
        cmd == ('lvm batch --no-auto /dev/sdc /dev/sdd '
                '--journal-size 500M --journal-devices /dev/sda /dev/sdb '
                '--filestore --yes --no-systemd')
        for cmd in cmds), f'Expected {cmd} in {cmds}'
Esempio n. 10
0
def test_ceph_volume_command_2():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(size='200GB:350GB',
                                                       rotational=True),
                          db_devices=DeviceSelection(size='200GB:350GB',
                                                     rotational=False),
                          wal_devices=DeviceSelection(size='10G'))
    spec.validate()
    inventory = _mk_inventory(
        _mk_device(rotational=True, size="300.00 GB") * 2 +
        _mk_device(rotational=False, size="300.00 GB") * 2 +
        _mk_device(size="10.0 GB", rotational=False) * 2)
    sel = drive_selection.DriveSelection(spec, inventory)
    cmd = translate.to_ceph_volume(sel, []).run()
    assert cmd == (
        'lvm batch --no-auto /dev/sda /dev/sdb '
        '--db-devices /dev/sdc /dev/sdd --wal-devices /dev/sde /dev/sdf '
        '--yes --no-systemd')
Esempio n. 11
0
def test_ceph_volume_command_8():
    spec = DriveGroupSpec(placement=PlacementSpec(host_pattern='*'),
                          service_id='foobar',
                          data_devices=DeviceSelection(rotational=True,
                                                       model='INTEL SSDS'),
                          db_devices=DeviceSelection(model='INTEL SSDP'),
                          filter_logic='OR',
                          osd_id_claims={})
    spec.validate()
    inventory = _mk_inventory(
        _mk_device(rotational=True, size='1.82 TB',
                   model='ST2000DM001-1ER1') +  # data
        _mk_device(rotational=False, size="223.0 GB", model='INTEL SSDSC2KG24')
        +  # data
        _mk_device(rotational=False,
                   size="349.0 GB",
                   model='INTEL SSDPED1K375GA')  # wal/db
    )
    sel = drive_selection.DriveSelection(spec, inventory)
    cmd = translate.to_ceph_volume(sel, []).run()
    assert cmd == 'lvm batch --no-auto /dev/sda /dev/sdb --db-devices /dev/sdc --yes --no-systemd'
Esempio n. 12
0
def test_raw_ceph_volume_command_0():
    spec = DriveGroupSpec(
        placement=PlacementSpec(host_pattern='*'),
        service_id='foobar',
        data_devices=DeviceSelection(rotational=True),
        db_devices=DeviceSelection(rotational=False),
        method='raw',
    )
    spec.validate()
    inventory = _mk_inventory(
        _mk_device(rotational=True) +  # data
        _mk_device(rotational=True) +  # data
        _mk_device(rotational=False) +  # db
        _mk_device(rotational=False)  # db
    )
    exp_cmds = [
        'raw prepare --bluestore --data /dev/sda --block.db /dev/sdc',
        'raw prepare --bluestore --data /dev/sdb --block.db /dev/sdd'
    ]
    sel = drive_selection.DriveSelection(spec, inventory)
    cmds = translate.to_ceph_volume(sel, []).run()
    assert all(cmd in exp_cmds
               for cmd in cmds), f'Expected {exp_cmds} to match {cmds}'