You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/05/03 14:05:04 UTC
git commit: updated refs/heads/4.4 to dd30769
Repository: cloudstack
Updated Branches:
refs/heads/4.4 71e0cff46 -> dd3076987
CLOUDSTACK-6170 Corrected an issue related to the "Reinstall VM" command and managed storage with VMware
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dd307698
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dd307698
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dd307698
Branch: refs/heads/4.4
Commit: dd3076987f5120bf5bee1457a1b980125139191d
Parents: 71e0cff
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Thu May 1 21:50:47 2014 -0600
Committer: Daan Hoogland <da...@onecht.net>
Committed: Sat May 3 14:04:49 2014 +0200
----------------------------------------------------------------------
.../resource/VmwareStorageProcessor.java | 6 +-
.../com/cloud/storage/VolumeApiServiceImpl.java | 2 +-
server/src/com/cloud/vm/UserVmManagerImpl.java | 59 ++++++++++++++------
3 files changed, 45 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dd307698/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index ff893b2..7bc5bd3 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -1334,7 +1334,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
AttachAnswer answer = new AttachAnswer(disk);
if (isAttach) {
- vmMo.attachDisk(new String[] {datastoreVolumePath}, morDs);
+ vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
} else {
vmMo.removeAllSnapshots();
vmMo.detachDisk(datastoreVolumePath, false);
@@ -1800,7 +1800,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
return null;
}
- private void deleteVmfsDatastore(VmwareHypervisorHost hyperHost, String volumeUuid, String storageIpAddress, int storagePortNumber, String iqn) throws Exception {
+ private void removeVmfsDatastore(VmwareHypervisorHost hyperHost, String volumeUuid, String storageIpAddress, int storagePortNumber, String iqn) throws Exception {
// hyperHost.unmountDatastore(volumeUuid);
VmwareContext context = hostService.getServiceContext(null);
@@ -1994,7 +1994,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
VmwareContext context = hostService.getServiceContext(null);
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
- deleteVmfsDatastore(hyperHost, VmwareResource.getDatastoreName(iqn), storageHost, storagePort, trimIqn(iqn));
+ removeVmfsDatastore(hyperHost, VmwareResource.getDatastoreName(iqn), storageHost, storagePort, trimIqn(iqn));
}
private void removeManagedTargetsFromCluster(List<String> iqns) throws Exception {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dd307698/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 2cf0512..6db3a2d 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1473,7 +1473,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
// Mark the volume as detached
_volsDao.detachVolume(volume.getId());
- // volume.getPoolId() should be null if the VM we are attaching the disk to has never been started before
+ // volume.getPoolId() should be null if the VM we are detaching the disk from has never been started before
DataStore dataStore = volume.getPoolId() != null ? dataStoreMgr.getDataStore(volume.getPoolId(), DataStoreRole.Primary) : null;
volService.disconnectVolumeFromHost(volFactory.getVolume(volume.getId()), host, dataStore);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dd307698/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 54b9c57..b55fb19 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -71,6 +71,7 @@ import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationSer
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.PrimaryDataStore;
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;
@@ -82,6 +83,7 @@ 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.DeleteCommand;
import org.apache.cloudstack.storage.command.DettachCommand;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
@@ -97,7 +99,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;
@@ -4610,14 +4611,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
_resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.volume);
}
+ handleManagedStorage(vm, root);
+
_volsDao.attachVolume(newVol.getId(), vmId, newVol.getDeviceId());
/* 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
@@ -4672,19 +4673,44 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
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());
+ VolumeInfo volumeInfo = volFactory.getVolume(root.getId());
+ Host host = _hostDao.findById(hostId);
+
+ final Command cmd;
+
+ if (host.getHypervisorType() == HypervisorType.XenServer) {
+ DiskTO disk = new DiskTO(volumeInfo.getTO(), 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
+ cmd = new DettachCommand(disk, vm.getInstanceName());
+
+ DettachCommand detachCommand = (DettachCommand)cmd;
- // 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());
+ detachCommand.setManaged(true);
- cmd.setManaged(true);
+ detachCommand.setStorageHost(storagePool.getHostAddress());
+ detachCommand.setStoragePort(storagePool.getPort());
- cmd.setStorageHost(storagePool.getHostAddress());
- cmd.setStoragePort(storagePool.getPort());
+ detachCommand.set_iScsiName(root.get_iScsiName());
+ }
+ else if (host.getHypervisorType() == HypervisorType.VMware) {
+ PrimaryDataStore primaryDataStore = (PrimaryDataStore)volumeInfo.getDataStore();
+ Map<String, String> details = primaryDataStore.getDetails();
+
+ if (details == null) {
+ details = new HashMap<String, String>();
+
+ primaryDataStore.setDetails(details);
+ }
- cmd.set_iScsiName(root.get_iScsiName());
+ details.put(DiskTO.MANAGED, Boolean.TRUE.toString());
+
+ cmd = new DeleteCommand(volumeInfo.getTO());
+ }
+ else {
+ throw new CloudRuntimeException("This hypervisor type is not supported on managed storage for this command.");
+ }
Commands cmds = new Commands(Command.OnError.Stop);
@@ -4707,13 +4733,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
}
- 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 = _hostDao.findById(hostId);
+ // root.getPoolId() should be null if the VM we are detaching the disk from has never been started before
+ DataStore dataStore = root.getPoolId() != null ? _dataStoreMgr.getDataStore(root.getPoolId(), DataStoreRole.Primary) : null;
- volumeMgr.disconnectVolumeFromHost(volFactory.getVolume(root.getId()), host, dataStore);
- }
+ volumeMgr.disconnectVolumeFromHost(volFactory.getVolume(root.getId()), host, dataStore);
}
}
}