Esempio n. 1
0
def prepare(args, cfg, activate_prepared_disk):
    LOG.debug(
        'Preparing cluster %s disks %s',
        args.cluster,
        ' '.join(':'.join(x or '' for x in t) for t in args.disk),
        )

    key = get_bootstrap_osd_key(cluster=args.cluster)

    bootstrapped = set()
    errors = 0
    for hostname, disk, journal in args.disk:
        try:
            if disk is None:
                raise exc.NeedDiskError(hostname)

            distro = hosts.get(hostname, username=args.username)
            LOG.info(
                'Distro info: %s %s %s',
                distro.name,
                distro.release,
                distro.codename
            )

            if hostname not in bootstrapped:
                bootstrapped.add(hostname)
                LOG.debug('Deploying osd to %s', hostname)

                conf_data = StringIO()
                cfg.write(conf_data)
                distro.conn.remote_module.write_conf(
                    args.cluster,
                    conf_data.getvalue(),
                    args.overwrite_conf
                )

                create_osd(distro.conn, args.cluster, key)

            LOG.debug('Preparing host %s disk %s journal %s activate %s',
                      hostname, disk, journal, activate_prepared_disk)

            prepare_disk(
                distro.conn,
                cluster=args.cluster,
                disk=disk,
                journal=journal,
                activate_prepared_disk=activate_prepared_disk,
                zap=args.zap_disk,
                fs_type=args.fs_type,
                dmcrypt=args.dmcrypt,
                dmcrypt_dir=args.dmcrypt_key_dir,
            )

            # give the OSD a few seconds to start
            time.sleep(5)
            catch_osd_errors(distro.conn, distro.conn.logger, args)
            LOG.debug('Host %s is now ready for osd use.', hostname)
            distro.conn.exit()

        except RuntimeError as e:
            LOG.error(e)
            errors += 1

    if errors:
        raise exc.GenericError('Failed to create %d OSDs' % errors)
Esempio n. 2
0
def create(args, cfg, create=False):
    if not args.host:
        raise RuntimeError(
            'Required host was not specified as a positional argument')
    LOG.debug('Creating OSD on cluster %s with data device %s', args.cluster,
              args.data)

    key = get_bootstrap_osd_key(cluster=args.cluster)

    bootstrapped = set()
    errors = 0
    hostname = args.host

    try:
        if args.data is None:
            raise exc.NeedDiskError(hostname)

        distro = hosts.get(hostname,
                           username=args.username,
                           callbacks=[packages.ceph_is_installed])
        LOG.info('Distro info: %s %s %s', distro.name, distro.release,
                 distro.codename)

        if hostname not in bootstrapped:
            bootstrapped.add(hostname)
            LOG.debug('Deploying osd to %s', hostname)

            conf_data = conf.ceph.load_raw(args)
            distro.conn.remote_module.write_conf(args.cluster, conf_data,
                                                 args.overwrite_conf)

            create_osd_keyring(distro.conn, args.cluster, key)

        # default to bluestore unless explicitly told not to
        storetype = 'bluestore'
        if args.filestore:
            storetype = 'filestore'

        create_osd(
            distro.conn,
            cluster=args.cluster,
            data=args.data,
            journal=args.journal,
            zap=args.zap_disk,
            fs_type=args.fs_type,
            dmcrypt=args.dmcrypt,
            dmcrypt_dir=args.dmcrypt_key_dir,
            storetype=storetype,
            block_wal=args.block_wal,
            block_db=args.block_db,
            debug=args.debug,
        )

        # give the OSD a few seconds to start
        time.sleep(5)
        catch_osd_errors(distro.conn, distro.conn.logger, args)
        LOG.debug('Host %s is now ready for osd use.', hostname)
        distro.conn.exit()

    except RuntimeError as e:
        LOG.error(e)
        errors += 1

    if errors:
        raise exc.GenericError('Failed to create %d OSDs' % errors)
