From 492dd78f1ca94e848c9e7cf850f420ad229868f4 Mon Sep 17 00:00:00 2001 From: prachi Date: Thu, 31 Mar 2011 23:04:17 -0700 Subject: [PATCH] Bug 9180 - Default local SR on XenServer won't be used - Update the diskoffering for system VMs to change the value of use_local_storage, when the global config 'system.vm.use.local.storage' is changed. --- .../ConfigurationManagerImpl.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 3d67d10ae22..2a519d01083 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -284,6 +284,36 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura s_logger.error("Failed to update configuration option, name: " + name + ", value:" + value); throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support."); } + + if(Config.SystemVMUseLocalStorage.key().equalsIgnoreCase(name)){ + if(s_logger.isDebugEnabled()){ + s_logger.debug("Config 'system.vm.use.local.storage' changed to value:" + value + ", need to update System VM offerings"); + } + boolean useLocalStorage = Boolean.parseBoolean(_configDao.getValue(Config.SystemVMUseLocalStorage.key())); + ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName("Cloud.com-ConsoleProxy"); + if(serviceOffering != null){ + serviceOffering.setUseLocalStorage(useLocalStorage); + if(!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)){ + s_logger.error("Failed to update ConsoleProxy offering's use_local_storage option to value:" + useLocalStorage); + } + } + + serviceOffering = _serviceOfferingDao.findByName("Cloud.Com-SoftwareRouter"); + if(serviceOffering != null){ + serviceOffering.setUseLocalStorage(useLocalStorage); + if(!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)){ + s_logger.error("Failed to update SoftwareRouter offering's use_local_storage option to value:" + useLocalStorage); + } + } + + serviceOffering = _serviceOfferingDao.findByName("Cloud.com-SecondaryStorage"); + if(serviceOffering != null){ + serviceOffering.setUseLocalStorage(useLocalStorage); + if(!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)){ + s_logger.error("Failed to update SecondaryStorage offering's use_local_storage option to value:" + useLocalStorage); + } + } + } }