write cluster configuration to /etc/ceph/{cluster}.conf
420468
def write_conf(cluster, conf, overwrite):
    
    import os

    path = '/etc/ceph/{cluster}.conf'.format(cluster=cluster)
    tmp = '{path}.{pid}.tmp'.format(path=path, pid=os.getpid())

    if os.path.exists(path):
        with open(path) as f:
            old = f.read()
            if old != conf and not overwrite:
                raise RuntimeError('config file %s exists with different content; use --overwrite-conf to overwrite' % path)
    with open(tmp, 'w') as f:
        f.write(conf)
        f.flush()
        os.fsync(f)
    os.rename(tmp, path)
935673
private static Map<String, Object> processConf(Map<String, ?> conf) {
        Map<String, Object> m = new HashMap<String, Object>(conf.size());
        for (String s : conf.keySet()) {
            Object o = conf.get(s);
            if (s.startsWith("act.")) s = s.substring(4);
            m.put(s, o);
            m.put(Config.canonical(s), o);
        }
        return m;
    }
294940
def create_osd_keyring(conn, cluster, key):
    
    logger = conn.logger
    path = '/var/lib/ceph/bootstrap-osd/{cluster}.keyring'.format(
        cluster=cluster,
    )
    if not conn.remote_module.path_exists(path):
        logger.warning('osd keyring does not exist yet, creating one')
        conn.remote_module.write_keyring(path, key)
672280
def create_osd(
        conn,
        cluster,
        data,
        journal,
        zap,
        fs_type,
        dmcrypt,
        dmcrypt_dir,
        storetype,
        block_wal,
        block_db,
        **kw):
    
    ceph_volume_executable = system.executable_path(conn, 'ceph-volume')
    args = [
        ceph_volume_executable,
        '--cluster', cluster,
        'lvm',
        'create',
        '--%s' % storetype,
        '--data', data
    ]
    if zap:
        LOG.warning('zapping is no longer supported when preparing')
    if dmcrypt:
        args.append('--dmcrypt')
        # TODO: re-enable dmcrypt support once ceph-volume grows it
        LOG.warning('dmcrypt is currently not supported')

    if storetype == 'bluestore':
        if block_wal:
            args.append('--block.wal')
            args.append(block_wal)
        if block_db:
            args.append('--block.db')
            args.append(block_db)
    elif storetype == 'filestore':
        if not journal:
            raise RuntimeError('A journal lv or GPT partition must be specified when using filestore')
        args.append('--journal')
        args.append(journal)

    if kw.get('debug'):
        remoto.process.run(
            conn,
            args,
            extend_env={'CEPH_VOLUME_DEBUG': '1'}
        )

    else:
        remoto.process.run(
            conn,
            args
        )
521165
def rsync(config_file, source, target, override_cluster_name, down):
    

    config = yaml.load(open(config_file).read())
    if override_cluster_name is not None:
        config["cluster_name"] = override_cluster_name
    config = _bootstrap_config(config)
    head_node = _get_head_node(
        config, config_file, override_cluster_name, create_if_needed=False)

    provider = get_node_provider(config["provider"], config["cluster_name"])
    try:
        updater = NodeUpdaterThread(
            node_id=head_node,
            provider_config=config["provider"],
            provider=provider,
            auth_config=config["auth"],
            cluster_name=config["cluster_name"],
            file_mounts=config["file_mounts"],
            initialization_commands=[],
            setup_commands=[],
            runtime_hash="",
        )
        if down:
            rsync = updater.rsync_down
        else:
            rsync = updater.rsync_up
        rsync(source, target, check_error=False)
    finally:
        provider.cleanup()
1321126
def _merge_system_configs(host_config, container_config, out_file=None):
    
    out = copy.deepcopy(container_config)
    for k, v in host_config.items():
        if k in set(["galaxy_config"]):
            out[k] = v
        elif k == "resources":
            for pname, resources in v.items():
                if not isinstance(resources, dict) and pname not in out[k]:
                    out[k][pname] = resources
                else:
                    for rname, rval in resources.items():
                        if (rname in set(["cores", "jvm_opts", "memory"])
                              or pname in set(["gatk", "mutect"])):
                            if pname not in out[k]:
                                out[k][pname] = {}
                            out[k][pname][rname] = rval
    # Ensure final file is relocatable by mapping back to reference directory
    if "bcbio_system" in out and ("galaxy_config" not in out or not os.path.isabs(out["galaxy_config"])):
        out["galaxy_config"] = os.path.normpath(os.path.join(os.path.dirname(out["bcbio_system"]),
                                                             os.pardir, "galaxy",
                                                             "universe_wsgi.ini"))
    if out_file:
        with open(out_file, "w") as out_handle:
            yaml.safe_dump(out, out_handle, default_flow_style=False, allow_unicode=False)
    return out
672952
def write_config(self):
        
        if not os.path.exists(os.path.dirname(self.config_file)):
            os.makedirs(os.path.dirname(self.config_file))
        with open(self.config_file, 'w') as f:
            f.write(json.dumps(self.config))
            f.close()
31890
def write(settings_path, settings_data, merge=True):
    
    settings_path = Path(settings_path)
    if settings_path.exists() and merge:  # pragma: no cover
        with io.open(
            str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF
        ) as open_file:
            object_merge(yaml.full_load(open_file), settings_data)

    with io.open(
        str(settings_path),
        "w",
        encoding=default_settings.ENCODING_FOR_DYNACONF,
    ) as open_file:
        yaml.dump(settings_data, open_file)
