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

This commit is contained in:
Mike Tutkowski 2014-01-09 22:08:22 -07:00
parent 6944bf9bba
commit 7ef78aac40
3 changed files with 38 additions and 15 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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;
@ -787,6 +791,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 {