Esempio n. 3
0
def prepare(args, cfg, activate_prepared_disk):
    LOG.debug(
        'Preparing cluster %s disks %s',
        args.cluster,
        ' '.join(':'.join(x or '' for x in t) for t in args.disk),
    )

    hosts_in_danger = exceeds_max_osds(args)

    if hosts_in_danger:
        LOG.warning(
            'if ``kernel.pid_max`` is not increased to a high enough value')
        LOG.warning('the following hosts will encounter issues:')
        for host, count in hosts_in_danger.items():
            LOG.warning('Host: %8s, OSDs: %s' % (host, count))

    key = get_bootstrap_osd_key(cluster=args.cluster)

    bootstrapped = set()
    errors = 0
    for hostname, disk, journal in args.disk:
        try:
            if disk is None:
                raise exc.NeedDiskError(hostname)

            distro = hosts.get(hostname,
                               username=args.username,
                               callbacks=[packages.ceph_is_installed])
            LOG.info('Distro info: %s %s %s', distro.name, distro.release,
                     distro.codename)

            if hostname not in bootstrapped:
                bootstrapped.add(hostname)
                LOG.debug('Deploying osd to %s', hostname)

                conf_data = StringIO()
                cfg.write(conf_data)
                distro.conn.remote_module.write_conf(args.cluster,
                                                     conf_data.getvalue(),
                                                     args.overwrite_conf)

                create_osd_keyring(distro.conn, args.cluster, key)

            LOG.debug('Preparing host %s disk %s journal %s activate %s',
                      hostname, disk, journal, activate_prepared_disk)

            storetype = None
            if args.bluestore:
                storetype = 'bluestore'

            prepare_disk(
                distro.conn,
                cluster=args.cluster,
                disk=disk,
                journal=journal,
                activate_prepared_disk=activate_prepared_disk,
                init=distro.init,
                zap=args.zap_disk,
                fs_type=args.fs_type,
                dmcrypt=args.dmcrypt,
                dmcrypt_dir=args.dmcrypt_key_dir,
                storetype=storetype,
            )

            # give the OSD a few seconds to start
            time.sleep(5)
            catch_osd_errors(distro.conn, distro.conn.logger, args)
            LOG.debug('Host %s is now ready for osd use.', hostname)
            distro.conn.exit()

        except RuntimeError as e:
            LOG.error(e)
            errors += 1

    if errors:
        raise exc.GenericError('Failed to create %d OSDs' % errors)