955983
def write_config(configfile, content):
    
    with open(configfile, 'w+') as ymlfile:
        yaml.dump(
            content,
            ymlfile,
            default_flow_style=False,
        )
998202
def writeClusters(start, buf, len = buf.length)
      clus = start; num, leftover = len.divmod(@bytesPerCluster); num += 1 if leftover > 0
      0.upto(num - 1) do |offset|
        local = buf[offset * @bytesPerCluster, @bytesPerCluster]
        if local.length < @bytesPerCluster then local += ("\0" * (@bytesPerCluster - local.length)) end
        @stream.seek(clusToByte(clus), IO::SEEK_SET)
        @stream.write(local, @bytesPerCluster)
        break if offset == num - 1 # ugly hack to prevent allocating more than needed.
        nxt = getFatEntry(clus)
        nxt = allocClusters(clus) if nxt > CC_END_OF_CHAIN
        clus = nxt
      end
    end
871238
public void writeConfiguration(final YarnClusterSubmissionFromCS yarnClusterSubmissionFromCS,
                                 final JobFolder jobFolderOnDFS) throws IOException {
    final File yarnAppParametersFile = new File(yarnClusterSubmissionFromCS.getDriverFolder(),
        fileNames.getYarnBootstrapAppParamFilePath());

    final File yarnJobParametersFile = new File(yarnClusterSubmissionFromCS.getDriverFolder(),
        fileNames.getYarnBootstrapJobParamFilePath());

    try (final FileOutputStream appFileOutputStream = new FileOutputStream(yarnAppParametersFile)) {
      try (final FileOutputStream jobFileOutputStream = new FileOutputStream(yarnJobParametersFile)) {
        // this is mainly a test hook.
        writeAvroYarnAppSubmissionParametersToOutputStream(yarnClusterSubmissionFromCS, appFileOutputStream);
        writeAvroYarnJobSubmissionParametersToOutputStream(
            yarnClusterSubmissionFromCS, jobFolderOnDFS.getPath().toString(), jobFileOutputStream);
      }
    }
  }
1326883
def _write_options(name, configuration):
    '''
    
    '''
    _check_portname(name)

    pkg = next(iter(configuration))
    conf_ptr = configuration[pkg]

    dirname = _options_dir(name)
    if not os.path.isdir(dirname):
        try:
            os.makedirs(dirname)
        except OSError as exc:
            raise CommandExecutionError(
                'Unable to make {0}: {1}'.format(dirname, exc)
            )

    with salt.utils.files.fopen(os.path.join(dirname, 'options'), 'w') as fp_:
        sorted_options = list(conf_ptr)
        sorted_options.sort()
        fp_.write(salt.utils.stringutils.to_str(
            '# This file was auto-generated by Salt (http://saltstack.com)\n'
            '# Options for {0}\n'
            '_OPTIONS_READ={0}\n'
            '_FILE_COMPLETE_OPTIONS_LIST={1}\n'
            .format(pkg, ' '.join(sorted_options))
        ))
        opt_tmpl = 'OPTIONS_FILE_{0}SET+={1}\n'
        for opt in sorted_options:
            fp_.write(salt.utils.stringutils.to_str(
                opt_tmpl.format(
                    '' if conf_ptr[opt] == 'on' else 'UN',
                    opt
                )
            ))
958753
def _write_conf(conf, path=MAIN_CF):
    '''
    
    '''
    with salt.utils.files.fopen(path, 'w') as fh_:
        for line in conf:
            line = salt.utils.stringutils.to_str(line)
            if isinstance(line, dict):
                fh_.write(' '.join(line))
            else:
                fh_.write(line)
            fh_.write('\n')
1371298
def write_config(config, config_path=CONFIG_PATH):
    
    if not os.path.exists(config_path):
        os.makedirs(os.path.dirname(config_path))
    with open(config_path, 'w', encoding='utf-8') as f:
        config.write(f)
471483
def execute(self):
        
        creator = make_creator(self.params.config,
                               storage_path=self.params.storage)
        cluster_name = self.params.cluster
        try:
            cluster = creator.load_cluster(cluster_name)
            if self.params.update:
                cluster.update()
        except (ClusterNotFound, ConfigurationError) as ex:
            log.error("Listing nodes from cluster %s: %s", cluster_name, ex)
            return

        if self.params.pretty_json:
            print(json.dumps(cluster, default=dict, indent=4))
        elif self.params.json:
            print(json.dumps(cluster, default=dict))
        else:
            print(cluster_summary(cluster))
            for cls in cluster.nodes:
                print("%s nodes:" % cls)
                print("")
                for node in cluster.nodes[cls]:
                    txt = ["    " + i for i in node.pprint().splitlines()]
                    print('  - ' + "\n".join(txt)[4:])
                    print("")
1072084
def cluster_set_config_epoch(self, config_epoch):
        """"""
        fut = self.execute(b'CLUSTER', b'SET-CONFIG-EPOCH', config_epoch)
        return wait_ok(fut)
794898
def write_config(path, shape=None, dtype=None, name="conf.json", overwrite=True, credentials=None):
    
    import json
    from thunder.writers import get_file_writer

    writer = get_file_writer(path)
    conf = {'shape': shape, 'dtype': str(dtype)}

    confwriter = writer(path, name, overwrite=overwrite, credentials=credentials)
    confwriter.write(json.dumps(conf, indent=2))

    successwriter = writer(path, "SUCCESS", overwrite=overwrite, credentials=credentials)
    successwriter.write('')