From 6ae1c8fa3127a9cdf6de6fa627ed61e8e3213e1c Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 27 Aug 2010 18:30:25 -0700 Subject: [PATCH] Enable logging for deploydb and add support for hypervisor type in service offering --- server/src/com/cloud/test/DatabaseConfig.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java index 7633f0bd734..8fb5fc5104c 100644 --- a/server/src/com/cloud/test/DatabaseConfig.java +++ b/server/src/com/cloud/test/DatabaseConfig.java @@ -42,6 +42,7 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.apache.log4j.Logger; +import org.apache.log4j.xml.DOMConfigurator; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -56,6 +57,7 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDaoImpl; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.dao.DiskOfferingDaoImpl; +import com.cloud.utils.PropertiesUtil; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.db.DB; import com.cloud.utils.db.Transaction; @@ -332,6 +334,15 @@ public class DatabaseConfig { public static void main(String[] args) { System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"); + + File file = PropertiesUtil.findConfigFile("log4j-cloud.xml"); + if(file != null) { + System.out.println("Log4j configuration from : " + file.getAbsolutePath()); + DOMConfigurator.configureAndWatch(file.getAbsolutePath(), 10000); + } else { + System.out.println("Configure log4j with default properties"); + } + if (args.length < 1) { s_logger.error("error starting database config, missing initial data file"); } else { @@ -715,6 +726,7 @@ public class DatabaseConfig { int ramSize = Integer.parseInt(_currentObjectParams.get("ramSize")); int speed = Integer.parseInt(_currentObjectParams.get("speed")); String useLocalStorageValue = _currentObjectParams.get("useLocalStorage"); + String hypervisorType = _currentObjectParams.get("hypervisorType"); // int nwRate = Integer.parseInt(_currentObjectParams.get("nwRate")); // int mcRate = Integer.parseInt(_currentObjectParams.get("mcRate")); @@ -741,7 +753,7 @@ public class DatabaseConfig { useLocalStorage = false; } - ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, nwRate, mcRate, ha, displayText, type, useLocalStorage, false, null, null); + ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, nwRate, mcRate, ha, displayText, type, useLocalStorage, false, null, hypervisorType); ServiceOfferingDaoImpl dao = ComponentLocator.inject(ServiceOfferingDaoImpl.class); try { dao.persist(serviceOffering);