You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/01/10 23:47:20 UTC

[4/25] removed componentlocator and inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/server/src/com/cloud/alert/AlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java
index 2ad21ed..bcd364e 100755
--- a/server/src/com/cloud/alert/AlertManagerImpl.java
+++ b/server/src/com/cloud/alert/AlertManagerImpl.java
@@ -72,7 +72,6 @@ import com.cloud.storage.StoragePoolVO;
 import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.SearchCriteria;
 import com.sun.mail.smtp.SMTPMessage;
@@ -116,9 +115,9 @@ public class AlertManagerImpl implements AlertManager {
     private double _publicIPCapacityThreshold = 0.75;
     private double _privateIPCapacityThreshold = 0.75;
     private double _secondaryStorageCapacityThreshold = 0.75; 
-	private double _vlanCapacityThreshold = 0.75;
-	private double _directNetworkPublicIpCapacityThreshold = 0.75;
-	private double _localStorageCapacityThreshold = 0.75;
+    private double _vlanCapacityThreshold = 0.75;
+    private double _directNetworkPublicIpCapacityThreshold = 0.75;
+    private double _localStorageCapacityThreshold = 0.75;
     Map<Short,Double> _capacityTypeThresholdMap = new HashMap<Short, Double>();
 
     @Override
@@ -149,7 +148,7 @@ public class AlertManagerImpl implements AlertManager {
 
         _emailAlert = new EmailAlert(emailAddresses, smtpHost, smtpPort, useAuth, smtpUsername, smtpPassword, emailSender, smtpDebug);
 
-         
+
         String storageCapacityThreshold = _configDao.getValue(Config.StorageCapacityThreshold.key());
         String cpuCapacityThreshold = _configDao.getValue(Config.CPUCapacityThreshold.key());
         String memoryCapacityThreshold = _configDao.getValue(Config.MemoryCapacityThreshold.key());
@@ -160,7 +159,7 @@ public class AlertManagerImpl implements AlertManager {
         String vlanCapacityThreshold = _configDao.getValue(Config.VlanCapacityThreshold.key());
         String directNetworkPublicIpCapacityThreshold = _configDao.getValue(Config.DirectNetworkPublicIpCapacityThreshold.key());
         String localStorageCapacityThreshold = _configDao.getValue(Config.LocalStorageCapacityThreshold.key());
-        
+
         if (storageCapacityThreshold != null) {
             _storageCapacityThreshold = Double.parseDouble(storageCapacityThreshold);
         }
@@ -174,10 +173,10 @@ public class AlertManagerImpl implements AlertManager {
             _memoryCapacityThreshold = Double.parseDouble(memoryCapacityThreshold);
         }
         if (publicIPCapacityThreshold != null) {
-        	_publicIPCapacityThreshold = Double.parseDouble(publicIPCapacityThreshold);
+            _publicIPCapacityThreshold = Double.parseDouble(publicIPCapacityThreshold);
         }
         if (privateIPCapacityThreshold != null) {
-        	_privateIPCapacityThreshold = Double.parseDouble(privateIPCapacityThreshold);
+            _privateIPCapacityThreshold = Double.parseDouble(privateIPCapacityThreshold);
         }
         if (secondaryStorageCapacityThreshold != null) {
             _secondaryStorageCapacityThreshold = Double.parseDouble(secondaryStorageCapacityThreshold);
@@ -191,7 +190,7 @@ public class AlertManagerImpl implements AlertManager {
         if (localStorageCapacityThreshold != null) {
             _localStorageCapacityThreshold = Double.parseDouble(localStorageCapacityThreshold);
         }
-        
+
         _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_STORAGE, _storageCapacityThreshold);
         _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, _storageAllocCapacityThreshold);
         _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_CPU, _cpuCapacityThreshold);
@@ -203,19 +202,19 @@ public class AlertManagerImpl implements AlertManager {
         _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP, _directNetworkPublicIpCapacityThreshold);
         _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_LOCAL_STORAGE, _localStorageCapacityThreshold);
 
-        
+
         String capacityCheckPeriodStr = configs.get("capacity.check.period");
         if (capacityCheckPeriodStr != null) {
             _capacityCheckPeriod = Long.parseLong(capacityCheckPeriodStr);
             if(_capacityCheckPeriod <= 0)
-            	_capacityCheckPeriod = Long.parseLong(Config.CapacityCheckPeriod.getDefaultValue());
+                _capacityCheckPeriod = Long.parseLong(Config.CapacityCheckPeriod.getDefaultValue());
         }
-        
+
         String cpuOverProvisioningFactorStr = configs.get("cpu.overprovisioning.factor");
         if (cpuOverProvisioningFactorStr != null) {
             _cpuOverProvisioningFactor = NumbersUtil.parseFloat(cpuOverProvisioningFactorStr,1);
             if(_cpuOverProvisioningFactor < 1){
-            	_cpuOverProvisioningFactor = 1;
+                _cpuOverProvisioningFactor = 1;
             }
         }
 
@@ -273,122 +272,122 @@ public class AlertManagerImpl implements AlertManager {
         //        is stopped we updated the amount allocated, and when VM sync reports a changed state, we update
         //        the amount allocated.  Hopefully it's limited to 3 entry points and will keep the amount allocated
         //        per host accurate.        
-        
+
         try {
-        	
-        	if (s_logger.isDebugEnabled()) {
+
+            if (s_logger.isDebugEnabled()) {
                 s_logger.debug("recalculating system capacity");
                 s_logger.debug("Executing cpu/ram capacity update");
             }
-        	
-	        // Calculate CPU and RAM capacities
-	        // 	get all hosts...even if they are not in 'UP' state
-	        List<HostVO> hosts = _resourceMgr.listAllNotInMaintenanceHostsInOneZone(Host.Type.Routing, null);	        	        
-	        for (HostVO host : hosts) {
-	        	_capacityMgr.updateCapacityForHost(host);
-	        }
-	        
-	        if (s_logger.isDebugEnabled()) {
-	        	s_logger.debug("Done executing cpu/ram capacity update");
-	        	s_logger.debug("Executing storage capacity update");
-	        }
-	        // Calculate storage pool capacity
-	        List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
-	        for (StoragePoolVO pool : storagePools) {
-	            long disk = _capacityMgr.getAllocatedPoolCapacity(pool, null);
-	            if (pool.isShared()){
-	            	_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, disk);
-	            }else {
-	            	_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, disk);
-	            }
-	        }
-	        
-	        if (s_logger.isDebugEnabled()) {
-	        	s_logger.debug("Done executing storage capacity update");
-	        	s_logger.debug("Executing capacity updates for public ip and Vlans");
-	        }
-
-        	List<DataCenterVO> datacenters = _dcDao.listAll();
-        	for (DataCenterVO datacenter : datacenters) {
-        		long dcId = datacenter.getId();
-		
-		        //NOTE
-		        //What happens if we have multiple vlans? Dashboard currently shows stats 
-		        //with no filter based on a vlan
-		        //ideal way would be to remove out the vlan param, and filter only on dcId
-		        //implementing the same
-        		
-            	// Calculate new Public IP capacity for Virtual Network
-        		if (datacenter.getNetworkType() == NetworkType.Advanced){        			
-        			createOrUpdateIpCapacity(dcId, null, CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP, datacenter.getAllocationState());
-        		}
-                
-            	// Calculate new Public IP capacity for Direct Attached Network
-		        createOrUpdateIpCapacity(dcId, null, CapacityVO.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP, datacenter.getAllocationState());
-                
+
+            // Calculate CPU and RAM capacities
+            // 	get all hosts...even if they are not in 'UP' state
+            List<HostVO> hosts = _resourceMgr.listAllNotInMaintenanceHostsInOneZone(Host.Type.Routing, null);	        	        
+            for (HostVO host : hosts) {
+                _capacityMgr.updateCapacityForHost(host);
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Done executing cpu/ram capacity update");
+                s_logger.debug("Executing storage capacity update");
+            }
+            // Calculate storage pool capacity
+            List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
+            for (StoragePoolVO pool : storagePools) {
+                long disk = _capacityMgr.getAllocatedPoolCapacity(pool, null);
+                if (pool.isShared()){
+                    _storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, disk);
+                }else {
+                    _storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, disk);
+                }
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Done executing storage capacity update");
+                s_logger.debug("Executing capacity updates for public ip and Vlans");
+            }
+
+            List<DataCenterVO> datacenters = _dcDao.listAll();
+            for (DataCenterVO datacenter : datacenters) {
+                long dcId = datacenter.getId();
+
+                //NOTE
+                //What happens if we have multiple vlans? Dashboard currently shows stats 
+                //with no filter based on a vlan
+                //ideal way would be to remove out the vlan param, and filter only on dcId
+                //implementing the same
+
+                // Calculate new Public IP capacity for Virtual Network
+                if (datacenter.getNetworkType() == NetworkType.Advanced){        			
+                    createOrUpdateIpCapacity(dcId, null, CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP, datacenter.getAllocationState());
+                }
+
+                // Calculate new Public IP capacity for Direct Attached Network
+                createOrUpdateIpCapacity(dcId, null, CapacityVO.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP, datacenter.getAllocationState());
+
                 if (datacenter.getNetworkType() == NetworkType.Advanced){
-                	//Calculate VLAN's capacity
-                	createOrUpdateVlanCapacity(dcId, datacenter.getAllocationState());
+                    //Calculate VLAN's capacity
+                    createOrUpdateVlanCapacity(dcId, datacenter.getAllocationState());
                 }
-		    }        
-        	
-        	if (s_logger.isDebugEnabled()) {
-	        	s_logger.debug("Done capacity updates for public ip and Vlans");
-	        	s_logger.debug("Executing capacity updates for private ip");
-	        }
-        	
-	        // Calculate new Private IP capacity
-	        List<HostPodVO> pods = _podDao.listAll();
-	        for (HostPodVO pod : pods) {
-	            long podId = pod.getId();
-	            long dcId = pod.getDataCenterId();
-
-	            createOrUpdateIpCapacity(dcId, podId, CapacityVO.CAPACITY_TYPE_PRIVATE_IP, _configMgr.findPodAllocationState(pod));
-	        }
-	        
-	        if (s_logger.isDebugEnabled()) {
-	        	s_logger.debug("Done executing capacity updates for private ip");
-	        	s_logger.debug("Done recalculating system capacity");
-	        }
+            }        
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Done capacity updates for public ip and Vlans");
+                s_logger.debug("Executing capacity updates for private ip");
+            }
+
+            // Calculate new Private IP capacity
+            List<HostPodVO> pods = _podDao.listAll();
+            for (HostPodVO pod : pods) {
+                long podId = pod.getId();
+                long dcId = pod.getDataCenterId();
+
+                createOrUpdateIpCapacity(dcId, podId, CapacityVO.CAPACITY_TYPE_PRIVATE_IP, _configMgr.findPodAllocationState(pod));
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Done executing capacity updates for private ip");
+                s_logger.debug("Done recalculating system capacity");
+            }
 
         } catch (Throwable t) {        	
-        	s_logger.error("Caught exception in recalculating capacity", t);
+            s_logger.error("Caught exception in recalculating capacity", t);
         }
     }
