Example #1
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
        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 == 'sysvinit':  # Debian uses sysvinit

        remoto.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)
Example #2
0
def create(distro, args, monitor_keyring):
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)

    # 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,
    )
Example #3
0
def create(distro, logger, args, monitor_keyring):
    hostname = distro.sudo_conn.modules.socket.gethostname().split('.')[0]
    common.mon_create(distro, logger, args, monitor_keyring, hostname)

    if distro.init == 'upstart': # Ubuntu uses upstart
        check_call(
            distro.sudo_conn,
            logger,
            [
                'initctl',
                'emit',
                'ceph-mon',
                'cluster={cluster}'.format(cluster=args.cluster),
                'id={hostname}'.format(hostname=hostname),
            ],
            patch=False,
        )

    elif distro.init == 'sysvinit': # Debian uses sysvinit
        service = common.which_service(distro.sudo_conn, logger)

        check_call(
            distro.sudo_conn,
            logger,
            [
                service,
                'ceph',
                'start',
                'mon.{hostname}'.format(hostname=hostname)
            ],
            patch=False,
        )
    else:
        raise RuntimeError('create cannot use init %s' % distro.init)
Example #4
0
def create(distro, logger, args, monitor_keyring):
    hostname = distro.sudo_conn.modules.socket.gethostname().split('.')[0]
    common.mon_create(distro, logger, args, monitor_keyring, hostname)

    if distro.init == 'upstart':  # Ubuntu uses upstart
        check_call(
            distro.sudo_conn,
            logger,
            [
                'initctl',
                'emit',
                'ceph-mon',
                'cluster={cluster}'.format(cluster=args.cluster),
                'id={hostname}'.format(hostname=hostname),
            ],
            patch=False,
        )

    elif distro.init == 'sysvinit':  # Debian uses sysvinit
        service = common.which_service(distro.sudo_conn, logger)

        check_call(
            distro.sudo_conn,
            logger,
            [
                service, 'ceph', 'start',
                'mon.{hostname}'.format(hostname=hostname)
            ],
            patch=False,
        )
    else:
        raise RuntimeError('create cannot use init %s' % distro.init)
Example #5
0
def create(distro, args, monitor_keyring):
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)

    # 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,
    )
Example #6
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,
        )
