예제 #1
0
def activate(args, cfg):
    LOG.debug(
        "Activating cluster %s disks %s",
        args.cluster,
        # join elements of t with ':', t's with ' '
        # allow None in elements of t; print as empty
        " ".join(":".join((s or "") for s in t) for t in args.disk),
    )

    for hostname, disk, journal in args.disk:

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

        LOG.debug("activating host %s disk %s", hostname, disk)
        LOG.debug("will use init type: %s", distro.init)

        remoto.process.run(distro.conn, ["ceph-disk", "-v", "activate", "--mark-init", distro.init, "--mount", disk])
        # give the OSD a few seconds to start
        time.sleep(5)
        catch_osd_errors(distro.conn, distro.conn.logger, args)

        if distro.is_el:
            system.enable_service(distro.conn)

        distro.conn.exit()
예제 #2
0
def start_mon_service(distro, cluster, hostname):
    """
    start mon service depending on distro init
    """
    if distro.init == 'sysvinit':
        service = distro.conn.remote_module.which_service()
        remoto.process.run(
            distro.conn,
            [
                service, 'ceph', '-c',
                '/etc/ceph/{cluster}.conf'.format(cluster=cluster), 'start',
                'mon.{hostname}'.format(hostname=hostname)
            ],
            timeout=7,
        )
        system.enable_service(distro.conn)

    elif distro.init == 'upstart':
        remoto.process.run(
            distro.conn,
            [
                'initctl',
                'emit',
                'ceph-mon',
                'cluster={cluster}'.format(cluster=cluster),
                'id={hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )

    # centos7为system
    elif distro.init == 'systemd':
        # enable ceph target for this host (in case it isn't already enabled)
        remoto.process.run(
            distro.conn,
            ['systemctl', 'enable', 'ceph.target'],
            timeout=7,
        )

        # enable and start this mon instance
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'enable',
                'ceph-mon@{hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'start',
                'ceph-mon@{hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )
예제 #3
0
def create(distro, args, monitor_keyring):
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)

    if distro.init == 'sysvinit':
        service = distro.conn.remote_module.which_service()
        remoto.process.run(
            distro.conn,
            [
                service, 'ceph', '-c',
                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
                'start', 'mon.{hostname}'.format(hostname=hostname)
            ],
            timeout=7,
        )

        system.enable_service(distro.conn)
    elif distro.init == 'upstart':
        remoto.process.run(
            distro.conn,
            [
                'initctl',
                'emit',
                'ceph-mon',
                'cluster={cluster}'.format(cluster=args.cluster),
                'id={hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )

    elif distro.init == 'systemd':
        # enable ceph target for this host (in case it isn't already enabled)
        remoto.process.run(
            distro.conn,
            ['systemctl', 'enable', 'ceph.target'],
            timeout=7,
        )

        # enable and start this mon instance
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'enable',
                'ceph-mon@{hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'start',
                'ceph-mon@{hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )
예제 #4
0
def prepare_disk(
        conn,
        cluster,
        disk,
        journal,
        activate_prepared_disk,
        init,
        zap,
        fs_type,
        dmcrypt,
        dmcrypt_dir,
        storetype):
    """
    Run on osd node, prepares a data disk for use.
    """
    ceph_disk_executable = system.executable_path(conn, 'ceph-disk')
    args = [
        ceph_disk_executable,
        '-v',
        'prepare',
        ]
    if zap:
        args.append('--zap-disk')
    if dmcrypt:
        args.append('--dmcrypt')
        if dmcrypt_dir is not None:
            args.append('--dmcrypt-key-dir')
            args.append(dmcrypt_dir)
    if storetype:
        args.append('--' + storetype)
    args.extend([
        '--cluster',
        cluster,
        '--fs-type',
        fs_type,
        '--',
        disk,
    ])

    if journal is not None:
        args.append(journal)

    remoto.process.run(
        conn,
        args
    )

    if activate_prepared_disk:
        # we don't simply run activate here because we don't know
        # which partition ceph-disk prepare created as the data
        # volume.  instead, we rely on udev to do the activation and
        # just give it a kick to ensure it wakes up.  we also enable
        # ceph.target, the other key piece of activate.
        if init == 'systemd':
            system.enable_service(conn, "ceph.target")
        elif init == 'sysvinit':
            system.enable_service(conn, "ceph")
예제 #5
0
def install(distro, version_kind, version, adjust_repos, **kw):
    packages = map_components(NON_SPLIT_PACKAGES, kw.pop('components', []))

    distro.packager.install(packages)

    # Start and enable services
    for unit in SYSTEMD_UNITS:
        if unit not in SYSTEMD_UNITS_SKIP_START:
            start_service(distro.conn, unit)
        if unit not in SYSTEMD_UNITS_SKIP_ENABLE:
            enable_service(distro.conn, unit)
예제 #6
0
def prepare_disk(
        conn,
        cluster,
        disk,
        journal,
        activate_prepared_disk,
        init,
        zap,
        fs_type,
        dmcrypt,
        dmcrypt_dir):
    """
    Run on osd node, prepares a data disk for use.
    """
    ceph_disk_executable = system.executable_path(conn, 'ceph-disk')
    args = [
        ceph_disk_executable,
        '-v',
        'prepare',
        ]
    if zap:
        args.append('--zap-disk')
    if dmcrypt:
        args.append('--dmcrypt')
        if dmcrypt_dir is not None:
            args.append('--dmcrypt-key-dir')
            args.append(dmcrypt_dir)
    args.extend([
        '--cluster',
        cluster,
        '--fs-type',
        fs_type,
        '--',
        disk,
    ])

    if journal is not None:
        args.append(journal)

    remoto.process.run(
        conn,
        args
    )

    if activate_prepared_disk:
        # we don't simply run activate here because we don't know
        # which partition ceph-disk prepare created as the data
        # volume.  instead, we rely on udev to do the activation and
        # just give it a kick to ensure it wakes up.  we also enable
        # ceph.target, the other key piece of activate.
        if init == 'systemd':
            system.enable_service(conn, "ceph.target")
        elif init == 'sysvinit':
            system.enable_service(conn, "ceph")
예제 #7
0
def create(distro, args, monitor_keyring):
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)

    if distro.init == 'sysvinit':
        service = distro.conn.remote_module.which_service()
        remoto.process.run(
            distro.conn,
            [
                service,
                'ceph',
                '-c',
                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
                'start',
                'mon.{hostname}'.format(hostname=hostname)
            ],
            timeout=7,
        )

        system.enable_service(distro.conn)
    elif distro.init == 'systemd':
       # enable ceph target for this host (in case it isn't already enabled)
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'enable',
                'ceph.target'
            ],
            timeout=7,
        )

        # enable and start this mon instance
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'enable',
                'ceph-mon@{hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'start',
                'ceph-mon@{hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )
