def extract_mon_conf_files(orig_env, tar_filename): controller = env_util.get_one_controller(orig_env) conf_filename = get_ceph_conf_filename(controller) conf_dir = os.path.dirname(conf_filename) hostname = short_hostname(node_util.get_hostname_remotely(controller)) db_path = "/var/lib/ceph/mon/ceph-{0}".format(hostname) node_util.tar_files(tar_filename, controller, conf_dir, db_path) return conf_filename, db_path
def extract_mon_conf_files(orig_env, tar_filename): controller = env_util.get_one_controller(orig_env) conf_filename = ceph.get_ceph_conf_filename(controller) conf_dir = os.path.dirname(conf_filename) hostname = short_hostname( node_util.get_hostname_remotely(controller)) db_path = "/var/lib/ceph/mon/ceph-{0}".format(hostname) node_util.tar_files(tar_filename, controller, conf_dir, db_path) return conf_filename, db_path
def test_tar_files(node, mock_ssh_popen, mock_open): content = b'fake data\nin\nthe\narchive' proc = mock_ssh_popen.return_value.__enter__.return_value proc.stdout = io.BytesIO(content) buf = io.BytesIO() mock_open.return_value.write.side_effect = buf.write node_util.tar_files('filename', node, 'a.file', 'b.file') mock_ssh_popen.assert_called_once_with( ['tar', '-czvP', 'a.file', 'b.file'], stdout=ssh.PIPE, node=node) mock_open.assert_called_once_with('filename', 'wb') assert buf.getvalue() == content