cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [05/11] Moved volume related code into cloud-engine-orchestration
Date Tue, 13 Aug 2013 04:09:37 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
deleted file mode 100755
index 1efeb80..0000000
--- a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
+++ /dev/null
@@ -1,284 +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 org.apache.cloudstack.platform.orchestration;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.springframework.stereotype.Component;
-
-import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
-import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
-import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
-import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
-import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
-import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
-import org.apache.cloudstack.engine.service.api.OrchestrationService;
-
-import com.cloud.deploy.DeploymentPlan;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.hypervisor.Hypervisor;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.NetworkVO;
-import com.cloud.service.ServiceOfferingVO;
-import com.cloud.service.dao.ServiceOfferingDao;
-import com.cloud.storage.DiskOfferingVO;
-import com.cloud.storage.VolumeManager;
-import com.cloud.storage.dao.DiskOfferingDao;
-import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.user.dao.AccountDao;
-import com.cloud.utils.Pair;
-import com.cloud.utils.component.ComponentContext;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.dao.UserVmDao;
-import com.cloud.vm.dao.VMInstanceDao;
-
-
-@Component
-public class CloudOrchestrator implements OrchestrationService {
-
-	@Inject
-	private VMEntityManager vmEntityManager;
-
-	@Inject
-	private VirtualMachineManager _itMgr;
-
-	@Inject
-	protected VMTemplateDao _templateDao = null;
-
-    @Inject
-    protected VMInstanceDao _vmDao;
-
-    @Inject
-    protected UserVmDao _userVmDao = null;
-
-	@Inject
-	protected ServiceOfferingDao _serviceOfferingDao;
-
-	@Inject
-	protected DiskOfferingDao _diskOfferingDao = null;
-
-	@Inject
-	protected NetworkDao _networkDao;
-
-	@Inject
-	protected AccountDao _accountDao = null;
-
-    @Inject
-    VolumeManager _volumeMgr;
-
-	public CloudOrchestrator() {
-	}
-
-    public VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String
hypervisor, String hostName, int cpu, int speed, long memory, List<String> networks,
List<String> computeTags,
-            Map<String, String> details, String owner) {
-        return null;
-    }
-
-    public String reserve(String vm, String planner, Long until) throws InsufficientCapacityException
{
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String deploy(String reservationId) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public void joinNetwork(String network1, String network2) {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void createNetwork() {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void destroyNetwork() {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public VolumeEntity createVolume() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public TemplateEntity registerTemplate(String name, URL path, String os, Hypervisor hypervisor)
{
-        return null;
-    }
-
-    @Override
-    public void destroyNetwork(String networkUuid) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void destroyVolume(String volumeEntity) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public VirtualMachineEntity createVirtualMachine(
-            String id,
-            String owner,
-            String templateId,
-            String hostName,
-            String displayName,
-            String hypervisor,
-            int cpu,
-            int speed,
-            long memory,
-            Long diskSize,
-            List<String> computeTags,
-            List<String> rootDiskTags,
-            Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException
{
-
-    	// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName,
displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
-
-        List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO,
NicProfile>>();
-        for (String uuid : networkNicMap.keySet()) {
-            NetworkVO network = _networkDao.findByUuid(uuid);
-            if(network != null){
-                networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
-            }
-        }
-
-    	VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
-    	vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags,
new ArrayList<String>(networkNicMap.keySet()));
-
-
-    	HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
-
-    	//load vm instance and offerings and call virtualMachineManagerImpl
-    	VMInstanceVO vm = _vmDao.findByUuid(id);
-
-		// If the template represents an ISO, a disk offering must be passed in, and will be used
to create the root disk
-		// Else, a disk offering is optional, and if present will be used to create the data disk
-
-    	Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null,
null);
-		List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO,
Long>>();
-
-		ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
-		rootDiskOffering.first(offering);
-
-		if(vm.getDiskOfferingId() != null){
-    		DiskOfferingVO diskOffering = _diskOfferingDao.findById(vm.getDiskOfferingId());
-    		if (diskOffering == null) {
-    			throw new InvalidParameterValueException("Unable to find disk offering " + vm.getDiskOfferingId());
-    		}
-    		Long size = null;
-    		if (diskOffering.getDiskSize() == 0) {
-    			size = diskSize;
-    			if (size == null) {
-    				throw new InvalidParameterValueException(
-    						"Disk offering " + diskOffering
-    								+ " requires size parameter.");
-    			}
-                _volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024);
-    		}
-    		dataDiskOfferings.add(new Pair<DiskOfferingVO, Long>(diskOffering, size));
-		}
-
-
-
-        _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)),
offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType);
-
-        return vmEntity;
-    }
-
-    @Override
-    public VirtualMachineEntity createVirtualMachineFromScratch(String id, String owner,
String isoId, String hostName, String displayName, String hypervisor, String os, int cpu,
int speed, long memory,Long diskSize,
-            List<String> computeTags, List<String> rootDiskTags, Map<String,
NicProfile> networkNicMap, DeploymentPlan plan)  throws InsufficientCapacityException {
-
-    	// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName,
displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
-    	VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
-    	vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags,
new ArrayList<String>(networkNicMap.keySet()));
-
-    	//load vm instance and offerings and call virtualMachineManagerImpl
-    	VMInstanceVO vm = _vmDao.findByUuid(id);
-
-
-		Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null,
null);
-		ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
-		rootDiskOffering.first(offering);
-
-		List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO,
Long>>();
-		Long diskOfferingId = vm.getDiskOfferingId();
-		if (diskOfferingId == null) {
-			throw new InvalidParameterValueException(
-					"Installing from ISO requires a disk offering to be specified for the root disk.");
-		}
-		DiskOfferingVO diskOffering = _diskOfferingDao.findById(diskOfferingId);
-		if (diskOffering == null) {
-			throw new InvalidParameterValueException("Unable to find disk offering " + diskOfferingId);
-		}
-		Long size = null;
-		if (diskOffering.getDiskSize() == 0) {
-			size = diskSize;
-			if (size == null) {
-				throw new InvalidParameterValueException("Disk offering "
-						+ diskOffering + " requires size parameter.");
-			}
-            _volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024);
-        }
-		rootDiskOffering.first(diskOffering);
-		rootDiskOffering.second(size);
-
-        List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO,
NicProfile>>();
-        for (String uuid : networkNicMap.keySet()) {
-            NetworkVO network = _networkDao.findByUuid(uuid);
-            if(network != null){
-                networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
-            }
-        }
-
-		HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
-
-        _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering,
rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType);
-
-        return vmEntity;
-    }
-
-    @Override
-    public NetworkEntity createNetwork(String id, String name, String domainName, String
cidr, String gateway) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-	@Override
-	public VirtualMachineEntity getVirtualMachine(String id) {
-		VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, vmEntityManager);
-		return vmEntity;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index cb2870e..d5e8a84 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
 import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
