Beispiel #1
0
def create_parser(prog, description):
    """
    Both prepare and create share the same parser, those are defined here to
    avoid duplication
    """
    parser = argparse.ArgumentParser(
        prog=prog,
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description=description,
    )
    parser.add_argument(
        '--data',
        required=True,
    type=arg_validators.ValidDevice(as_string=True),
        help='a raw device to use for the OSD',
    )
    parser.add_argument(
        '--bluestore',
        action='store_true',
        help='Use BlueStore backend')
    parser.add_argument(
        '--crush-device-class',
        dest='crush_device_class',
        help='Crush device class to assign this OSD to',
        default=""
    )
    parser.add_argument(
        '--no-tmpfs',
        action='store_true',
        help='Do not use a tmpfs mount for OSD data dir'
    )
    parser.add_argument(
        '--block.db',
        dest='block_db',
        help='Path to bluestore block.db block device'
    )
    parser.add_argument(
        '--block.wal',
        dest='block_wal',
        help='Path to bluestore block.wal block device'
    )
    parser.add_argument(
        '--dmcrypt',
        action='store_true',
        help='Enable device encryption via dm-crypt',
    )
    return parser
Beispiel #2
0
def create_parser(prog, description):
    """
    Both prepare and create share the same parser, those are defined here to
    avoid duplication
    """
    parser = argparse.ArgumentParser(
        prog=prog,
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description=description,
    )
    parser.add_argument(
        '--data',
        required=True,
        type=arg_validators.ValidDevice(as_string=True),
        help='a raw device to use for the OSD',
    )
    parser.add_argument('--bluestore',
                        action='store_true',
                        help='Use BlueStore backend')
    parser.add_argument(
        '--crush-device-class',
        dest='crush_device_class',
        help='Crush device class to assign this OSD to',
    )
    parser.add_argument(
        '--osd-id',
        help='Reuse an existing OSD id',
    )
    parser.add_argument(
        '--osd-fsid',
        help='Reuse an existing OSD UUID',
    )
    parser.add_argument(
        '--cluster-fsid',
        help='Specify the cluster fsid, useful when no ceph.conf is available',
    )
    parser.add_argument('--no-tmpfs',
                        action='store_true',
                        help='Do not use a tmpfs mount for OSD data dir')
    return parser
Beispiel #3
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.ValidDevice(),
            default=[],
            help='Devices to provision OSDs',
        )
        parser.add_argument(
            '--db-devices',
            nargs='*',
            type=arg_validators.ValidDevice(),
            default=[],
            help='Devices to provision OSDs db volumes',
        )
        parser.add_argument(
            '--wal-devices',
            nargs='*',
            type=arg_validators.ValidDevice(),
            default=[],
            help='Devices to provision OSDs wal volumes',
        )
        parser.add_argument(
            '--journal-devices',
            nargs='*',
            type=arg_validators.ValidDevice(),
            default=[],
            help='Devices to provision OSDs journal volumes',
        )
        parser.add_argument(
            '--no-auto',
            action='store_true',
            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='Autodetect the objectstore by inspecting the OSD',
        )
        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', '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(
            '--block-db-size',
            type=int,
            help=
            'Set (or override) the "bluestore_block_db_size" value, in bytes')
        parser.add_argument(
            '--block-wal-size',
            type=int,
            help=
            'Set (or override) the "bluestore_block_wal_size" value, in bytes')
        parser.add_argument(
            '--journal-size',
            type=int,
            help='Override the "osd_journal_size" value, in megabytes')
        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',
        )
        self.args = parser.parse_args(argv)
        self.parser = parser
        for dev_list in ['', 'db_', 'wal_', 'journal_']:
            setattr(self, '{}usable'.format(dev_list), [])
Beispiel #4
0
 def setup(self):
     self.validator = arg_validators.ValidDevice()
