mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
agent: Never write to agent.properties
A daemon should never write to a configuration file Admins might use tools like Puppet and they don't like changing files
This commit is contained in:
parent
6c015d4f81
commit
c4f847518f
@ -412,34 +412,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
||||
return "scripts/storage/qcow2";
|
||||
}
|
||||
|
||||
private void saveProperties(Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
final File file = PropertiesUtil.findConfigFile("agent.properties");
|
||||
if (file == null) {
|
||||
throw new ConfigurationException("Unable to find agent.properties.");
|
||||
}
|
||||
|
||||
s_logger.info("agent.properties found at " + file.getAbsolutePath());
|
||||
|
||||
try {
|
||||
Properties _properties = new Properties();
|
||||
_properties.load(new FileInputStream(file));
|
||||
Set<String> names = _properties.stringPropertyNames();
|
||||
for (String key : params.keySet()) {
|
||||
if (!names.contains(key)) {
|
||||
_properties.setProperty(key, (String) params.get(key));
|
||||
}
|
||||
}
|
||||
_properties.store(new FileOutputStream(file), "");
|
||||
} catch (final FileNotFoundException ex) {
|
||||
throw new CloudRuntimeException("Cannot find the file: "
|
||||
+ file.getAbsolutePath(), ex);
|
||||
} catch (final IOException ex) {
|
||||
throw new CloudRuntimeException("IOException in reading "
|
||||
+ file.getAbsolutePath(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
@ -749,7 +721,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
||||
}
|
||||
params.put("vm.migrate.speed", String.valueOf(_migrateSpeed));
|
||||
}
|
||||
saveProperties(params);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user