-    
 
-    
+
+
     private void createOrUpdateVlanCapacity(long dcId, AllocationState capacityState) {
-    	
-    	SearchCriteria<CapacityVO> capacitySC = _capacityDao.createSearchCriteria();
+
+        SearchCriteria<CapacityVO> capacitySC = _capacityDao.createSearchCriteria();
 
         List<CapacityVO> capacities = _capacityDao.search(capacitySC, null);
         capacitySC = _capacityDao.createSearchCriteria();
         capacitySC.addAnd("dataCenterId", SearchCriteria.Op.EQ, dcId);
         capacitySC.addAnd("capacityType", SearchCriteria.Op.EQ, Capacity.CAPACITY_TYPE_VLAN);
         capacities = _capacityDao.search(capacitySC, null);
-		
-       int totalVlans = _dcDao.countZoneVlans(dcId, false);
-       int allocatedVlans = _dcDao.countZoneVlans(dcId, true);
-        
+
+        int totalVlans = _dcDao.countZoneVlans(dcId, false);
+        int allocatedVlans = _dcDao.countZoneVlans(dcId, true);
+
         if (capacities.size() == 0){
-        	CapacityVO newVlanCapacity = new CapacityVO(null, dcId, null, null, allocatedVlans, totalVlans, Capacity.CAPACITY_TYPE_VLAN);
-        	if (capacityState == AllocationState.Disabled){
-        		newVlanCapacity.setCapacityState(CapacityState.Disabled);
-        	} 
+            CapacityVO newVlanCapacity = new CapacityVO(null, dcId, null, null, allocatedVlans, totalVlans, Capacity.CAPACITY_TYPE_VLAN);
+            if (capacityState == AllocationState.Disabled){
+                newVlanCapacity.setCapacityState(CapacityState.Disabled);
+            } 
             _capacityDao.persist(newVlanCapacity);
         }else if ( !(capacities.get(0).getUsedCapacity() == allocatedVlans 
-        		&& capacities.get(0).getTotalCapacity() == totalVlans) ){
-        	CapacityVO capacity = capacities.get(0);
-        	capacity.setUsedCapacity(allocatedVlans);
-        	capacity.setTotalCapacity(totalVlans);
+                && capacities.get(0).getTotalCapacity() == totalVlans) ){
+            CapacityVO capacity = capacities.get(0);
+            capacity.setUsedCapacity(allocatedVlans);
+            capacity.setTotalCapacity(totalVlans);
             _capacityDao.update(capacity.getId(), capacity);        	
         }
-        
-        
-	}
 
