cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [07/11] git commit: updated refs/heads/master to 5b616ea
Date Tue, 13 Aug 2013 04:09:39 GMT
Moved volume related code into cloud-engine-orchestration


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/de2bd96d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/de2bd96d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/de2bd96d

Branch: refs/heads/master
Commit: de2bd96d983350b31a013b0b19f103822c9bc46d
Parents: ae8ed58
Author: Alex Huang <alex.huang@citrix.com>
Authored: Mon Aug 12 19:01:13 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Mon Aug 12 19:06:51 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/offering/DiskOffering.java    |    1 +
 .../service/VolumeOrchestrationService.java     |   88 +
 .../engine/orchestration/CloudOrchestrator.java |  284 ++
 .../orchestration/VolumeOrchestrator.java       | 2861 ++++++++++++++++++
 .../orchestration/CloudOrchestrator.java        |  284 --
 .../motion/AncientDataMotionStrategy.java       |    4 +-
 .../storage/test/ChildTestConfiguration.java    |    6 +-
 .../storage/snapshot/SnapshotServiceImpl.java   |    7 +-
 plugins/hypervisors/vmware/pom.xml              |    5 +
 .../vmware/resource/VmwareResource.java         |   33 +-
 .../CloudStackPrimaryDataStoreDriverImpl.java   |    6 +-
 server/src/com/cloud/api/ApiDBUtils.java        |    6 +-
 .../cloud/ha/HighAvailabilityManagerImpl.java   |    4 +-
 .../com/cloud/server/ManagementServerImpl.java  |    4 +-
 .../src/com/cloud/storage/StorageManager.java   |    8 +-
 .../com/cloud/storage/StorageManagerImpl.java   |   48 -
 .../com/cloud/storage/VolumeApiServiceImpl.java |    5 +-
 server/src/com/cloud/storage/VolumeManager.java |   80 -
 .../com/cloud/storage/VolumeManagerImpl.java    | 2861 ------------------
 .../storage/snapshot/SnapshotManagerImpl.java   |    4 +-
 .../com/cloud/template/TemplateManagerImpl.java |    4 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java  |    6 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java |    4 +-
 server/test/com/cloud/vm/UserVmManagerTest.java |    4 +-
 .../cloud/vm/VirtualMachineManagerImplTest.java |    4 +-
 25 files changed, 3292 insertions(+), 3329 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/api/src/com/cloud/offering/DiskOffering.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/offering/DiskOffering.java b/api/src/com/cloud/offering/DiskOffering.java
index 587d4a0..c7bf5c1 100644
--- a/api/src/com/cloud/offering/DiskOffering.java
+++ b/api/src/com/cloud/offering/DiskOffering.java
@@ -82,4 +82,5 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId
     void setIopsWriteRate(Long iopsWriteRate);
 
     Long getIopsWriteRate();
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
new file mode 100644
index 0000000..091bc92
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
@@ -0,0 +1,88 @@
+/*
+ * 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.engine.orchestration.service;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.Pod;
+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.offering.DiskOffering;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.Volume;
+import com.cloud.storage.Volume.Type;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.Account;
+import com.cloud.utils.fsm.NoTransitionException;
+import com.cloud.vm.DiskProfile;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+public interface VolumeOrchestrationService {
+    VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long
destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException;
+
+    Volume allocateDuplicateVolume(Volume oldVol, Long templateId);
+
+    boolean volumeOnSharedStoragePool(Volume volume);
+
+    boolean volumeInactive(Volume volume);
+
+    String getVmNameOnVolume(Volume volume);
+
+    Volume migrateVolume(Volume volume, StoragePool destPool);
+
+    void destroyVolume(Volume volume);
+
+    DiskProfile allocateRawVolume(Type type, String name, DiskOffering offering, Long size,
VirtualMachine vm, VirtualMachineTemplate template, Account owner);
+
+    VolumeInfo createVolumeOnPrimaryStorage(VirtualMachine vm, Volume 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, DiskOffering offering, VirtualMachineTemplate
template, VirtualMachine vm, Account owner);
+
+    String getVmNameFromVolumeId(long volumeId);
+
+    String getStoragePoolOfVolume(long volumeId);
+
+    boolean validateVolumeSizeRange(long size);
+
+    StoragePool findStoragePool(DiskProfile dskCh, DataCenter dc, Pod pod, Long clusterId,
Long hostId, VirtualMachine vm, Set<StoragePool> avoid);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de2bd96d/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
new file mode 100755
index 0000000..7200f98
--- /dev/null
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
@@ -0,0 +1,284 @@
+/*
+ * 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.engine.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.orchestration.service.VolumeOrchestrationService;
+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.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
+    VolumeOrchestrationService _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;
+	}
+
+}


Mime
View raw message