Exemplo n.º 1
0
 def test_reject_partition(self, mocked_device):
     mocked_device.return_value = MagicMock(
         is_partition=True,
         has_gpt_headers=False,
     )
     with pytest.raises(ArgumentError):
         arg_validators.ValidBatchDevice()('foo')
Exemplo n.º 2
0
    def __init__(self, argv):
        parser = argparse.ArgumentParser(
            prog='ceph-volume lvm batch',
            formatter_class=argparse.RawDescriptionHelpFormatter,
            description=self._help,
        )

        parser.add_argument(
            'devices',
            metavar='DEVICES',
            nargs='*',
            type=arg_validators.ValidBatchDevice(),
            default=[],
            help='Devices to provision OSDs',
        )
        parser.add_argument(
            '--db-devices',
            nargs='*',
            type=arg_validators.ValidBatchDevice(),
            default=[],
            help='Devices to provision OSDs db volumes',
        )
        parser.add_argument(
            '--wal-devices',
            nargs='*',
            type=arg_validators.ValidBatchDevice(),
            default=[],
            help='Devices to provision OSDs wal volumes',
        )
        parser.add_argument(
            '--journal-devices',
            nargs='*',
            type=arg_validators.ValidBatchDevice(),
            default=[],
            help='Devices to provision OSDs journal volumes',
        )
        parser.add_argument(
            '--auto',
            action='store_true',
            help=
            ('deploy multi-device OSDs if rotational and non-rotational drives '
             'are passed in DEVICES'),
            default=True)
        parser.add_argument(
            '--no-auto',
            action='store_false',
            dest='auto',
            help=
            ('deploy standalone OSDs if rotational and non-rotational drives '
             'are passed in DEVICES'),
        )
        parser.add_argument(
            '--bluestore',
            action='store_true',
            help='bluestore objectstore (default)',
        )
        parser.add_argument(
            '--filestore',
            action='store_true',
            help='filestore objectstore',
        )
        parser.add_argument(
            '--report',
            action='store_true',
            help='Only report on OSD that would be created and exit',
        )
        parser.add_argument(
            '--yes',
            action='store_true',
            help='Avoid prompting for confirmation when provisioning',
        )
        parser.add_argument(
            '--format',
            help='output format, defaults to "pretty"',
            default='pretty',
            choices=['json', 'json-pretty', 'pretty'],
        )
        parser.add_argument(
            '--dmcrypt',
            action='store_true',
            help='Enable device encryption via dm-crypt',
        )
        parser.add_argument(
            '--crush-device-class',
            dest='crush_device_class',
            help='Crush device class to assign this OSD to',
        )
        parser.add_argument(
            '--no-systemd',
            dest='no_systemd',
            action='store_true',
            help=
            'Skip creating and enabling systemd units and starting OSD services',
        )
        parser.add_argument(
            '--osds-per-device',
            type=int,
            default=1,
            help='Provision more than 1 (the default) OSD per device',
        )
        parser.add_argument(
            '--data-slots',
            type=int,
            help=('Provision more than 1 (the default) OSD slot per device'
                  ' if more slots then osds-per-device are specified, slots'
                  'will stay unoccupied'),
        )
        parser.add_argument(
            '--data-allocate-fraction',
            type=arg_validators.ValidFraction(),
            help='Fraction to allocate from data device (0,1.0]',
            default=1.0)
        parser.add_argument(
            '--block-db-size',
            type=disk.Size.parse,
            help=
            'Set (or override) the "bluestore_block_db_size" value, in bytes')
        parser.add_argument(
            '--block-db-slots',
            type=int,
            help='Provision slots on DB device, can remain unoccupied')
        parser.add_argument(
            '--block-wal-size',
            type=disk.Size.parse,
            help=
            'Set (or override) the "bluestore_block_wal_size" value, in bytes')
        parser.add_argument(
            '--block-wal-slots',
            type=int,
            help='Provision slots on WAL device, can remain unoccupied')

        def journal_size_in_mb_hack(size):
            # TODO give user time to adjust, then remove this
            if size and size[-1].isdigit():
                mlogger.warning('DEPRECATION NOTICE')
                mlogger.warning(
                    '--journal-size as integer is parsed as megabytes')
                mlogger.warning(
                    'A future release will parse integers as bytes')
                mlogger.warning('Add a "M" to explicitly pass a megabyte size')
                size += 'M'
            return disk.Size.parse(size)

        parser.add_argument(
            '--journal-size',
            type=journal_size_in_mb_hack,
            help='Override the "osd_journal_size" value, in megabytes')
        parser.add_argument(
            '--journal-slots',
            type=int,
            help='Provision slots on journal device, can remain unoccupied')
        parser.add_argument(
            '--prepare',
            action='store_true',
            help='Only prepare all OSDs, do not activate',
        )
        parser.add_argument('--osd-ids',
                            nargs='*',
                            default=[],
                            help='Reuse existing OSD ids',
                            type=common.valid_osd_id)
        self.args = parser.parse_args(argv)
        self.parser = parser
        for dev_list in ['', 'db_', 'wal_', 'journal_']:
            setattr(self, '{}usable'.format(dev_list), [])
Exemplo n.º 3
0
 def setup(self):
     self.validator = arg_validators.ValidBatchDevice()