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)
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, )
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)
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, )
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, )
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")
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, )
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')
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')
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')
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"
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"
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'
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'
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, )
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, )
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)
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, )
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, )
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, )
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)
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, )
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, )
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)