You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mt...@apache.org on 2014/01/15 08:19:50 UTC
git commit: updated refs/heads/4.3 to fef4c79
Updated Branches:
refs/heads/4.3 032888c46 -> fef4c79cb
CLOUDSTACK-5873: [Automation] Failed to attach volume to VM, if the vm is created with option startvm=false
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fef4c79c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fef4c79c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fef4c79c
Branch: refs/heads/4.3
Commit: fef4c79cb20adbf0019e02e9fa890a2a519be554
Parents: 032888c
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Tue Jan 14 19:40:14 2014 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Wed Jan 15 00:18:34 2014 -0700
----------------------------------------------------------------------
.../apache/cloudstack/storage/volume/VolumeServiceImpl.java | 6 ++++--
.../xen/src/com/cloud/hypervisor/XenServerGuru.java | 6 +++++-
server/src/com/cloud/storage/VolumeApiServiceImpl.java | 9 ++++++---
3 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fef4c79c/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index b9dbd92..7796565 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -159,8 +159,9 @@ public class VolumeServiceImpl implements VolumeService {
return null;
}
+ @Override
public boolean connectVolumeToHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) {
- DataStoreDriver dataStoreDriver = dataStore.getDriver();
+ DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
return ((PrimaryDataStoreDriver)dataStoreDriver).connectVolumeToHost(volumeInfo, host, dataStore);
@@ -169,8 +170,9 @@ public class VolumeServiceImpl implements VolumeService {
return false;
}
+ @Override
public void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) {
- DataStoreDriver dataStoreDriver = dataStore.getDriver();
+ DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
((PrimaryDataStoreDriver)dataStoreDriver).disconnectVolumeFromHost(volumeInfo, host, dataStore);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fef4c79c/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 af37068..28bd724 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
@@ -101,7 +101,11 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
if (volume.getVolumeType() == Volume.Type.DATADISK) {
StoragePoolVO storagePool = _storagePoolDao.findById(volume.getPoolId());
- if (storagePool.isManaged()) {
+ // storagePool should be null if we are expunging a volume that was never
+ // attached to a VM that was started (the "trick" for storagePool to be null
+ // is that none of the VMs this volume may have been attached to were ever started,
+ // so the volume was never assigned to a storage pool)
+ if (storagePool != null && storagePool.isManaged()) {
DataTO volTO = _volFactory.getVolume(volume.getId()).getTO();
DiskTO disk = new DiskTO(volTO, volume.getDeviceId(), volume.getPath(), volume.getVolumeType());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fef4c79c/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 3de2767..0c89541 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1489,12 +1489,13 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
}
}
- DataStore dataStore = dataStoreMgr.getDataStore(volume.getPoolId(), DataStoreRole.Primary);
-
if (!sendCommand || (answer != null && answer.getResult())) {
// 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
+ DataStore dataStore = volume.getPoolId() != null ? dataStoreMgr.getDataStore(volume.getPoolId(), DataStoreRole.Primary) : null;
+
volService.disconnectVolumeFromHost(volFactory.getVolume(volume.getId()), host, dataStore);
return _volsDao.findById(volumeId);
@@ -1961,10 +1962,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
}
}
- DataStore dataStore = dataStoreMgr.getDataStore(volumeToAttachStoragePool.getId(), DataStoreRole.Primary);
+ // volumeToAttachStoragePool should be null if the VM we are attaching the disk to has never been started before
+ DataStore dataStore = volumeToAttachStoragePool != null ? dataStoreMgr.getDataStore(volumeToAttachStoragePool.getId(), DataStoreRole.Primary) : null;
boolean queryForChap = true;
+ // if we don't have a host, the VM we are attaching the disk to has never been started before
if (host != null) {
try {
// if connectVolumeToHost returns true, then we do not want to use CHAP because the volume is already connected to the host(s)