You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mt...@apache.org on 2014/01/10 06:38:50 UTC

git commit: updated refs/heads/master to 7ef78aa

Updated Branches:
  refs/heads/master 6944bf9bb -> 7ef78aac4


Merge from 4.3: CLOUDSTACK-5662: XenServer can't discover iSCSI targets with different credentials


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

Branch: refs/heads/master
Commit: 7ef78aac407de5a4cbc9408533a03bc4edb93131
Parents: 6944bf9
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Thu Jan 9 22:08:22 2014 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Thu Jan 9 22:37:39 2014 -0700

----------------------------------------------------------------------
 .../service/VolumeOrchestrationService.java     |  2 ++
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 31 ++++++++++----------
 .../orchestration/VolumeOrchestrator.java       | 20 +++++++++++++
 3 files changed, 38 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ef78aac/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
index 80e4f9d..f79d336 100644
--- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
@@ -94,6 +94,8 @@ public interface VolumeOrchestrationService {
 
     void cleanupVolumes(long vmId) throws ConcurrentOperationException;
 
+    void disconnectVolumesFromHost(long vmId, long hostId);
+
     void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, Map<Volume, StoragePool> volumeToPool);
 
     boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool) throws StorageUnavailableException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ef78aac/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index cabaa52..628528a 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -489,30 +489,32 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
 
         List<Command> volumeExpungeCommands = hvGuru.finalizeExpungeVolumes(vm);
 
-        if (volumeExpungeCommands != null) {
-            Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
+        Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
 
-            if (hostId != null) {
-                Commands cmds = new Commands(Command.OnError.Stop);
+        if (volumeExpungeCommands != null && hostId != null) {
+            Commands cmds = new Commands(Command.OnError.Stop);
 
-                for (Command volumeExpungeCommand : volumeExpungeCommands) {
-                    cmds.addCommand(volumeExpungeCommand);
-                }
+            for (Command volumeExpungeCommand : volumeExpungeCommands) {
+                cmds.addCommand(volumeExpungeCommand);
+            }
 
-                _agentMgr.send(hostId, cmds);
+            _agentMgr.send(hostId, cmds);
 
-                if (!cmds.isSuccessful()) {
-                    for (Answer answer : cmds.getAnswers()) {
-                        if (!answer.getResult()) {
-                            s_logger.warn("Failed to expunge vm due to: " + answer.getDetails());
+            if (!cmds.isSuccessful()) {
+                for (Answer answer : cmds.getAnswers()) {
+                    if (!answer.getResult()) {
+                        s_logger.warn("Failed to expunge vm due to: " + answer.getDetails());
 
-                            throw new CloudRuntimeException("Unable to expunge " + vm + " due to " + answer.getDetails());
-                        }
+                        throw new CloudRuntimeException("Unable to expunge " + vm + " due to " + answer.getDetails());
                     }
                 }
             }
         }
 
+        if (hostId != null) {
+            volumeMgr.disconnectVolumesFromHost(vm.getId(), hostId);
+        }
+
         // Clean up volumes based on the vm's instance id
         volumeMgr.cleanupVolumes(vm.getId());
 
@@ -524,7 +526,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         // send hypervisor-dependent commands before removing
         List<Command> finalizeExpungeCommands = hvGuru.finalizeExpunge(vm);
         if (finalizeExpungeCommands != null && finalizeExpungeCommands.size() > 0) {
-            Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
             if (hostId != null) {
                 Commands cmds = new Commands(Command.OnError.Stop);
                 for (Command command : finalizeExpungeCommands) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ef78aac/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index f094fb2..0d6d718 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -73,6 +73,8 @@ import com.cloud.exception.InsufficientStorageCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.StorageUnavailableException;
 import com.cloud.host.Host;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.offering.DiskOffering;
 import com.cloud.offering.ServiceOffering;
@@ -143,6 +145,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
     @Inject
     ConfigDepot _configDepot;
     @Inject
+    HostDao _hostDao;
+    @Inject
     SnapshotService _snapshotSrv;
 
     private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
@@ -788,6 +792,22 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
     }
 
     @Override
+    public void disconnectVolumesFromHost(long vmId, long hostId) {
+        HostVO host = _hostDao.findById(hostId);
+
+        List<VolumeVO> volumesForVm = _volsDao.findByInstance(vmId);
+
+        if (volumesForVm != null) {
+            for (VolumeVO volumeForVm : volumesForVm) {
+                VolumeInfo volumeInfo = volFactory.getVolume(volumeForVm.getId());
+                DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary);
+
+                volService.disconnectVolumeFromHost(volumeInfo, host, dataStore);
+            }
+        }
+    }
+
+    @Override
     @DB
     public Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException {
         VolumeInfo vol = volFactory.getVolume(volume.getId());