Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 373DD174DF for ; Thu, 23 Oct 2014 20:11:46 +0000 (UTC) Received: (qmail 18813 invoked by uid 500); 23 Oct 2014 20:11:46 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 18583 invoked by uid 500); 23 Oct 2014 20:11:45 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 18407 invoked by uid 99); 23 Oct 2014 20:11:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Oct 2014 20:11:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A09931F5D5; Thu, 23 Oct 2014 20:11:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dahn@apache.org To: commits@cloudstack.apache.org Date: Thu, 23 Oct 2014 20:11:48 -0000 Message-Id: <47b89a84b4054de8aa78c8c40d4923c0@git.apache.org> In-Reply-To: <3dff0203478a447fabb1d8e715b750aa@git.apache.org> References: <3dff0203478a447fabb1d8e715b750aa@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [04/23] git commit: updated refs/heads/hotfix/CLOUDSTACK-7776 to 9e89a28 Invoke grantAccess and revokeAccess one time each using a SnapshotInfo (where previously a VolumeInfo was being passed in) Handle the case where a SnapshotInfo is passed into the grantAccess and revokeAccess methods Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1b5bb7d8 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1b5bb7d8 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1b5bb7d8 Branch: refs/heads/hotfix/CLOUDSTACK-7776 Commit: 1b5bb7d8c6652574d210c8304c78f5ff384269db Parents: 57dacf9 Author: Mike Tutkowski Authored: Sun Oct 19 22:40:01 2014 -0600 Committer: Mike Tutkowski Committed: Tue Oct 21 16:01:14 2014 -0600 ---------------------------------------------------------------------- api/src/com/cloud/agent/api/to/DiskTO.java | 1 - .../snapshot/StorageSystemSnapshotStrategy.java | 23 ++----------- .../driver/SolidFirePrimaryDataStoreDriver.java | 34 ++++++++++++++------ 3 files changed, 26 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b5bb7d8/api/src/com/cloud/agent/api/to/DiskTO.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/agent/api/to/DiskTO.java b/api/src/com/cloud/agent/api/to/DiskTO.java index fcd2aaa..9e4dfd9 100644 --- a/api/src/com/cloud/agent/api/to/DiskTO.java +++ b/api/src/com/cloud/agent/api/to/DiskTO.java @@ -35,7 +35,6 @@ public class DiskTO { public static final String MOUNT_POINT = "mountpoint"; public static final String PROTOCOL_TYPE = "protocoltype"; public static final String PATH = "path"; - public static final String VOLUME_ID = "volumeId"; private DataTO data; private Long diskSeq; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b5bb7d8/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java ---------------------------------------------------------------------- diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java index c895459..1ba9d58 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java @@ -224,16 +224,7 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { _volService.grantAccess(volumeInfo, hostVO, dataStore); } - VolumeVO volume = _volumeDao.findById(volumeInfo.getId()); - - // the Folder field is used by grantAccess(VolumeInfo, Host, DataStore) when that method - // connects the host(s) to the volume - // this Folder change is NOT to be written to the DB; it is only temporarily used here so that - // the connect method can be passed in the expected data and do its work (on the volume that backs - // the snapshot) - volume.setFolder(destDetails.get(DiskTO.VOLUME_ID)); - - _volService.grantAccess(volumeInfo, hostVO, dataStore); + _volService.grantAccess(snapshotInfo, hostVO, dataStore); snapshotAndCopyAnswer = (SnapshotAndCopyAnswer)_agentMgr.send(hostVO.getId(), snapshotAndCopyCommand); } @@ -242,16 +233,7 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { } finally { try { - VolumeVO volume = _volumeDao.findById(volumeInfo.getId()); - - // the Folder field is used by revokeAccess(VolumeInfo, Host, DataStore) when that method - // disconnects the host(s) from the volume - // this Folder change is NOT to be written to the DB; it is only temporarily used here so that - // the disconnect method can be passed in the expected data and do its work (on the volume that backs - // the snapshot) - volume.setFolder(destDetails.get(DiskTO.VOLUME_ID)); - - _volService.revokeAccess(volumeInfo, hostVO, dataStore); + _volService.revokeAccess(snapshotInfo, hostVO, dataStore); // if sourceDetails != null, we need to disconnect the host(s) from the volume if (sourceDetails != null) { @@ -324,7 +306,6 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { long snapshotId = snapshotInfo.getId(); - destDetails.put(DiskTO.VOLUME_ID, getProperty(snapshotId, DiskTO.VOLUME_ID)); destDetails.put(DiskTO.IQN, getProperty(snapshotId, DiskTO.IQN)); destDetails.put(DiskTO.CHAP_INITIATOR_USERNAME, getProperty(snapshotId, DiskTO.CHAP_INITIATOR_USERNAME)); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b5bb7d8/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java ---------------------------------------------------------------------- diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java index 00fd761..f66b5a1 100644 --- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java +++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java @@ -128,13 +128,11 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { @Override public synchronized boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore) { - VolumeInfo volumeInfo = (VolumeInfo)dataObject; - - if (volumeInfo == null || host == null || dataStore == null) { + if (dataObject == null || host == null || dataStore == null) { return false; } - long sfVolumeId = Long.parseLong(volumeInfo.getFolder()); + long sfVolumeId = getSolidFireVolumeId(dataObject); long clusterId = host.getClusterId(); long storagePoolId = dataStore.getId(); @@ -173,13 +171,11 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { @Override public synchronized void revokeAccess(DataObject dataObject, Host host, DataStore dataStore) { - VolumeInfo volumeInfo = (VolumeInfo)dataObject; - - if (volumeInfo == null || host == null || dataStore == null) { + if (dataObject == null || host == null || dataStore == null) { return; } - long sfVolumeId = Long.parseLong(volumeInfo.getFolder()); + long sfVolumeId = getSolidFireVolumeId(dataObject); long clusterId = host.getClusterId(); long storagePoolId = dataStore.getId(); @@ -201,6 +197,24 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { } } + private long getSolidFireVolumeId(DataObject dataObject) { + if (dataObject.getType() == DataObjectType.VOLUME) { + return Long.parseLong(((VolumeInfo)dataObject).getFolder()); + } + + if (dataObject.getType() == DataObjectType.SNAPSHOT) { + SnapshotDetailsVO snapshotDetails = _snapshotDetailsDao.findDetail(dataObject.getId(), SolidFireUtil.VOLUME_ID); + + if (snapshotDetails == null || snapshotDetails.getValue() == null) { + throw new CloudRuntimeException("Unable to locate the volume ID associated with the following snapshot ID: " + dataObject.getId()); + } + + return Long.parseLong(snapshotDetails.getValue()); + } + + throw new CloudRuntimeException("Invalid DataObjectType (" + dataObject.getType() + ") passed to getSolidFireVolumeId(DataObject)"); + } + private long getDefaultMinIops(long storagePoolId) { StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS); @@ -559,7 +573,7 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { private void updateSnapshotDetails(long csSnapshotId, long sfNewVolumeId, long storagePoolId, long sfNewVolumeSize, String sfNewVolumeIqn) { SnapshotDetailsVO snapshotDetail = new SnapshotDetailsVO(csSnapshotId, - DiskTO.VOLUME_ID, + SolidFireUtil.VOLUME_ID, String.valueOf(sfNewVolumeId), false); @@ -596,7 +610,7 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { try { SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao); - SnapshotDetailsVO snapshotDetails = _snapshotDetailsDao.findDetail(snapshotId, DiskTO.VOLUME_ID); + SnapshotDetailsVO snapshotDetails = _snapshotDetailsDao.findDetail(snapshotId, SolidFireUtil.VOLUME_ID); long volumeId = Long.parseLong(snapshotDetails.getValue());