예제 #8
0
def activate(args, cfg):
    LOG.debug(
        'Activating cluster %s disks %s',
        args.cluster,
        # join elements of t with ':', t's with ' '
        # allow None in elements of t; print as empty
        ' '.join(':'.join((s or '') for s in t) for t in args.disk),
        )

    for hostname, disk, journal in args.disk:

        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
        )

        LOG.debug('activating host %s disk %s', hostname, disk)
        LOG.debug('will use init type: %s', distro.init)

        ceph_disk_executable = system.executable_path(distro.conn, 'ceph-disk')
        remoto.process.run(
            distro.conn,
            [
                ceph_disk_executable,
                '-v',
                'activate',
                '--mark-init',
                distro.init,
                '--mount',
                disk,
            ],
        )
        # give the OSD a few seconds to start
        time.sleep(5)
        catch_osd_errors(distro.conn, distro.conn.logger, args)

        if distro.init == 'systemd':
            system.enable_service(distro.conn, "ceph.target")
        elif distro.init == 'sysvinit':
            system.enable_service(distro.conn, "ceph")

        distro.conn.exit()
예제 #9
0
def activate(args, cfg):
    LOG.debug(
        'Activating cluster %s disks %s',
        args.cluster,
        # join elements of t with ':', t's with ' '
        # allow None in elements of t; print as empty
        ' '.join(':'.join((s or '') for s in t) for t in args.disk),
        )

    for hostname, disk, journal in args.disk:

        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
        )

        LOG.debug('activating host %s disk %s', hostname, disk)
        LOG.debug('will use init type: %s', distro.init)

        ceph_disk_executable = system.executable_path(distro.conn, 'ceph-disk')
        remoto.process.run(
            distro.conn,
            [
                ceph_disk_executable,
                '-v',
                'activate',
                '--mark-init',
                distro.init,
                '--mount',
                disk,
            ],
        )
        # give the OSD a few seconds to start
        time.sleep(5)
        catch_osd_errors(distro.conn, distro.conn.logger, args)

        if distro.init == 'systemd':
            system.enable_service(distro.conn, "ceph.target")
        elif distro.init == 'sysvinit':
            system.enable_service(distro.conn, "ceph")

        distro.conn.exit()
