Esempio n. 1
0
def mirror_install(distro, repo_url, gpg_url, adjust_repos):
    repo_url = repo_url.strip('/')  # Remove trailing slashes
    gpg_url_path = gpg_url.split('file://')[-1]  # Remove file if present

    pkg_managers.yum_clean(distro.conn)

    if adjust_repos:
        process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpg_url_path,
            ]
        )

        ceph_repo_content = templates.ceph_repo.format(
            repo_url=repo_url,
            gpg_url=gpg_url
        )

        distro.conn.remote_module.write_yum_repo(ceph_repo_content)

    # Before any install, make sure we have `wget`
    pkg_managers.yum(distro.conn, 'wget')

    pkg_managers.yum(distro.conn, 'ceph')
Esempio n. 2
0
def mirror_install(distro, repo_url, gpg_url, adjust_repos):
    repo_url = repo_url.strip('/')  # Remove trailing slashes
    gpg_url_path = gpg_url.split('file://')[-1]  # Remove file if present

    pkg_managers.yum_clean(distro.conn)

    if adjust_repos:
        process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpg_url_path,
            ]
        )

        ceph_repo_content = templates.ceph_repo.format(
            repo_url=repo_url,
            gpg_url=gpg_url
        )

        distro.conn.remote_module.write_yum_repo(ceph_repo_content)

    # Before any install, make sure we have `wget`
    pkg_managers.yum(distro.conn, 'wget')

    pkg_managers.yum(distro.conn, 'ceph')
Esempio n. 3
0
def mirror_install(distro, repo_url, gpg_url, adjust_repos):
    repo_url = repo_url.strip('/')  # Remove trailing slashes
    gpg_url_path = gpg_url.split('file://')[-1]  # Remove file if present

    if adjust_repos:
        process.run(distro.conn, [
            'rpm',
            '--import',
            gpg_url_path,
        ])

        ceph_repo_content = templates.ceph_repo.format(repo_url=repo_url,
                                                       gpg_url=gpg_url)

        distro.conn.remote_module.write_yum_repo(ceph_repo_content)

    process.run(
        distro.conn,
        [
            'zypper',
            '--non-interactive',
            '--quiet',
            'install',
            'ceph',
        ],
    )
Esempio n. 4
0
def disk_zap(args):
    cfg = conf.ceph.load(args)

    for hostname, disk, journal in args.disk:
        if not disk or not hostname:
            raise RuntimeError('zap command needs both HOSTNAME and DISK but got "%s %s"' % (hostname, disk))
        LOG.debug('zapping %s on %s', disk, hostname)
        distro = hosts.get(hostname, username=args.username)
        LOG.info(
            'Distro info: %s %s %s',
            distro.name,
            distro.release,
            distro.codename
        )

        # NOTE: this mirrors ceph-disk-prepare --zap-disk DEV
        # zero the device
        distro.conn.remote_module.zeroing(disk)

        process.run(
            distro.conn,
            [
                'sgdisk',
                '--zap-all',
                '--clear',
                '--mbrtogpt',
                '--',
                disk,
            ],
        )
        distro.conn.exit()
Esempio n. 5
0
def disk_zap(args):
    cfg = conf.ceph.load(args)

    for hostname, disk, journal in args.disk:
        if not disk or not hostname:
            raise RuntimeError(
                'zap command needs both HOSTNAME and DISK but got "%s %s"' %
                (hostname, disk))
        LOG.debug('zapping %s on %s', disk, hostname)
        distro = hosts.get(hostname, username=args.username)
        LOG.info('Distro info: %s %s %s', distro.name, distro.release,
                 distro.codename)

        # NOTE: this mirrors ceph-disk-prepare --zap-disk DEV
        # zero the device
        distro.conn.remote_module.zeroing(disk)

        process.run(
            distro.conn,
            [
                'sgdisk',
                '--zap-all',
                '--clear',
                '--mbrtogpt',
                '--',
                disk,
            ],
        )
        distro.conn.exit()
