incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [9/44] Revert "Merge remote-tracking branch 'origin/javelin' into javelin"
Date Tue, 15 Jan 2013 02:04:55 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index cbcdccb..592a7ad 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -20,7 +20,6 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -32,16 +31,20 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
+import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
+import org.apache.cloudstack.api.command.admin.host.AddHostCmd;
+import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd;
+import org.apache.cloudstack.api.command.admin.host.CancelMaintenanceCmd;
+import org.apache.cloudstack.api.command.admin.host.PrepareForMaintenanceCmd;
+import org.apache.cloudstack.api.command.admin.host.ReconnectHostCmd;
+import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd;
+import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
+import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
 import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
 import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
-import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
-import org.apache.cloudstack.api.command.admin.host.*;
 import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
-import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
-import com.cloud.storage.S3;
-import com.cloud.storage.S3VO;
-import com.cloud.storage.s3.S3Manager;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -59,12 +62,7 @@ import com.cloud.agent.api.UpdateHostPasswordCommand;
 import com.cloud.agent.manager.AgentAttache;
 import com.cloud.agent.manager.allocator.PodAllocator;
 import com.cloud.agent.transport.Request;
-import org.apache.cloudstack.api.ApiConstants;
 import com.cloud.api.ApiDBUtils;
-import org.apache.cloudstack.api.command.admin.host.AddHostCmd;
-import org.apache.cloudstack.api.command.admin.host.CancelMaintenanceCmd;
-import org.apache.cloudstack.api.command.admin.host.PrepareForMaintenanceCmd;
-import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd;
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDao;
@@ -112,6 +110,8 @@ import com.cloud.org.Grouping.AllocationState;
 import com.cloud.org.Managed;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.storage.GuestOSCategoryVO;
+import com.cloud.storage.S3;
+import com.cloud.storage.S3VO;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolHostVO;
@@ -125,6 +125,7 @@ import com.cloud.storage.dao.GuestOSCategoryDao;
 import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.s3.S3Manager;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
 import com.cloud.storage.swift.SwiftManager;
 import com.cloud.template.VirtualMachineTemplate;
@@ -135,7 +136,6 @@ import com.cloud.user.UserContext;
 import com.cloud.utils.Pair;
 import com.cloud.utils.StringUtils;
 import com.cloud.utils.UriUtils;
-import com.cloud.utils.component.Adapters;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.SearchCriteria;
@@ -219,7 +219,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
     // @com.cloud.utils.component.Inject(adapter = PodAllocator.class)
     @Inject 
     protected List<PodAllocator> _podAllocators = null;
-    
+
     @Inject
     protected VMTemplateDao  _templateDao;
     @Inject
@@ -236,9 +236,9 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
 
     @PostConstruct
     public void init() {
-    	// TODO initialize pod allocators here instead
+        // TODO initialize pod allocators here instead
     }
-    
+
     private void insertListener(Integer event, ResourceListener listener) {
         List<ResourceListener> lst = _lifeCycleListeners.get(event);
         if (lst == null) {
@@ -510,10 +510,10 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
 
     @Override
     public Discoverer getMatchingDiscover(Hypervisor.HypervisorType hypervisorType) {
-    	for(Discoverer discoverer : _discoverers) {
+        for(Discoverer discoverer : _discoverers) {
             if (discoverer.getHypervisorType() == hypervisorType)
                 return discoverer;
-    	}
+        }
         return null;
     }
 
@@ -1629,7 +1629,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
                     }
                 }
             }
-            
+
             if (s_logger.isDebugEnabled()) {
                 new Request(-1l, -1l, cmds, true, false).logD("Startup request from directly connected host: ", true);
             }
@@ -1670,7 +1670,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
                         }
                     }
                 }
