in vagrant/src/main/java/org/jclouds/vagrant/internal/MachineConfig.java [87:116]
public void save(Map<String, Object> config) {
File parent = configPath.getParentFile();
if (!parent.exists() && !parent.mkdirs()) {
if (!parent.exists()) {
throw new IllegalStateException("Failure creating folder " + parent.getAbsolutePath());
}
}
Map<String, Object> configWithoutVersion = Maps.filterKeys(config,
Predicates.not(Predicates.equalTo(VagrantConstants.CONFIG_JCLOUDS_VERSION)));
String version = VagrantConstants.CONFIG_JCLOUDS_VERSION + ": " + JcloudsVersion.get().toString() + "\n";
String output = version + Joiner.on("\n").withKeyValueSeparator(": ").join(configWithoutVersion);
FileOutputStream fileOut = null;
BufferedWriter out = null;
try {
fileOut = new FileOutputStream(configPath);
out = new BufferedWriter(new OutputStreamWriter(fileOut, Charsets.UTF_8));
out.write(output);
} catch (IOException e) {
throw new IllegalStateException("Failed writing to machine config file " + configPath.getAbsolutePath(), e);
} finally {
if (out != null) {
Closeables2.closeQuietly(out);
} else if (fileOut != null) {
Closeables2.closeQuietly(fileOut);
}
}
}