Esempio n. 6
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)

        process.run(
            distro.conn,
            [
                'ceph-disk-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()
Esempio n. 7
0
def install_epel(distro):
    """
    CentOS and Scientific need the EPEL repo, otherwise Ceph cannot be
    installed.
    """
    if distro.name.lower() in ['centos', 'scientific']:
        distro.conn.logger.info('adding EPEL repository')
        if float(distro.release) >= 6:
            process.run(
                distro.conn,
                ['wget', 'http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'],
            )
            pkg_managers.rpm(
                distro.conn,
                [
                    '--replacepkgs',
                    'epel-release-6*.rpm',
                ],
            )
        else:
            process.run(
                distro.conn,
                ['wget', 'wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm'],
            )
            pkg_managers.rpm(
                distro.conn,
                [
                    '--replacepkgs',
                    'epel-release-5*.rpm'
                ],
            )
Esempio n. 8
0
def mirror_install(distro, repo_url, gpg_url, adjust_repos):
    repo_url = repo_url.strip('/')  # Remove trailing slashes

    if adjust_repos:
        process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpg_url,
            ]
        )

        ceph_repo_content = templates.ceph_repo.format(
            repo_url=repo_url,
            gpg_url=gpg_url
        )

        distro.conn.remote_module.write_yum_repo(ceph_repo_content)

    process.run(
        distro.conn,
        [
            'zypper',
            '--non-interactive',
            '--quiet',
            'install',
            'ceph',
            ],
        )
Esempio n. 9
0
def repo_install(distro, repo_name, baseurl, gpgkey, **kw):
    # Get some defaults
    name = kw.get('name', '%s repo' % repo_name)
    enabled = kw.get('enabled', 1)
    gpgcheck = kw.get('gpgcheck', 1)
    install_ceph = kw.pop('install_ceph', False)
    _type = 'repo-md'
    baseurl = baseurl.strip('/')  # Remove trailing slashes

    if gpgkey:
        process.run(distro.conn, [
            'rpm',
            '--import',
            gpgkey,
        ])

    repo_content = templates.custom_repo.format(
        repo_name=repo_name,
        name=name,
        baseurl=baseurl,
        enabled=enabled,
        gpgcheck=gpgcheck,
        _type=_type,
        gpgkey=gpgkey,
    )

    distro.conn.remote_module.write_yum_repo(repo_content,
                                             "%s.repo" % repo_name)

    # Some custom repos do not need to install ceph
    if install_ceph:
        # Before any install, make sure we have `wget`
        pkg_managers.zypper(distro.conn, 'wget')

        pkg_managers.zypper(distro.conn, 'ceph')
Esempio n. 10
0
def create(distro, args, monitor_keyring):
    logger = distro.conn.logger
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)
    service = distro.conn.remote_module.which_service()

    if not service:
        logger.warning('could not find `service` executable')

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

    elif distro.init == 'sysvinit':  # Debian uses sysvinit

        process.run(
            distro.conn,
            [
                service, 'ceph', '-c',
                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
                'start', 'mon.{hostname}'.format(hostname=hostname)
            ],
            timeout=7,
        )
    else:
        raise RuntimeError('create cannot use init %s' % distro.init)
Esempio n. 11
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)
Esempio n. 12
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.ceph.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)
Esempio n. 13
0
def install(distro, version_kind, version, adjust_repos):
    process.run(
        distro.conn,
        [
            'pacman',
            '-S',
            '--noconfirm',
            '--needed',
            'ceph',
            'gdisk'
        ],
    )
Esempio n. 14
0
def prepare_disk(
        conn,
        cluster,
        disk,
        journal,
        activate_prepared_disk,
        zap,
        fs_type,
        dmcrypt,
        dmcrypt_dir):
    """
    Run on osd node, prepares a data disk for use.
    """
    args = [
        'ceph-disk-prepare',
        ]
    if zap:
        args.append('--zap-disk')
    if fs_type:
        if fs_type not in ('btrfs', 'ext4', 'xfs'):
            raise argparse.ArgumentTypeError(
                "FS_TYPE must be one of 'btrfs', 'ext4' or 'xfs'")
        args.extend(['--fs-type', fs_type])
    if dmcrypt:
        args.append('--dmcrypt')
        if dmcrypt_dir is not None:
            args.append('--dmcrypt-key-dir')
            args.append(dmcrypt_dir)
    args.extend([
        '--cluster',
        cluster,
        '--',
        disk,
    ])

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

    process.run(
        conn,
        args
    )

    if activate_prepared_disk:
        return process.run(
            conn,
            [
                'udevadm',
                'trigger',
                '--subsystem-match=block',
                '--action=add',
            ],
        )
Esempio n. 15
0
def create(distro, args, monitor_keyring):
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)

    process.run(
        distro.conn,
        [
            'rcceph', '-c',
            '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster), 'start',
            'mon.{hostname}'.format(hostname=hostname)
        ],
        timeout=7,
    )
