@@ -193,8 +193,8 @@ public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore
193193 throw new CloudRuntimeException ("grantAccess : Storage Pool not found for id: " + dataStore .getId ());
194194 }
195195 if (storagePool .getScope () != ScopeType .CLUSTER && storagePool .getScope () != ScopeType .ZONE ) {
196- s_logger .error ("grantAccess: Only Cluster and ZONE scoped primary storage is supported for storage Pool: " + storagePool .getName ());
197- throw new CloudRuntimeException ("grantAccess: Only Cluster and ZONE scoped primary storage is supported for Storage Pool: " + storagePool .getName ());
196+ s_logger .error ("grantAccess: Only Cluster and Zone scoped primary storage is supported for storage Pool: " + storagePool .getName ());
197+ throw new CloudRuntimeException ("grantAccess: Only Cluster and Zone scoped primary storage is supported for Storage Pool: " + storagePool .getName ());
198198 }
199199
200200 if (dataObject .getType () == DataObjectType .VOLUME ) {
@@ -255,6 +255,10 @@ public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore)
255255 s_logger .error ("revokeAccess : Storage Pool not found for id: " + dataStore .getId ());
256256 throw new CloudRuntimeException ("revokeAccess : Storage Pool not found for id: " + dataStore .getId ());
257257 }
258+ if (storagePool .getScope () != ScopeType .CLUSTER && storagePool .getScope () != ScopeType .ZONE ) {
259+ s_logger .error ("revokeAccess: Only Cluster and Zone scoped primary storage is supported for storage Pool: " + storagePool .getName ());
260+ throw new CloudRuntimeException ("revokeAccess: Only Cluster and Zone scoped primary storage is supported for Storage Pool: " + storagePool .getName ());
261+ }
258262
259263 if (dataObject .getType () == DataObjectType .VOLUME ) {
260264 VolumeVO volumeVO = volumeDao .findById (dataObject .getId ());
@@ -283,11 +287,16 @@ private void revokeAccessForVolume(StoragePoolVO storagePool, VolumeVO volumeVO,
283287 String accessGroupName = utils .getIgroupName (svmName , scopeId );
284288 CloudStackVolume cloudStackVolume = getCloudStackVolumeByName (storageStrategy , svmName , volumeVO .getPath ());
285289 AccessGroup accessGroup = getAccessGroupByName (storageStrategy , svmName , accessGroupName );
290+ //TODO check if initiator does exits in igroup, will throw the error ?
291+ if (!accessGroup .getIgroup ().getInitiators ().contains (host .getStorageUrl ())) {
292+ s_logger .error ("grantAccess: initiator [{}] is not present in iGroup [{}]" , host .getStorageUrl (), accessGroupName );
293+ throw new CloudRuntimeException ("grantAccess: initiator [" + host .getStorageUrl () + "] is not present in iGroup [" + accessGroupName );
294+ }
286295
287- Map <String , String > enableLogicalAccessMap = new HashMap <>();
288- enableLogicalAccessMap .put (Constants .LUN_DOT_UUID , cloudStackVolume .getLun ().getUuid ().toString ());
289- enableLogicalAccessMap .put (Constants .IGROUP_DOT_UUID , accessGroup .getIgroup ().getUuid ());
290- storageStrategy .disableLogicalAccess (enableLogicalAccessMap );
296+ Map <String , String > disableLogicalAccessMap = new HashMap <>();
297+ disableLogicalAccessMap .put (Constants .LUN_DOT_UUID , cloudStackVolume .getLun ().getUuid ().toString ());
298+ disableLogicalAccessMap .put (Constants .IGROUP_DOT_UUID , accessGroup .getIgroup ().getUuid ());
299+ storageStrategy .disableLogicalAccess (disableLogicalAccessMap );
291300 }
292301 }
293302
@@ -297,8 +306,8 @@ private CloudStackVolume getCloudStackVolumeByName(StorageStrategy storageStrate
297306 getCloudStackVolumeMap .put (Constants .SVM_DOT_NAME , svmName );
298307 CloudStackVolume cloudStackVolume = storageStrategy .getCloudStackVolume (getCloudStackVolumeMap );
299308 if (cloudStackVolume == null ||cloudStackVolume .getLun () == null || cloudStackVolume .getLun ().getName () == null ) {
300- s_logger .error ("revokeAccessForVolume : Failed to get LUN details [{}]" , cloudStackVolumeName );
301- throw new CloudRuntimeException ("revokeAccessForVolume : Failed to get LUN [" + cloudStackVolumeName + "]" );
309+ s_logger .error ("getCloudStackVolumeByName : Failed to get LUN details [{}]" , cloudStackVolumeName );
310+ throw new CloudRuntimeException ("getCloudStackVolumeByName : Failed to get LUN [" + cloudStackVolumeName + "]" );
302311 }
303312 return cloudStackVolume ;
304313 }
@@ -309,8 +318,8 @@ private AccessGroup getAccessGroupByName(StorageStrategy storageStrategy, String
309318 getAccessGroupMap .put (Constants .SVM_DOT_NAME , svmName );
310319 AccessGroup accessGroup = storageStrategy .getAccessGroup (getAccessGroupMap );
311320 if (accessGroup == null || accessGroup .getIgroup () == null || accessGroup .getIgroup ().getName () == null ) {
312- s_logger .error ("revokeAccessForVolume : Failed to get iGroup details [{}]" , accessGroupName );
313- throw new CloudRuntimeException ("revokeAccessForVolume : Failed to get iGroup details [" + accessGroupName + "]" );
321+ s_logger .error ("getAccessGroupByName : Failed to get iGroup details [{}]" , accessGroupName );
322+ throw new CloudRuntimeException ("getAccessGroupByName : Failed to get iGroup details [" + accessGroupName + "]" );
314323 }
315324 return accessGroup ;
316325 }
0 commit comments