From c4f847518f9075e1a3a69c1ba742c716bb1d7cb0 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Wed, 8 Aug 2012 20:37:25 +0200 Subject: [PATCH] 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 --- .../resource/LibvirtComputingResource.java | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 359497e9796..dea00bd5ce3 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -412,34 +412,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements return "scripts/storage/qcow2"; } - private void saveProperties(Map 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 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 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; }