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.
This commit is contained in:
prachi 2011-03-31 23:04:17 -07:00
parent 04626d8202
commit 492dd78f1c
1 changed files with 30 additions and 0 deletions

View File

@ -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);
}
}
}
}