예제 #10
0
파일: install.py 프로젝트: ceph/ceph-deploy
def install(distro, version_kind, version, adjust_repos, **kw):
    packages = map_components(
        NON_SPLIT_PACKAGES,
        kw.pop('components', [])
    )

    distro.packager.install(
        packages
    )

    # Start and enable services
    for unit in SYSTEMD_UNITS:
        if unit not in SYSTEMD_UNITS_SKIP_START:
            start_service(distro.conn, unit)
        if unit not in SYSTEMD_UNITS_SKIP_ENABLE:
            enable_service(distro.conn, unit)
예제 #11
0
def create(distro, args, monitor_keyring):
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)
    service = distro.conn.remote_module.which_service()

    remoto.process.run(
        distro.conn,
        [
            service,
            'ceph',
            '-c',
            '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
            'start',
            'mon.{hostname}'.format(hostname=hostname)
        ],
        timeout=7,
    )

    system.enable_service(distro.conn)
예제 #12
0
파일: osd.py 프로젝트: jebtang/ceph-deploy
def activate(args, cfg):
    LOG.debug(
        'Activating cluster %s disks %s',
        args.cluster,
        # join elements of t with ':', t's with ' '
        # allow None in elements of t; print as empty
        ' '.join(':'.join((s or '') for s in t) for t in args.disk),
        )

    for hostname, disk, journal in args.disk:

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

        LOG.debug('activating host %s disk %s', hostname, disk)
        LOG.debug('will use init type: %s', distro.init)

        remoto.process.run(
            distro.conn,
            [
                'ceph-disk',
                '-v',
                'activate',
                '--mark-init',
                distro.init,
                '--mount',
                disk,
            ],
        )
        # give the OSD a few seconds to start
        time.sleep(5)
        catch_osd_errors(distro.conn, distro.conn.logger, args)
        distro.conn.exit()

        if distro.is_el:
            system.enable_service(distro.conn)
예제 #13
0
파일: rgw.py 프로젝트: rtulke/ceph-deploy
def create_rgw(distro, name, cluster, init):
    conn = distro.conn

    path = "/var/lib/ceph/radosgw/{cluster}-{name}".format(cluster=cluster, name=name)

    conn.remote_module.safe_mkdir(path)

    bootstrap_keyring = "/var/lib/ceph/bootstrap-rgw/{cluster}.keyring".format(cluster=cluster)

    keypath = os.path.join(path, "keyring")

    stdout, stderr, returncode = remoto.process.check(
        conn,
        [
            "ceph",
            "--cluster",
            cluster,
            "--name",
            "client.bootstrap-rgw",
            "--keyring",
            bootstrap_keyring,
            "auth",
            "get-or-create",
            "client.{name}".format(name=name),
            "osd",
            "allow rwx",
            "mon",
            "allow rw",
            "-o",
            os.path.join(keypath),
        ],
    )
    if returncode > 0 and returncode != errno.EACCES:
        for line in stderr:
            conn.logger.error(line)
        for line in stdout:
            # yes stdout as err because this is an error
            conn.logger.error(line)
        conn.logger.error("exit code from command was: %s" % returncode)
        raise RuntimeError("could not create rgw")

        remoto.process.check(
            conn,
            [
                "ceph",
                "--cluster",
                cluster,
                "--name",
                "client.bootstrap-rgw",
                "--keyring",
                bootstrap_keyring,
                "auth",
                "get-or-create",
                "client.{name}".format(name=name),
                "osd",
                "allow *",
                "mon",
                "allow *",
                "-o",
                os.path.join(keypath),
            ],
        )

    conn.remote_module.touch_file(os.path.join(path, "done"))
    conn.remote_module.touch_file(os.path.join(path, init))

    if init == "upstart":
        remoto.process.run(
            conn,
            ["initctl", "emit", "radosgw", "cluster={cluster}".format(cluster=cluster), "id={name}".format(name=name)],
            timeout=7,
        )
    elif init == "sysvinit":
        remoto.process.run(conn, ["service", "ceph", "start", "rgw.{name}".format(name=name)], timeout=7)

    if distro.is_el:
        system.enable_service(distro.conn)