Esempio n. 16
0
def repo_install(distro, repo_name, baseurl, gpgkey, **kw):
    # Get some defaults
    safe_filename = '%s.list' % repo_name.replace(' ', '-')
    install_ceph = kw.pop('install_ceph', False)
    baseurl = baseurl.strip('/')  # Remove trailing slashes

    if gpgkey:
        process.run(
            distro.conn,
            [
                'wget',
                '-O',
                'release.asc',
                gpgkey,
            ],
            stop_on_nonzero=False,
        )

    process.run(
        distro.conn,
        [
            'apt-key',
            'add',
            'release.asc'
        ]
    )

    distro.conn.remote_module.write_sources_list(
        baseurl,
        distro.codename,
        safe_filename
    )

    # repo is not operable until an update
    pkg_managers.apt_update(distro.conn)

    if install_ceph:
        # Before any install, make sure we have `wget`
        packages = (
            'ceph',
            'ceph-mds',
            'ceph-common',
            'ceph-fs-common',
            # ceph only recommends gdisk, make sure we actually have
            # it; only really needed for osds, but minimal collateral
            'gdisk',
        )

        pkg_managers.apt(distro.conn, packages)
        pkg_managers.apt(distro.conn, 'ceph')
Esempio n. 17
0
def mirror_install(distro, repo_url, gpg_url, adjust_repos):
    repo_url = repo_url.strip("/")  # Remove trailing slashes

    if adjust_repos:
        process.run(distro.conn, ["rpm", "--import", gpg_url])

        ceph_repo_content = templates.ceph_repo.format(repo_url=repo_url, gpg_url=gpg_url)

        distro.conn.remote_module.write_yum_repo(ceph_repo_content)

    # Before any install, make sure we have `wget`
    pkg_managers.yum(distro.conn, "wget")

    pkg_managers.yum(distro.conn, "ceph")
Esempio n. 18
0
def create(distro, args, monitor_keyring):
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)

    process.run(
        distro.conn,
        [
            'rcceph',
            '-c',
            '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
            'start',
            'mon.{hostname}'.format(hostname=hostname)
        ],
        timeout=7,
    )
Esempio n. 19
0
def disk_list(args, cfg):
    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('Listing disks on {hostname}...'.format(hostname=hostname))
        process.run(
            distro.conn,
            [
                'ceph-disk',
                'list',
            ],
        )
        distro.conn.exit()
Esempio n. 20
0
def uninstall(conn, purge=False):
    packages = [
        'ceph',
        'libcephfs1',
        'librados2',
        'librbd1',
    ]
    cmd = [
        'zypper',
        '--non-interactive',
        '--quiet',
        'remove',
    ]

    cmd.extend(packages)
    process.run(conn, cmd)
Esempio n. 21
0
def uninstall(conn, purge=False):
    packages = [
        'ceph',
        'libcephfs1',
        'librados2',
        'librbd1',
        ]
    cmd = [
        'zypper',
        '--non-interactive',
        '--quiet',
        'remove',
        ]

    cmd.extend(packages)
    process.run(conn, cmd)
Esempio n. 22
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()

    process.run(
        distro.conn,
        [
            "rcceph",
            "-c",
            "/etc/ceph/{cluster}.conf".format(cluster=args.cluster),
            "start",
            "mon.{hostname}".format(hostname=hostname),
        ],
        timeout=7,
    )
Esempio n. 23
0
def install_epel(distro):
    """
    CentOS and Scientific need the EPEL repo, otherwise Ceph cannot be
    installed.
    """
    if distro.name.lower() in ["centos", "scientific"]:
        distro.conn.logger.info("adding EPEL repository")
        if float(distro.release) >= 6:
            process.run(
                distro.conn, ["wget", "http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm"]
            )
            pkg_managers.rpm(distro.conn, ["--replacepkgs", "epel-release-6*.rpm"])
        else:
            process.run(
                distro.conn, ["wget", "http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm"]
            )
            pkg_managers.rpm(distro.conn, ["--replacepkgs", "epel-release-5*.rpm"])
Esempio n. 24
0
def yum(conn, package, *a, **kw):
    cmd = [
        'yum',
        '-y',
        '-q',
        'install',
        package,
    ]
    return process.run(conn, cmd, *a, **kw)
Esempio n. 25
0
def repo_install(distro, repo_name, baseurl, gpgkey, **kw):
    # Get some defaults
    name = kw.get('name', '%s repo' % repo_name)
    enabled = kw.get('enabled', 1)
    gpgcheck = kw.get('gpgcheck', 1)
    install_ceph = kw.pop('install_ceph', False)
    proxy = kw.get('proxy', '')
    _type = 'repo-md'
    baseurl = baseurl.strip('/')  # Remove trailing slashes

    pkg_managers.yum_clean(distro.conn)

    if gpgkey:
        process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpgkey,
            ]
        )

    repo_content = templates.custom_repo.format(
        repo_name=repo_name,
        name = name,
        baseurl = baseurl,
        enabled = enabled,
        gpgcheck = gpgcheck,
        _type = _type,
        gpgkey = gpgkey,
        proxy = proxy,
    )

    distro.conn.remote_module.write_yum_repo(
        repo_content,
        "%s.repo" % repo_name
    )

    # Some custom repos do not need to install ceph
    if install_ceph:
        # Before any install, make sure we have `wget`
        pkg_managers.yum(distro.conn, 'wget')

        pkg_managers.yum(distro.conn, 'ceph')
Esempio n. 26
0
def disk_list(args, cfg):
    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('Listing disks on {hostname}...'.format(hostname=hostname))
        process.run(
            distro.conn,
            [
                'ceph-disk',
                'list',
            ],
        )
        distro.conn.exit()
Esempio n. 27
0
def ssh_copy_keys(hostname, username=None):
    LOG.info('making sure passwordless SSH succeeds')
    if ssh.can_connect_passwordless(hostname):
        return

    LOG.warning('could not connect via SSH')

    # Create the key if it doesn't exist:
    id_rsa_pub_file = os.path.expanduser(u'~/.ssh/id_rsa.pub')
    id_rsa_file = id_rsa_pub_file.split('.pub')[0]
    if not os.path.exists(id_rsa_file):
        LOG.info('creating a passwordless id_rsa.pub key file')
        with get_local_connection(LOG) as conn:
            process.run(
                conn,
                [
                    'ssh-keygen',
                    '-t',
                    'rsa',
                    '-N',
                    "",
                    '-f',
                    id_rsa_file,
                ]
            )

    # Get the contents of id_rsa.pub and push it to the host
    LOG.info('will connect again with password prompt')
    distro = hosts.get(hostname, username)  # XXX Add username
    auth_keys_path = '.ssh/authorized_keys'
    if not distro.conn.remote_module.path_exists(auth_keys_path):
        distro.conn.logger.warning(
            '.ssh/authorized_keys does not exist, will skip adding keys'
        )
    else:
        LOG.info('adding public keys to authorized_keys')
        with open(os.path.expanduser('~/.ssh/id_rsa.pub'), 'r') as id_rsa:
            contents = id_rsa.read()
        distro.conn.remote_module.append_to_file(
            auth_keys_path,
            contents
        )
    distro.conn.exit()
Esempio n. 28
0
def apt_update(conn):
    cmd = [
        'apt-get',
        '-q',
        'update',
    ]
    return process.run(
        conn,
        cmd,
    )
Esempio n. 29
0
def ssh_copy_keys(hostname, username=None):
    LOG.info('making sure passwordless SSH succeeds')
    if ssh.can_connect_passwordless(hostname):
        return

    LOG.warning('could not connect via SSH')

    # Create the key if it doesn't exist:
    id_rsa_pub_file = os.path.expanduser(u'~/.ssh/id_rsa.pub')
    id_rsa_file = id_rsa_pub_file.split('.pub')[0]
    if not os.path.exists(id_rsa_file):
        LOG.info('creating a passwordless id_rsa.pub key file')
        with get_local_connection(LOG) as conn:
            process.run(
                conn,
                [
                    'ssh-keygen',
                    '-t',
                    'rsa',
                    '-N',
                    "",
                    '-f',
                    id_rsa_file,
                ]
            )

    # Get the contents of id_rsa.pub and push it to the host
    LOG.info('will connect again with password prompt')
    distro = hosts.get(hostname, username)  # XXX Add username
    auth_keys_path = '.ssh/authorized_keys'
    if not distro.conn.remote_module.path_exists(auth_keys_path):
        distro.conn.logger.warning(
            '.ssh/authorized_keys does not exist, will skip adding keys'
        )
    else:
        LOG.info('adding public keys to authorized_keys')
        with open(os.path.expanduser('~/.ssh/id_rsa.pub'), 'r') as id_rsa:
            contents = id_rsa.read()
        distro.conn.remote_module.append_to_file(
            auth_keys_path,
            contents
        )
    distro.conn.exit()
Esempio n. 30
0
def mirror_install(distro, repo_url, gpg_url, adjust_repos):
    repo_url = repo_url.strip('/')  # Remove trailing slashes
    gpg_path = gpg_url.split('file://')[-1]

    if adjust_repos:
        if not gpg_url.startswith('file://'):
            process.run(
                distro.conn,
                [
                    'wget',
                    '-O',
                    'release.asc',
                    gpg_url,
                ],
                stop_on_nonzero=False,
            )

        gpg_file = 'release.asc' if not gpg_url.startswith('file://') else gpg_path
        process.run(
            distro.conn,
            [
                'apt-key',
                'add',
                gpg_file,
            ]
        )

        distro.conn.remote_module.write_sources_list(repo_url, distro.codename)

    # Before any install, make sure we have `wget`
    pkg_managers.apt_update(distro.conn)
    packages = (
        'ceph',
        'ceph-mds',
        'ceph-common',
        'ceph-fs-common',
        # ceph only recommends gdisk, make sure we actually have
        # it; only really needed for osds, but minimal collateral
        'gdisk',
    )

    pkg_managers.apt(distro.conn, packages)
    pkg_managers.apt(distro.conn, 'ceph')
Esempio n. 31
0
def apt_update(conn):
    cmd = [
        'apt-get',
        '-q',
        'update',
    ]
    return process.run(
        conn,
        cmd,
    )
Esempio n. 32
0
def create(distro, logger, args, monitor_keyring):
    hostname = remote_shortname(distro.sudo_conn.modules.socket)
    common.mon_create(distro, logger, args, monitor_keyring, hostname)
    service = common.which_service(distro.sudo_conn, logger)

    distro.sudo_conn.close()

    # TODO transition this once pushy is out
    rconn = get_connection(hostname, logger)

    process.run(
        rconn,
        [
            service, 'ceph', '-c',
            '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster), 'start',
            'mon.{hostname}'.format(hostname=hostname)
        ],
        exit=True,
        timeout=7,
    )
Esempio n. 33
0
def create(distro, logger, args, monitor_keyring):
    hostname = remote_shortname(distro.sudo_conn.modules.socket)
    common.mon_create(distro, logger, args, monitor_keyring, hostname)
    service = common.which_service(distro.sudo_conn, logger)

    distro.sudo_conn.close()

    # TODO transition this once pushy is out
    rconn = get_connection(hostname, logger)
    process.run(
        rconn,
        [
            service,
            'ceph',
            'start',
            'mon.{hostname}'.format(hostname=hostname)
        ],
        exit=True,
        timeout=7,
    )
Esempio n. 34
0
def apt(conn, package, *a, **kw):
    cmd = [
        'env',
        'DEBIAN_FRONTEND=noninteractive',
        'apt-get',
        '-q',
        'install',
        '--assume-yes',
        package,
    ]
    return process.run(conn, cmd, *a, **kw)
Esempio n. 35
0
def mirror_install(distro, repo_url, gpg_url, adjust_repos):
    repo_url = repo_url.strip('/')  # Remove trailing slashes
    gpg_path = gpg_url.split('file://')[-1]

    if adjust_repos:
        if not gpg_url.startswith('file://'):
            process.run(
                distro.conn,
                [
                    'wget',
                    '-O',
                    'release.asc',
                    gpg_url,
                ],
                stop_on_nonzero=False,
            )

        gpg_file = 'release.asc' if not gpg_url.startswith(
            'file://') else gpg_path
        process.run(distro.conn, [
            'apt-key',
            'add',
            gpg_file,
        ])

        distro.conn.remote_module.write_sources_list(repo_url, distro.codename)

    # Before any install, make sure we have `wget`
    pkg_managers.apt_update(distro.conn)
    packages = (
        'ceph',
        'ceph-mds',
        'ceph-common',
        'ceph-fs-common',
        # ceph only recommends gdisk, make sure we actually have
        # it; only really needed for osds, but minimal collateral
        'gdisk',
    )

    pkg_managers.apt(distro.conn, packages)
    pkg_managers.apt(distro.conn, 'ceph')
Esempio n. 36
0
def yum_remove(conn, packages, *a, **kw):
    cmd = [
        'yum',
        '-y',
        '-q',
        'remove',
    ]
    if isinstance(packages, str):
        cmd.append(packages)
    else:
        cmd.extend(packages)
    return process.run(conn, cmd, *a, **kw)
Esempio n. 37
0
def yum_clean(conn, item=None):
    item = item or 'all'
    cmd = [
        'yum',
        'clean',
        item,
    ]

    return process.run(
        conn,
        cmd,
    )
Esempio n. 38
0
def mirror_install(distro, repo_url, gpg_url, adjust_repos):
    repo_url = repo_url.strip('/')  # Remove trailing slashes

    if adjust_repos:
        process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpg_url,
            ]
        )

        ceph_repo_content = templates.ceph_repo.format(
            repo_url=repo_url,
            gpg_url=gpg_url
        )

        distro.conn.remote_module.write_yum_repo(ceph_repo_content)

    pkg_managers.yum(distro.conn, 'ceph')
Esempio n. 39
0
def rpm(conn, rpm_args=None, *a, **kw):
    """
    A minimal front end for ``rpm`. Extra flags can be passed in via
    ``rpm_args`` as an iterable.
    """
    rpm_args = rpm_args or []
    cmd = [
        'rpm',
        '-Uvh',
    ]
    cmd.extend(rpm_args)
    return process.run(conn, cmd, *a, **kw)
Esempio n. 40
0
def yum_clean(conn, item=None):
    item = item or 'all'
    cmd = [
        'yum',
        'clean',
        item,
    ]

    return process.run(
        conn,
        cmd,
    )
Esempio n. 41
0
def install(distro, version_kind, version, adjust_repos):
    release = distro.release
    machine = distro.machine_type

    # Even before EPEL, make sure we have `wget`
    pkg_managers.yum(distro.conn, "wget")

    # Get EPEL installed before we continue:
    if adjust_repos:
        install_epel(distro)
    if version_kind in ["stable", "testing"]:
        key = "release"
    else:
        key = "autobuild"

    if adjust_repos:
        process.run(
            distro.conn,
            ["rpm", "--import", "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/{key}.asc".format(key=key)],
        )

        if version_kind == "stable":
            url = "http://ceph.com/rpm-{version}/el6/".format(version=version)
        elif version_kind == "testing":
            url = "http://ceph.com/rpm-testing/"
        elif version_kind == "dev":
            url = "http://gitbuilder.ceph.com/ceph-rpm-centos{release}-{machine}-basic/ref/{version}/".format(
                release=release.split(".", 1)[0], machine=machine, version=version
            )

        process.run(
            distro.conn, ["rpm", "-Uvh", "--replacepkgs", "{url}noarch/ceph-release-1-0.el6.noarch.rpm".format(url=url)]
        )

    process.run(distro.conn, ["yum", "-y", "-q", "install", "ceph"])
Esempio n. 42
0
def install(distro, version_kind, version, adjust_repos):
    release = distro.release
    machine = distro.machine_type

    if version_kind in ['stable', 'testing']:
        key = 'release'
    else:
        key = 'autobuild'

    if adjust_repos:
        process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/{key}.asc".format(key=key)
            ]
        )

        if version_kind == 'stable':
            url = 'http://ceph.com/rpm-{version}/fc{release}/'.format(
                version=version,
                release=release,
                )
        elif version_kind == 'testing':
            url = 'http://ceph.com/rpm-testing/fc{release}'.format(
                release=release,
                )
        elif version_kind == 'dev':
            url = 'http://gitbuilder.ceph.com/ceph-rpm-fc{release}-{machine}-basic/ref/{version}/'.format(
                release=release.split(".", 1)[0],
                machine=machine,
                version=version,
                )

        process.run(
            distro.conn,
            [
                'rpm',
                '-Uvh',
                '--replacepkgs',
                '--force',
                '--quiet',
                '{url}noarch/ceph-release-1-0.fc{release}.noarch.rpm'.format(
                    url=url,
                    release=release,
                    ),
            ]
        )

    process.run(
        distro.conn,
        [
            'yum',
            '-y',
            '-q',
            'install',
            'ceph',
        ],
    )
Esempio n. 43
0
def create(distro, logger, args, monitor_keyring):
    hostname = remote_shortname(distro.sudo_conn.modules.socket)
    common.mon_create(distro, logger, args, monitor_keyring, hostname)
    service = common.which_service(distro.sudo_conn, logger)

    distro.sudo_conn.close()
    # TODO transition this once pushy is out
    rconn = get_connection(hostname, logger)

    if distro.init == 'upstart':  # Ubuntu uses upstart
        process.run(
            rconn,
            [
                'initctl',
                'emit',
                'ceph-mon',
                'cluster={cluster}'.format(cluster=args.cluster),
                'id={hostname}'.format(hostname=hostname),
            ],
            exit=True,
            timeout=7,
        )

    elif distro.init == 'sysvinit':  # Debian uses sysvinit

        process.run(
            rconn,
            [
                service,
                'ceph',
                '-c',
                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
                'start',
                'mon.{hostname}'.format(hostname=hostname)
            ],
            exit=True,
            timeout=7,
        )
    else:
        raise RuntimeError('create cannot use init %s' % distro.init)
Esempio n. 44
0
def install(distro, version_kind, version, adjust_repos):
    release = distro.release
    machine = distro.machine_type

    pkg_managers.yum_clean(distro.conn)

    # Even before EPEL, make sure we have `wget`
    pkg_managers.yum(distro.conn, 'wget')

    # Get EPEL installed before we continue:
    if adjust_repos:
        install_epel(distro)
    if version_kind in ['stable', 'testing']:
        key = 'release'
    else:
        key = 'autobuild'

    if adjust_repos:
        process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/{key}.asc".format(key=key)
            ]
        )

        if version_kind == 'stable':
            url = 'http://ceph.com/rpm-{version}/el6/'.format(
                version=version,
                )
        elif version_kind == 'testing':
            url = 'http://ceph.com/rpm-testing/el6/'
        elif version_kind == 'dev':
            url = 'http://gitbuilder.ceph.com/ceph-rpm-centos{release}-{machine}-basic/ref/{version}/'.format(
                release=release.split(".",1)[0],
                machine=machine,
                version=version,
                )

        process.run(
            distro.conn,
            [
                'rpm',
                '-Uvh',
                '--replacepkgs',
                '{url}noarch/ceph-release-1-0.el6.noarch.rpm'.format(url=url),
            ],
        )

    process.run(
        distro.conn,
        [
            'yum',
            '-y',
            '-q',
            'install',
            'ceph',
        ],
    )
Esempio n. 45
0
def create(distro, args, monitor_keyring):
    logger = distro.conn.logger
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)
    systemctl = distro.conn.remote_module.which('systemctl')

    if not systemctl:
        logger.warning('could not find `systemctl` command')
        
    if distro.init == 'systemd':
        process.run(
            distro.conn,
            [
                systemctl,
                'enable',
                'ceph-mon@{hostname}'.format(hostname=hostname)
            ],
            timeout=7,
        )
        process.run(
            distro.conn,
            [
                systemctl,
                'start',
                'ceph-mon@{hostname}'.format(hostname=hostname)
            ],
            timeout=7,
        )
        
        process.run(
            distro.conn,
            [
                systemctl,
                'enable',
                'ceph-create-keys@{hostname}'.format(hostname=hostname)            
            ],
            timeout=7,
        )
        process.run(
            distro.conn,
            [
                systemctl,
                'start',
                'ceph-create-keys@{hostname}'.format(hostname=hostname)            
            ],
            timeout=7,
        )
    else:
        raise RuntimeError('create cannot use init %s' % distro.init)
Esempio n. 46
0
def create(distro, args, monitor_keyring):
    logger = distro.conn.logger
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)
    service = distro.conn.remote_module.which_service()

    if not service:
        logger.warning('could not find `service` executable')

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

    elif distro.init == 'sysvinit':  # Debian uses sysvinit

        process.run(
            distro.conn,
            [
                service,
                'ceph',
                '-c',
                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
                'start',
                'mon.{hostname}'.format(hostname=hostname)
            ],
            timeout=7,
        )
    else:
        raise RuntimeError('create cannot use init %s' % distro.init)
Esempio n. 47
0
def repo_install(distro, repo_name, baseurl, gpgkey, **kw):
    # Get some defaults
    safe_filename = '%s.list' % repo_name.replace(' ', '-')
    install_ceph = kw.pop('install_ceph', False)
    baseurl = baseurl.strip('/')  # Remove trailing slashes

    if gpgkey:
        process.run(
            distro.conn,
            [
                'wget',
                '-O',
                'release.asc',
                gpgkey,
            ],
            stop_on_nonzero=False,
        )

    process.run(distro.conn, ['apt-key', 'add', 'release.asc'])

    distro.conn.remote_module.write_sources_list(baseurl, distro.codename,
                                                 safe_filename)

    if install_ceph:
        # Before any install, make sure we have `wget`
        pkg_managers.apt_update(distro.conn)
        packages = (
            'ceph',
            'ceph-mds',
            'ceph-common',
            'ceph-fs-common',
            # ceph only recommends gdisk, make sure we actually have
            # it; only really needed for osds, but minimal collateral
            'gdisk',
        )

        pkg_managers.apt(distro.conn, packages)
        pkg_managers.apt(distro.conn, 'ceph')
Esempio n. 48
0
def yum(conn, package, *a, **kw):
    cmd = [
        'yum',
        '-y',
        '-q',
        'install',
        package,
    ]
    return process.run(
        conn,
        cmd,
        *a,
        **kw
    )