@@ -66,7 +67,6 @@ import com.cloud.server.ManagementService;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
-import com.cloud.storage.VolumeManager;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.SnapshotDao;
@@ -116,7 +116,7 @@ public class
     @Inject
     VMTemplatePoolDao templatePoolDao;
     @Inject
-    VolumeManager volumeMgr;
+    VolumeOrchestrationService volumeMgr;
     @Inject
     StorageCacheManager cacheMgr;
     @Inject

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
index 86cafa8..0f97f31 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.cloudstack.storage.test;
 import java.io.IOException;
 
 import org.apache.cloudstack.acl.APIChecker;
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.engine.service.api.OrchestrationService;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDaoImpl;
@@ -63,7 +64,6 @@ import com.cloud.server.auth.UserAuthenticator;
 import com.cloud.service.dao.ServiceOfferingDaoImpl;
 import com.cloud.storage.OCFS2ManagerImpl;
 import com.cloud.storage.StorageManager;
-import com.cloud.storage.VolumeManager;
 import com.cloud.storage.dao.DiskOfferingDaoImpl;
 import com.cloud.storage.dao.SnapshotDaoImpl;
 import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
@@ -172,8 +172,8 @@ public class ChildTestConfiguration extends TestConfiguration {
     }
 
     @Bean
-    public VolumeManager volumeMgr() {
-        return Mockito.mock(VolumeManager.class);
+    public VolumeOrchestrationService volumeMgr() {
+        return Mockito.mock(VolumeOrchestrationService.class);
     }
 
     @Bean

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
index f8d9cbc..cabd91b 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
@@ -20,7 +20,6 @@ package org.apache.cloudstack.storage.snapshot;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.Snapshot;
-import com.cloud.storage.VolumeManager;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.snapshot.SnapshotManager;
@@ -28,6 +27,8 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.fsm.NoTransitionException;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.engine.subsystem.api.storage.*;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
@@ -40,10 +41,12 @@ import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
+
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+
 import java.util.concurrent.ExecutionException;
 
 @Component
@@ -65,7 +68,7 @@ public class SnapshotServiceImpl implements SnapshotService {
     @Inject
     protected SnapshotManager snapshotMgr;
     @Inject
-    protected VolumeManager volumeMgr;
+    protected VolumeOrchestrationService volumeMgr;
     @Inject
     protected SnapshotStateMachineManager stateMachineManager;
     @Inject

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/plugins/hypervisors/vmware/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/pom.xml b/plugins/hypervisors/vmware/pom.xml
index 16c77b3..46d51e8 100644
--- a/plugins/hypervisors/vmware/pom.xml
+++ b/plugins/hypervisors/vmware/pom.xml
@@ -44,6 +44,11 @@
       <scope>compile</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-orchestration</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>com.cloud.com.vmware</groupId>
       <artifactId>vmware-vim25</artifactId>
       <version>${cs.vmware.api.version}</version>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index a76794f..1438111 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -28,7 +28,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.concurrent.*;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
@@ -40,12 +39,13 @@ import java.util.Random;
 import java.util.Set;
 import java.util.TimeZone;
 import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.cloud.agent.api.to.DhcpTO;
-import com.cloud.storage.resource.VmwareStorageSubsystemCommandHandler;
 import org.apache.log4j.Logger;
 import org.apache.log4j.NDC;
 
@@ -109,6 +109,14 @@ import com.vmware.vim25.VirtualMachineRuntimeInfo;
 import com.vmware.vim25.VirtualSCSISharing;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
 
+import org.apache.cloudstack.engine.orchestration.VolumeOrchestrator;
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
+import org.apache.cloudstack.storage.command.DeleteCommand;
+import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+
 import com.cloud.agent.IAgentControl;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.AttachIsoCommand;
@@ -237,18 +245,15 @@ import com.cloud.agent.api.storage.CopyVolumeCommand;
 import com.cloud.agent.api.storage.CreateAnswer;
 import com.cloud.agent.api.storage.CreateCommand;
 import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
-import com.cloud.agent.api.storage.CreateVolumeOVAAnswer;
-import com.cloud.agent.api.storage.CreateVolumeOVACommand;
 import com.cloud.agent.api.storage.DestroyCommand;
 import com.cloud.agent.api.storage.MigrateVolumeAnswer;
 import com.cloud.agent.api.storage.MigrateVolumeCommand;
-import com.cloud.agent.api.storage.PrepareOVAPackingAnswer;
-import com.cloud.agent.api.storage.PrepareOVAPackingCommand;
 import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
 import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
 import com.cloud.agent.api.storage.ResizeVolumeAnswer;
 import com.cloud.agent.api.storage.ResizeVolumeCommand;
 import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.agent.api.to.DhcpTO;
 import com.cloud.agent.api.to.DiskTO;
 import com.cloud.agent.api.to.FirewallRuleTO;
 import com.cloud.agent.api.to.IpAddressTO;
@@ -301,12 +306,10 @@ import com.cloud.serializer.GsonHelper;
 import com.cloud.storage.Storage;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.Volume;
-import com.cloud.storage.VolumeManager;
-import com.cloud.storage.VolumeManagerImpl;
 import com.cloud.storage.resource.StoragePoolResource;
 import com.cloud.storage.resource.StorageSubsystemCommandHandler;
-import com.cloud.storage.resource.StorageSubsystemCommandHandlerBase;
 import com.cloud.storage.resource.VmwareStorageProcessor;
+import com.cloud.storage.resource.VmwareStorageSubsystemCommandHandler;
 import com.cloud.storage.template.TemplateProp;
 import com.cloud.utils.DateUtil;
 import com.cloud.utils.NumbersUtil;
@@ -326,12 +329,6 @@ import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.VirtualMachineName;
 import com.cloud.vm.VmDetailConstants;
 
-import org.apache.cloudstack.storage.command.DeleteCommand;
-import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
-import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
-import org.apache.cloudstack.storage.to.TemplateObjectTO;
-import org.apache.cloudstack.storage.to.VolumeObjectTO;
-
 
 public class VmwareResource implements StoragePoolResource, ServerResource, VmwareHostService
{
     private static final Logger s_logger = Logger.getLogger(VmwareResource.class);
@@ -343,7 +340,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
     protected final int _shutdown_waitMs = 300000;		// wait up to 5 minutes for shutdown
 
     @Inject
-    protected VolumeManager volMgr;
+    protected VolumeOrchestrationService volMgr;
 
     // out an operation
     protected final int _retry = 24;
@@ -6240,7 +6237,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         _guestTrafficInfo = (VmwareTrafficLabel) params.get("guestTrafficInfo");
         _publicTrafficInfo = (VmwareTrafficLabel) params.get("publicTrafficInfo");
         VmwareContext context = getServiceContext();
-        volMgr = ComponentContext.inject(VolumeManagerImpl.class);
+        volMgr = ComponentContext.inject(VolumeOrchestrator.class);
         try {
             VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
             mgr.setupResourceStartupParams(params);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
index 9ea91b5..55e2583 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
@@ -30,13 +30,14 @@ import com.cloud.host.dao.HostDao;
 import com.cloud.storage.ResizeVolumePayload;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
-import com.cloud.storage.VolumeManager;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.snapshot.SnapshotManager;
 import com.cloud.vm.dao.VMInstanceDao;
+
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.engine.subsystem.api.storage.*;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.storage.command.CommandResult;
@@ -44,6 +45,7 @@ import org.apache.cloudstack.storage.command.CreateObjectCommand;
 import org.apache.cloudstack.storage.command.DeleteCommand;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.volume.VolumeObject;
+
 import org.apache.log4j.Logger;
 
 import javax.inject.Inject;
@@ -61,7 +63,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
     @Inject
     StorageManager storageMgr;
     @Inject
-    VolumeManager volumeMgr;
+    VolumeOrchestrationService volumeMgr;
     @Inject
     VMInstanceDao vmDao;
     @Inject

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/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 b79e677..1ada63f 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -52,6 +52,7 @@ import org.apache.cloudstack.api.response.UserResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.framework.jobs.AsyncJob;
 import org.apache.cloudstack.framework.jobs.AsyncJobManager;
@@ -235,7 +236,6 @@ import com.cloud.storage.UploadVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.Volume.Type;
-import com.cloud.storage.VolumeManager;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.GuestOSCategoryDao;
@@ -293,7 +293,7 @@ public class ApiDBUtils {
     static AsyncJobManager _asyncMgr;
     static SecurityGroupManager _securityGroupMgr;
     static StorageManager _storageMgr;
-    static VolumeManager _volumeMgr;
+    static VolumeOrchestrationService _volumeMgr;
     static UserVmManager _userVmMgr;
     static NetworkModel _networkModel;
     static NetworkManager _networkMgr;
@@ -411,7 +411,7 @@ public class ApiDBUtils {
     @Inject private NetworkManager networkMgr;
     @Inject private StatsCollector statsCollector;
     @Inject private TemplateManager templateMgr;
-    @Inject private VolumeManager volumeMgr;
+    @Inject private VolumeOrchestrationService volumeMgr;
 
     @Inject private AccountDao accountDao;
     @Inject private AccountVlanMapDao accountVlanMapDao;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
index 825e1ed..6b0d3c4 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -33,6 +33,7 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.NDC;
 
 import org.apache.cloudstack.context.ServerContexts;
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
 import com.cloud.agent.AgentManager;
@@ -60,7 +61,6 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.ManagementServer;
 import com.cloud.storage.StorageManager;
-import com.cloud.storage.VolumeManager;
 import com.cloud.storage.dao.GuestOSCategoryDao;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.user.AccountManager;
@@ -154,7 +154,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements
HighAvai
     @Inject
     ConfigurationDao _configDao;
     @Inject
-    VolumeManager volumeMgr;
+    VolumeOrchestrationService volumeMgr;
 
     String _instance;
     ScheduledExecutorService _executor;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/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 cdf7b6f..2941cc8 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -425,6 +425,7 @@ import org.apache.cloudstack.api.command.user.vpn.UpdateVpnCustomerGatewayCmd;
 import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
 import org.apache.cloudstack.config.Configuration;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
@@ -525,7 +526,6 @@ import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Volume;
-import com.cloud.storage.VolumeManager;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.GuestOSCategoryDao;
@@ -651,7 +651,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     @Inject
     private StorageManager _storageMgr;
     @Inject
-    private VolumeManager _volumeMgr;
+    private VolumeOrchestrationService _volumeMgr;
     @Inject
     private VirtualMachineManager _itMgr;
     @Inject

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/server/src/com/cloud/storage/StorageManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManager.java b/server/src/com/cloud/storage/StorageManager.java
index af4e8c2..4bd6b0e 100755
--- a/server/src/com/cloud/storage/StorageManager.java
+++ b/server/src/com/cloud/storage/StorageManager.java
@@ -18,7 +18,6 @@ package com.cloud.storage;
 
 import java.math.BigDecimal;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
@@ -29,8 +28,6 @@ import com.cloud.agent.api.Command;
 import com.cloud.agent.api.StoragePoolInfo;
 import com.cloud.agent.manager.Commands;
 import com.cloud.capacity.CapacityVO;
-import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.Pod;
 import com.cloud.exception.ConnectionException;
 import com.cloud.exception.StorageUnavailableException;
 import com.cloud.host.Host;
@@ -38,7 +35,6 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.utils.Pair;
-import com.cloud.vm.DiskProfile;
 import com.cloud.vm.VMInstanceVO;
 
 public interface StorageManager extends StorageService {
@@ -106,9 +102,7 @@ public interface StorageManager extends StorageService {
 
     boolean registerHostListener(String providerUuid, HypervisorHostListener listener);
 
-    StoragePool findStoragePool(DiskProfile dskCh, DataCenterVO dc,
-            Pod pod, Long clusterId, Long hostId, VMInstanceVO vm,
-            Set<StoragePool> avoid);
+
 
     void connectHostToSharedPool(long hostId, long poolId)
             throws StorageUnavailableException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/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 df0832a..4e61380 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -31,7 +31,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
-import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -66,7 +65,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
@@ -107,11 +105,8 @@ import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.Pod;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.deploy.DataCenterDeployment;
-import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.exception.AgentUnavailableException;
 import com.cloud.exception.ConnectionException;
 import com.cloud.exception.DiscoveryException;
@@ -168,11 +163,8 @@ import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.DiskProfile;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine.State;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.VirtualMachineProfileImpl;
 import com.cloud.vm.dao.VMInstanceDao;
 
 @Component
@@ -266,16 +258,6 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
     @Inject
     EndPointSelector _epSelector;
 
-    protected List<StoragePoolAllocator> _storagePoolAllocators;
-
-    public List<StoragePoolAllocator> getStoragePoolAllocators() {
-        return _storagePoolAllocators;
-    }
-
-    public void setStoragePoolAllocators(List<StoragePoolAllocator> _storagePoolAllocators)
{
-        this._storagePoolAllocators = _storagePoolAllocators;
-    }
-
     protected List<StoragePoolDiscoverer> _discoverers;
 
     public List<StoragePoolDiscoverer> getDiscoverers() {
@@ -404,36 +386,6 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
     }
 
     @Override
-    public StoragePool findStoragePool(DiskProfile dskCh, final DataCenterVO dc, Pod pod,
Long clusterId, Long hostId, VMInstanceVO vm,
-            final Set<StoragePool> avoid) {
-        Long podId = null;
-        if (pod != null) {
-            podId = pod.getId();
-        } else if (clusterId != null) {
-            ClusterVO cluster = _clusterDao.findById(clusterId);
-            if (cluster != null) {
-                podId = cluster.getPodId();
-            }
-        }
-
-        VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
-        for (StoragePoolAllocator allocator : _storagePoolAllocators) {
-
-            ExcludeList avoidList = new ExcludeList();
-            for (StoragePool pool : avoid) {
-                avoidList.addPool(pool.getId());
-            }
-            DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), podId, clusterId,
hostId, null, null);
-
-            final List<StoragePool> poolList = allocator.allocateToPool(dskCh, profile,
plan, avoidList, 1);
-            if (poolList != null && !poolList.isEmpty()) {
-                return (StoragePool) dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary);
-            }
-        }
-        return null;
-    }
-
-    @Override
     public Answer[] sendToPool(StoragePool pool, Commands cmds) throws StorageUnavailableException
{
         return sendToPool(pool, null, null, cmds).second();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index f7beb9a..b2104ad 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -39,6 +39,7 @@ import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.UpdateVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@@ -166,7 +167,7 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDao;
 public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiService {
     private final static Logger s_logger = Logger.getLogger(VolumeApiServiceImpl.class);
     @Inject
-    VolumeManager _volumeMgr;
+    VolumeOrchestrationService _volumeMgr;
 
     @Inject
     EntityManager _entityMgr;
@@ -717,7 +718,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         while ((pod = _resourceMgr.findPod(null, null, dc, account.getId(), podsToAvoid))
!= null) {
             podsToAvoid.add(pod.first().getId());
             // Determine what storage pool to store the volume in
-            while ((pool = storageMgr.findStoragePool(dskCh, dc, pod.first(), null, null,
null, poolsToAvoid)) != null) {
+            while ((pool = _volumeMgr.findStoragePool(dskCh, dc, pod.first(), null, null,
null, poolsToAvoid)) != null) {
                 break;
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/server/src/com/cloud/storage/VolumeManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManager.java b/server/src/com/cloud/storage/VolumeManager.java
deleted file mode 100644
index 944abc0..0000000
--- a/server/src/com/cloud/storage/VolumeManager.java
+++ /dev/null
@@ -1,80 +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.Map;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientStorageCapacityException;
-import com.cloud.exception.StorageUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.Volume.Type;
-import com.cloud.user.Account;
-import com.cloud.utils.fsm.NoTransitionException;
-import com.cloud.vm.DiskProfile;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-
-public interface VolumeManager {
-    VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long
destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException;
-
-    VolumeVO allocateDuplicateVolume(VolumeVO oldVol, Long templateId);
-
-    boolean volumeOnSharedStoragePool(VolumeVO volume);
-
-    boolean volumeInactive(Volume volume);
-
-    String getVmNameOnVolume(Volume volume);
-
-    Volume migrateVolume(Volume volume, StoragePool destPool);
-
-    void destroyVolume(VolumeVO volume);
-
-    DiskProfile allocateRawVolume(Type type, String name, DiskOfferingVO offering, Long size,
VMInstanceVO vm, VMTemplateVO template, Account owner);
-
-    VolumeInfo createVolumeOnPrimaryStorage(VMInstanceVO vm, VolumeVO rootVolumeOfVm, VolumeInfo
volume, HypervisorType rootDiskHyperType) throws NoTransitionException;
-
-    void release(VirtualMachineProfile profile);
-
-    void cleanupVolumes(long vmId) throws ConcurrentOperationException;
-
-    void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost,
Map<Volume, StoragePool> volumeToPool);
-
-    boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool);
-
-    void prepareForMigration(VirtualMachineProfile vm, DeployDestination dest);
-
-    void prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException,
InsufficientStorageCapacityException, ConcurrentOperationException;
-
-    boolean canVmRestartOnAnotherServer(long vmId);
-
-    DiskProfile allocateTemplatedVolume(Type type, String name, DiskOfferingVO offering,
VMTemplateVO template, VMInstanceVO vm, Account owner);
-
-    String getVmNameFromVolumeId(long volumeId);
-
-    String getStoragePoolOfVolume(long volumeId);
-
-    boolean validateVolumeSizeRange(long size);
-}


Mime
View raw message