Esempio n. 4
0
def prepare(args, cfg, activate_prepared_disk):
    LOG.debug(
        'Preparing cluster %s disks %s',
        args.cluster,
        ' '.join(':'.join(x or '' for x in t) for t in args.disk),
        )
    if args.filestore:
        if args.fs_type == 'f2fs':
            LOG.debug('start run prepare_all_disk')

            admin_keyring_path = '/Ceph/Meta/Keyring/client.admin.keyring'
            admin_key = get_admin_key()

            errors = 0
            # hostname, pIP, cIP, disk, journal, strategy, mode, nvme_def_used, nvme_tt_nums, ssd_def_used,ssd_tt_used, hdd_def_used, hdd_tt_nums, cache_nums, cache_dis_type
            for hostname, pIP, cIP, disk, journal, strategy, mode, nvme_def_used, nvme_tt_nums, ssd_def_used,ssd_tt_used, hdd_def_used, hdd_tt_nums, cache_nums, cache_dis_type in args.disk:
                try:
                    distro = hosts.get(
                        hostname,
                        username=args.username,
                        callbacks=[packages.ceph_is_installed]
                    )

                    LOG.info('distro info: %s %s %s', distro.name, distro.release, distro.codename)
                    rlogger = logging.getLogger(hostname)

                    # get client.admin.keyring from manager node
                    if not distro.conn.remote_module.path_exists(admin_keyring_path):
                        LOG.debug('client.admin.keyring not exist yet, creating one')
                        distro.conn.remote_module.write_keyring(admin_keyring_path, admin_key)

                    # ensure remote hostname is good to go
                    #hostname_is_compatible(distro.conn, rlogger, hostname)
                    localIP = net.get_nonlocal_ip(hostname)
                    LOG.debug('get host ip : %s' ,localIP)
                    LOG.debug('Create:add mon to ceph.conf')
                    distro.mon.create_all(distro, args, hostname, pIP, cIP, disk, journal, strategy, mode, nvme_def_used, nvme_tt_nums, ssd_def_used,ssd_tt_used, hdd_def_used, hdd_tt_nums, cache_nums, cache_dis_type)
                    distro.conn.exit()
                except RuntimeError as e:
                    LOG.error(e)
                    errors += 1

            # start sync all osd ceph.conf
            conf_data = conf.ceph.load_raw(args)
            errnos = 0
            for hostname, pIP, cIP, disk, journal, strategy, mode, nvme_def_used, nvme_tt_nums, ssd_def_used, ssd_tt_used, hdd_def_used, hdd_tt_nums, cache_nums, cache_dis_type in args.disk:
                LOG.debug('sync configfile for host %s ...', hostname)
                try:
                    distro = hosts.get(hostname, username=args.username)
                    distro.conn.remote_module.write_conf(
                        args.cluster,
                        conf_data,
                        args.overwrite_conf,
                    )
                    distro.conn.exit()
                except RuntimeError as e:
                    LOG.error(e)
                    errnos += 1
            if errnos:
                raise exc.GenericError('Failed to sync configfile %d monitors' % errors)
            return

    hosts_in_danger = exceeds_max_osds(args)

    if hosts_in_danger:
        LOG.warning('if ``kernel.pid_max`` is not increased to a high enough value')
        LOG.warning('the following hosts will encounter issues:')
        for host, count in hosts_in_danger.items():
            LOG.warning('Host: %8s, OSDs: %s' % (host, count))

    key = get_bootstrap_osd_key(cluster=args.cluster)

    bootstrapped = set()
    errors = 0
    for hostname, disk, journal in args.disk:
        localIP = net.get_nonlocal_ip(hostname)
        LOG.debug('hostname:%s ; ip:%s' % (hostname, localIP))
        try:
            if disk is None:
                raise exc.NeedDiskError(hostname)

            distro = hosts.get(
                hostname,
                username=args.username,
                callbacks=[packages.ceph_is_installed]
            )
            LOG.info(
                'Distro info: %s %s %s',
                distro.name,
                distro.release,
                distro.codename
            )

            if hostname not in bootstrapped:
                bootstrapped.add(hostname)
                LOG.debug('Deploying osd to %s', hostname)

                conf_data = conf.ceph.load_raw(args)
                distro.conn.remote_module.write_conf(
                    args.cluster,
                    conf_data,
                    args.overwrite_conf
                )

                create_osd_keyring(distro.conn, args.cluster, key)

            LOG.debug('Preparing host %s disk %s journal %s activate %s',
                      hostname, disk, journal, activate_prepared_disk)

            storetype = None
            if args.bluestore:
                storetype = 'bluestore'
            if args.filestore:
                storetype = 'filestore'

            prepare_disk(
                distro.conn,
                cluster=args.cluster,
                disk=disk,
                journal=journal,
                activate_prepared_disk=activate_prepared_disk,
                init=distro.init,
                zap=args.zap_disk,
                fs_type=args.fs_type,
                dmcrypt=args.dmcrypt,
                dmcrypt_dir=args.dmcrypt_key_dir,
                storetype=storetype,
                block_wal=args.block_wal,
                block_db=args.block_db
            )

            # give the OSD a few seconds to start
            time.sleep(5)
            catch_osd_errors(distro.conn, distro.conn.logger, args)
            LOG.debug('Host %s is now ready for osd use.', hostname)
            distro.conn.exit()

        except RuntimeError as e:
            LOG.error(e)
            errors += 1

    if errors:
        raise exc.GenericError('Failed to create %d OSDs' % errors)