Esempio n. 49
0
def create(distro, logger, args, monitor_keyring):
    hostname = remote_shortname(distro.sudo_conn.modules.socket)
    common.mon_create(distro, logger, args, monitor_keyring, hostname)
    service = common.which_service(distro.sudo_conn, logger)

    distro.sudo_conn.close()
    # TODO transition this once pushy is out
    rconn = get_connection(hostname, logger)

    if distro.init == 'upstart':  # Ubuntu uses upstart
        process.run(
            rconn,
            [
                'initctl',
                'emit',
                'ceph-mon',
                'cluster={cluster}'.format(cluster=args.cluster),
                'id={hostname}'.format(hostname=hostname),
            ],
            exit=True,
            timeout=7,
        )

    elif distro.init == 'sysvinit':  # Debian uses sysvinit

        process.run(
            rconn,
            [
                service, 'ceph', '-c',
                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
                'start', 'mon.{hostname}'.format(hostname=hostname)
            ],
            exit=True,
            timeout=7,
        )
    else:
        raise RuntimeError('create cannot use init %s' % distro.init)
Esempio n. 50
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)

        process.run(
            distro.conn,
            [
                'ceph-disk-activate',
                '--mark-init',
                distro.init,
                '--mount',
                disk,
            ],
        )
        # give the OSD a few seconds to start
        time.sleep(5)
        catch_osd_errors(distro.conn, distro.logger, args)
        distro.conn.exit()
Esempio n. 51
0
def yum(conn, packages, *a, **kw):
    if isinstance(packages, str):
        packages = [packages]

    cmd = [
        'yum',
        '-y',
        'install',
    ]
    cmd.extend(packages)
    return process.run(
        conn,
        cmd,
        *a,
        **kw
    )
Esempio n. 52
0
def apt_remove(conn, packages, *a, **kw):
    purge = kw.pop('purge', False)
    cmd = [
        'apt-get',
        '-q',
        'remove',
        '-f',
        '-y',
        '--force-yes',
    ]
    if purge:
        cmd.append('--purge')
    cmd.append('--')
    cmd.extend(packages)

    return process.run(conn, cmd, *a, **kw)
Esempio n. 53
0
def yum(conn, packages, *a, **kw):
    if isinstance(packages, str):
        packages = [packages]

    cmd = [
        'yum',
        '-y',
        '-q',
        'install',
    ]
    cmd.extend(packages)
    return process.run(
        conn,
        cmd,
        *a,
        **kw
    )
Esempio n. 54
0
def install(distro, version_kind, version, adjust_repos):
    release = distro.release
    machine = distro.machine_type

    if version_kind in ['stable', 'testing']:
        key = 'release'
    else:
        key = 'autobuild'

    if adjust_repos:
        process.run(distro.conn, [
            'rpm', '--import',
            "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/{key}.asc".
            format(key=key)
        ])

        if version_kind == 'stable':
            url = 'http://ceph.com/rpm-{version}/fc{release}/'.format(
                version=version,
                release=release,
            )
        elif version_kind == 'testing':
            url = 'http://ceph.com/rpm-testing/fc{release}'.format(
                release=release, )
        elif version_kind == 'dev':
            url = 'http://gitbuilder.ceph.com/ceph-rpm-fc{release}-{machine}-basic/ref/{version}/'.format(
                release=release.split(".", 1)[0],
                machine=machine,
                version=version,
            )

        process.run(distro.conn, [
            'rpm',
            '-Uvh',
            '--replacepkgs',
            '--force',
            '--quiet',
            '{url}noarch/ceph-release-1-0.fc{release}.noarch.rpm'.format(
                url=url,
                release=release,
            ),
        ])

    process.run(
        distro.conn,
        [
            'yum',
            '-y',
            '-q',
            'install',
            'ceph',
        ],
    )
Esempio n. 55
0
def apt(conn, packages, *a, **kw):
    if isinstance(packages, str):
        packages = [packages]
    cmd = [
        'env',
        'DEBIAN_FRONTEND=noninteractive',
        'apt-get',
        '-q',
        'install',
        '--assume-yes',
    ]
    cmd.extend(packages)
    return process.run(
        conn,
        cmd,
        *a,
        **kw
    )
Esempio n. 56
0
def zypper_remove(conn, packages, *a, **kw):
    cmd = [
        'zypper',
        '--non-interactive',
        '--quiet',
        'remove',
        ]

    if isinstance(packages, str):
        cmd.append(packages)
    else:
        cmd.extend(packages)
    return process.run(
        conn,
        cmd,
        *a,
        **kw
    )
Esempio n. 57
0
def zypper(conn, packages, *a, **kw):
    if isinstance(packages, str):
        packages = [packages]

    cmd = [
        'zypper',
        '--non-interactive',
        '--quiet',
        'install',
    ]

    cmd.extend(packages)
    return process.run(
        conn,
        cmd,
        *a,
        **kw
    )