cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject git commit: updated refs/heads/master to 6944bf9
Date Fri, 10 Jan 2014 05:03:27 GMT
Updated Branches:
  refs/heads/master ae35782cc -> 6944bf9bb


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/6944bf9b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6944bf9b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6944bf9b

Branch: refs/heads/master
Commit: 6944bf9bba5363ad35764b8ee6a31e43a96490d3
Parents: ae35782
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Thu Jan 9 22:02:43 2014 -0700
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Thu Jan 9 22:02:43 2014 -0700

----------------------------------------------------------------------
 .../com/cloud/hypervisor/HypervisorGuru.java    |  2 +
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 28 +++++++++
 .../src/com/cloud/hypervisor/XenServerGuru.java | 61 ++++++++++++++++++--
 .../xen/resource/CitrixResourceBase.java        |  6 +-
 .../xen/resource/XenServerStorageProcessor.java |  2 +-
 .../cloud/hypervisor/HypervisorGuruBase.java    |  5 ++
 6 files changed, 94 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6944bf9b/api/src/com/cloud/hypervisor/HypervisorGuru.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/hypervisor/HypervisorGuru.java b/api/src/com/cloud/hypervisor/HypervisorGuru.java
index 0349372..4a35cec 100644
--- a/api/src/com/cloud/hypervisor/HypervisorGuru.java
+++ b/api/src/com/cloud/hypervisor/HypervisorGuru.java
@@ -75,4 +75,6 @@ public interface HypervisorGuru extends Adapter {
      *
      */
     List<Command> finalizeExpungeNics(VirtualMachine vm, List<NicProfile> nics);
+
+    List<Command> finalizeExpungeVolumes(VirtualMachine vm);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6944bf9b/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 c553607..cabaa52 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -485,6 +485,34 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         List<Command> nicExpungeCommands = hvGuru.finalizeExpungeNics(vm, profile.getNics());
         _networkMgr.cleanupNics(profile);
 
+        s_logger.debug("Cleaning up hypervisor data structures (ex. SRs in XenServer) for
managed storage");
+
+        List<Command> volumeExpungeCommands = hvGuru.finalizeExpungeVolumes(vm);
+
+        if (volumeExpungeCommands != null) {
+            Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
+
+            if (hostId != null) {
+                Commands cmds = new Commands(Command.OnError.Stop);
+
+                for (Command volumeExpungeCommand : volumeExpungeCommands) {
+                    cmds.addCommand(volumeExpungeCommand);
+                }
+
+                _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());
+
+                            throw new CloudRuntimeException("Unable to expunge " + vm + "
due to " + answer.getDetails());
+                        }
+                    }
+                }
+            }
+        }
+
         // Clean up volumes based on the vm's instance id
         volumeMgr.cleanupVolumes(vm.getId());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6944bf9b/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
index fd9bfae..4f21a02 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
@@ -16,18 +16,17 @@
 // under the License.
 package com.cloud.hypervisor;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
-import org.apache.cloudstack.storage.command.CopyCommand;
-
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
+import com.cloud.agent.api.to.DiskTO;
 import com.cloud.agent.api.to.NfsTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.host.HostInfo;
@@ -35,11 +34,24 @@ import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.GuestOSVO;
+import com.cloud.storage.Volume;
+import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.GuestOSDao;
+import com.cloud.storage.dao.VolumeDao;
 import com.cloud.template.VirtualMachineTemplate.BootloaderType;
 import com.cloud.utils.Pair;
+import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.command.CopyCommand;
+import org.apache.cloudstack.storage.command.DettachCommand;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+
 @Local(value = HypervisorGuru.class)
 public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru {
     @Inject
@@ -48,6 +60,12 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
     EndPointSelector endPointSelector;
     @Inject
     HostDao hostDao;
+    @Inject
+    VolumeDao _volumeDao;
+    @Inject
+    PrimaryDataStoreDao _storagePoolDao;
+    @Inject
+    VolumeDataFactory _volFactory;
 
     protected XenServerGuru() {
         super();
@@ -80,6 +98,39 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
     }
 
     @Override
+    public List<Command> finalizeExpungeVolumes(VirtualMachine vm) {
+        List<Command> commands = new ArrayList<Command>();
+
+        List<VolumeVO> volumes = _volumeDao.findByInstance(vm.getId());
+
+        if (volumes != null) {
+            for (VolumeVO volume : volumes) {
+                if (volume.getVolumeType() == Volume.Type.DATADISK) {
+                    StoragePoolVO storagePool = _storagePoolDao.findById(volume.getPoolId());
+
+                    if (storagePool.isManaged()) {
+                        DataTO volTO = _volFactory.getVolume(volume.getId()).getTO();
+                        DiskTO disk = new DiskTO(volTO, volume.getDeviceId(), volume.getPath(),
volume.getVolumeType());
+
+                        DettachCommand cmd = new DettachCommand(disk, vm.getInstanceName());
+
+                        cmd.setManaged(true);
+
+                        cmd.setStorageHost(storagePool.getHostAddress());
+                        cmd.setStoragePort(storagePool.getPort());
+
+                        cmd.set_iScsiName(volume.get_iScsiName());
+
+                        commands.add(cmd);
+                    }
+                }
+            }
+        }
+
+        return commands;
+    }
+
+    @Override
     public Pair<Boolean, Long> getCommandHostDelegation(long hostId, Command cmd) {
         if (cmd instanceof CopyCommand) {
             CopyCommand cpyCommand = (CopyCommand)cmd;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6944bf9b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 2d7baa2..accaa85 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -6537,9 +6537,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
         return vdi;
     }
 
-    protected void handleSrAndVdiDetach(String iqn) throws Exception {
-        Connection conn = getConnection();
-
+    protected void handleSrAndVdiDetach(String iqn, Connection conn) throws Exception {
         SR sr = getStorageRepository(conn, iqn);
 
         removeSR(conn, sr);
@@ -6647,7 +6645,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
                 vdi.setNameLabel(conn, "detached");
 
                 if (cmd.isManaged()) {
-                    handleSrAndVdiDetach(cmd.get_iScsiName());
+                    handleSrAndVdiDetach(cmd.get_iScsiName(), conn);
                 }
 
                 return new AttachVolumeAnswer(cmd);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6944bf9b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
index 47f3955..5d2363f 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
@@ -423,7 +423,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
             }
 
             if (cmd.isManaged()) {
-                hypervisorResource.handleSrAndVdiDetach(cmd.get_iScsiName());
+                hypervisorResource.handleSrAndVdiDetach(cmd.get_iScsiName(), conn);
             }
 
             return new DettachAnswer(disk);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6944bf9b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
index aa0fa59..7fb79fa 100644
--- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
+++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
@@ -150,4 +150,9 @@ public abstract class HypervisorGuruBase extends AdapterBase implements
Hypervis
     public List<Command> finalizeExpungeNics(VirtualMachine vm, List<NicProfile>
nics) {
         return null;
     }
+
+    @Override
+    public List<Command> finalizeExpungeVolumes(VirtualMachine vm) {
+        return null;
+    }
 }


Mime
View raw message