예제 #14
0
파일: common.py 프로젝트: ceph/ceph-deploy
def start_mon_service(distro, cluster, hostname):
    """
    start mon service depending on distro init
    """
    if distro.init == 'sysvinit':
        service = distro.conn.remote_module.which_service()
        remoto.process.run(
            distro.conn,
            [
                service,
                'ceph',
                '-c',
                '/etc/ceph/{cluster}.conf'.format(cluster=cluster),
                'start',
                'mon.{hostname}'.format(hostname=hostname)
            ],
            timeout=7,
        )
        system.enable_service(distro.conn)

    elif distro.init == 'upstart':
        remoto.process.run(
             distro.conn,
             [
                 'initctl',
                 'emit',
                 'ceph-mon',
                 'cluster={cluster}'.format(cluster=cluster),
                 'id={hostname}'.format(hostname=hostname),
             ],
             timeout=7,
         )

    elif distro.init == 'systemd':
       # enable ceph target for this host (in case it isn't already enabled)
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'enable',
                'ceph.target'
            ],
            timeout=7,
        )

        # enable and start this mon instance
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'enable',
                'ceph-mon@{hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )
        remoto.process.run(
            distro.conn,
            [
                'systemctl',
                'start',
                'ceph-mon@{hostname}'.format(hostname=hostname),
            ],
            timeout=7,
        )
예제 #15
0
파일: mgr.py 프로젝트: sheepcat/ceph-deploy
def create_mgr(distro, name, cluster, init):
    conn = distro.conn

    path = '/Ceph/Data/Mgr/{cluster}-{name}'.format(cluster=cluster, name=name)

    conn.remote_module.safe_mkdir(path)

    bootstrap_keyring = '/Ceph/Data/Mgr/{cluster}.keyring'.format(
        cluster=cluster)

    keypath = os.path.join(path, 'keyring')

    stdout, stderr, returncode = remoto.process.check(conn, [
        'ceph',
        '--cluster',
        cluster,
        '--name',
        'client.bootstrap-mgr',
        '--keyring',
        bootstrap_keyring,
        'auth',
        'get-or-create',
        'mgr.{name}'.format(name=name),
        'mon',
        'allow profile mgr',
        'osd',
        'allow *',
        'mds',
        'allow *',
        '-o',
        os.path.join(keypath),
    ])
    LOG.info("---stdout:%s, stderr:%s, returncode:%s---", stdout, stderr,
             returncode)
    if returncode > 0:
        for line in stderr:
            conn.logger.error(line)
        for line in stdout:
            # yes stdout as err because this is an error
            conn.logger.error(line)
        conn.logger.error('exit code from command was: %s' % returncode)
        raise RuntimeError('could not create mgr')

    conn.remote_module.touch_file(os.path.join(path, 'done'))
    conn.remote_module.touch_file(os.path.join(path, init))

    if init == 'upstart':
        remoto.process.run(conn, [
            'initctl',
            'emit',
            'ceph-mgr',
            'cluster={cluster}'.format(cluster=cluster),
            'id={name}'.format(name=name),
        ],
                           timeout=7)
    elif init == 'sysvinit':
        remoto.process.run(conn, [
            'service',
            'ceph',
            'start',
            'mgr.{name}'.format(name=name),
        ],
                           timeout=7)
        if distro.is_el:
            system.enable_service(distro.conn)
    elif init == 'systemd':
        remoto.process.run(conn, [
            'systemctl',
            'enable',
            'ceph-mgr@{name}'.format(name=name),
        ],
                           timeout=7)
        remoto.process.run(conn, [
            'systemctl',
            'start',
            'ceph-mgr@{name}'.format(name=name),
        ],
                           timeout=7)
        remoto.process.run(conn, [
            'systemctl',
            'enable',
            'ceph.target',
        ],
                           timeout=7)
