You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/05/17 04:28:44 UTC

[GitHub] [cloudstack] sureshanaparti commented on a diff in pull request #6367: Updated PowerFlex/ScaleIO storage plugin to support separate (storage) network for Hosts(KVM)/Storage connection.

sureshanaparti commented on code in PR #6367:
URL: https://github.com/apache/cloudstack/pull/6367#discussion_r874353922


##########
plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java:
##########
@@ -191,41 +194,59 @@ public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore)
                 final VolumeVO volume = volumeDao.findById(dataObject.getId());
                 LOGGER.debug("Revoking access for PowerFlex volume: " + volume.getPath());
 
-                final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
-                final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
-                if (sdc == null) {
+                final String sdcId = getConnectedSdc(dataStore.getId(), host.getId());
+                if (StringUtils.isBlank(sdcId)) {
                     throw new CloudRuntimeException("Unable to revoke access for volume: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
                 }
 
-                client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(volume.getPath()), sdc.getId());
+                final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
+                client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(volume.getPath()), sdcId);
             } else if (DataObjectType.TEMPLATE.equals(dataObject.getType())) {
                 final VMTemplateStoragePoolVO templatePoolRef = vmTemplatePoolDao.findByPoolTemplate(dataStore.getId(), dataObject.getId(), null);
                 LOGGER.debug("Revoking access for PowerFlex template volume: " + templatePoolRef.getInstallPath());
 
-                final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
-                final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
-                if (sdc == null) {
+                final String sdcId = getConnectedSdc(dataStore.getId(), host.getId());
+                if (StringUtils.isBlank(sdcId)) {
                     throw new CloudRuntimeException("Unable to revoke access for template: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
                 }
 
-                client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(templatePoolRef.getInstallPath()), sdc.getId());
+                final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
+                client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(templatePoolRef.getInstallPath()), sdcId);
             } else if (DataObjectType.SNAPSHOT.equals(dataObject.getType())) {
                 SnapshotInfo snapshot = (SnapshotInfo) dataObject;
                 LOGGER.debug("Revoking access for PowerFlex volume snapshot: " + snapshot.getPath());
 
-                final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
-                final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
-                if (sdc == null) {
+                final String sdcId = getConnectedSdc(dataStore.getId(), host.getId());
+                if (StringUtils.isBlank(sdcId)) {
                     throw new CloudRuntimeException("Unable to revoke access for snapshot: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
                 }
 
-                client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(snapshot.getPath()), sdc.getId());
+                final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
+                client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(snapshot.getPath()), sdcId);
             }
         } catch (Exception e) {
             LOGGER.warn("Failed to revoke access due to: " + e.getMessage(), e);
         }
     }
 
+    private String getConnectedSdc(long poolId, long hostId) {
+        try {
+            StoragePoolHostVO poolHostVO = storagePoolHostDao.findByPoolHost(poolId, hostId);
+            if (poolHostVO == null) {
+                return null;
+            }
+
+            final ScaleIOGatewayClient client = getScaleIOClient(poolId);
+            if (client.isSdcConnected(poolHostVO.getLocalPath())) {
+                return poolHostVO.getLocalPath();
+            }
+        } catch (Exception e) {

Review Comment:
   yes, any issue with storage client is caught here & logged, and returns null.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org