예제 #1
0
def mon_create(distro, args, monitor_keyring, hostname):
    logger = distro.conn.logger
    logger.debug('remote hostname: %s' % hostname)
    path = paths.mon.path(args.cluster, hostname)
    done_path = paths.mon.done(args.cluster, hostname)
    init_path = paths.mon.init(args.cluster, hostname, distro.init)

    configuration = conf.load(args)
    conf_data = StringIO()
    configuration.write(conf_data)

    # write the configuration file
    distro.conn.remote_module.write_conf(
        args.cluster,
        conf_data.getvalue(),
        args.overwrite_conf,
    )

    # if the mon path does not exist, create it
    distro.conn.remote_module.create_mon_path(path)

    logger.debug('checking for done path: %s' % done_path)
    if not distro.conn.remote_module.path_exists(done_path):
        logger.debug('done path does not exist: %s' % done_path)
        if not distro.conn.remote_module.path_exists(
                paths.mon.constants.tmp_path):
            logger.info('creating tmp path: %s' % paths.mon.constants.tmp_path)
            distro.conn.remote_module.makedir(paths.mon.constants.tmp_path)
        keyring = paths.mon.keyring(args.cluster, hostname)

        logger.info('creating keyring file: %s' % keyring)
        distro.conn.remote_module.write_monitor_keyring(
            keyring,
            monitor_keyring,
        )

        process.run(
            distro.conn,
            [
                'ceph-mon',
                '--cluster',
                args.cluster,
                '--mkfs',
                '-i',
                hostname,
                '--keyring',
                keyring,
            ],
        )

        logger.info('unlinking keyring file %s' % keyring)
        distro.conn.remote_module.unlink(keyring)

    # create the done file
    distro.conn.remote_module.create_done_path(done_path)

    # create init path
    distro.conn.remote_module.create_init_path(init_path)
예제 #2
0
def mon_create(distro, args, monitor_keyring, hostname):
    logger = distro.conn.logger
    logger.debug('remote hostname: %s' % hostname)
    path = paths.mon.path(args.cluster, hostname)
    done_path = paths.mon.done(args.cluster, hostname)
    init_path = paths.mon.init(args.cluster, hostname, distro.init)

    configuration = conf.load(args)
    conf_data = StringIO()
    configuration.write(conf_data)

    # write the configuration file
    distro.conn.remote_module.write_conf(
        args.cluster,
        conf_data.getvalue(),
        args.overwrite_conf,
    )

    # if the mon path does not exist, create it
    distro.conn.remote_module.create_mon_path(path)

    logger.debug('checking for done path: %s' % done_path)
    if not distro.conn.remote_module.path_exists(done_path):
        logger.debug('done path does not exist: %s' % done_path)
        if not distro.conn.remote_module.path_exists(paths.mon.constants.tmp_path):
            logger.info('creating tmp path: %s' % paths.mon.constants.tmp_path)
            distro.conn.remote_module.makedir(paths.mon.constants.tmp_path)
        keyring = paths.mon.keyring(args.cluster, hostname)

        logger.info('creating keyring file: %s' % keyring)
        distro.conn.remote_module.write_monitor_keyring(
            keyring,
            monitor_keyring,
        )

        process.run(
            distro.conn,
            [
                'ceph-mon',
                '--cluster', args.cluster,
                '--mkfs',
                '-i', hostname,
                '--keyring', keyring,
            ],
        )

        logger.info('unlinking keyring file %s' % keyring)
        distro.conn.remote_module.unlink(keyring)

    # create the done file
    distro.conn.remote_module.create_done_path(done_path)

    # create init path
    distro.conn.remote_module.create_init_path(init_path)