Beispiel #5
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.ValidDevice(),
            default=[],
            help='Devices to provision OSDs',
        )
        parser.add_argument(
            '--db-devices',
            nargs='*',
            type=arg_validators.ValidDevice(),
            default=[],
            help='Devices to provision OSDs db volumes',
        )
        parser.add_argument(
            '--wal-devices',
            nargs='*',
            type=arg_validators.ValidDevice(),
            default=[],
            help='Devices to provision OSDs wal volumes',
        )
        parser.add_argument(
            '--journal-devices',
            nargs='*',
            type=arg_validators.ValidDevice(),
            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(
            '--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',
        )
        self.args = parser.parse_args(argv)
        self.parser = parser
        for dev_list in ['', 'db_', 'wal_', 'journal_']:
            setattr(self, '{}usable'.format(dev_list), [])
Beispiel #6
0
        '--keyring',
        bootstrap_keyring,
        'osd',
        'purge-new',
        osd_name % osd_id,
        '--yes-i-really-mean-it',
    ]

    process.run(cmd)


common_args = {
    '--data': {
        'help': 'OSD data path. A physical device or logical volume',
        'required': True,
        'type': arg_validators.ValidDevice(as_string=True),
        #'default':,
        #'type':,
    },
    '--data-size': {
        'help': 'Size of data LV in case a device was passed in --data',
        'default': '0',
        'type': disk.Size.parse
    },
    '--data-slots': {
        'help':
        ('Intended number of slots on data device. The new OSD gets one'
         'of those slots or 1/nth of the available capacity'),
        'type':
        int,
        'default':
Beispiel #7
0
    def main(self):
        sub_command_help = dedent("""
        Zaps the given logical volume(s), raw device(s) or partition(s) for reuse by ceph-volume.
        If given a path to a logical volume it must be in the format of vg/lv. Any
        filesystems present on the given device, vg/lv, or partition will be removed and
        all data will be purged.

        If the logical volume, raw device or partition is being used for any ceph related
        mount points they will be unmounted.

        However, the lv or partition will be kept intact.

        Example calls for supported scenarios:

          Zapping a logical volume:

              ceph-volume lvm zap {vg name/lv name}

          Zapping a partition:

              ceph-volume lvm zap /dev/sdc1

          Zapping many raw devices:

              ceph-volume lvm zap /dev/sda /dev/sdb /db/sdc

          Zapping devices associated with an OSD ID:

              ceph-volume lvm zap --osd-id 1

            Optionally include the OSD FSID

              ceph-volume lvm zap --osd-id 1 --osd-fsid 55BD4219-16A7-4037-BC20-0F158EFCC83D

        If the --destroy flag is given and you are zapping a raw device or partition
        then all vgs and lvs that exist on that raw device or partition will be destroyed.

        This is especially useful if a raw device or partition was used by ceph-volume lvm create
        or ceph-volume lvm prepare commands previously and now you want to reuse that device.

        For example:

          ceph-volume lvm zap /dev/sda --destroy

        If the --destroy flag is given and you are zapping an lv then the lv is still
        kept intact for reuse.

        """)
        parser = argparse.ArgumentParser(
            prog='ceph-volume lvm zap',
            formatter_class=argparse.RawDescriptionHelpFormatter,
            description=sub_command_help,
        )

        parser.add_argument(
            'devices',
            metavar='DEVICES',
            nargs='*',
            type=arg_validators.ValidDevice(gpt_ok=True),
            default=[],
            help=
            'Path to one or many lv (as vg/lv), partition (as /dev/sda1) or device (as /dev/sda)'
        )

        parser.add_argument(
            '--destroy',
            action='store_true',
            default=False,
            help=
            'Destroy all volume groups and logical volumes if you are zapping a raw device or partition',
        )

        parser.add_argument(
            '--osd-id',
            help='Specify an OSD ID to detect associated devices for zapping',
        )

        parser.add_argument(
            '--osd-fsid',
            help='Specify an OSD FSID to detect associated devices for zapping',
        )

        if len(self.argv) == 0:
            print(sub_command_help)
            return

        self.args = parser.parse_args(self.argv)

        if self.args.osd_id or self.args.osd_fsid:
            self.zap_osd()
        else:
            self.zap()
Beispiel #8
0
    def main(self):
        parser = argparse.ArgumentParser(
            prog='ceph-volume lvm batch',
            formatter_class=argparse.RawDescriptionHelpFormatter,
            description=self.print_help(),
        )

        parser.add_argument(
            'devices',
            metavar='DEVICES',
            nargs='*',
            type=arg_validators.ValidDevice(),
            default=[],
            help='Devices to provision OSDs',
        )
        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='Autodetect the objectstore by inspecting the OSD',
        )
        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', '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(
            '--block-db-size',
            type=int,
            help='Set (or override) the "bluestore_block_db_size" value, in bytes'
        )
        parser.add_argument(
            '--journal-size',
            type=int,
            help='Override the "osd_journal_size" value, in megabytes'
        )
        parser.add_argument(
            '--prepare',
            action='store_true',
            help='Only prepare all OSDs, do not activate',
        )
        args = parser.parse_args(self.argv)

        if not args.devices:
            return parser.print_help()

        # Default to bluestore here since defaulting it in add_argument may
        # cause both to be True
        if not args.bluestore and not args.filestore:
            args.bluestore = True

        if args.report:
            self.report(args)
        else:
            self.execute(args)
Beispiel #9
0
def common_parser(prog, description):
    """
    Both prepare and create share the same parser, those are defined here to
    avoid duplication
    """
    parser = argparse.ArgumentParser(
        prog=prog,
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description=description,
    )

    required_group = parser.add_argument_group('required arguments')
    filestore_group = parser.add_argument_group('filestore')
    bluestore_group = parser.add_argument_group('bluestore')

    required_group.add_argument(
        '--data',
        required=True,
        type=arg_validators.ValidDevice(as_string=True),
        help='OSD data path. A physical device or logical volume',
    )

    required_group.add_argument(
        '--data-size',
        help='Size of data LV in case a device was passed in --data',
        default=0,
    )

    required_group.add_argument(
        '--data-slots',
        help=('Intended number of slots on data device. The new OSD gets one'
              'of those slots or 1/nth of the available capacity'),
        default=1,
    )

    filestore_group.add_argument(
        '--filestore',
        action='store_true',
        help='Use the filestore objectstore',
    )

    filestore_group.add_argument(
        '--journal',
        help='(REQUIRED) A logical volume (vg_name/lv_name), or path to a device',
    )

    filestore_group.add_argument(
        '--journal-size',
        help='Size of journal LV in case a raw block device was passed in --journal',
        default=0,
    )

    bluestore_group.add_argument(
        '--bluestore',
        action='store_true',
        help='Use the bluestore objectstore',
    )

    bluestore_group.add_argument(
        '--block.db',
        dest='block_db',
        help='Path to bluestore block.db logical volume or device',
    )

    bluestore_group.add_argument(
        '--block.db-size',
        dest='block_db_size',
        help='Size of block.db LV in case device was passed in --block.db',
        default=0,
    )

    required_group.add_argument(
        '--block.db-slots',
        dest='block_db_slots',
        help=('Intended number of slots on db device. The new OSD gets one'
              'of those slots or 1/nth of the available capacity'),
        default=1,
    )

    bluestore_group.add_argument(
        '--block.wal',
        dest='block_wal',
        help='Path to bluestore block.wal logical volume or device',
    )

    bluestore_group.add_argument(
        '--block.wal-size',
        dest='block_wal_size',
        help='Size of block.wal LV in case device was passed in --block.wal',
        default=0,
    )

    required_group.add_argument(
        '--block.wal-slots',
        dest='block_wal_slots',
        help=('Intended number of slots on wal device. The new OSD gets one'
              'of those slots or 1/nth of the available capacity'),
        default=1,
    )

    parser.add_argument(
        '--osd-id',
        help='Reuse an existing OSD id',
    )

    parser.add_argument(
        '--osd-fsid',
        help='Reuse an existing OSD fsid',
    )

    parser.add_argument(
        '--cluster-fsid',
        help='Specify the cluster fsid, useful when no ceph.conf is available',
    )

    parser.add_argument(
        '--crush-device-class',
        dest='crush_device_class',
        help='Crush device class to assign this OSD to',
    )

    parser.add_argument(
        '--dmcrypt',
        action='store_true',
        help='Enable device encryption via dm-crypt',
    )

    parser.add_argument(
        '--no-systemd',
        dest='no_systemd',
        action='store_true',
        help='Skip creating and enabling systemd units and starting OSD services when activating',
    )

    # Do not parse args, so that consumers can do something before the args get
    # parsed triggering argparse behavior
    return parser