mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Revert "CLOUDSTACK-6170" due to unit test failure.
This reverts commit 50b5e2e247ebff54fda8c8c2cd4957ffd47bcf12.
This commit is contained in:
parent
50b5e2e247
commit
a1831bc864
@ -21,7 +21,6 @@ package org.apache.cloudstack.engine.orchestration.service;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
@ -95,8 +94,6 @@ public interface VolumeOrchestrationService {
|
||||
|
||||
void cleanupVolumes(long vmId) throws ConcurrentOperationException;
|
||||
|
||||
void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore);
|
||||
|
||||
void disconnectVolumesFromHost(long vmId, long hostId);
|
||||
|
||||
void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, Map<Volume, StoragePool> volumeToPool);
|
||||
|
||||
@ -37,10 +37,8 @@ import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
|
||||
@ -833,15 +831,6 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) {
|
||||
DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
|
||||
|
||||
if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
|
||||
((PrimaryDataStoreDriver)dataStoreDriver).disconnectVolumeFromHost(volumeInfo, host, dataStore);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnectVolumesFromHost(long vmId, long hostId) {
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
|
||||
@ -70,8 +70,6 @@ import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
||||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
@ -83,13 +81,11 @@ import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJobManager;
|
||||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||
import org.apache.cloudstack.storage.command.DettachCommand;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.GetVmDiskStatsAnswer;
|
||||
import com.cloud.agent.api.GetVmDiskStatsCommand;
|
||||
import com.cloud.agent.api.GetVmStatsAnswer;
|
||||
@ -98,8 +94,6 @@ import com.cloud.agent.api.PvlanSetupCommand;
|
||||
import com.cloud.agent.api.StartAnswer;
|
||||
import com.cloud.agent.api.VmDiskStatsEntry;
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
import com.cloud.agent.api.to.DiskTO;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
@ -205,7 +199,6 @@ import com.cloud.storage.SnapshotVO;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
@ -455,8 +448,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
DeploymentPlanningManager _planningMgr;
|
||||
@Inject
|
||||
VolumeApiService _volumeService;
|
||||
@Inject
|
||||
DataStoreManager _dataStoreMgr;
|
||||
|
||||
protected ScheduledExecutorService _executor = null;
|
||||
protected int _expungeInterval;
|
||||
@ -4660,9 +4651,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
/* Detach and destory the old root volume */
|
||||
|
||||
_volsDao.detachVolume(root.getId());
|
||||
|
||||
handleManagedStorage(vm, root);
|
||||
|
||||
volumeMgr.destroyVolume(root);
|
||||
|
||||
// For VMware hypervisor since the old root volume is replaced by the new root volume, force expunge old root volume if it has been created in storage
|
||||
@ -4710,59 +4698,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
|
||||
}
|
||||
|
||||
private void handleManagedStorage(UserVmVO vm, VolumeVO root) {
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(root.getPoolId());
|
||||
|
||||
if (storagePool.isManaged()) {
|
||||
Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
|
||||
|
||||
if (hostId != null) {
|
||||
DataTO volTO = volFactory.getVolume(root.getId()).getTO();
|
||||
DiskTO disk = new DiskTO(volTO, root.getDeviceId(), root.getPath(), root.getVolumeType());
|
||||
|
||||
// it's OK in this case to send a detach command to the host for a root volume as this
|
||||
// will simply lead to the SR that supports the root volume being removed
|
||||
DettachCommand cmd = new DettachCommand(disk, vm.getInstanceName());
|
||||
|
||||
cmd.setManaged(true);
|
||||
|
||||
cmd.setStorageHost(storagePool.getHostAddress());
|
||||
cmd.setStoragePort(storagePool.getPort());
|
||||
|
||||
cmd.set_iScsiName(root.get_iScsiName());
|
||||
|
||||
Commands cmds = new Commands(Command.OnError.Stop);
|
||||
|
||||
cmds.addCommand(cmd);
|
||||
|
||||
try {
|
||||
_agentMgr.send(hostId, cmds);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new CloudRuntimeException(ex.getMessage());
|
||||
}
|
||||
|
||||
if (!cmds.isSuccessful()) {
|
||||
for (Answer answer : cmds.getAnswers()) {
|
||||
if (!answer.getResult()) {
|
||||
s_logger.warn("Failed to reset vm due to: " + answer.getDetails());
|
||||
|
||||
throw new CloudRuntimeException("Unable to reset " + vm + " due to " + answer.getDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hostId != null) {
|
||||
// root.getPoolId() should be null if the VM we are attaching the disk to has never been started before
|
||||
DataStore dataStore = root.getPoolId() != null ? _dataStoreMgr.getDataStore(root.getPoolId(), DataStoreRole.Primary) : null;
|
||||
Host host = this._hostDao.findById(hostId);
|
||||
|
||||
volumeMgr.disconnectVolumeFromHost(volFactory.getVolume(root.getId()), host, dataStore);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareStop(VirtualMachineProfile profile) {
|
||||
UserVmVO vm = _vmDao.findById(profile.getId());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user