예제 #16
0
def create_rgw(distro, name, cluster, init):
    conn = distro.conn

    path = '/var/lib/ceph/radosgw/{cluster}-{name}'.format(cluster=cluster,
                                                           name=name)

    conn.remote_module.safe_makedirs(path)

    bootstrap_keyring = '/var/lib/ceph/bootstrap-rgw/{cluster}.keyring'.format(
        cluster=cluster)

    keypath = os.path.join(path, 'keyring')

    stdout, stderr, returncode = remoto.process.check(conn, [
        'ceph',
        '--cluster',
        cluster,
        '--name',
        'client.bootstrap-rgw',
        '--keyring',
        bootstrap_keyring,
        'auth',
        'get-or-create',
        'client.{name}'.format(name=name),
        'osd',
        'allow rwx',
        'mon',
        'allow rw',
        '-o',
        os.path.join(keypath),
    ])
    if returncode > 0 and returncode != errno.EACCES:
        for line in stderr:
            conn.logger.error(line)
        for line in stdout:
            # yes stdout as err because this is an error
            conn.logger.error(line)
        conn.logger.error('exit code from command was: %s' % returncode)
        raise RuntimeError('could not create rgw')

        remoto.process.check(conn, [
            'ceph',
            '--cluster',
            cluster,
            '--name',
            'client.bootstrap-rgw',
            '--keyring',
            bootstrap_keyring,
            'auth',
            'get-or-create',
            'client.{name}'.format(name=name),
            'osd',
            'allow *',
            'mon',
            'allow *',
            '-o',
            os.path.join(keypath),
        ])

    conn.remote_module.touch_file(os.path.join(path, 'done'))
    conn.remote_module.touch_file(os.path.join(path, init))

    if init == 'upstart':
        remoto.process.run(conn, [
            'initctl',
            'emit',
            'radosgw',
            'cluster={cluster}'.format(cluster=cluster),
            'id={name}'.format(name=name),
        ],
                           timeout=7)
    elif init == 'sysvinit':
        remoto.process.run(conn, [
            'service',
            'ceph-radosgw',
            'start',
        ],
                           timeout=7)
        if distro.is_el:
            system.enable_service(distro.conn, service='ceph-radosgw')
    elif init == 'systemd':
        remoto.process.run(conn, [
            'systemctl',
            'enable',
            'ceph-radosgw@{name}'.format(name=name),
        ],
                           timeout=7)
        remoto.process.run(conn, [
            'systemctl',
            'start',
            'ceph-radosgw@{name}'.format(name=name),
        ],
                           timeout=7)
        remoto.process.run(conn, [
            'systemctl',
            'enable',
            'ceph.target',
        ],
                           timeout=7)
예제 #17
0
파일: mgr.py 프로젝트: wido/ceph-deploy
def create_mgr(distro, name, cluster, init):
    conn = distro.conn

    path = '/var/lib/ceph/mgr/{cluster}-{name}'.format(
        cluster=cluster,
        name=name
        )

    conn.remote_module.safe_makedirs(path)

    bootstrap_keyring = '/var/lib/ceph/bootstrap-mgr/{cluster}.keyring'.format(
        cluster=cluster
        )

    keypath = os.path.join(path, 'keyring')

    stdout, stderr, returncode = remoto.process.check(
        conn,
        [
            'ceph',
            '--cluster', cluster,
            '--name', 'client.bootstrap-mgr',
            '--keyring', bootstrap_keyring,
            'auth', 'get-or-create', 'mgr.{name}'.format(name=name),
            'mon', 'allow profile mgr',
            'osd', 'allow *',
            'mds', 'allow *',
            '-o',
            os.path.join(keypath),
        ]
    )
    if returncode > 0:
        for line in stderr:
            conn.logger.error(line)
        for line in stdout:
            # yes stdout as err because this is an error
            conn.logger.error(line)
        conn.logger.error('exit code from command was: %s' % returncode)
        raise RuntimeError('could not create mgr')

    conn.remote_module.touch_file(os.path.join(path, 'done'))
    conn.remote_module.touch_file(os.path.join(path, init))

    if init == 'upstart':
        remoto.process.run(
            conn,
            [
                'initctl',
                'emit',
                'ceph-mgr',
                'cluster={cluster}'.format(cluster=cluster),
                'id={name}'.format(name=name),
            ],
            timeout=7
        )
    elif init == 'sysvinit':
        remoto.process.run(
            conn,
            [
                'service',
                'ceph',
                'start',
                'mgr.{name}'.format(name=name),
            ],
            timeout=7
        )
        if distro.is_el:
            system.enable_service(distro.conn)
    elif init == 'systemd':
        remoto.process.run(
            conn,
            [
                'systemctl',
                'enable',
                'ceph-mgr@{name}'.format(name=name),
            ],
            timeout=7
        )
        remoto.process.run(
            conn,
            [
                'systemctl',
                'start',
                'ceph-mgr@{name}'.format(name=name),
            ],
            timeout=7
        )
        remoto.process.run(
            conn,
            [
                'systemctl',
                'enable',
                'ceph.target',
            ],
            timeout=7
        )