Example #7
0
    def test_create_mon_path_if_nonexistent(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(side_effect=path_exists(["/"]))
        args = Mock(return_value=["cluster", "1234", "initd"])
        args.cluster = "cluster"
        with patch("ceph_deploy.hosts.common.conf.load"):
            mon_create(self.distro, self.logger, args, Mock(), "hostname")

        result = self.distro.sudo_conn.modules.os.makedirs.call_args_list[0]
        assert result == call("/var/lib/ceph/mon/cluster-hostname")
Example #8
0
def create(distro, logger, args, monitor_keyring):
    hostname = distro.sudo_conn.modules.socket.gethostname().split('.')[0]
    common.mon_create(distro, logger, args, monitor_keyring, hostname)
    service = common.which_service(distro.sudo_conn, logger)
    check_call(
        distro.sudo_conn,
        logger,
        [service, 'ceph', 'start', 'mon.{hostname}'.format(hostname=hostname)],
        patch=False,
    )
Example #9
0
    def test_create_mon_path_if_nonexistent(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(
            side_effect=path_exists(['/']))
        args = Mock(return_value=['cluster', '1234', 'initd'])
        args.cluster = 'cluster'
        with patch('ceph_deploy.hosts.common.conf.load'):
            mon_create(self.distro, self.logger, args, Mock(), 'hostname')

        result = self.distro.sudo_conn.modules.os.makedirs.call_args_list[0]
        assert result == call('/var/lib/ceph/mon/cluster-hostname')
Example #10
0
    def test_create_mon_tmp_path_if_nonexistent(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(
            side_effect=path_exists(['/cluster-hostname']))
        self.paths.mon.constants.tmp_path = '/var/lib/ceph/tmp'
        args = Mock(return_value=['cluster', '1234', 'initd'])
        args.cluster = 'cluster'
        with patch('ceph_deploy.hosts.common.conf.load'):
            mon_create(self.distro, args, Mock(), 'hostname')

        result = self.distro.conn.remote_module.create_mon_path.call_args_list[-1]
        assert result == call('/var/lib/ceph/mon/cluster-hostname')
Example #11
0
    def test_create_mon_tmp_path_if_nonexistent(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(
            side_effect=path_exists(['/cluster-hostname']))
        self.paths.mon.constants.tmp_path = '/var/lib/ceph/tmp'
        args = Mock(return_value=['cluster', '1234', 'initd'])
        args.cluster = 'cluster'
        with patch('ceph_deploy.hosts.common.conf.load'):
            mon_create(self.distro, args, Mock(), 'hostname')

        result = self.distro.conn.remote_module.create_mon_path.call_args_list[-1]
        assert result ==mock.call('/var/lib/ceph/mon/cluster-hostname')
Example #12
0
    def test_write_init_path(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(side_effect=path_exists(["/"]))
        args = Mock(return_value=["cluster", "1234", "initd"])
        args.cluster = "cluster"

        with patch("ceph_deploy.hosts.common.conf.load"):
            with patch("ceph_deploy.hosts.common.remote") as fake_remote:
                mon_create(self.distro, self.logger, args, Mock(), "hostname")

        result = fake_remote.call_args_list[-1][0][-1].__name__
        assert result == "create_init_path"
Example #13
0
    def test_write_keyring(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(side_effect=path_exists(["/"]))
        args = Mock(return_value=["cluster", "1234", "initd"])
        args.cluster = "cluster"
        with patch("ceph_deploy.hosts.common.conf.load"):
            with patch("ceph_deploy.hosts.common.remote") as fake_remote:
                mon_create(self.distro, self.logger, args, Mock(), "hostname")

        # the second argument to `remote()` should be the write func
        result = fake_remote.call_args_list[1][0][-1].__name__
        assert result == "write_monitor_keyring"
Example #14
0
    def test_write_keyring(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(
            side_effect=path_exists(['/']))
        args = Mock(return_value=['cluster', '1234', 'initd'])
        args.cluster = 'cluster'
        with patch('ceph_deploy.hosts.common.conf.load'):
            with patch('ceph_deploy.hosts.common.remote') as fake_remote:
                mon_create(self.distro, self.logger, args, Mock(), 'hostname')

        # the second argument to `remote()` should be the write func
        result = fake_remote.call_args_list[1][0][-1].__name__
        assert result == 'write_monitor_keyring'
Example #15
0
    def test_write_init_path(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(
            side_effect=path_exists(['/']))
        args = Mock(return_value=['cluster', '1234', 'initd'])
        args.cluster = 'cluster'

        with patch('ceph_deploy.hosts.common.conf.load'):
            with patch('ceph_deploy.hosts.common.remote') as fake_remote:
                mon_create(self.distro, self.logger, args, Mock(), 'hostname')

        result = fake_remote.call_args_list[-1][0][-1].__name__
        assert result == 'create_init_path'
Example #16
0
    def test_write_init_path(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(
            side_effect=path_exists(['/']))
        args = Mock(return_value=['cluster', '1234', 'initd'])
        args.cluster = 'cluster'

        with patch('ceph_deploy.hosts.common.conf.load'):
            with patch('ceph_deploy.hosts.common.remote') as fake_remote:
                mon_create(self.distro, self.logger, args, Mock(), 'hostname')

        result = fake_remote.call_args_list[-1][0][-1].__name__
        assert result == 'create_init_path'
Example #17
0
    def test_write_keyring(self):
        self.distro.sudo_conn.modules.os.path.exists = Mock(
            side_effect=path_exists(['/']))
        args = Mock(return_value=['cluster', '1234', 'initd'])
        args.cluster = 'cluster'
        with patch('ceph_deploy.hosts.common.conf.load'):
            with patch('ceph_deploy.hosts.common.remote') as fake_remote:
                mon_create(self.distro, self.logger, args, Mock(), 'hostname')

        # the second argument to `remote()` should be the write func
        result = fake_remote.call_args_list[1][0][-1].__name__
        assert result == 'write_monitor_keyring'
Example #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,
    )
Example #19
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,
        )
Example #20
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)
Example #21
0
def create(distro, logger, args, monitor_keyring):
    hostname = distro.sudo_conn.modules.socket.gethostname().split('.')[0]
    common.mon_create(distro, logger, args, monitor_keyring, hostname)
    service = common.which_service(distro.sudo_conn, logger)
    check_call(
        distro.sudo_conn,
        logger,
        [
            service,
            'ceph',
            'start',
            'mon.{hostname}'.format(hostname=hostname)
        ],
        patch=False,
    )
Example #22
0
def create(distro, args, monitor_keyring):
    hostname = distro.conn.remote_module.shortname()
    common.mon_create(distro, args, monitor_keyring, hostname)

    remoto.process.run(
        distro.conn,
        [
            'rcceph',
            '-c',
            '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
            'start',
            'mon.{hostname}'.format(hostname=hostname)
        ],
        timeout=7,
    )
Example #23
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,
    )
Example #24
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)
Example #25
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,
    )
Example #26
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,
    )
Example #27
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)
Example #28
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
        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 == 'sysvinit':  # Debian uses sysvinit

        remoto.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)
Example #29
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)