예제 #3
0
def mon_create(distro, logger, args, monitor_keyring, hostname):
    logger.debug('remote hostname: %s' % hostname)
    path = paths.mon.path(args.cluster, hostname)
    done_path = paths.mon.done(args.cluster, hostname)
    init_path = paths.mon.init(args.cluster, hostname, distro.init)

    configuration = conf.load(args)
    conf_data = StringIO()
    configuration.write(conf_data)

    with remote(distro.sudo_conn, logger, conf.write_conf) as remote_func:
        remote_func(args.cluster, conf_data.getvalue(), overwrite=args.overwrite_conf)

    if not distro.sudo_conn.modules.os.path.exists(path):
        logger.info('creating path: %s' % path)
        distro.sudo_conn.modules.os.makedirs(path)

    logger.debug('checking for done path: %s' % done_path)
    if not distro.sudo_conn.modules.os.path.exists(done_path):
        logger.debug('done path does not exist: %s' % done_path)
        if not distro.sudo_conn.modules.os.path.exists(paths.mon.constants.tmp_path):
            logger.info('creating tmp path: %s' % paths.mon.constants.tmp_path)
            distro.sudo_conn.modules.os.makedirs(paths.mon.constants.tmp_path)
        keyring = paths.mon.keyring(args.cluster, hostname)

        def write_monitor_keyring(keyring, monitor_keyring):
            """create the monitor keyring file"""
            with file(keyring, 'w') as f:
                f.write(monitor_keyring)

        logger.info('creating keyring file: %s' % keyring)
        with remote(distro.sudo_conn, logger, write_monitor_keyring) as remote_func:
            remote_func(keyring, monitor_keyring)

        check_call(
            distro.sudo_conn,
            logger,
            [
                'ceph-mon',
                '--cluster', args.cluster,
                '--mkfs',
                '-i', hostname,
                '--keyring', keyring,
            ],
        )

        logger.info('unlinking keyring file %s' % keyring)
        distro.sudo_conn.modules.os.unlink(keyring)

    def create_done_path(done_path):
        """create a done file to avoid re-doing the mon deployment"""
        with file(done_path, 'w'):
            pass

    with remote(distro.sudo_conn, logger, create_done_path) as remote_func:
        remote_func(done_path)

    def create_init_path(init_path):
        """create the init path if it does not exist"""
        import os
        if not os.path.exists(init_path):
            with file(init_path, 'w'):
                pass

    with remote(distro.sudo_conn, logger, create_init_path) as remote_func:
        remote_func(init_path)
예제 #4
0
def mon_create(distro, logger, args, monitor_keyring, hostname):
    logger.debug('remote hostname: %s' % hostname)
    path = paths.mon.path(args.cluster, hostname)
    done_path = paths.mon.done(args.cluster, hostname)
    init_path = paths.mon.init(args.cluster, hostname, distro.init)

    configuration = conf.load(args)
    conf_data = StringIO()
    configuration.write(conf_data)

    with remote(distro.sudo_conn, logger, conf.write_conf) as remote_func:
        remote_func(args.cluster,
                    conf_data.getvalue(),
                    overwrite=args.overwrite_conf)

    if not distro.sudo_conn.modules.os.path.exists(path):
        logger.info('creating path: %s' % path)
        distro.sudo_conn.modules.os.makedirs(path)

    logger.debug('checking for done path: %s' % done_path)
    if not distro.sudo_conn.modules.os.path.exists(done_path):
        logger.debug('done path does not exist: %s' % done_path)
        if not distro.sudo_conn.modules.os.path.exists(
                paths.mon.constants.tmp_path):
            logger.info('creating tmp path: %s' % paths.mon.constants.tmp_path)
            distro.sudo_conn.modules.os.makedirs(paths.mon.constants.tmp_path)
        keyring = paths.mon.keyring(args.cluster, hostname)

        def write_monitor_keyring(keyring, monitor_keyring):
            """create the monitor keyring file"""
            with file(keyring, 'w') as f:
                f.write(monitor_keyring)

        logger.info('creating keyring file: %s' % keyring)
        with remote(distro.sudo_conn, logger,
                    write_monitor_keyring) as remote_func:
            remote_func(keyring, monitor_keyring)

        check_call(
            distro.sudo_conn,
            logger,
            [
                'ceph-mon',
                '--cluster',
                args.cluster,
                '--mkfs',
                '-i',
                hostname,
                '--keyring',
                keyring,
            ],
        )

        logger.info('unlinking keyring file %s' % keyring)
        distro.sudo_conn.modules.os.unlink(keyring)

    def create_done_path(done_path):
        """create a done file to avoid re-doing the mon deployment"""
        with file(done_path, 'w'):
            pass

    with remote(distro.sudo_conn, logger, create_done_path) as remote_func:
        remote_func(done_path)

    def create_init_path(init_path):
        """create the init path if it does not exist"""
        import os
        if not os.path.exists(init_path):
            with file(init_path, 'w'):
                pass

    with remote(distro.sudo_conn, logger, create_init_path) as remote_func:
        remote_func(init_path)