Exemplo n.º 1
0
def choose_init(module):
    """
    Select a init system

    Returns the name of a init system (systemd, sysvinit ...).
    """

    if is_systemd(module.conn):
        return 'systemd'

    return 'sysvinit'
Exemplo n.º 2
0
def choose_init(module):
    """
    Select a init system

    Returns the name of a init system (systemd, sysvinit ...).
    """


    if is_systemd(module.conn):
        return 'systemd'

    return 'sysvinit'
Exemplo n.º 3
0
def choose_init(module):
    """
    Select a init system

    Returns the name of a init system (upstart, sysvinit ...).
    """
    if is_systemd(module.conn) or module.conn.remote_module.path_exists(
            "/lib/systemd/system/ceph.target"):
        return 'systemd'

    if is_upstart(module.conn):
        return 'upstart'

    return 'sysvinit'
Exemplo n.º 4
0
def choose_init(module):
    """
    Select a init system

    Returns the name of a init system (upstart, sysvinit ...).
    """

    if module.normalized_release.int_major < 7:
        return 'sysvinit'

    if not module.conn.remote_module.path_exists("/usr/lib/systemd/system/ceph.target"):
        return 'sysvinit'

    if is_systemd(module.conn):
        return 'systemd'

    return 'systemd'
Exemplo n.º 5
0
def choose_init(module):
    """
    Select a init system

    Returns the name of a init system (upstart, sysvinit ...).
    """

    if module.normalized_release.int_major < 7:
        return 'sysvinit'

    if not module.conn.remote_module.path_exists("/usr/lib/systemd/system/ceph.target"):
        return 'sysvinit'

    if is_systemd(module.conn):
        return 'systemd'

    return 'systemd'
Exemplo n.º 6
0
def choose_init(module):
    """
    Select a init system

    Returns the name of a init system (upstart, sysvinit ...).
    """
    # Upstart checks first because when installing ceph, the
    # `/lib/systemd/system/ceph.target` file may be created, fooling this
    # detection mechanism.
    if is_upstart(module.conn):
        return 'upstart'

    if is_systemd(module.conn) or module.conn.remote_module.path_exists(
            "/lib/systemd/system/ceph.target"):
        return 'systemd'

    return 'sysvinit'
Exemplo n.º 7
0
def choose_init(module):
    """
    Select a init system

    Returns the name of a init system (upstart, sysvinit ...).
    """

    # 兼容XenServer/WinServer,由于WinServer的major版本号<7,基于CentOS7.2,所以首先判断is_systemd
    if is_systemd(module.conn):
        return 'systemd'

    if module.normalized_release.int_major < 7:
        return 'sysvinit'

    if not module.conn.remote_module.path_exists("/usr/lib/systemd/system/ceph.target"):
        return 'sysvinit'

    return 'systemd'
Exemplo n.º 8
0
def destroy_mon(conn, cluster, hostname):
    import datetime
    import time
    retries = 5

    # mon的目录,比如/var/lib/ceph/mon/ceph-node1
    path = paths.mon.path(cluster, hostname)

    if conn.remote_module.path_exists(path):
        # remove from cluster
        # 从集群中删除mon
        remoto.process.run(
            conn,
            [
                'ceph',
                '--cluster={cluster}'.format(cluster=cluster),
                '-n', 'mon.',
                '-k', '{path}/keyring'.format(path=path),
                'mon',
                'remove',
                hostname,
            ],
            timeout=7,
        )

        # stop
        if conn.remote_module.path_exists(os.path.join(path, 'upstart')) or system.is_upstart(conn):
            status_args = [
                'initctl',
                'status',
                'ceph-mon',
                'cluster={cluster}'.format(cluster=cluster),
                'id={hostname}'.format(hostname=hostname),
            ]

        elif conn.remote_module.path_exists(os.path.join(path, 'sysvinit')):
            status_args = [
                'service',
                'ceph',
                'status',
                'mon.{hostname}'.format(hostname=hostname),
            ]
        elif system.is_systemd(conn):
            # 停止mon服务
            status_args = [
                'systemctl',
                'stop',
                'ceph-mon@{hostname}.service'.format(hostname=hostname),
            ]
        else:
            raise RuntimeError('could not detect a supported init system, cannot continue')

        while retries:
            conn.logger.info('polling the daemon to verify it stopped')
            if is_running(conn, status_args):
                time.sleep(5)
                retries -= 1
                if retries <= 0:
                    raise RuntimeError('ceph-mon deamon did not stop')
            else:
                break

        # archive old monitor directory
        fn = '{cluster}-{hostname}-{stamp}'.format(
            hostname=hostname,
            cluster=cluster,
            stamp=datetime.datetime.utcnow().strftime("%Y-%m-%dZ%H:%M:%S"),
            )

        # 创建/var/lib/ceph/mon-removed目录
        remoto.process.run(
            conn,
            [
                'mkdir',
                '-p',
                '/var/lib/ceph/mon-removed',
            ],
        )

        # 将mon数据文件移动到/var/lib/ceph/mon-removed目录归档文件
        conn.remote_module.make_mon_removed_dir(path, fn)
Exemplo n.º 9
0
def destroy_mon(conn, cluster, hostname):
    import datetime
    import time
    retries = 5

    path = paths.mon.path(cluster, hostname)

    if conn.remote_module.path_exists(path):
        # remove from cluster
        remoto.process.run(
            conn,
            [
                'ceph',
                '--cluster={cluster}'.format(cluster=cluster),
                '-n', 'mon.',
                '-k', '{path}/keyring'.format(path=path),
                'mon',
                'remove',
                hostname,
            ],
            timeout=7,
        )

        # stop
        if conn.remote_module.path_exists(os.path.join(path, 'upstart')) or system.is_upstart(conn):
            status_args = [
                'initctl',
                'status',
                'ceph-mon',
                'cluster={cluster}'.format(cluster=cluster),
                'id={hostname}'.format(hostname=hostname),
            ]

        elif conn.remote_module.path_exists(os.path.join(path, 'sysvinit')):
            status_args = [
                'service',
                'ceph',
                'status',
                'mon.{hostname}'.format(hostname=hostname),
            ]
        elif system.is_systemd(conn):
            status_args = [
                'systemctl',
                'stop',
                'ceph-mon@{hostname}.service'.format(hostname=hostname),
            ]
        else:
            raise RuntimeError('could not detect a supported init system, cannot continue')

        while retries:
            conn.logger.info('polling the daemon to verify it stopped')
            if is_running(conn, status_args):
                time.sleep(5)
                retries -= 1
                if retries <= 0:
                    raise RuntimeError('ceph-mon deamon did not stop')
            else:
                break

        # archive old monitor directory
        fn = '{cluster}-{hostname}-{stamp}'.format(
            hostname=hostname,
            cluster=cluster,
            stamp=datetime.datetime.utcnow().strftime("%Y-%m-%dZ%H:%M:%S"),
            )

        remoto.process.run(
            conn,
            [
                'mkdir',
                '-p',
                '/var/lib/ceph/mon-removed',
            ],
        )

        conn.remote_module.make_mon_removed_dir(path, fn)