-	public void createOrUpdateIpCapacity(Long dcId, Long podId, short capacityType, AllocationState capacityState){
+
+    }
+
+    public void createOrUpdateIpCapacity(Long dcId, Long podId, short capacityType, AllocationState capacityState){
         SearchCriteria<CapacityVO> capacitySC = _capacityDao.createSearchCriteria();
 
         List<CapacityVO> capacities = _capacityDao.search(capacitySC, null);
@@ -401,55 +400,55 @@ public class AlertManagerImpl implements AlertManager {
         int allocatedIPs;
         capacities = _capacityDao.search(capacitySC, null);
         if (capacityType == CapacityVO.CAPACITY_TYPE_PRIVATE_IP){
-        	totalIPs = _privateIPAddressDao.countIPs(podId, dcId, false);
-        	allocatedIPs = _privateIPAddressDao.countIPs(podId, dcId, true);
+            totalIPs = _privateIPAddressDao.countIPs(podId, dcId, false);
+            allocatedIPs = _privateIPAddressDao.countIPs(podId, dcId, true);
         }else if (capacityType == CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP){
-        	totalIPs = _publicIPAddressDao.countIPsForNetwork(dcId, false, VlanType.VirtualNetwork);
+            totalIPs = _publicIPAddressDao.countIPsForNetwork(dcId, false, VlanType.VirtualNetwork);
             allocatedIPs = _publicIPAddressDao.countIPsForNetwork(dcId, true, VlanType.VirtualNetwork);
         }else {
-        	totalIPs = _publicIPAddressDao.countIPsForNetwork(dcId, false, VlanType.DirectAttached);
+            totalIPs = _publicIPAddressDao.countIPsForNetwork(dcId, false, VlanType.DirectAttached);
             allocatedIPs = _publicIPAddressDao.countIPsForNetwork(dcId, true, VlanType.DirectAttached);
         }
-        
+
         if (capacities.size() == 0){
-        	CapacityVO newPublicIPCapacity = new CapacityVO(null, dcId, podId, null, allocatedIPs, totalIPs, capacityType);
-        	if (capacityState == AllocationState.Disabled){
-        		newPublicIPCapacity.setCapacityState(CapacityState.Disabled);
-        	}        		
+            CapacityVO newPublicIPCapacity = new CapacityVO(null, dcId, podId, null, allocatedIPs, totalIPs, capacityType);
+            if (capacityState == AllocationState.Disabled){
+                newPublicIPCapacity.setCapacityState(CapacityState.Disabled);
+            }        		
             _capacityDao.persist(newPublicIPCapacity);
         }else if ( !(capacities.get(0).getUsedCapacity() == allocatedIPs 
-        		&& capacities.get(0).getTotalCapacity() == totalIPs) ){
-        	CapacityVO capacity = capacities.get(0);
-        	capacity.setUsedCapacity(allocatedIPs);
-        	capacity.setTotalCapacity(totalIPs);
+                && capacities.get(0).getTotalCapacity() == totalIPs) ){
+            CapacityVO capacity = capacities.get(0);
+            capacity.setUsedCapacity(allocatedIPs);
+            capacity.setTotalCapacity(totalIPs);
             _capacityDao.update(capacity.getId(), capacity);
         }
-        
+
     }
 
     class CapacityChecker extends TimerTask {
         @Override
-		public void run() {
+        public void run() {
             try {
-            	s_logger.debug("Running Capacity Checker ... ");
-            	checkForAlerts();
-            	s_logger.debug("Done running Capacity Checker ... ");
+                s_logger.debug("Running Capacity Checker ... ");
+                checkForAlerts();
+                s_logger.debug("Done running Capacity Checker ... ");
             } catch (Throwable t) {
                 s_logger.error("Exception in CapacityChecker", t);
             }
         }
     }
-    
-    
+
+
     public void checkForAlerts(){
-    	
-    	recalculateCapacity();
+
+        recalculateCapacity();
 
         // abort if we can't possibly send an alert...
         if (_emailAlert == null) {
             return;
         }
-        
+
         //Get all datacenters, pods and clusters in the system.
         List<DataCenterVO> dataCenterList = _dcDao.listAll();
         List<ClusterVO> clusterList = _clusterDao.listAll();
@@ -458,89 +457,89 @@ public class AlertManagerImpl implements AlertManager {
         List<Short> dataCenterCapacityTypes = getCapacityTypesAtZoneLevel();         
         List<Short> podCapacityTypes = getCapacityTypesAtPodLevel();        
         List<Short> clusterCapacityTypes = getCapacityTypesAtClusterLevel();        
-        
+
         // Generate Alerts for Zone Level capacities
         for(DataCenterVO dc : dataCenterList){
-        	for (Short capacityType : dataCenterCapacityTypes){
-        		List<SummedCapacity> capacity = new ArrayList<SummedCapacity>();
-        		capacity = _capacityDao.findCapacityBy(capacityType.intValue(), dc.getId(), null, null);
-        		
-        		if (capacityType == Capacity.CAPACITY_TYPE_SECONDARY_STORAGE){
-        			capacity.add(getUsedStats(capacityType, dc.getId(), null, null));
-        		}
-        		if (capacity == null || capacity.size() == 0){
-        			continue;
-        		}
-        		double totalCapacity = capacity.get(0).getTotalCapacity(); 
+            for (Short capacityType : dataCenterCapacityTypes){
+                List<SummedCapacity> capacity = new ArrayList<SummedCapacity>();
+                capacity = _capacityDao.findCapacityBy(capacityType.intValue(), dc.getId(), null, null);
+
+                if (capacityType == Capacity.CAPACITY_TYPE_SECONDARY_STORAGE){
+                    capacity.add(getUsedStats(capacityType, dc.getId(), null, null));
+                }
+                if (capacity == null || capacity.size() == 0){
+                    continue;
+                }
+                double totalCapacity = capacity.get(0).getTotalCapacity(); 
                 double usedCapacity =  capacity.get(0).getUsedCapacity();
                 if (totalCapacity != 0 && usedCapacity/totalCapacity > _capacityTypeThresholdMap.get(capacityType)){
-                	generateEmailAlert(dc, null, null, totalCapacity, usedCapacity, capacityType);
+                    generateEmailAlert(dc, null, null, totalCapacity, usedCapacity, capacityType);
                 }
-        	}
+            }
         }
-        
+
         // Generate Alerts for Pod Level capacities
         for( HostPodVO pod : podList){
-        	for (Short capacityType : podCapacityTypes){
-        		List<SummedCapacity> capacity = _capacityDao.findCapacityBy(capacityType.intValue(), pod.getDataCenterId(), pod.getId(), null);
-        		if (capacity == null || capacity.size() == 0){
-        			continue;
-        		}
-        		double totalCapacity = capacity.get(0).getTotalCapacity(); 
+            for (Short capacityType : podCapacityTypes){
+                List<SummedCapacity> capacity = _capacityDao.findCapacityBy(capacityType.intValue(), pod.getDataCenterId(), pod.getId(), null);
+                if (capacity == null || capacity.size() == 0){
+                    continue;
+                }
+                double totalCapacity = capacity.get(0).getTotalCapacity(); 
                 double usedCapacity =  capacity.get(0).getUsedCapacity();
                 if (totalCapacity != 0 && usedCapacity/totalCapacity > _capacityTypeThresholdMap.get(capacityType)){
-                	generateEmailAlert(ApiDBUtils.findZoneById(pod.getDataCenterId()), pod, null, 
-                			totalCapacity, usedCapacity, capacityType);
+                    generateEmailAlert(ApiDBUtils.findZoneById(pod.getDataCenterId()), pod, null, 
+                            totalCapacity, usedCapacity, capacityType);
                 }
-        	}
+            }
         }
-        
+
         // Generate Alerts for Cluster Level capacities
         for( ClusterVO cluster : clusterList){
-        	for (Short capacityType : clusterCapacityTypes){
-        		List<SummedCapacity> capacity = new ArrayList<SummedCapacity>();
-        		float overProvFactor = 1f;
-        		capacity = _capacityDao.findCapacityBy(capacityType.intValue(), cluster.getDataCenterId(), null, cluster.getId());
-        		
-        		if (capacityType == Capacity.CAPACITY_TYPE_STORAGE){
-        			capacity.add(getUsedStats(capacityType, cluster.getDataCenterId(), cluster.getPodId(), cluster.getId()));
-        		}
-        		if (capacity == null || capacity.size() == 0){
-        			continue;
-        		}        		
-        		if (capacityType == Capacity.CAPACITY_TYPE_CPU){
-        			overProvFactor = ApiDBUtils.getCpuOverprovisioningFactor();
-        		}
-        		
-        		double totalCapacity = capacity.get(0).getTotalCapacity() * overProvFactor; 
+            for (Short capacityType : clusterCapacityTypes){
+                List<SummedCapacity> capacity = new ArrayList<SummedCapacity>();
+                float overProvFactor = 1f;
+                capacity = _capacityDao.findCapacityBy(capacityType.intValue(), cluster.getDataCenterId(), null, cluster.getId());
+
+                if (capacityType == Capacity.CAPACITY_TYPE_STORAGE){
+                    capacity.add(getUsedStats(capacityType, cluster.getDataCenterId(), cluster.getPodId(), cluster.getId()));
+                }
+                if (capacity == null || capacity.size() == 0){
+                    continue;
+                }        		
+                if (capacityType == Capacity.CAPACITY_TYPE_CPU){
+                    overProvFactor = ApiDBUtils.getCpuOverprovisioningFactor();
+                }
+
+                double totalCapacity = capacity.get(0).getTotalCapacity() * overProvFactor; 
                 double usedCapacity =  capacity.get(0).getUsedCapacity() + capacity.get(0).getReservedCapacity();
                 if (totalCapacity != 0 && usedCapacity/totalCapacity > _capacityTypeThresholdMap.get(capacityType)){
-                	generateEmailAlert(ApiDBUtils.findZoneById(cluster.getDataCenterId()), ApiDBUtils.findPodById(cluster.getPodId()), cluster,
-                			totalCapacity, usedCapacity, capacityType);
+                    generateEmailAlert(ApiDBUtils.findZoneById(cluster.getDataCenterId()), ApiDBUtils.findPodById(cluster.getPodId()), cluster,
+                            totalCapacity, usedCapacity, capacityType);
                 }
-        	}
+            }
         }
-        
+
     }
-    
+
     private SummedCapacity getUsedStats(short capacityType, long zoneId, Long podId, Long clusterId){
-    	CapacityVO capacity;
-    	if (capacityType == Capacity.CAPACITY_TYPE_SECONDARY_STORAGE){
-    		capacity = _storageMgr.getSecondaryStorageUsedStats(null, zoneId);
-    	}else{
-    		capacity = _storageMgr.getStoragePoolUsedStats(null, clusterId, podId, zoneId);
-    	}
-    	if (capacity != null){
-    		return new SummedCapacity(capacity.getUsedCapacity(), 0, capacity.getTotalCapacity(), capacityType, clusterId, podId);	
-    	}else{
-    		return null;
-    	}
-    	
+        CapacityVO capacity;
+        if (capacityType == Capacity.CAPACITY_TYPE_SECONDARY_STORAGE){
+            capacity = _storageMgr.getSecondaryStorageUsedStats(null, zoneId);
+        }else{
+            capacity = _storageMgr.getStoragePoolUsedStats(null, clusterId, podId, zoneId);
+        }
+        if (capacity != null){
+            return new SummedCapacity(capacity.getUsedCapacity(), 0, capacity.getTotalCapacity(), capacityType, clusterId, podId);	
+        }else{
+            return null;
+        }
+
     }
-    
+
     private void generateEmailAlert(DataCenterVO dc, HostPodVO pod, ClusterVO cluster, double totalCapacity, double usedCapacity, short capacityType){
-    	
-    	String msgSubject = null;
+
+        String msgSubject = null;
         String msgContent = null;
         String totalStr;
         String usedStr;
@@ -548,10 +547,10 @@ public class AlertManagerImpl implements AlertManager {
         short alertType = -1;
         Long podId = pod == null ? null : pod.getId();
         Long clusterId = cluster == null ? null : cluster.getId();
-        
-    	switch (capacityType) {
-    	
-    	//Cluster Level
+
+        switch (capacityType) {
+
+        //Cluster Level
         case CapacityVO.CAPACITY_TYPE_MEMORY:
             msgSubject = "System Alert: Low Available Memory in cluster " +cluster.getName()+ " pod " +pod.getName()+ " of availability zone " + dc.getName();
             totalStr = formatBytesToMegabytes(totalCapacity);
@@ -587,24 +586,24 @@ public class AlertManagerImpl implements AlertManager {
             msgContent = "Unallocated storage space is low, total: " + totalStr + " MB, allocated: " + usedStr + " MB (" + pctStr + "%)";
             alertType = ALERT_TYPE_LOCAL_STORAGE;
             break;
-           
-        //Pod Level    
+
+            //Pod Level    
         case CapacityVO.CAPACITY_TYPE_PRIVATE_IP:        	
-        	msgSubject = "System Alert: Number of unallocated private IPs is low in pod " +pod.getName()+ " of availability zone " + dc.getName();
-        	totalStr = Double.toString(totalCapacity);
+            msgSubject = "System Alert: Number of unallocated private IPs is low in pod " +pod.getName()+ " of availability zone " + dc.getName();
+            totalStr = Double.toString(totalCapacity);
             usedStr = Double.toString(usedCapacity);
-        	msgContent = "Number of unallocated private IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)";
-        	alertType = ALERT_TYPE_PRIVATE_IP;
-        	break;
-        
-        //Zone Level
+            msgContent = "Number of unallocated private IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)";
+            alertType = ALERT_TYPE_PRIVATE_IP;
+            break;
+
+            //Zone Level
         case CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE:        	
-        	msgSubject = "System Alert: Low Available Secondary Storage in availability zone " + dc.getName();
-        	totalStr = formatBytesToMegabytes(totalCapacity);
+            msgSubject = "System Alert: Low Available Secondary Storage in availability zone " + dc.getName();
+            totalStr = formatBytesToMegabytes(totalCapacity);
             usedStr = formatBytesToMegabytes(usedCapacity);
-        	msgContent = "Available secondary storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)";
-        	alertType = ALERT_TYPE_SECONDARY_STORAGE;
-        	break;
+            msgContent = "Available secondary storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)";
+            alertType = ALERT_TYPE_SECONDARY_STORAGE;
+            break;
         case CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP:
             msgSubject = "System Alert: Number of unallocated virtual network public IPs is low in availability zone " + dc.getName();
             totalStr = Double.toString(totalCapacity);
@@ -627,47 +626,47 @@ public class AlertManagerImpl implements AlertManager {
             alertType = ALERT_TYPE_VLAN;
             break;
         }
-    	
-    	try {
-    		if (s_logger.isDebugEnabled()){
-    			s_logger.debug(msgSubject);
-    			s_logger.debug(msgContent);
-    		}
-			_emailAlert.sendAlert(alertType, dc.getId(), podId, clusterId, msgSubject, msgContent);
-    	} catch (Exception ex) {
+
+        try {
+            if (s_logger.isDebugEnabled()){
+                s_logger.debug(msgSubject);
+                s_logger.debug(msgContent);
+            }
+            _emailAlert.sendAlert(alertType, dc.getId(), podId, clusterId, msgSubject, msgContent);
+        } catch (Exception ex) {
             s_logger.error("Exception in CapacityChecker", ex);        
-		}
+        }
     }
-    
+
     private List<Short> getCapacityTypesAtZoneLevel(){
-    	
-    	List<Short> dataCenterCapacityTypes = new ArrayList<Short>();
-    	dataCenterCapacityTypes.add(Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP);
-    	dataCenterCapacityTypes.add(Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP);
-    	dataCenterCapacityTypes.add(Capacity.CAPACITY_TYPE_SECONDARY_STORAGE);
-    	dataCenterCapacityTypes.add(Capacity.CAPACITY_TYPE_VLAN);
-		return dataCenterCapacityTypes;
-    	
+
+        List<Short> dataCenterCapacityTypes = new ArrayList<Short>();
+        dataCenterCapacityTypes.add(Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP);
+        dataCenterCapacityTypes.add(Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP);
+        dataCenterCapacityTypes.add(Capacity.CAPACITY_TYPE_SECONDARY_STORAGE);
+        dataCenterCapacityTypes.add(Capacity.CAPACITY_TYPE_VLAN);
+        return dataCenterCapacityTypes;
+
     }
-    
+
     private List<Short> getCapacityTypesAtPodLevel(){
-    	
-    	List<Short> podCapacityTypes = new ArrayList<Short>();
-    	podCapacityTypes.add(Capacity.CAPACITY_TYPE_PRIVATE_IP);    	
-		return podCapacityTypes;
-    	
+
+        List<Short> podCapacityTypes = new ArrayList<Short>();
+        podCapacityTypes.add(Capacity.CAPACITY_TYPE_PRIVATE_IP);    	
+        return podCapacityTypes;
+
     }
-    
+
     private List<Short> getCapacityTypesAtClusterLevel(){
-    	
-    	List<Short> clusterCapacityTypes = new ArrayList<Short>();
-    	clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_CPU);
-    	clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_MEMORY);
-    	clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_STORAGE);
-    	clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
-    	clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_LOCAL_STORAGE);
-		return clusterCapacityTypes;
-    	
+
+        List<Short> clusterCapacityTypes = new ArrayList<Short>();
+        clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_CPU);
+        clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_MEMORY);
+        clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_STORAGE);
+        clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
+        clusterCapacityTypes.add(Capacity.CAPACITY_TYPE_LOCAL_STORAGE);
+        return clusterCapacityTypes;
+
     }
 
     class EmailAlert {
@@ -735,12 +734,12 @@ public class AlertManagerImpl implements AlertManager {
         public void sendAlert(short alertType, long dataCenterId, Long podId, Long clusterId, String subject, String content) throws MessagingException, UnsupportedEncodingException {
             AlertVO alert = null;
             if ((alertType != AlertManager.ALERT_TYPE_HOST) &&
-                (alertType != AlertManager.ALERT_TYPE_USERVM) &&
-                (alertType != AlertManager.ALERT_TYPE_DOMAIN_ROUTER) &&
-                (alertType != AlertManager.ALERT_TYPE_CONSOLE_PROXY) &&
-                (alertType != AlertManager.ALERT_TYPE_SSVM) &&
-                (alertType != AlertManager.ALERT_TYPE_STORAGE_MISC) &&
-                (alertType != AlertManager.ALERT_TYPE_MANAGMENT_NODE)) {
+                    (alertType != AlertManager.ALERT_TYPE_USERVM) &&
+                    (alertType != AlertManager.ALERT_TYPE_DOMAIN_ROUTER) &&
+                    (alertType != AlertManager.ALERT_TYPE_CONSOLE_PROXY) &&
+                    (alertType != AlertManager.ALERT_TYPE_SSVM) &&
+                    (alertType != AlertManager.ALERT_TYPE_STORAGE_MISC) &&
+                    (alertType != AlertManager.ALERT_TYPE_MANAGMENT_NODE)) {
                 alert = _alertDao.getLastAlert(alertType, dataCenterId, podId, clusterId);
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java b/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
index 37e3850..7e74422 100644
--- a/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
+++ b/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
@@ -25,13 +25,10 @@ import javax.naming.ConfigurationException;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
-import com.cloud.alert.AlertAdapter;
-import com.cloud.alert.AlertManager;
 import com.cloud.consoleproxy.ConsoleProxyAlertEventArgs;
 import com.cloud.consoleproxy.ConsoleProxyManager;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.events.SubscriptionMgr;
 import com.cloud.vm.ConsoleProxyVO;
 import com.cloud.vm.dao.ConsoleProxyDao;
@@ -39,178 +36,178 @@ import com.cloud.vm.dao.ConsoleProxyDao;
 @Component
 @Local(value=AlertAdapter.class)
 public class ConsoleProxyAlertAdapter implements AlertAdapter {
-	
-	private static final Logger s_logger = Logger.getLogger(ConsoleProxyAlertAdapter.class);
-	
-	@Inject private AlertManager _alertMgr;
+
+    private static final Logger s_logger = Logger.getLogger(ConsoleProxyAlertAdapter.class);
+
+    @Inject private AlertManager _alertMgr;
     private String _name;
-    
-	@Inject private DataCenterDao _dcDao;
-	@Inject private ConsoleProxyDao _consoleProxyDao;
-    
+
+    @Inject private DataCenterDao _dcDao;
+    @Inject private ConsoleProxyDao _consoleProxyDao;
+
     public void onProxyAlert(Object sender, ConsoleProxyAlertEventArgs args) {
-    	if(s_logger.isDebugEnabled())
-    		s_logger.debug("received console proxy alert");
-    	
-    	DataCenterVO dc = _dcDao.findById(args.getZoneId());
-    	ConsoleProxyVO proxy = args.getProxy();
-    	if(proxy == null)
-    		proxy = _consoleProxyDao.findById(args.getProxyId());
-    	
-    	switch(args.getType()) {
-    	case ConsoleProxyAlertEventArgs.PROXY_CREATED :
-        	if(s_logger.isDebugEnabled())
-        		s_logger.debug("New console proxy created, zone: " + dc.getName() + ", proxy: " + 
-        			proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
-        			proxy.getPrivateIpAddress());
-			break;
-    		
-    	case ConsoleProxyAlertEventArgs.PROXY_UP :
-        	if(s_logger.isDebugEnabled())
-        		s_logger.debug("Console proxy is up, zone: " + dc.getName() + ", proxy: " + 
-        			proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
-        			proxy.getPrivateIpAddress());
-    		
-			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_CONSOLE_PROXY,
-				args.getZoneId(),
-				proxy.getPodIdToDeployIn(),
-				"Console proxy up in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
-				 	+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
-			 	"Console proxy up (zone " + dc.getName() + ")" 	
-			);
-			break;
-    		
-    	case ConsoleProxyAlertEventArgs.PROXY_DOWN :
-        	if(s_logger.isDebugEnabled())
-        		s_logger.debug("Console proxy is down, zone: " + dc.getName() + ", proxy: " + 
-        			proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
-        			(proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
-    		
-			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_CONSOLE_PROXY,
-				args.getZoneId(),
-				proxy.getPodIdToDeployIn(),
-				"Console proxy down in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
-				 	+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
-			 	"Console proxy down (zone " + dc.getName() + ")" 	
-			);
-			break;
-    		
-    	case ConsoleProxyAlertEventArgs.PROXY_REBOOTED :
-        	if(s_logger.isDebugEnabled())
-        		s_logger.debug("Console proxy is rebooted, zone: " + dc.getName() + ", proxy: " + 
-        			proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
-        			(proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
-    		
-			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_CONSOLE_PROXY,
-				args.getZoneId(),
-				proxy.getPodIdToDeployIn(),
-				"Console proxy rebooted in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
-				 	+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
-			 	"Console proxy rebooted (zone " + dc.getName() + ")" 	
-			);
-			break;
-			
-    	case ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE :
-        	if(s_logger.isDebugEnabled())
-        		s_logger.debug("Console proxy creation failure, zone: " + dc.getName() + ", proxy: " + 
-        			proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
-        			(proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
-    		
-			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_CONSOLE_PROXY,
-				args.getZoneId(),
-				proxy.getPodIdToDeployIn(),
-				"Console proxy creation failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
-				 	+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) 
-				 	+ ", error details: " + args.getMessage(),
-			 	"Console proxy creation failure (zone " + dc.getName() + ")"
-			);
-    		break;
-    		
-    	case ConsoleProxyAlertEventArgs.PROXY_START_FAILURE :
-        	if(s_logger.isDebugEnabled())
-        		s_logger.debug("Console proxy startup failure, zone: " + dc.getName() + ", proxy: " + 
-        			proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
-        			(proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
-    		
-			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_CONSOLE_PROXY,
-				args.getZoneId(),
-				proxy.getPodIdToDeployIn(),
-				"Console proxy startup failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
-				 	+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) 
-				 	+ ", error details: " + args.getMessage(),
-			 	"Console proxy startup failure (zone " + dc.getName() + ")" 	
-			);
-    		break;
-    	
-    	case ConsoleProxyAlertEventArgs.PROXY_FIREWALL_ALERT :
-        	if(s_logger.isDebugEnabled())
-        		s_logger.debug("Console proxy firewall alert, zone: " + dc.getName() + ", proxy: " + 
-        			proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
-        			(proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
-    		
-			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_CONSOLE_PROXY,
-				args.getZoneId(),
-				proxy.getPodIdToDeployIn(),
-				"Failed to open console proxy firewall port. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() 
-					+ ", public IP: " + proxy.getPublicIpAddress() 
-					+ ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
-				"Console proxy alert (zone " + dc.getName() + ")"	
-			);
-    		break;
-    	
-    	case ConsoleProxyAlertEventArgs.PROXY_STORAGE_ALERT :
-        	if(s_logger.isDebugEnabled())
-        		s_logger.debug("Console proxy storage alert, zone: " + dc.getName() + ", proxy: " + 
-        			proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
-        			proxy.getPrivateIpAddress() + ", message: " + args.getMessage());
-    		
-			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_STORAGE_MISC,
-				args.getZoneId(),
-				proxy.getPodIdToDeployIn(),
-				"Console proxy storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),
-				"Console proxy alert (zone " + dc.getName() + ")"
-			);
-    		break;
-    	}
+        if(s_logger.isDebugEnabled())
+            s_logger.debug("received console proxy alert");
+
+        DataCenterVO dc = _dcDao.findById(args.getZoneId());
+        ConsoleProxyVO proxy = args.getProxy();
+        if(proxy == null)
+            proxy = _consoleProxyDao.findById(args.getProxyId());
+
+        switch(args.getType()) {
+        case ConsoleProxyAlertEventArgs.PROXY_CREATED :
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("New console proxy created, zone: " + dc.getName() + ", proxy: " + 
+                        proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
+                        proxy.getPrivateIpAddress());
+            break;
+
+        case ConsoleProxyAlertEventArgs.PROXY_UP :
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("Console proxy is up, zone: " + dc.getName() + ", proxy: " + 
+                        proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
+                        proxy.getPrivateIpAddress());
+
+            _alertMgr.sendAlert(
+                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    args.getZoneId(),
+                    proxy.getPodIdToDeployIn(),
+                    "Console proxy up in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
+                    + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
+                    "Console proxy up (zone " + dc.getName() + ")" 	
+                    );
+            break;
+
+        case ConsoleProxyAlertEventArgs.PROXY_DOWN :
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("Console proxy is down, zone: " + dc.getName() + ", proxy: " + 
+                        proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
+                        (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
+
+            _alertMgr.sendAlert(
+                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    args.getZoneId(),
+                    proxy.getPodIdToDeployIn(),
+                    "Console proxy down in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
+                    + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
+                    "Console proxy down (zone " + dc.getName() + ")" 	
+                    );
+            break;
+
+        case ConsoleProxyAlertEventArgs.PROXY_REBOOTED :
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("Console proxy is rebooted, zone: " + dc.getName() + ", proxy: " + 
+                        proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
+                        (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
+
+            _alertMgr.sendAlert(
+                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    args.getZoneId(),
+                    proxy.getPodIdToDeployIn(),
+                    "Console proxy rebooted in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
+                    + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
+                    "Console proxy rebooted (zone " + dc.getName() + ")" 	
+                    );
+            break;
+
+        case ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE :
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("Console proxy creation failure, zone: " + dc.getName() + ", proxy: " + 
+                        proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
+                        (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
+
+            _alertMgr.sendAlert(
+                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    args.getZoneId(),
+                    proxy.getPodIdToDeployIn(),
+                    "Console proxy creation failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
+                    + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) 
+                    + ", error details: " + args.getMessage(),
+                    "Console proxy creation failure (zone " + dc.getName() + ")"
+                    );
+            break;
+
+        case ConsoleProxyAlertEventArgs.PROXY_START_FAILURE :
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("Console proxy startup failure, zone: " + dc.getName() + ", proxy: " + 
+                        proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
+                        (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
+
+            _alertMgr.sendAlert(
+                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    args.getZoneId(),
+                    proxy.getPodIdToDeployIn(),
+                    "Console proxy startup failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
+                    + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) 
+                    + ", error details: " + args.getMessage(),
+                    "Console proxy startup failure (zone " + dc.getName() + ")" 	
+                    );
+            break;
+
+        case ConsoleProxyAlertEventArgs.PROXY_FIREWALL_ALERT :
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("Console proxy firewall alert, zone: " + dc.getName() + ", proxy: " + 
+                        proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
+                        (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
+
+            _alertMgr.sendAlert(
+                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    args.getZoneId(),
+                    proxy.getPodIdToDeployIn(),
+                    "Failed to open console proxy firewall port. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() 
+                    + ", public IP: " + proxy.getPublicIpAddress() 
+                    + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()),
+                    "Console proxy alert (zone " + dc.getName() + ")"	
+                    );
+            break;
+
+        case ConsoleProxyAlertEventArgs.PROXY_STORAGE_ALERT :
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("Console proxy storage alert, zone: " + dc.getName() + ", proxy: " + 
+                        proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + 
+                        proxy.getPrivateIpAddress() + ", message: " + args.getMessage());
+
+            _alertMgr.sendAlert(
+                    AlertManager.ALERT_TYPE_STORAGE_MISC,
+                    args.getZoneId(),
+                    proxy.getPodIdToDeployIn(),
+                    "Console proxy storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),
+                    "Console proxy alert (zone " + dc.getName() + ")"
+                    );
+            break;
+        }
+    }
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params)
+            throws ConfigurationException {
+
+        if (s_logger.isInfoEnabled())
+            s_logger.info("Start configuring console proxy alert manager : " + name);
+
+        try {
+            SubscriptionMgr.getInstance().subscribe(ConsoleProxyManager.ALERT_SUBJECT, this, "onProxyAlert");
+        } catch (SecurityException e) {
+            throw new ConfigurationException("Unable to register console proxy event subscription, exception: " + e);
+        } catch (NoSuchMethodException e) {
+            throw new ConfigurationException("Unable to register console proxy event subscription, exception: " + e);
+        }
+
+        return true;
+    }
+
+    @Override
+    public String getName() {
+        return _name;
+    }
+
+    @Override
+    public boolean start() {
+        return true;
+    }
+
+    @Override
+    public boolean stop() {
+        return true;
     }
-    
-	@Override
-	public boolean configure(String name, Map<String, Object> params)
-		throws ConfigurationException {
-		
-		if (s_logger.isInfoEnabled())
-			s_logger.info("Start configuring console proxy alert manager : " + name);
-
-		try {
-			SubscriptionMgr.getInstance().subscribe(ConsoleProxyManager.ALERT_SUBJECT, this, "onProxyAlert");
-		} catch (SecurityException e) {
-			throw new ConfigurationException("Unable to register console proxy event subscription, exception: " + e);
-		} catch (NoSuchMethodException e) {
-			throw new ConfigurationException("Unable to register console proxy event subscription, exception: " + e);
-		}
-		
-		return true;
-	}
-
-	@Override
-	public String getName() {
-		return _name;
-	}
-
-	@Override
-	public boolean start() {
-		return true;
-	}
-
-	@Override
-	public boolean stop() {
-		return true;
-	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 5e8a044..8a15dd1 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -22,6 +22,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import javax.inject.Inject;
+
 import org.apache.cloudstack.api.ApiConstants.HostDetails;
 import org.apache.cloudstack.api.ApiConstants.VMDetails;
 import org.apache.cloudstack.api.response.AccountResponse;
@@ -114,11 +116,11 @@ import com.cloud.network.NetworkManager;
 import com.cloud.network.NetworkProfile;
 import com.cloud.network.NetworkRuleConfigVO;
 import com.cloud.network.NetworkVO;
+import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PhysicalNetworkVO;
-import com.cloud.network.Site2SiteVpnGatewayVO;
 import com.cloud.network.Site2SiteCustomerGatewayVO;
-import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.Site2SiteVpnGatewayVO;
 import com.cloud.network.as.AutoScalePolicy;
 import com.cloud.network.as.AutoScalePolicyConditionMapVO;
 import com.cloud.network.as.AutoScalePolicyVO;
@@ -139,15 +141,15 @@ import com.cloud.network.dao.FirewallRulesDao;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.LoadBalancerDao;
 import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.NetworkDomainDao;
 import com.cloud.network.dao.NetworkRuleConfigDao;
+import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
 import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
 import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
-import com.cloud.network.dao.Site2SiteVpnGatewayDao;
 import com.cloud.network.dao.Site2SiteCustomerGatewayDao;
+import com.cloud.network.dao.Site2SiteVpnGatewayDao;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.security.SecurityGroup;
@@ -160,6 +162,7 @@ import com.cloud.network.vpc.VpcManager;
 import com.cloud.network.vpc.VpcOffering;
 import com.cloud.network.vpc.VpcVO;
 import com.cloud.network.vpc.dao.StaticRouteDao;
+import com.cloud.network.vpc.dao.VpcDao;
 import com.cloud.network.vpc.dao.VpcGatewayDao;
 import com.cloud.network.vpc.dao.VpcOfferingDao;
 import com.cloud.offering.NetworkOffering;
@@ -229,7 +232,6 @@ import com.cloud.user.dao.UserStatisticsDao;
 import com.cloud.uservm.UserVm;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.vm.ConsoleProxyVO;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.InstanceGroup;
@@ -246,194 +248,102 @@ import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.UserVmDetailsDao;
 import com.cloud.vm.dao.VMInstanceDao;
-import com.cloud.network.vpc.dao.VpcDao;
 
 public class ApiDBUtils {
     private static ManagementServer _ms;
-    public static AsyncJobManager _asyncMgr;
-    private static SecurityGroupManager _securityGroupMgr;
-    private static StorageManager _storageMgr;
-    private static UserVmManager _userVmMgr;
-    private static NetworkManager _networkMgr;
-    private static StatsCollector _statsCollector;
-
-    private static AccountDao _accountDao;
-    private static AccountVlanMapDao _accountVlanMapDao;
-    private static ClusterDao _clusterDao;
-    private static CapacityDao _capacityDao;
-    private static DiskOfferingDao _diskOfferingDao;
-    private static DomainDao _domainDao;
-    private static DomainRouterDao _domainRouterDao;
-    private static DomainRouterJoinDao _domainRouterJoinDao;
-    private static GuestOSDao _guestOSDao;
-    private static GuestOSCategoryDao _guestOSCategoryDao;
-    private static HostDao _hostDao;
-    private static IPAddressDao _ipAddressDao;
-    private static LoadBalancerDao _loadBalancerDao;
-    private static SecurityGroupDao _securityGroupDao;
-    private static SecurityGroupJoinDao _securityGroupJoinDao;
-    private static NetworkRuleConfigDao _networkRuleConfigDao;
-    private static HostPodDao _podDao;
-    private static ServiceOfferingDao _serviceOfferingDao;
-    private static SnapshotDao _snapshotDao;
-    private static StoragePoolDao _storagePoolDao;
-    private static VMTemplateDao _templateDao;
-    private static VMTemplateDetailsDao _templateDetailsDao;
-    private static VMTemplateHostDao _templateHostDao;
-    private static VMTemplateSwiftDao _templateSwiftDao;
-    private static VMTemplateS3Dao _templateS3Dao;
-    private static UploadDao _uploadDao;
-    private static UserDao _userDao;
-    private static UserStatisticsDao _userStatsDao;
-    private static UserVmDao _userVmDao;
-    private static UserVmJoinDao _userVmJoinDao;
-    private static VlanDao _vlanDao;
-    private static VolumeDao _volumeDao;
-    private static Site2SiteVpnGatewayDao _site2SiteVpnGatewayDao;
-    private static Site2SiteCustomerGatewayDao _site2SiteCustomerGatewayDao;
-    private static VolumeHostDao _volumeHostDao;
-    private static DataCenterDao _zoneDao;
-    private static NetworkOfferingDao _networkOfferingDao;
-    private static NetworkDao _networkDao;
-    private static PhysicalNetworkDao _physicalNetworkDao;
-    private static ConfigurationService _configMgr;
-    private static ConfigurationDao _configDao;
-    private static ConsoleProxyDao _consoleProxyDao;
-    private static FirewallRulesCidrsDao _firewallCidrsDao;
-    private static VMInstanceDao _vmDao;
-    private static ResourceLimitService _resourceLimitMgr;
-    private static ProjectService _projectMgr;
-    private static ResourceManager _resourceMgr;
-    private static AccountDetailsDao _accountDetailsDao;
-    private static NetworkDomainDao _networkDomainDao;
-    private static HighAvailabilityManager _haMgr;
-    private static VpcManager _vpcMgr;
-    private static TaggedResourceService _taggedResourceService;
-    private static UserVmDetailsDao _userVmDetailsDao;
-    private static SSHKeyPairDao _sshKeyPairDao;
-
-    private static ConditionDao _asConditionDao;
-    private static AutoScalePolicyConditionMapDao _asPolicyConditionMapDao;
-    private static AutoScaleVmGroupPolicyMapDao _asVmGroupPolicyMapDao;
-    private static AutoScalePolicyDao _asPolicyDao;
-    private static AutoScaleVmProfileDao _asVmProfileDao;
-    private static AutoScaleVmGroupDao _asVmGroupDao;
-    private static CounterDao _counterDao;
-    private static ResourceTagJoinDao _tagJoinDao;
-    private static EventJoinDao _eventJoinDao;
-    private static InstanceGroupJoinDao _vmGroupJoinDao;
-    private static UserAccountJoinDao _userAccountJoinDao;
-    private static ProjectJoinDao _projectJoinDao;
-    private static ProjectAccountJoinDao _projectAccountJoinDao;
-    private static ProjectInvitationJoinDao _projectInvitationJoinDao;
-    private static HostJoinDao _hostJoinDao;
-    private static VolumeJoinDao _volJoinDao;
-    private static StoragePoolJoinDao _poolJoinDao;
-    private static AccountJoinDao _accountJoinDao;
-    private static AsyncJobJoinDao _jobJoinDao;
-
-    private static PhysicalNetworkTrafficTypeDao _physicalNetworkTrafficTypeDao;
-    private static PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
-    private static FirewallRulesDao _firewallRuleDao;
-    private static StaticRouteDao _staticRouteDao;
-    private static VpcGatewayDao _vpcGatewayDao;
-    private static VpcDao _vpcDao;
-    private static VpcOfferingDao _vpcOfferingDao;
-    private static SnapshotPolicyDao _snapshotPolicyDao;
-    private static AsyncJobDao _asyncJobDao;
+    @Inject static AsyncJobManager _asyncMgr;
+    @Inject static SecurityGroupManager _securityGroupMgr;
+    @Inject static StorageManager _storageMgr;
+    @Inject static UserVmManager _userVmMgr;
+    @Inject static NetworkManager _networkMgr;
+    @Inject static StatsCollector _statsCollector;
+
+    @Inject static AccountDao _accountDao;
+    @Inject static AccountVlanMapDao _accountVlanMapDao;
+    @Inject static ClusterDao _clusterDao;
+    @Inject static CapacityDao _capacityDao;
+    @Inject static DiskOfferingDao _diskOfferingDao;
+    @Inject static DomainDao _domainDao;
+    @Inject static DomainRouterDao _domainRouterDao;
+    @Inject static DomainRouterJoinDao _domainRouterJoinDao;
+    @Inject static GuestOSDao _guestOSDao;
+    @Inject static GuestOSCategoryDao _guestOSCategoryDao;
+    @Inject static HostDao _hostDao;
+    @Inject static IPAddressDao _ipAddressDao;
+    @Inject static LoadBalancerDao _loadBalancerDao;
+    @Inject static SecurityGroupDao _securityGroupDao;
+    @Inject static SecurityGroupJoinDao _securityGroupJoinDao;
+    @Inject static NetworkRuleConfigDao _networkRuleConfigDao;
+    @Inject static HostPodDao _podDao;
+    @Inject static ServiceOfferingDao _serviceOfferingDao;
+    @Inject static SnapshotDao _snapshotDao;
+    @Inject static StoragePoolDao _storagePoolDao;
+    @Inject static VMTemplateDao _templateDao;
+    @Inject static VMTemplateDetailsDao _templateDetailsDao;
+    @Inject static VMTemplateHostDao _templateHostDao;
+    @Inject static VMTemplateSwiftDao _templateSwiftDao;
+    @Inject static VMTemplateS3Dao _templateS3Dao;
+    @Inject static UploadDao _uploadDao;
+    @Inject static UserDao _userDao;
+    @Inject static UserStatisticsDao _userStatsDao;
+    @Inject static UserVmDao _userVmDao;
+    @Inject static UserVmJoinDao _userVmJoinDao;
+    @Inject static VlanDao _vlanDao;
+    @Inject static VolumeDao _volumeDao;
+    @Inject static Site2SiteVpnGatewayDao _site2SiteVpnGatewayDao;
+    @Inject static Site2SiteCustomerGatewayDao _site2SiteCustomerGatewayDao;
+    @Inject static VolumeHostDao _volumeHostDao;
+    @Inject static DataCenterDao _zoneDao;
+    @Inject static NetworkOfferingDao _networkOfferingDao;
+    @Inject static NetworkDao _networkDao;
+    @Inject static PhysicalNetworkDao _physicalNetworkDao;
+    @Inject static ConfigurationService _configMgr;
+    @Inject static ConfigurationDao _configDao;
+    @Inject static ConsoleProxyDao _consoleProxyDao;
+    @Inject static FirewallRulesCidrsDao _firewallCidrsDao;
+    @Inject static VMInstanceDao _vmDao;
+    @Inject static ResourceLimitService _resourceLimitMgr;
+    @Inject static ProjectService _projectMgr;
+    @Inject static ResourceManager _resourceMgr;
+    @Inject static AccountDetailsDao _accountDetailsDao;
+    @Inject static NetworkDomainDao _networkDomainDao;
+    @Inject static HighAvailabilityManager _haMgr;
+    @Inject static VpcManager _vpcMgr;
+    @Inject static TaggedResourceService _taggedResourceService;
+    @Inject static UserVmDetailsDao _userVmDetailsDao;
+    @Inject static SSHKeyPairDao _sshKeyPairDao;
+
+    @Inject static ConditionDao _asConditionDao;
+    @Inject static AutoScalePolicyConditionMapDao _asPolicyConditionMapDao;
+    @Inject static AutoScaleVmGroupPolicyMapDao _asVmGroupPolicyMapDao;
+    @Inject static AutoScalePolicyDao _asPolicyDao;
+    @Inject static AutoScaleVmProfileDao _asVmProfileDao;
+    @Inject static AutoScaleVmGroupDao _asVmGroupDao;
+    @Inject static CounterDao _counterDao;
+    @Inject static ResourceTagJoinDao _tagJoinDao;
+    @Inject static EventJoinDao _eventJoinDao;
+    @Inject static InstanceGroupJoinDao _vmGroupJoinDao;
+    @Inject static UserAccountJoinDao _userAccountJoinDao;
+    @Inject static ProjectJoinDao _projectJoinDao;
+    @Inject static ProjectAccountJoinDao _projectAccountJoinDao;
+    @Inject static ProjectInvitationJoinDao _projectInvitationJoinDao;
+    @Inject static HostJoinDao _hostJoinDao;
+    @Inject static VolumeJoinDao _volJoinDao;
+    @Inject static StoragePoolJoinDao _poolJoinDao;
+    @Inject static AccountJoinDao _accountJoinDao;
+    @Inject static AsyncJobJoinDao _jobJoinDao;
+
+    @Inject static PhysicalNetworkTrafficTypeDao _physicalNetworkTrafficTypeDao;
+    @Inject static PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
+    @Inject static FirewallRulesDao _firewallRuleDao;
+    @Inject static StaticRouteDao _staticRouteDao;
+    @Inject static VpcGatewayDao _vpcGatewayDao;
+    @Inject static VpcDao _vpcDao;
+    @Inject static VpcOfferingDao _vpcOfferingDao;
+    @Inject static SnapshotPolicyDao _snapshotPolicyDao;
+    @Inject static AsyncJobDao _asyncJobDao;
 
     static {
-        _ms = (ManagementServer) ComponentLocator.getComponent(ManagementServer.Name);
-        ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
-        _asyncMgr = locator.getManager(AsyncJobManager.class);
-        _securityGroupMgr = locator.getManager(SecurityGroupManager.class);
-        _storageMgr = locator.getManager(StorageManager.class);
-        _userVmMgr = locator.getManager(UserVmManager.class);
-        _networkMgr = locator.getManager(NetworkManager.class);
-        _configMgr = locator.getManager(ConfigurationService.class);
-
-        _accountDao = locator.getDao(AccountDao.class);
-        _accountVlanMapDao = locator.getDao(AccountVlanMapDao.class);
-        _clusterDao = locator.getDao(ClusterDao.class);
-        _capacityDao = locator.getDao(CapacityDao.class);
-        _diskOfferingDao = locator.getDao(DiskOfferingDao.class);
-        _domainDao = locator.getDao(DomainDao.class);
-        _domainRouterDao = locator.getDao(DomainRouterDao.class);
-        _domainRouterJoinDao = locator.getDao(DomainRouterJoinDao.class);
-        _guestOSDao = locator.getDao(GuestOSDao.class);
-        _guestOSCategoryDao = locator.getDao(GuestOSCategoryDao.class);
-        _hostDao = locator.getDao(HostDao.class);
-        _ipAddressDao = locator.getDao(IPAddressDao.class);
-        _loadBalancerDao = locator.getDao(LoadBalancerDao.class);
-        _networkRuleConfigDao = locator.getDao(NetworkRuleConfigDao.class);
-        _podDao = locator.getDao(HostPodDao.class);
-        _serviceOfferingDao = locator.getDao(ServiceOfferingDao.class);
-        _snapshotDao = locator.getDao(SnapshotDao.class);
-        _storagePoolDao = locator.getDao(StoragePoolDao.class);
-        _templateDao = locator.getDao(VMTemplateDao.class);
-        _templateDetailsDao = locator.getDao(VMTemplateDetailsDao.class);
-        _templateHostDao = locator.getDao(VMTemplateHostDao.class);
-        _templateSwiftDao = locator.getDao(VMTemplateSwiftDao.class);
-        _templateS3Dao = locator.getDao(VMTemplateS3Dao.class);
-        _uploadDao = locator.getDao(UploadDao.class);
-        _userDao = locator.getDao(UserDao.class);
-        _userStatsDao = locator.getDao(UserStatisticsDao.class);
-        _userVmDao = locator.getDao(UserVmDao.class);
-        _userVmJoinDao = locator.getDao(UserVmJoinDao.class);
-        _vlanDao = locator.getDao(VlanDao.class);
-        _volumeDao = locator.getDao(VolumeDao.class);
-        _site2SiteVpnGatewayDao = locator.getDao(Site2SiteVpnGatewayDao.class);
-        _site2SiteCustomerGatewayDao = locator.getDao(Site2SiteCustomerGatewayDao.class);
-        _volumeHostDao = locator.getDao(VolumeHostDao.class);
-        _zoneDao = locator.getDao(DataCenterDao.class);
-        _securityGroupDao = locator.getDao(SecurityGroupDao.class);
-        _securityGroupJoinDao = locator.getDao(SecurityGroupJoinDao.class);
-        _networkOfferingDao = locator.getDao(NetworkOfferingDao.class);
-        _networkDao = locator.getDao(NetworkDao.class);
-        _physicalNetworkDao = locator.getDao(PhysicalNetworkDao.class);
-        _configDao = locator.getDao(ConfigurationDao.class);
-        _consoleProxyDao = locator.getDao(ConsoleProxyDao.class);
-        _firewallCidrsDao = locator.getDao(FirewallRulesCidrsDao.class);
-        _vmDao = locator.getDao(VMInstanceDao.class);
-        _resourceLimitMgr = locator.getManager(ResourceLimitService.class);
-        _projectMgr = locator.getManager(ProjectService.class);
-        _resourceMgr = locator.getManager(ResourceManager.class);
-        _accountDetailsDao = locator.getDao(AccountDetailsDao.class);
-        _networkDomainDao = locator.getDao(NetworkDomainDao.class);
-        _haMgr = locator.getManager(HighAvailabilityManager.class);
-        _vpcMgr = locator.getManager(VpcManager.class);
-        _taggedResourceService = locator.getManager(TaggedResourceService.class);
-        _sshKeyPairDao = locator.getDao(SSHKeyPairDao.class);
-        _userVmDetailsDao = locator.getDao(UserVmDetailsDao.class);
-        _asConditionDao = locator.getDao(ConditionDao.class);
-        _asPolicyDao = locator.getDao(AutoScalePolicyDao.class);
-        _asPolicyConditionMapDao = locator.getDao(AutoScalePolicyConditionMapDao.class);
-        _counterDao = locator.getDao(CounterDao.class);
-        _asVmGroupPolicyMapDao = locator.getDao(AutoScaleVmGroupPolicyMapDao.class);
-        _tagJoinDao = locator.getDao(ResourceTagJoinDao.class);
-        _vmGroupJoinDao = locator.getDao(InstanceGroupJoinDao.class);
-        _eventJoinDao = locator.getDao(EventJoinDao.class);
-        _userAccountJoinDao = locator.getDao(UserAccountJoinDao.class);
-        _projectJoinDao = locator.getDao(ProjectJoinDao.class);
-        _projectAccountJoinDao = locator.getDao(ProjectAccountJoinDao.class);
-        _projectInvitationJoinDao = locator.getDao(ProjectInvitationJoinDao.class);
-        _hostJoinDao = locator.getDao(HostJoinDao.class);
-        _volJoinDao = locator.getDao(VolumeJoinDao.class);
-        _poolJoinDao = locator.getDao(StoragePoolJoinDao.class);
-        _accountJoinDao = locator.getDao(AccountJoinDao.class);
-        _jobJoinDao = locator.getDao(AsyncJobJoinDao.class);
-
-        _physicalNetworkTrafficTypeDao = locator.getDao(PhysicalNetworkTrafficTypeDao.class);
-        _physicalNetworkServiceProviderDao = locator.getDao(PhysicalNetworkServiceProviderDao.class);
-        _firewallRuleDao = locator.getDao(FirewallRulesDao.class);
-        _staticRouteDao = locator.getDao(StaticRouteDao.class);
-        _vpcGatewayDao = locator.getDao(VpcGatewayDao.class);
-        _asVmProfileDao = locator.getDao(AutoScaleVmProfileDao.class);
-        _asVmGroupDao = locator.getDao(AutoScaleVmGroupDao.class);
-        _vpcDao = locator.getDao(VpcDao.class);
-        _vpcOfferingDao = locator.getDao(VpcOfferingDao.class);
-        _snapshotPolicyDao = locator.getDao(SnapshotPolicyDao.class);
-        _asyncJobDao = locator.getDao(AsyncJobDao.class);
 
         // Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
         _statsCollector = StatsCollector.getInstance();
@@ -611,7 +521,7 @@ public class ApiDBUtils {
     }
 
     public static boolean isChildDomain(long parentId, long childId) {
-    	return _domainDao.isChildDomain(parentId, childId);
+        return _domainDao.isChildDomain(parentId, childId);
     }
 
     public static DomainRouterVO findDomainRouterById(Long routerId) {
@@ -1016,7 +926,7 @@ public class ApiDBUtils {
             else
                 scaleDownPolicyIds.add(autoScalePolicy.getId());
         }
-      }
+    }
     public static String getKeyPairName(String sshPublicKey) {
         SSHKeyPairVO sshKeyPair = _sshKeyPairDao.findByPublicKey(sshPublicKey);
         //key might be removed prior to this point
@@ -1226,7 +1136,7 @@ public class ApiDBUtils {
     }
 
     public static DomainRouterResponse fillRouterDetails(DomainRouterResponse vrData, DomainRouterJoinVO vr){
-         return _domainRouterJoinDao.setDomainRouterResponse(vrData, vr);
+        return _domainRouterJoinDao.setDomainRouterResponse(vrData, vr);
     }
 
     public static List<DomainRouterJoinVO> newDomainRouterView(VirtualRouter vr){
@@ -1238,7 +1148,7 @@ public class ApiDBUtils {
     }
 
     public static UserVmResponse fillVmDetails(UserVmResponse vmData, UserVmJoinVO vm){
-         return _userVmJoinDao.setUserVmResponse(vmData, vm);
+        return _userVmJoinDao.setUserVmResponse(vmData, vm);
     }
 
     public static List<UserVmJoinVO> newUserVmView(UserVm... userVms){
@@ -1250,7 +1160,7 @@ public class ApiDBUtils {
     }
 
     public static SecurityGroupResponse fillSecurityGroupDetails(SecurityGroupResponse vsgData, SecurityGroupJoinVO sg){
-         return _securityGroupJoinDao.setSecurityGroupResponse(vsgData, sg);
+        return _securityGroupJoinDao.setSecurityGroupResponse(vsgData, sg);
     }
 
     public static List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg){
@@ -1312,7 +1222,7 @@ public class ApiDBUtils {
     }
 
     public static ProjectResponse fillProjectDetails(ProjectResponse rsp, ProjectJoinVO proj){
-         return _projectJoinDao.setProjectResponse(rsp,proj);
+        return _projectJoinDao.setProjectResponse(rsp,proj);
     }
 
     public static List<ProjectJoinVO> newProjectView(Project proj){
@@ -1344,7 +1254,7 @@ public class ApiDBUtils {
     }
 
     public static HostResponse fillHostDetails(HostResponse vrData, HostJoinVO vr){
-         return _hostJoinDao.setHostResponse(vrData, vr);
+        return _hostJoinDao.setHostResponse(vrData, vr);
     }
 
     public static List<HostJoinVO> newHostView(Host vr){
@@ -1358,42 +1268,42 @@ public class ApiDBUtils {
 
     public static VolumeResponse fillVolumeDetails(VolumeResponse vrData, VolumeJoinVO vr){
         return _volJoinDao.setVolumeResponse(vrData, vr);
-   }
+    }
 
-   public static List<VolumeJoinVO> newVolumeView(Volume vr){
-       return _volJoinDao.newVolumeView(vr);
-   }
+    public static List<VolumeJoinVO> newVolumeView(Volume vr){
+        return _volJoinDao.newVolumeView(vr);
+    }
 
-   public static StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO vr) {
-       return _poolJoinDao.newStoragePoolResponse(vr);
-   }
+    public static StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO vr) {
+        return _poolJoinDao.newStoragePoolResponse(vr);
+    }
 
-   public static StoragePoolResponse fillStoragePoolDetails(StoragePoolResponse vrData, StoragePoolJoinVO vr){
+    public static StoragePoolResponse fillStoragePoolDetails(StoragePoolResponse vrData, StoragePoolJoinVO vr){
         return _poolJoinDao.setStoragePoolResponse(vrData, vr);
-   }
+    }
 
-   public static List<StoragePoolJoinVO> newStoragePoolView(StoragePool vr){
-       return _poolJoinDao.newStoragePoolView(vr);
-   }
+    public static List<StoragePoolJoinVO> newStoragePoolView(StoragePool vr){
+        return _poolJoinDao.newStoragePoolView(vr);
+    }
 
 
-   public static AccountResponse newAccountResponse(AccountJoinVO ve) {
-       return _accountJoinDao.newAccountResponse(ve);
-   }
+    public static AccountResponse newAccountResponse(AccountJoinVO ve) {
+        return _accountJoinDao.newAccountResponse(ve);
+    }
 
-   public static AccountJoinVO newAccountView(Account e){
-       return _accountJoinDao.newAccountView(e);
-   }
+    public static AccountJoinVO newAccountView(Account e){
+        return _accountJoinDao.newAccountView(e);
+    }
 
-   public static AccountJoinVO findAccountViewById(Long accountId) {
-       return _accountJoinDao.findByIdIncludingRemoved(accountId);
-   }
+    public static AccountJoinVO findAccountViewById(Long accountId) {
+        return _accountJoinDao.findByIdIncludingRemoved(accountId);
+    }
 
-   public static AsyncJobResponse newAsyncJobResponse(AsyncJobJoinVO ve) {
-       return _jobJoinDao.newAsyncJobResponse(ve);
-   }
+    public static AsyncJobResponse newAsyncJobResponse(AsyncJobJoinVO ve) {
+        return _jobJoinDao.newAsyncJobResponse(ve);
+    }
 
-   public static AsyncJobJoinVO newAsyncJobView(AsyncJob e){
-       return _jobJoinDao.newAsyncJobView(e);
-   }
+    public static AsyncJobJoinVO newAsyncJobView(AsyncJob e){
+        return _jobJoinDao.newAsyncJobView(e);
+    }
 }