-                
+
                 if (tempHost != null) {
                     /* Change agent status to Alert */
                     _agentMgr.agentStatusTransitTo(tempHost, Status.Event.AgentDisconnected, _nodeId);
@@ -2179,7 +2179,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
 
     @Override
     public Pair<HostPodVO, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO offering, DataCenterVO dc, long accountId, Set<Long> avoids) {
-    	for(PodAllocator allocator : _podAllocators) {
+        for(PodAllocator allocator : _podAllocators) {
             final Pair<HostPodVO, Long> pod = allocator.allocateTo(template, offering, dc, accountId, avoids);
             if (pod != null) {
                 return pod;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/server/CloudStackComponentComposer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/CloudStackComponentComposer.java b/server/src/com/cloud/server/CloudStackComponentComposer.java
new file mode 100644
index 0000000..ae06325
--- /dev/null
+++ b/server/src/com/cloud/server/CloudStackComponentComposer.java
@@ -0,0 +1,184 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.server;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.alert.AlertManagerImpl;
+import com.cloud.api.query.QueryManagerImpl;
+import com.cloud.async.AsyncJobManager;
+import com.cloud.async.SyncQueueManager;
+import com.cloud.capacity.CapacityManagerImpl;
+import com.cloud.cluster.ClusterFenceManagerImpl;
+import com.cloud.cluster.ClusterManagerImpl;
+import com.cloud.configuration.ConfigurationManager;
+import com.cloud.consoleproxy.ConsoleProxyManager;
+import com.cloud.dao.EntityManagerImpl;
+import com.cloud.ha.HighAvailabilityManager;
+import com.cloud.hypervisor.HypervisorGuruManagerImpl;
+import com.cloud.keystore.KeystoreManager;
+import com.cloud.maint.UpgradeManagerImpl;
+import com.cloud.network.ExternalLoadBalancerUsageManager;
+import com.cloud.network.NetworkManagerImpl;
+import com.cloud.network.StorageNetworkManager;
+import com.cloud.network.as.AutoScaleManagerImpl;
+import com.cloud.network.firewall.FirewallManagerImpl;
+import com.cloud.network.lb.LoadBalancingRulesManagerImpl;
+import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
+import com.cloud.network.rules.RulesManagerImpl;
+import com.cloud.network.security.SecurityGroupManagerImpl2;
+import com.cloud.network.vpc.NetworkACLManagerImpl;
+import com.cloud.network.vpc.VpcManagerImpl;
+import com.cloud.network.vpn.RemoteAccessVpnManagerImpl;
+import com.cloud.network.vpn.Site2SiteVpnManagerImpl;
+import com.cloud.projects.ProjectManagerImpl;
+import com.cloud.resource.ResourceManagerImpl;
+import com.cloud.resourcelimit.ResourceLimitManagerImpl;
+import com.cloud.storage.OCFS2Manager;
+import com.cloud.storage.StorageManagerImpl;
+import com.cloud.storage.download.DownloadMonitor;
+import com.cloud.storage.s3.S3Manager;
+import com.cloud.storage.secondary.SecondaryStorageManagerImpl;
+import com.cloud.storage.snapshot.SnapshotManagerImpl;
+import com.cloud.storage.snapshot.SnapshotSchedulerImpl;
+import com.cloud.storage.swift.SwiftManager;
+import com.cloud.storage.upload.UploadMonitor;
+import com.cloud.tags.TaggedResourceManagerImpl;
+import com.cloud.template.TemplateManagerImpl;
+import com.cloud.user.AccountManagerImpl;
+import com.cloud.user.DomainManagerImpl;
+import com.cloud.utils.component.Manager;
+import com.cloud.vm.UserVmManagerImpl;
+import com.cloud.vm.VirtualMachineManager;
+
+@Component
+public class CloudStackComponentComposer {
+	// @Inject CheckPointManagerImpl _checkPointMgr;
+    @Inject ClusterManagerImpl _clusterMgr;
+    @Inject ClusterFenceManagerImpl _clusterFenceMgr;
+    @Inject AgentManager _AgentMgr;
+    @Inject SyncQueueManager _sycnQueueMgr;
+    @Inject AsyncJobManager _jobMgr;
+    @Inject ConfigurationManager _confMgr;
+    @Inject AccountManagerImpl _accountMgr;
+    @Inject DomainManagerImpl _domainMgr;
+    @Inject ResourceLimitManagerImpl _resLimitMgr;
+    @Inject NetworkManagerImpl _networkMgr;
+    @Inject DownloadMonitor _downloadMonitor;
+    @Inject UploadMonitor _uploadMonitor;
+    @Inject KeystoreManager _ksMgr;
+    @Inject SecondaryStorageManagerImpl _ssMgr;
+    @Inject UserVmManagerImpl _userVmMgr;
+    @Inject UpgradeManagerImpl _upgradeMgr;
+    @Inject StorageManagerImpl _storageMgr;
+    @Inject AlertManagerImpl _alertMgr;
+    @Inject TemplateManagerImpl _tmplMgr;
+    @Inject SnapshotManagerImpl _snpahsotMgr;
+    @Inject SnapshotSchedulerImpl _snapshotScheduleMgr;
+    @Inject SecurityGroupManagerImpl2 _sgMgr;
+    @Inject EntityManagerImpl _entityMgr;
+    @Inject LoadBalancingRulesManagerImpl _lbRuleMgr;
+    @Inject AutoScaleManagerImpl _asMgr;
+    @Inject RulesManagerImpl _rulesMgr;
+    @Inject RemoteAccessVpnManagerImpl _acVpnMgr;
+    @Inject CapacityManagerImpl _capacityMgr;
+    @Inject VirtualMachineManager _vmMgr;
+    @Inject HypervisorGuruManagerImpl _hvGuruMgr;
+    @Inject ResourceManagerImpl _resMgr;
+    @Inject OCFS2Manager _ocfsMgr;
+    @Inject FirewallManagerImpl _fwMgr;
+    @Inject ConsoleProxyManager _cpMgr;
+    @Inject ProjectManagerImpl _prjMgr;
+    @Inject SwiftManager _swiftMgr;
+    @Inject S3Manager _s3Mgr;
+    @Inject StorageNetworkManager _storageNetworkMgr;
+    @Inject ExternalLoadBalancerUsageManager _extlbUsageMgr;
+    @Inject HighAvailabilityManager _haMgr;
+    @Inject VpcManagerImpl _vpcMgr;
+    @Inject VpcVirtualNetworkApplianceManager _vpcNetApplianceMgr;
+    @Inject NetworkACLManagerImpl _networkAclMgr;
+    @Inject TaggedResourceManagerImpl _taggedResMgr;
+    @Inject Site2SiteVpnManagerImpl _s2sVpnMgr;
+    @Inject QueryManagerImpl _queryMgr;
+    
+    List<Manager> _managers = new ArrayList<Manager>();
+
+    public CloudStackComponentComposer() {
+    }
+    
+    @PostConstruct
+    void init() {
+    	// _managers.add(_checkPointMgr);
+        _managers.add(_clusterMgr);
+        _managers.add(_clusterFenceMgr);
+        _managers.add(_AgentMgr);
+        _managers.add(_sycnQueueMgr);
+        _managers.add(_jobMgr);
+        _managers.add(_confMgr);
+        _managers.add(_accountMgr);
+        _managers.add(_domainMgr);
+        _managers.add(_resLimitMgr);
+        _managers.add(_networkMgr);
+        _managers.add(_downloadMonitor);
+        _managers.add(_uploadMonitor);
+        _managers.add(_ksMgr);
+        _managers.add(_ssMgr);
+        _managers.add(_userVmMgr);
+        _managers.add(_upgradeMgr);
+        _managers.add(_storageMgr);
+        _managers.add(_alertMgr);
+        _managers.add(_tmplMgr);
+        _managers.add(_snpahsotMgr);
+        _managers.add(_snapshotScheduleMgr);
+        _managers.add(_sgMgr);
+        _managers.add(_entityMgr);
+        _managers.add(_lbRuleMgr);
+        _managers.add(_asMgr);
+        _managers.add(_rulesMgr);
+        _managers.add(_acVpnMgr);
+        _managers.add(_capacityMgr);
+        _managers.add(_vmMgr);
+        _managers.add(_hvGuruMgr);
+        _managers.add(_resMgr);
+        _managers.add(_ocfsMgr);
+        _managers.add(_fwMgr);
+        _managers.add(_cpMgr);
+        _managers.add(_prjMgr);
+        _managers.add(_swiftMgr);
+        _managers.add(_s3Mgr);
+        _managers.add(_storageNetworkMgr);
+        _managers.add(_extlbUsageMgr);
+        _managers.add(_haMgr);
+        _managers.add(_vpcMgr);
+        _managers.add(_vpcNetApplianceMgr);
+        _managers.add(_networkAclMgr);
+        _managers.add(_taggedResMgr);
+        _managers.add(_s2sVpnMgr);
+        _managers.add(_queryMgr);
+    }
+    
+    public List<Manager> getManagers() {
+    	return _managers;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/server/ConfigurationServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index 4b4d8df..77de9bb 100755
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -287,7 +287,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
         _identityDao.initializeDefaultUuid("user_ip_address");
         _identityDao.initializeDefaultUuid("counter");
     }
-    */
+     */
 
     private String getMountParent() {
         return getEnvironmentProperty("mount.parent");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/server/ManagementServerExtImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerExtImpl.java b/server/src/com/cloud/server/ManagementServerExtImpl.java
index 03e50eb..ed05395 100644
--- a/server/src/com/cloud/server/ManagementServerExtImpl.java
+++ b/server/src/com/cloud/server/ManagementServerExtImpl.java
@@ -32,8 +32,8 @@ import com.cloud.domain.dao.DomainDao;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.projects.Project;
+import com.cloud.utils.PropertiesUtil;
 import org.apache.cloudstack.api.response.UsageTypeResponse;
-import org.springframework.stereotype.Component;
 
 import com.cloud.usage.UsageJobVO;
 import com.cloud.usage.UsageTypes;
@@ -48,7 +48,6 @@ import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.Transaction;
 
-@Component
 public class ManagementServerExtImpl extends ManagementServerImpl implements ManagementServerExt {
     @Inject private AccountDao _accountDao;
     @Inject private DomainDao _domainDao;
@@ -209,8 +208,9 @@ public class ManagementServerExtImpl extends ManagementServerImpl implements Man
     }
 
     @Override
-    public String[] getPropertiesFiles() {
-        return new String[] { "commands.properties", "commands-ext.properties" };
+    public Map<String, String> getProperties() {
+        return PropertiesUtil.processConfigFile(new String[]
+                { "commands.properties", "commands-ext.properties" });
     }
 
     private Date computeAdjustedTime(Date initialDate, TimeZone targetTZ, boolean adjustToDayStart) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 60bab00..65501e3 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -58,7 +58,6 @@ import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
 import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
 import org.apache.cloudstack.api.command.admin.resource.ListCapacityCmd;
 import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
-import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
 import org.apache.cloudstack.api.command.admin.systemvm.DestroySystemVmCmd;
 import org.apache.cloudstack.api.command.admin.systemvm.ListSystemVMsCmd;
 import org.apache.cloudstack.api.command.admin.systemvm.RebootSystemVmCmd;
@@ -86,7 +85,6 @@ import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
 import org.apache.cloudstack.api.response.ExtractResponse;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.GetVncPortAnswer;
@@ -186,7 +184,6 @@ import com.cloud.storage.GuestOsCategory;
 import com.cloud.storage.Storage;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.StorageManager;
-import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolVO;
 import com.cloud.storage.Upload;
 import com.cloud.storage.Upload.Mode;
@@ -223,6 +220,7 @@ import com.cloud.utils.EnumUtils;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.PasswordGenerator;
+import com.cloud.utils.PropertiesUtil;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.Adapter;
 import com.cloud.utils.component.ComponentContext;
@@ -381,8 +379,14 @@ public class ManagementServerImpl implements ManagementServer {
     S3Manager _s3Mgr;
 
     @Inject
-    ComponentContext _placeholder;			// create a dependency to ComponentContext so that it can be loaded beforehead
- 
+    ComponentContext _forceContextRef;			// create a dependency to ComponentContext so that it can be loaded beforehead
+   
+    @Inject
+    EventUtils	_forceEventUtilsRef;
+
+    @Inject
+    CloudStackComponentComposer _componentRegistry;
+     
     private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
     private KeystoreManager _ksMgr;
 
@@ -393,7 +397,7 @@ public class ManagementServerImpl implements ManagementServer {
     @Inject List<UserAuthenticator> _userAuthenticators;
 
     private String _hashKey = null;
-
+    
     public ManagementServerImpl() {
     }
 
@@ -448,12 +452,11 @@ public class ManagementServerImpl implements ManagementServer {
         Map<String, GenericDaoBase> daos = ComponentContext.getApplicationContext().getBeansOfType(
                 GenericDaoBase.class);
 
+ 		Map<String, Object> params = new HashMap<String, Object>();
         for (GenericDaoBase dao : daos.values()) {
             try {
                 s_logger.info("Starting dao " + ComponentContext.getTargetClass(dao).getName());
-
-                // TODO
-                // dao.configure(dao.getClass().getSimpleName(), params);
+                dao.configure(dao.getClass().getSimpleName(), params);
             } catch (Exception e) {
                 s_logger.error("Problems with running checker:" + ComponentContext.getTargetClass(dao).getName(), e);
                 System.exit(1);
@@ -462,12 +465,8 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     private void startManagers() {
-		@SuppressWarnings("rawtypes")
-		Map<String, Manager> managers = ComponentContext.getApplicationContext().getBeansOfType(
-				Manager.class);
-			
-		Map<String, Object> params = new HashMap<String, Object>();
-		for(Manager manager : managers.values()) {
+ 		Map<String, Object> params = new HashMap<String, Object>();
+		for(Manager manager : _componentRegistry.getManagers()) {
 			s_logger.info("Start manager: " + ComponentContext.getTargetClass(manager).getName() + "...");
 			try {
 				if(!manager.configure(manager.getClass().getSimpleName(), params)) {
@@ -2392,8 +2391,9 @@ public class ManagementServerImpl implements ManagementServer {
     }
 
     @Override
-    public String[] getPropertiesFiles() {
-        return new String[] { "commands.properties" };
+    public Map<String, String> getProperties() {
+        return PropertiesUtil.processConfigFile(new String[]
+                { "commands.properties" });
     }
 
     protected class EventPurgeTask implements Runnable {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/servlet/CloudStartupServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/CloudStartupServlet.java b/server/src/com/cloud/servlet/CloudStartupServlet.java
index de133ab..bbcf353 100755
--- a/server/src/com/cloud/servlet/CloudStartupServlet.java
+++ b/server/src/com/cloud/servlet/CloudStartupServlet.java
@@ -27,7 +27,6 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.log4j.xml.DOMConfigurator;
 
-import com.cloud.api.ApiServer;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.server.ConfigurationServer;
 import com.cloud.server.ManagementServer;
@@ -42,17 +41,14 @@ public class CloudStartupServlet extends HttpServlet implements ServletContextLi
 
     @Override
     public void init() throws ServletException {
-        initLog4j();
-
-        // Save Configuration Values
-        ConfigurationServer c = ComponentContext.getCompanent(ConfigurationServer.class);
+    	initLog4j();
+        ConfigurationServer c = (ConfigurationServer)ComponentContext.getComponent(ConfigurationServer.Name);
         try {
             c.persistDefaultValues();
-
-            ManagementServer ms = ComponentContext.getCompanent(ManagementServer.class);
+            ManagementServer ms = (ManagementServer)ComponentContext.getComponent(ManagementServer.Name);
             ms.startup();
             ms.enableAdminUser("password");
-            ApiServer.initApiServer(ms.getPropertiesFiles());
+            //ApiServer.initApiServer();
         } catch (InvalidParameterValueException ipve) {
             s_logger.error("Exception starting management server ", ipve);
             throw new ServletException (ipve.getMessage());
@@ -75,18 +71,18 @@ public class CloudStartupServlet extends HttpServlet implements ServletContextLi
     @Override
     public void contextDestroyed(ServletContextEvent sce) {
     }
-
+    
     private void initLog4j() {
-        File file = PropertiesUtil.findConfigFile("log4j-cloud.xml");
-        if (file != null) {
-            s_logger.info("log4j configuration found at " + file.getAbsolutePath());
-            DOMConfigurator.configureAndWatch(file.getAbsolutePath());
-        } else {
-            file = PropertiesUtil.findConfigFile("log4j-cloud.properties");
-            if (file != null) {
-                s_logger.info("log4j configuration found at " + file.getAbsolutePath());
-                PropertyConfigurator.configureAndWatch(file.getAbsolutePath());
-            }
-        }
-    }
+    	File file = PropertiesUtil.findConfigFile("log4j-cloud.xml");
+    	if (file != null) {
+        s_logger.info("log4j configuration found at " + file.getAbsolutePath());
+        DOMConfigurator.configureAndWatch(file.getAbsolutePath());
+	    } else {
+	        file = PropertiesUtil.findConfigFile("log4j-cloud.properties");
+	        if (file != null) {
+	            s_logger.info("log4j configuration found at " + file.getAbsolutePath());
+	            PropertyConfigurator.configureAndWatch(file.getAbsolutePath());
+	        }
+	    }
+   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/servlet/ConsoleProxyServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
index afa5c40..6a47ba2 100644
--- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java
+++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
@@ -25,17 +25,20 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.PostConstruct;
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
+import javax.inject.Inject;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import org.apache.cloudstack.api.IdentityService;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
-import org.apache.cloudstack.api.IdentityService;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.host.HostVO;
 import com.cloud.server.ManagementServer;
@@ -46,7 +49,6 @@ import com.cloud.user.User;
 import com.cloud.uservm.UserVm;
 import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.db.Transaction;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
@@ -57,17 +59,27 @@ import com.cloud.vm.VirtualMachineManager;
  * Console access : /conosole?cmd=access&vm=xxx
  * Authentication : /console?cmd=auth&vm=xxx&sid=xxx
  */
+@Component("consoleServlet")
 public class ConsoleProxyServlet extends HttpServlet {
     private static final long serialVersionUID = -5515382620323808168L;
     public static final Logger s_logger = Logger.getLogger(ConsoleProxyServlet.class.getName());
     private static final int DEFAULT_THUMBNAIL_WIDTH = 144;
     private static final int DEFAULT_THUMBNAIL_HEIGHT = 110;
 
-    private final static AccountManager _accountMgr = ComponentLocator.getLocator(ManagementServer.Name).getManager(AccountManager.class);
-    private final static VirtualMachineManager _vmMgr = ComponentLocator.getLocator(ManagementServer.Name).getManager(VirtualMachineManager.class);
-    private final static ManagementServer _ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name);
-    private final static IdentityService _identityService = ComponentLocator.getLocator(ManagementServer.Name).getManager(IdentityService.class); 
+    @Inject AccountManager _accountMgr;
+    @Inject VirtualMachineManager _vmMgr;
+    @Inject ManagementServer _ms;
+    @Inject IdentityService _identityService; 
 
+    static ManagementServer s_ms;
+    public ConsoleProxyServlet() {
+    }
+    
+    @PostConstruct
+    void initComponent() {
+    	s_ms = _ms;
+    }
+    
     @Override
     protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
         doGet(req, resp);
@@ -398,7 +410,7 @@ public class ConsoleProxyServlet extends HttpServlet {
 
             long ts = normalizedHashTime.getTime();
             ts = ts/60000;		// round up to 1 minute
-            String secretKey = _ms.getHashKey();
+            String secretKey = s_ms.getHashKey();
 
             SecretKeySpec keySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
             mac.init(keySpec);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/servlet/RegisterCompleteServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/RegisterCompleteServlet.java b/server/src/com/cloud/servlet/RegisterCompleteServlet.java
index 7755851..5922455 100644
--- a/server/src/com/cloud/servlet/RegisterCompleteServlet.java
+++ b/server/src/com/cloud/servlet/RegisterCompleteServlet.java
@@ -19,125 +19,111 @@ package com.cloud.servlet;
 import java.net.URLEncoder;
 import java.util.List;
 
+import javax.inject.Inject;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.configuration.Configuration;
 import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.server.ManagementServer;
 import com.cloud.user.Account;
 import com.cloud.user.AccountService;
 import com.cloud.user.User;
 import com.cloud.user.UserVO;
 import com.cloud.user.dao.UserDao;
 import com.cloud.utils.SerialVersionUID;
-import com.cloud.utils.component.ComponentLocator;
 
+@Component("registerCompleteServlet")
 public class RegisterCompleteServlet extends HttpServlet implements ServletContextListener {
-	public static final Logger s_logger = Logger.getLogger(RegisterCompleteServlet.class.getName());
-	
+    public static final Logger s_logger = Logger.getLogger(RegisterCompleteServlet.class.getName());
+
     static final long serialVersionUID = SerialVersionUID.CloudStartupServlet;
-   
-    protected static AccountService _accountSvc = null;
-    protected static ConfigurationDao _configDao = null;
-    protected static UserDao _userDao = null;
-    
-	@Override
-    public void init() throws ServletException {
-		ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
-		_accountSvc = locator.getManager(AccountService.class);
-		_configDao = locator.getDao(ConfigurationDao.class);
-		_userDao = locator.getDao(UserDao.class);
-	}
-	
-	@Override
-	public void contextInitialized(ServletContextEvent sce) {
-	    try {
-	        init();
-	    } catch (ServletException e) {
-	        s_logger.error("Exception starting management server ", e);
-	        throw new RuntimeException(e);
-	    }
-	}
-	
-	@Override
-	public void contextDestroyed(ServletContextEvent sce) {
-	}
-	
-	@Override
+
+    @Inject AccountService _accountSvc = null;
+    @Inject ConfigurationDao _configDao = null;
+    @Inject UserDao _userDao = null;
+
+    @Override
+    public void contextInitialized(ServletContextEvent sce) {
+    }
+
+    @Override
+    public void contextDestroyed(ServletContextEvent sce) {
+    }
+
+    @Override
     protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
-		doGet(req, resp);
-	}
-	
-	@Override
+        doGet(req, resp);
+    }
+
+    @Override
     protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
-		String registrationToken = req.getParameter("token");
-		String expires = req.getParameter("expires");
-		int statusCode = HttpServletResponse.SC_OK;
-		String responseMessage = null;
-		
-		if (registrationToken == null || registrationToken.trim().length() == 0) {
-			statusCode = 503;
-			responseMessage = "{ \"registration_info\" : { \"errorcode\" : \"503\", \"errortext\" : \"Missing token\" } }";
-		} else {
-			s_logger.info("Attempting to register user account with token = "+registrationToken);
-			User resourceAdminUser = _accountSvc.getActiveUserByRegistrationToken(registrationToken);
-			if (resourceAdminUser != null) {
-				if(resourceAdminUser.isRegistered()) {
-					statusCode = 503;
-					responseMessage = "{ \"registration_info\" : { \"errorcode\" : \"503\", \"errortext\" : \"Expired token = " + registrationToken + "\" } }";
-				} else {
-					if(expires != null && expires.toLowerCase().equals("true")){
-						_accountSvc.markUserRegistered(resourceAdminUser.getId());
-					}
-					
-					Account resourceAdminAccount = _accountSvc.getActiveAccountById(resourceAdminUser.getAccountId());
-					Account rsUserAccount = _accountSvc.getActiveAccountByName(resourceAdminAccount.getAccountName()+"-user", resourceAdminAccount.getDomainId());
-					
-					List<UserVO> users =  _userDao.listByAccount(rsUserAccount.getId());
-					User rsUser = users.get(0);
-					
-					Configuration config = _configDao.findByName("endpointe.url");
-					
-					StringBuffer sb = new StringBuffer();
-			        sb.append("{ \"registration_info\" : { \"endpoint_url\" : \""+encodeParam(config.getValue())+"\", ");
-			        sb.append("\"domain_id\" : \""+resourceAdminAccount.getDomainId()+"\", ");
-			        sb.append("\"admin_account\" : \""+encodeParam(resourceAdminUser.getUsername())+"\", ");
-			        sb.append("\"admin_account_api_key\" : \""+resourceAdminUser.getApiKey()+"\", ");
-			        sb.append("\"admin_account_secret_key\" : \""+resourceAdminUser.getSecretKey()+"\", ");
-			        sb.append("\"user_account\" : \""+encodeParam(rsUser.getUsername())+"\", ");
-			        sb.append("\"user_account_api_key\" : \""+rsUser.getApiKey()+"\", ");
-			        sb.append("\"user_account_secret_key\" : \""+rsUser.getSecretKey()+"\" ");
-			        sb.append("} }");
-			        responseMessage = sb.toString();
-				}
-			} else {
-				statusCode = 503;
-				responseMessage = "{ \"registration_info\" : { \"errorcode\" : \"503\", \"errortext\" : \"Invalid token = " + registrationToken + "\" } }";
-			}
-		}
-        
+        String registrationToken = req.getParameter("token");
+        String expires = req.getParameter("expires");
+        int statusCode = HttpServletResponse.SC_OK;
+        String responseMessage = null;
+
+        if (registrationToken == null || registrationToken.trim().length() == 0) {
+            statusCode = 503;
+            responseMessage = "{ \"registration_info\" : { \"errorcode\" : \"503\", \"errortext\" : \"Missing token\" } }";
+        } else {
+            s_logger.info("Attempting to register user account with token = "+registrationToken);
+            User resourceAdminUser = _accountSvc.getActiveUserByRegistrationToken(registrationToken);
+            if (resourceAdminUser != null) {
+                if(resourceAdminUser.isRegistered()) {
+                    statusCode = 503;
+                    responseMessage = "{ \"registration_info\" : { \"errorcode\" : \"503\", \"errortext\" : \"Expired token = " + registrationToken + "\" } }";
+                } else {
+                    if(expires != null && expires.toLowerCase().equals("true")){
+                        _accountSvc.markUserRegistered(resourceAdminUser.getId());
+                    }
+
+                    Account resourceAdminAccount = _accountSvc.getActiveAccountById(resourceAdminUser.getAccountId());
+                    Account rsUserAccount = _accountSvc.getActiveAccountByName(resourceAdminAccount.getAccountName()+"-user", resourceAdminAccount.getDomainId());
+
+                    List<UserVO> users =  _userDao.listByAccount(rsUserAccount.getId());
+                    User rsUser = users.get(0);
+
+                    Configuration config = _configDao.findByName("endpointe.url");
+
+                    StringBuffer sb = new StringBuffer();
+                    sb.append("{ \"registration_info\" : { \"endpoint_url\" : \""+encodeParam(config.getValue())+"\", ");
+                    sb.append("\"domain_id\" : \""+resourceAdminAccount.getDomainId()+"\", ");
+                    sb.append("\"admin_account\" : \""+encodeParam(resourceAdminUser.getUsername())+"\", ");
+                    sb.append("\"admin_account_api_key\" : \""+resourceAdminUser.getApiKey()+"\", ");
+                    sb.append("\"admin_account_secret_key\" : \""+resourceAdminUser.getSecretKey()+"\", ");
+                    sb.append("\"user_account\" : \""+encodeParam(rsUser.getUsername())+"\", ");
+                    sb.append("\"user_account_api_key\" : \""+rsUser.getApiKey()+"\", ");
+                    sb.append("\"user_account_secret_key\" : \""+rsUser.getSecretKey()+"\" ");
+                    sb.append("} }");
+                    responseMessage = sb.toString();
+                }
+            } else {
+                statusCode = 503;
+                responseMessage = "{ \"registration_info\" : { \"errorcode\" : \"503\", \"errortext\" : \"Invalid token = " + registrationToken + "\" } }";
+            }
+        }
+
         try {
-	        resp.setContentType("text/javascript; charset=UTF-8");
-	        resp.setStatus(statusCode);
-			resp.getWriter().print(responseMessage);
+            resp.setContentType("text/javascript; charset=UTF-8");
+            resp.setStatus(statusCode);
+            resp.getWriter().print(responseMessage);
         } catch (Exception ex) {
-        	s_logger.error("unknown exception writing register complete response", ex);
+            s_logger.error("unknown exception writing register complete response", ex);
+        }
+    }
+
+    private String encodeParam(String value) {
+        try {
+            return URLEncoder.encode(value, "UTF-8").replaceAll("\\+", "%20");
+        } catch (Exception e) {
+            s_logger.warn("Unable to encode: " + value);
         }
-	}
-	
-	private String encodeParam(String value) {
-		try {
-			return URLEncoder.encode(value, "UTF-8").replaceAll("\\+", "%20");
-		} catch (Exception e) {
-			s_logger.warn("Unable to encode: " + value);
-		}
-		return value;
-	}
+        return value;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index ef36a82..bff76b9 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -28,7 +28,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -45,7 +44,10 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.cloudstack.api.command.admin.storage.*;
+import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
+import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
+import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
+import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
 import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
 import org.apache.log4j.Logger;
@@ -76,14 +78,12 @@ import com.cloud.agent.api.to.VolumeTO;
 import com.cloud.agent.manager.Commands;
 import com.cloud.alert.AlertManager;
 import com.cloud.api.ApiDBUtils;
-import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
 import com.cloud.async.AsyncJobManager;
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityManager;
 import com.cloud.capacity.CapacityState;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDao;
-import com.cloud.cluster.CheckPointManager;
 import com.cloud.cluster.ClusterManagerListener;
 import com.cloud.cluster.ManagementServerHostVO;
 import com.cloud.configuration.Config;
@@ -172,8 +172,7 @@ import com.cloud.utils.EnumUtils;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.UriUtils;
-import com.cloud.utils.component.Adapters;
-import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
@@ -322,8 +321,6 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
     @Inject
     protected ResourceManager _resourceMgr;
     @Inject
-    protected CheckPointManager _checkPointMgr;
-    @Inject
     protected DownloadMonitor _downloadMonitor;
     @Inject
     protected ResourceTagDao _resourceTagDao;
@@ -355,14 +352,14 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
     protected BigDecimal _overProvisioningFactor = new BigDecimal(1);
     private long _maxVolumeSizeInGb;
     private long _serverId;
-    private StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
+    private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
     private int _customDiskOfferingMinSize = 1;
     private int _customDiskOfferingMaxSize = 1024;
     private double _storageUsedThreshold = 1.0d;
     private double _storageAllocatedThreshold = 1.0d;
     protected BigDecimal _storageOverprovisioningFactor = new BigDecimal(1);
 
-	private boolean _recreateSystemVmEnabled;
+    private boolean _recreateSystemVmEnabled;
 
     public boolean share(VMInstanceVO vm, List<VolumeVO> vols, HostVO host, boolean cancelPreviousShare) throws StorageUnavailableException {
 
@@ -653,9 +650,9 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         Pair<VolumeVO, String> volumeDetails = createVolumeFromSnapshot(volume, snapshot);
         if (volumeDetails != null) {
             createdVolume = volumeDetails.first();
-        	UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, createdVolume.getAccountId(), createdVolume.getDataCenterId(), createdVolume.getId(), createdVolume.getName(), 
-        			                                   createdVolume.getDiskOfferingId(), null, createdVolume.getSize());
-        	_usageEventDao.persist(usageEvent);
+            UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, createdVolume.getAccountId(), createdVolume.getDataCenterId(), createdVolume.getId(), createdVolume.getName(), 
+                    createdVolume.getDiskOfferingId(), null, createdVolume.getSize());
+            _usageEventDao.persist(usageEvent);
         }
         return createdVolume;
     }
@@ -739,32 +736,32 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
     @DB
     public VolumeVO copyVolumeFromSecToPrimary(VolumeVO volume, VMInstanceVO vm, VMTemplateVO template, DataCenterVO dc, HostPodVO pod, Long clusterId, ServiceOfferingVO offering, DiskOfferingVO diskOffering,
             List<StoragePoolVO> avoids, long size, HypervisorType hyperType) throws NoTransitionException {
-    	
-    	final HashSet<StoragePool> avoidPools = new HashSet<StoragePool>(avoids);
-    	DiskProfile dskCh = createDiskCharacteristics(volume, template, dc, diskOffering);
-    	dskCh.setHyperType(vm.getHypervisorType());
-    	// Find a suitable storage to create volume on 
-	StoragePoolVO destPool = findStoragePool(dskCh, dc, pod, clusterId, null, vm, avoidPools);
-    	
-    	// Copy the volume from secondary storage to the destination storage pool    	  	
-    	stateTransitTo(volume, Event.CopyRequested);
-    	VolumeHostVO volumeHostVO = _volumeHostDao.findByVolumeId(volume.getId());
-    	HostVO secStorage = _hostDao.findById(volumeHostVO.getHostId());
-    	String secondaryStorageURL = secStorage.getStorageUrl();
-    	String[] volumePath = volumeHostVO.getInstallPath().split("/");
-    	String volumeUUID = volumePath[volumePath.length - 1].split("\\.")[0];
-    	
+
+        final HashSet<StoragePool> avoidPools = new HashSet<StoragePool>(avoids);
+        DiskProfile dskCh = createDiskCharacteristics(volume, template, dc, diskOffering);
+        dskCh.setHyperType(vm.getHypervisorType());
+        // Find a suitable storage to create volume on 
+        StoragePoolVO destPool = findStoragePool(dskCh, dc, pod, clusterId, null, vm, avoidPools);
+
+        // Copy the volume from secondary storage to the destination storage pool    	  	
+        stateTransitTo(volume, Event.CopyRequested);
+        VolumeHostVO volumeHostVO = _volumeHostDao.findByVolumeId(volume.getId());
+        HostVO secStorage = _hostDao.findById(volumeHostVO.getHostId());
+        String secondaryStorageURL = secStorage.getStorageUrl();
+        String[] volumePath = volumeHostVO.getInstallPath().split("/");
+        String volumeUUID = volumePath[volumePath.length - 1].split("\\.")[0];
+
         CopyVolumeCommand cvCmd = new CopyVolumeCommand(volume.getId(), volumeUUID, destPool, secondaryStorageURL, false, _copyvolumewait);
         CopyVolumeAnswer cvAnswer;
-		try {
+        try {
             cvAnswer = (CopyVolumeAnswer) sendToPool(destPool, cvCmd);
         } catch (StorageUnavailableException e1) {
-        	stateTransitTo(volume, Event.CopyFailed);
+            stateTransitTo(volume, Event.CopyFailed);
             throw new CloudRuntimeException("Failed to copy the volume from secondary storage to the destination primary storage pool.");
         }
 
         if (cvAnswer == null || !cvAnswer.getResult()) {
-        	stateTransitTo(volume, Event.CopyFailed);
+            stateTransitTo(volume, Event.CopyFailed);
             throw new CloudRuntimeException("Failed to copy the volume from secondary storage to the destination primary storage pool.");
         }        
         Transaction txn = Transaction.currentTxn();
@@ -778,11 +775,11 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), volume.getDiskOfferingId(), null, volume.getSize());
         _usageEventDao.persist(usageEvent);
         _volumeHostDao.remove(volumeHostVO.getId());
-    	txn.commit();
-		return volume;
-    	
+        txn.commit();
+        return volume;
+
     }
-    
+
     @Override
     @DB
     public VolumeVO createVolume(VolumeVO volume, VMInstanceVO vm, VMTemplateVO template, DataCenterVO dc, HostPodVO pod, Long clusterId, ServiceOfferingVO offering, DiskOfferingVO diskOffering,
@@ -848,11 +845,11 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                         String fullTmpltUrl = tmpltHostUrl + "/" + tmpltHostOn.getInstallPath();
                         cmd = new CreateCommand(dskCh, fullTmpltUrl, new StorageFilerTO(pool));
                     } else {
-                    tmpltStoredOn = _tmpltMgr.prepareTemplateForCreate(template, pool);
-                    if (tmpltStoredOn == null) {
-                        continue;
-                    }
-                    cmd = new CreateCommand(dskCh, tmpltStoredOn.getLocalDownloadPath(), new StorageFilerTO(pool));
+                        tmpltStoredOn = _tmpltMgr.prepareTemplateForCreate(template, pool);
+                        if (tmpltStoredOn == null) {
+                            continue;
+                        }
+                        cmd = new CreateCommand(dskCh, tmpltStoredOn.getLocalDownloadPath(), new StorageFilerTO(pool));
                     }
                 } else {
                     if (volume.getVolumeType() == Type.ROOT && Storage.ImageFormat.ISO == template.getFormat()) {
@@ -969,7 +966,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
 
         value = _configDao.getValue(Config.RecreateSystemVmEnabled.key());
         _recreateSystemVmEnabled = Boolean.parseBoolean(value);
-        
+
         value = _configDao.getValue(Config.StorageTemplateCleanupEnabled.key());
         _templateCleanupEnabled = (value == null ? true : Boolean.parseBoolean(value));
 
@@ -995,7 +992,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         int wrks = NumbersUtil.parseInt(workers, 10);
         _executor = Executors.newScheduledThreadPool(wrks, new NamedThreadFactory("StorageManager-Scavenger"));
 
-        _agentMgr.registerForHostEvents(ComponentLocator.inject(LocalStoragePoolListener.class), true, false, false);
+        _agentMgr.registerForHostEvents(ComponentContext.inject(LocalStoragePoolListener.class), true, false, false);
 
         String maxVolumeSizeInGbString = _configDao.getValue("storage.max.volume.size");
         _maxVolumeSizeInGb = NumbersUtil.parseLong(maxVolumeSizeInGbString, 2000);
@@ -1536,10 +1533,10 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
             // If it does , then you cannot delete the pool
             if (vlms.first() > 0) {
                 throw new CloudRuntimeException("Cannot delete pool " + sPool.getName() + " as there are associated vols" +
-                		" for this pool");
+                        " for this pool");
             }
         }
-        
+
 
         // First get the host_id from storage_pool_host_ref for given pool id
         StoragePoolVO lock = _storagePoolDao.acquireInLockTable(sPool.getId());
@@ -1733,7 +1730,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         return _volsDao.findById(volume.getId());
     }
 
-    
+
     /*
      * Upload the volume to secondary storage.
      * 
@@ -1742,19 +1739,19 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume", async = true)
     public VolumeVO uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException{
-    	Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCaller();
         long ownerId = cmd.getEntityOwnerId();
         Long zoneId = cmd.getZoneId();
         String volumeName = cmd.getVolumeName();
         String url = cmd.getUrl();
         String format = cmd.getFormat();
-        
-    	validateVolume(caller, ownerId, zoneId, volumeName, url, format);
-    	VolumeVO volume = persistVolume(caller, ownerId, zoneId, volumeName, url, cmd.getFormat());
-    	_downloadMonitor.downloadVolumeToStorage(volume, zoneId, url, cmd.getChecksum(), ImageFormat.valueOf(format.toUpperCase()));
-		return volume;    	
+
+        validateVolume(caller, ownerId, zoneId, volumeName, url, format);
+        VolumeVO volume = persistVolume(caller, ownerId, zoneId, volumeName, url, cmd.getFormat());
+        _downloadMonitor.downloadVolumeToStorage(volume, zoneId, url, cmd.getChecksum(), ImageFormat.valueOf(format.toUpperCase()));
+        return volume;    	
     }
-    
+
     private boolean validateVolume(Account caller, long ownerId, Long zoneId, String volumeName, String url, String format) throws ResourceAllocationException{
 
         // permission check
@@ -1762,7 +1759,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
 
         // Check that the resource limit for volumes won't be exceeded
         _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.volume);
-        
+
 
         // Verify that zone exists
         DataCenterVO zone = _dcDao.findById(zoneId);
@@ -1774,75 +1771,75 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
             throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zoneId);
         }
-        
-		if (url.toLowerCase().contains("file://")) {
-			throw new InvalidParameterValueException("File:// type urls are currently unsupported");
-		}
-		
-		ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase());
-		if (imgfmt == null) {
-			throw new IllegalArgumentException("Image format is incorrect " + format + ". Supported formats are " + EnumUtils.listValues(ImageFormat.values()));
-		}
-		
+
+        if (url.toLowerCase().contains("file://")) {
+            throw new InvalidParameterValueException("File:// type urls are currently unsupported");
+        }
+
+        ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase());
+        if (imgfmt == null) {
+            throw new IllegalArgumentException("Image format is incorrect " + format + ". Supported formats are " + EnumUtils.listValues(ImageFormat.values()));
+        }
+
         String userSpecifiedName = volumeName;
         if (userSpecifiedName == null) {
             userSpecifiedName = getRandomVolumeName();
         }
-		if((!url.toLowerCase().endsWith("vhd"))&&(!url.toLowerCase().endsWith("vhd.zip"))
-		        &&(!url.toLowerCase().endsWith("vhd.bz2"))&&(!url.toLowerCase().endsWith("vhd.gz")) 
-		        &&(!url.toLowerCase().endsWith("qcow2"))&&(!url.toLowerCase().endsWith("qcow2.zip"))
-		        &&(!url.toLowerCase().endsWith("qcow2.bz2"))&&(!url.toLowerCase().endsWith("qcow2.gz"))
-		        &&(!url.toLowerCase().endsWith("ova"))&&(!url.toLowerCase().endsWith("ova.zip"))
-		        &&(!url.toLowerCase().endsWith("ova.bz2"))&&(!url.toLowerCase().endsWith("ova.gz"))
-		        &&(!url.toLowerCase().endsWith("img"))&&(!url.toLowerCase().endsWith("raw"))){
-		        throw new InvalidParameterValueException("Please specify a valid " + format.toLowerCase());
-		    }
-			
-			if ((format.equalsIgnoreCase("vhd") && (!url.toLowerCase().endsWith(".vhd") && !url.toLowerCase().endsWith("vhd.zip") && !url.toLowerCase().endsWith("vhd.bz2") && !url.toLowerCase().endsWith("vhd.gz") ))
-				|| (format.equalsIgnoreCase("qcow2") && (!url.toLowerCase().endsWith(".qcow2") && !url.toLowerCase().endsWith("qcow2.zip") && !url.toLowerCase().endsWith("qcow2.bz2") && !url.toLowerCase().endsWith("qcow2.gz") ))
-				|| (format.equalsIgnoreCase("ova") && (!url.toLowerCase().endsWith(".ova") && !url.toLowerCase().endsWith("ova.zip") && !url.toLowerCase().endsWith("ova.bz2") && !url.toLowerCase().endsWith("ova.gz")))
-				|| (format.equalsIgnoreCase("raw") && (!url.toLowerCase().endsWith(".img") && !url.toLowerCase().endsWith("raw")))) {
-		        throw new InvalidParameterValueException("Please specify a valid URL. URL:" + url + " is an invalid for the format " + format.toLowerCase());
-			}
+        if((!url.toLowerCase().endsWith("vhd"))&&(!url.toLowerCase().endsWith("vhd.zip"))
+                &&(!url.toLowerCase().endsWith("vhd.bz2"))&&(!url.toLowerCase().endsWith("vhd.gz")) 
+                &&(!url.toLowerCase().endsWith("qcow2"))&&(!url.toLowerCase().endsWith("qcow2.zip"))
+                &&(!url.toLowerCase().endsWith("qcow2.bz2"))&&(!url.toLowerCase().endsWith("qcow2.gz"))
+                &&(!url.toLowerCase().endsWith("ova"))&&(!url.toLowerCase().endsWith("ova.zip"))
+                &&(!url.toLowerCase().endsWith("ova.bz2"))&&(!url.toLowerCase().endsWith("ova.gz"))
+                &&(!url.toLowerCase().endsWith("img"))&&(!url.toLowerCase().endsWith("raw"))){
+            throw new InvalidParameterValueException("Please specify a valid " + format.toLowerCase());
+        }
+
+        if ((format.equalsIgnoreCase("vhd") && (!url.toLowerCase().endsWith(".vhd") && !url.toLowerCase().endsWith("vhd.zip") && !url.toLowerCase().endsWith("vhd.bz2") && !url.toLowerCase().endsWith("vhd.gz") ))
+                || (format.equalsIgnoreCase("qcow2") && (!url.toLowerCase().endsWith(".qcow2") && !url.toLowerCase().endsWith("qcow2.zip") && !url.toLowerCase().endsWith("qcow2.bz2") && !url.toLowerCase().endsWith("qcow2.gz") ))
+                || (format.equalsIgnoreCase("ova") && (!url.toLowerCase().endsWith(".ova") && !url.toLowerCase().endsWith("ova.zip") && !url.toLowerCase().endsWith("ova.bz2") && !url.toLowerCase().endsWith("ova.gz")))
+                || (format.equalsIgnoreCase("raw") && (!url.toLowerCase().endsWith(".img") && !url.toLowerCase().endsWith("raw")))) {
+            throw new InvalidParameterValueException("Please specify a valid URL. URL:" + url + " is an invalid for the format " + format.toLowerCase());
+        }
         validateUrl(url);
-               
-    	return false;
+
+        return false;
     }
-    
+
     private String validateUrl(String url){
-		try {
-			URI uri = new URI(url);
-			if ((uri.getScheme() == null) || (!uri.getScheme().equalsIgnoreCase("http") 
-				&& !uri.getScheme().equalsIgnoreCase("https") && !uri.getScheme().equalsIgnoreCase("file"))) {
-				throw new IllegalArgumentException("Unsupported scheme for url: " + url);
-			}
-
-			int port = uri.getPort();
-			if (!(port == 80 || port == 443 || port == -1)) {
-				throw new IllegalArgumentException("Only ports 80 and 443 are allowed");
-			}
-			String host = uri.getHost();
-			try {
-				InetAddress hostAddr = InetAddress.getByName(host);
-				if (hostAddr.isAnyLocalAddress() || hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress() || hostAddr.isMulticastAddress()) {
-					throw new IllegalArgumentException("Illegal host specified in url");
-				}
-				if (hostAddr instanceof Inet6Address) {
-					throw new IllegalArgumentException("IPV6 addresses not supported (" + hostAddr.getHostAddress() + ")");
-				}
-			} catch (UnknownHostException uhe) {
-				throw new IllegalArgumentException("Unable to resolve " + host);
-			}
-			
-			return uri.toString();
-		} catch (URISyntaxException e) {
-			throw new IllegalArgumentException("Invalid URL " + url);
-		}
-    	
-    }
-    
+        try {
+            URI uri = new URI(url);
+            if ((uri.getScheme() == null) || (!uri.getScheme().equalsIgnoreCase("http") 
+                    && !uri.getScheme().equalsIgnoreCase("https") && !uri.getScheme().equalsIgnoreCase("file"))) {
+                throw new IllegalArgumentException("Unsupported scheme for url: " + url);
+            }
+
+            int port = uri.getPort();
+            if (!(port == 80 || port == 443 || port == -1)) {
+                throw new IllegalArgumentException("Only ports 80 and 443 are allowed");
+            }
+            String host = uri.getHost();
+            try {
+                InetAddress hostAddr = InetAddress.getByName(host);
+                if (hostAddr.isAnyLocalAddress() || hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress() || hostAddr.isMulticastAddress()) {
+                    throw new IllegalArgumentException("Illegal host specified in url");
+                }
+                if (hostAddr instanceof Inet6Address) {
+                    throw new IllegalArgumentException("IPV6 addresses not supported (" + hostAddr.getHostAddress() + ")");
+                }
+            } catch (UnknownHostException uhe) {
+                throw new IllegalArgumentException("Unable to resolve " + host);
+            }
+
+            return uri.toString();
+        } catch (URISyntaxException e) {
+            throw new IllegalArgumentException("Invalid URL " + url);
+        }
+
+    }
+
     private VolumeVO persistVolume(Account caller, long ownerId, Long zoneId, String volumeName, String url, String format) {
-    	
+
         Transaction txn = Transaction.currentTxn();
         txn.start();
 
@@ -1861,21 +1858,21 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
 
         volume = _volsDao.persist(volume);
         try {
-			stateTransitTo(volume, Event.UploadRequested);
-		} catch (NoTransitionException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+            stateTransitTo(volume, Event.UploadRequested);
+        } catch (NoTransitionException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
         UserContext.current().setEventDetails("Volume Id: " + volume.getId());
 
         // Increment resource count during allocation; if actual creation fails, decrement it
         _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.volume);
 
         txn.commit();
-		return volume;
-	}
-    	    
-    
+        return volume;
+    }
+
+
     /*
      * Just allocate a volume in the database, don't send the createvolume cmd to hypervisor. The volume will be finally
      * created
@@ -2049,9 +2046,9 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
 
         volume = _volsDao.persist(volume);
         if(cmd.getSnapshotId() == null){
-        	//for volume created from snapshot, create usage event after volume creation
-        	UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOfferingId, null, size);
-        	_usageEventDao.persist(usageEvent);
+            //for volume created from snapshot, create usage event after volume creation
+            UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOfferingId, null, size);
+            _usageEventDao.persist(usageEvent);
         }
 
         UserContext.current().setEventDetails("Volume Id: " + volume.getId());
@@ -2161,7 +2158,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         if (capacities.size() == 0) {
             CapacityVO capacity = new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity, capacityType);
             CapacityState capacityState = _configMgr.findClusterAllocationState(ApiDBUtils.findClusterById(storagePool.getClusterId())) == AllocationState.Disabled ?
-            				CapacityState.Disabled : CapacityState.Enabled;
+                    CapacityState.Disabled : CapacityState.Enabled;
             capacity.setCapacityState(capacityState);
             _capacityDao.persist(capacity);
         } else {
@@ -2182,7 +2179,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         s_logger.debug("Successfully set Capacity - " + totalOverProvCapacity + " for capacity type - " + capacityType + " , DataCenterId - "
                 + storagePool.getDataCenterId() + ", HostOrPoolId - " + storagePool.getId() + ", PodId " + storagePool.getPodId());
     }
-    
+
     @Override
     public List<Long> getUpHostsInPool(long poolId) {
         SearchCriteria<Long> sc = UpHostsInPoolSearch.create();
@@ -2283,7 +2280,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                             s_logger.warn("Unable to destroy " + vol.getId(), e);
                         }
                     }
-                    
+
                     // remove snapshots in Error state
                     List<SnapshotVO> snapshots = _snapshotDao.listAllByStatus(Snapshot.Status.Error);
                     for (SnapshotVO snapshotVO : snapshots) {
@@ -2293,7 +2290,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                             s_logger.warn("Unable to destroy " + snapshotVO.getId(), e);
                         }
                     }
-                    
+
                 } finally {
                     scanLock.unlock();
                 }
@@ -2432,7 +2429,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                     s_logger.warn("problem cleaning up snapshots in secondary storage " + secondaryStorageHost, e2);
                 }
             }
-            
+
             //CleanUp volumes on Secondary Storage.
             for (HostVO secondaryStorageHost : secondaryStorageHosts) {
                 try {
@@ -2460,7 +2457,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                             _volumeHostDao.remove(destroyedVolumeHostVO.getId());
                         }
                     }
-                
+
                 }catch (Exception e2) {
                     s_logger.warn("problem cleaning up volumes in secondary storage " + secondaryStorageHost, e2);
                 }
@@ -2894,12 +2891,12 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
 
         // Check that volume is completely Uploaded 
         if (volume.getState() == Volume.State.UploadOp){
-        	VolumeHostVO volumeHost = _volumeHostDao.findByVolumeId(volume.getId());
+            VolumeHostVO volumeHost = _volumeHostDao.findByVolumeId(volume.getId());
             if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS){
-            	throw new InvalidParameterValueException("Please specify a volume that is not uploading");
+                throw new InvalidParameterValueException("Please specify a volume that is not uploading");
             }            
         }
-        
+
         // Check that the volume is not already destroyed
         if (volume.getState() != Volume.State.Destroy) {
             if (!destroyVolume(volume)) {
@@ -3109,7 +3106,6 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                 volIds.add(volume.getId());
             }
 
-            checkPointTaskId = _checkPointMgr.pushCheckPoint(new StorageMigrationCleanupMaid(StorageMigrationCleanupMaid.StorageMigrationState.MIGRATING, volIds));
             transitResult = true;
         } finally {
             if (!transitResult) {
@@ -3166,7 +3162,6 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                         s_logger.debug("Failed to change volume state: " + e.toString());
                     }
                 }
-                _checkPointMgr.popCheckPoint(checkPointTaskId);
             } else {
                 // Need a transaction, make sure all the volumes get migrated to new storage pool
                 txn = Transaction.currentTxn();
@@ -3192,11 +3187,6 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                         }
                     }
                     transitResult = true;
-                    try {
-                        _checkPointMgr.popCheckPoint(checkPointTaskId);
-                    } catch (Exception e) {
-
-                    }
                 } finally {
                     if (!transitResult) {
                         txn.rollback();
@@ -3259,7 +3249,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Checking if we need to prepare " + vols.size() + " volumes for " + vm);
         }
-        
+
         boolean recreate = _recreateSystemVmEnabled;
 
         List<VolumeVO> recreateVols = new ArrayList<VolumeVO>(vols.size());
@@ -3270,8 +3260,8 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                 assignedPool = dest.getStorageForDisks().get(vol);
             }
             if (assignedPool == null && recreate) {
-            	assignedPool = _storagePoolDao.findById(vol.getPoolId());
-            	
+                assignedPool = _storagePoolDao.findById(vol.getPoolId());
+
             }
             if (assignedPool != null || recreate) {
                 Volume.State state = vol.getState();
@@ -3312,7 +3302,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                             StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId());
                             vm.addDisk(new VolumeTO(vol, pool));
                         }
-                        
+
                     }
                 }
             } else {
@@ -3331,10 +3321,10 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
             VolumeVO newVol;
             StoragePool existingPool = null;
             if (recreate && (dest.getStorageForDisks() == null || dest.getStorageForDisks().get(vol) == null)) {
-            	existingPool = _storagePoolDao.findById(vol.getPoolId());
-            	s_logger.debug("existing pool: " + existingPool.getId());
+                existingPool = _storagePoolDao.findById(vol.getPoolId());
+                s_logger.debug("existing pool: " + existingPool.getId());
             }
-            
+
             if (vol.getState() == Volume.State.Allocated || vol.getState() == Volume.State.Creating) {
                 newVol = vol;
             } else {
@@ -3429,12 +3419,12 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         if (toBeCreated.getTemplateId() != null) {
             template = _templateDao.findById(toBeCreated.getTemplateId());
         }
-        
+
         StoragePool pool = null;
         if (sPool != null) {
-        	pool = sPool;
+            pool = sPool;
         } else {
-        	pool = dest.getStorageForDisks().get(toBeCreated);
+            pool = dest.getStorageForDisks().get(toBeCreated);
         }
 
         if (pool != null) {
@@ -3465,12 +3455,12 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
                         String fullTmpltUrl = tmpltHostUrl + "/" + tmpltHostOn.getInstallPath();
                         cmd = new CreateCommand(diskProfile, fullTmpltUrl, new StorageFilerTO(pool));
                     } else {
-                    tmpltStoredOn = _tmpltMgr.prepareTemplateForCreate(template, pool);
-                    if (tmpltStoredOn == null) {
-                        s_logger.debug("Cannot use this pool " + pool + " because we can't propagate template " + template);
-                        return null;
-                    }
-                    cmd = new CreateCommand(diskProfile, tmpltStoredOn.getLocalDownloadPath(), new StorageFilerTO(pool));
+                        tmpltStoredOn = _tmpltMgr.prepareTemplateForCreate(template, pool);
+                        if (tmpltStoredOn == null) {
+                            s_logger.debug("Cannot use this pool " + pool + " because we can't propagate template " + template);
+                            return null;
+                        }
+                        cmd = new CreateCommand(diskProfile, tmpltStoredOn.getLocalDownloadPath(), new StorageFilerTO(pool));
                     }
                 } else {
                     if (template != null && Storage.ImageFormat.ISO == template.getFormat()) {
@@ -3513,27 +3503,27 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Expunging " + vol);
         }
-        
+
         //Find out if the volume is present on secondary storage
         VolumeHostVO volumeHost = _volumeHostDao.findByVolumeId(vol.getId());
         if(volumeHost != null){
-        	if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED){
-        		HostVO ssHost = _hostDao.findById(volumeHost.getHostId());
-        		DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(ssHost.getStorageUrl(), volumeHost.getInstallPath());            
-        		Answer answer = _agentMgr.sendToSecStorage(ssHost, dtCommand);
-        		if (answer == null || !answer.getResult()) {
-        			s_logger.debug("Failed to delete " + volumeHost + " due to " + ((answer == null) ? "answer is null" : answer.getDetails()));
-        			return;
-        		}
-        	}else if(volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS){									
-					s_logger.debug("Volume: " + vol.getName() + " is currently being uploaded; cant' delete it.");
-					throw new CloudRuntimeException("Please specify a volume that is not currently being uploaded.");
-        	}
+            if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED){
+                HostVO ssHost = _hostDao.findById(volumeHost.getHostId());
+                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(ssHost.getStorageUrl(), volumeHost.getInstallPath());            
+                Answer answer = _agentMgr.sendToSecStorage(ssHost, dtCommand);
+                if (answer == null || !answer.getResult()) {
+                    s_logger.debug("Failed to delete " + volumeHost + " due to " + ((answer == null) ? "answer is null" : answer.getDetails()));
+                    return;
+                }
+            }else if(volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS){									
+                s_logger.debug("Volume: " + vol.getName() + " is currently being uploaded; cant' delete it.");
+                throw new CloudRuntimeException("Please specify a volume that is not currently being uploaded.");
+            }
             _volumeHostDao.remove(volumeHost.getId());
             _volumeDao.remove(vol.getId());
             return;             
         }
-        
+
         String vmName = null;
         if (vol.getVolumeType() == Type.ROOT && vol.getInstanceId() != null) {
             VirtualMachine vm = _vmInstanceDao.findByIdIncludingRemoved(vol.getInstanceId());
@@ -3578,7 +3568,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         } catch (RuntimeException ex) {
             if (force) {
                 s_logger.info("Failed to expunge volume, but marking volume id=" + vol.getId() + " as expunged anyway " +
-                		"due to force=true. Volume failed to expunge due to ", ex);
+                        "due to force=true. Volume failed to expunge due to ", ex);
                 removeVolume = true;
             } else {
                 throw ex;
@@ -3869,14 +3859,14 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
             return null;
         }
     }
-    
+
     @Override
     public HypervisorType getHypervisorTypeFromFormat(ImageFormat format) {
-        
-    	if(format == null) {
+
+        if(format == null) {
             return HypervisorType.None;
-    	}
-    	
+        }
+
         if (format == ImageFormat.VHD) {
             return HypervisorType.XenServer;
         } else if (format == ImageFormat.OVA) {
@@ -3965,5 +3955,5 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
         }
         return true;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/storage/StorageMigrationCleanupMaid.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageMigrationCleanupMaid.java b/server/src/com/cloud/storage/StorageMigrationCleanupMaid.java
deleted file mode 100644
index 3ba8483..0000000
--- a/server/src/com/cloud/storage/StorageMigrationCleanupMaid.java
+++ /dev/null
@@ -1,121 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.cluster.CheckPointManager;
-import com.cloud.cluster.CleanupMaid;
-import com.cloud.server.ManagementServer;
-import com.cloud.storage.dao.VolumeDao;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.fsm.NoTransitionException;
-import com.cloud.utils.fsm.StateMachine2;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.dao.VMInstanceDao;
-
-public class StorageMigrationCleanupMaid implements CleanupMaid {
-	 private static final Logger s_logger = Logger.getLogger(StorageMigrationCleanupMaid.class);
-	public static enum StorageMigrationState {
-		MIGRATING,
-		MIGRATINGFAILED,
-		MIGRATINGSUCCESS;
-	}
-	
-	private List<Long> _volumesIds = new ArrayList<Long>();
-	private StorageMigrationState _migrateState;
-
-	public StorageMigrationCleanupMaid() {
-		
-	}
-	
-	public StorageMigrationCleanupMaid(StorageMigrationState state, List<Long> volumes) {
-		_migrateState = state;
-		_volumesIds = volumes;
-	}
-	
-	public void updateStaste(StorageMigrationState state) {
-		_migrateState = state;
-	}
-	
-	@Override
-	public int cleanup(CheckPointManager checkPointMgr) {
-		StateMachine2<Volume.State, Volume.Event, Volume> _stateMachine = Volume.State.getStateMachine();
-		
-		ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
-		VolumeDao volDao = locator.getDao(VolumeDao.class);
-		VMInstanceDao vmDao = locator.getDao(VMInstanceDao.class);
-		VirtualMachineManager vmMgr = locator.getManager(VirtualMachineManager.class);
-		Long vmInstanceId = null;
-		boolean success = true;
-		Transaction txn = Transaction.open(Transaction.CLOUD_DB);
-
-		try {
-			txn.start();
-			for (Long volumeId : _volumesIds) {
-				VolumeVO volume = volDao.findById(volumeId);
-				if (volume == null) {
-					continue;
-				}
-				vmInstanceId = volume.getInstanceId();
-				if (_migrateState == StorageMigrationState.MIGRATING && volume.getState() == Volume.State.Migrating) {
-					try {
-						_stateMachine.transitTo(volume, Volume.Event.OperationFailed, null, volDao);
-					} catch (NoTransitionException e) {
-						s_logger.debug("Failed to transit volume state: " + e.toString());
-						success = false;
-						break;
-					}
-				}
-			}
-			if (vmInstanceId != null) {
-				VMInstanceVO vm = vmDao.findById(vmInstanceId);
-				if (vm != null && vm.getState() == VirtualMachine.State.Migrating) {
-					try {
-						vmMgr.stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null);
-					} catch (NoTransitionException e) {
-						s_logger.debug("Failed to transit vm state");
-						success = false;
-					}
-				}
-			}
-			
-			if (success) {
-				txn.commit();
-			} 
-		} catch (Exception e) {
-			s_logger.debug("storage migration cleanup failed:" + e.toString());
-			txn.rollback();
-		}finally {
-			txn.close();
-		}
-
-		return 0;
-	}
-
-	@Override
-	public String getCleanupProcedure() {
-		return null;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/storage/allocator/GarbageCollectingStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/allocator/GarbageCollectingStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/GarbageCollectingStoragePoolAllocator.java
index 3e1030d..4eeae28 100644
--- a/server/src/com/cloud/storage/allocator/GarbageCollectingStoragePoolAllocator.java
+++ b/server/src/com/cloud/storage/allocator/GarbageCollectingStoragePoolAllocator.java
@@ -31,7 +31,7 @@ import com.cloud.deploy.DeploymentPlan;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
-import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.component.ComponentContext;
 import com.cloud.vm.DiskProfile;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
@@ -40,68 +40,66 @@ import com.cloud.vm.VirtualMachineProfile;
 @Local(value=StoragePoolAllocator.class)
 public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAllocator {
     private static final Logger s_logger = Logger.getLogger(GarbageCollectingStoragePoolAllocator.class);
-    
+
     StoragePoolAllocator _firstFitStoragePoolAllocator;
     StoragePoolAllocator _localStoragePoolAllocator;
     @Inject StorageManager _storageMgr;
     @Inject ConfigurationDao _configDao;
     boolean _storagePoolCleanupEnabled;
-    
+
     @Override
     public boolean allocatorIsCorrectType(DiskProfile dskCh) {
-    	return true;
+        return true;
     }
-    
+
     public Integer getStorageOverprovisioningFactor() {
-    	return null;
+        return null;
     }
-    
+
     public Long getExtraBytesPerVolume() {
-    	return null;
+        return null;
     }
-    
+
     @Override
     public List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
-    	
-    	if (!_storagePoolCleanupEnabled) {
-    		s_logger.debug("Storage pool cleanup is not enabled, so GarbageCollectingStoragePoolAllocator is being skipped.");
-    		return null;
-    	}
-    	
-    	// Clean up all storage pools
-    	_storageMgr.cleanupStorage(false);
-    	// Determine what allocator to use
-    	StoragePoolAllocator allocator;
-    	if (localStorageAllocationNeeded(dskCh)) {
-    		allocator = _localStoragePoolAllocator;
-    	} else {
-    		allocator = _firstFitStoragePoolAllocator;
-    	}
-
-    	// Try to find a storage pool after cleanup
+
+        if (!_storagePoolCleanupEnabled) {
+            s_logger.debug("Storage pool cleanup is not enabled, so GarbageCollectingStoragePoolAllocator is being skipped.");
+            return null;
+        }
+
+        // Clean up all storage pools
+        _storageMgr.cleanupStorage(false);
+        // Determine what allocator to use
+        StoragePoolAllocator allocator;
+        if (localStorageAllocationNeeded(dskCh)) {
+            allocator = _localStoragePoolAllocator;
+        } else {
+            allocator = _firstFitStoragePoolAllocator;
+        }
+
+        // Try to find a storage pool after cleanup
         ExcludeList myAvoids = new ExcludeList(avoid.getDataCentersToAvoid(), avoid.getPodsToAvoid(), avoid.getClustersToAvoid(), avoid.getHostsToAvoid(), avoid.getPoolsToAvoid());
-        
+
         return allocator.allocateToPool(dskCh, vmProfile, plan, myAvoids, returnUpTo);
     }
 
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         super.configure(name, params);
-        
-        ComponentLocator locator = ComponentLocator.getCurrentLocator();
-        
-        _firstFitStoragePoolAllocator = ComponentLocator.inject(FirstFitStoragePoolAllocator.class);
+
+        _firstFitStoragePoolAllocator = ComponentContext.inject(FirstFitStoragePoolAllocator.class);
         _firstFitStoragePoolAllocator.configure("GCFirstFitStoragePoolAllocator", params);
-        _localStoragePoolAllocator = ComponentLocator.inject(LocalStoragePoolAllocator.class);
+        _localStoragePoolAllocator = ComponentContext.inject(LocalStoragePoolAllocator.class);
         _localStoragePoolAllocator.configure("GCLocalStoragePoolAllocator", params);
-        
+
         String storagePoolCleanupEnabled = _configDao.getValue("storage.pool.cleanup.enabled");
         _storagePoolCleanupEnabled = (storagePoolCleanupEnabled == null) ? true : Boolean.parseBoolean(storagePoolCleanupEnabled);
-        
+
         return true;
     }
-    
+
     public GarbageCollectingStoragePoolAllocator() {
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/storage/allocator/UseLocalForRootAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/allocator/UseLocalForRootAllocator.java b/server/src/com/cloud/storage/allocator/UseLocalForRootAllocator.java
index ace7303..2c19406 100644
--- a/server/src/com/cloud/storage/allocator/UseLocalForRootAllocator.java
+++ b/server/src/com/cloud/storage/allocator/UseLocalForRootAllocator.java
@@ -34,7 +34,7 @@ import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.host.Host;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.Volume.Type;
-import com.cloud.utils.component.ComponentLocator;
+
 import com.cloud.vm.DiskProfile;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java b/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
index 7868b36..8347c4e 100644
--- a/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
@@ -34,7 +34,7 @@ import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeVO;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.utils.component.ComponentLocator;
+
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GenericDaoBase;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
index 9a50189..4019dff 100644
--- a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
@@ -35,7 +35,7 @@ import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StoragePoolDetailVO;
 import com.cloud.storage.StoragePoolStatus;
 import com.cloud.storage.StoragePoolVO;
-import com.cloud.utils.component.ComponentLocator;
+
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.GenericSearchBuilder;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
index 8093fd5..42f10d3 100755
--- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
@@ -59,7 +59,7 @@ import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
 import com.cloud.user.Account;
 import com.cloud.utils.Pair;
-import com.cloud.utils.component.ComponentLocator;
+
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GenericDaoBase;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/VolumeDaoImpl.java b/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
index d4cc692..a189d00 100755
--- a/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -39,7 +39,7 @@ import com.cloud.storage.Volume.Type;
 import com.cloud.storage.VolumeVO;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.utils.Pair;
-import com.cloud.utils.component.ComponentLocator;
+
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.GenericSearchBuilder;


Mime
View raw message