mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-5662: XenServer can't discover iSCSI targets with different credentials
This commit is contained in:
parent
c15cf12308
commit
e65fae412c
|
|
@ -93,6 +93,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;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
|
||||
|
|
|
|||
|
|
@ -483,30 +483,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());
|
||||
|
||||
|
|
@ -518,7 +520,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) {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,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;
|
||||
|
|
@ -140,6 +142,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
SnapshotDataFactory snapshotFactory;
|
||||
@Inject
|
||||
ConfigDepot _configDepot;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
|
||||
private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
|
||||
protected List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
|
|
@ -839,6 +843,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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue