Skip to content

Commit 4f6092f

Browse files
Gupta, SuryaGupta, Surya
authored andcommitted
CSTACKEX-36 Resolved Review Comments
1 parent da8a7f2 commit 4f6092f

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private void grantAccessForVolume(StoragePoolVO storagePool, VolumeVO volumeVO,
225225
String accessGroupName = utils.getIgroupName(svmName, scopeId);
226226
CloudStackVolume cloudStackVolume = getCloudStackVolumeByName(storageStrategy, svmName, volumeVO.getPath());
227227
AccessGroup accessGroup = getAccessGroupByName(storageStrategy, svmName, accessGroupName);
228-
if(!accessGroup.getIgroup().getInitiators().contains(host.getStorageUrl())) {
228+
if(accessGroup.getIgroup().getInitiators() == null || accessGroup.getIgroup().getInitiators().size() == 0 || !accessGroup.getIgroup().getInitiators().contains(host.getStorageUrl())) {
229229
s_logger.error("grantAccess: initiator [{}] is not present in iGroup [{}]", host.getStorageUrl(), accessGroupName);
230230
throw new CloudRuntimeException("grantAccess: initiator [" + host.getStorageUrl() + "] is not present in iGroup [" + accessGroupName);
231231
}
@@ -268,8 +268,8 @@ public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore)
268268
}
269269
revokeAccessForVolume(storagePool, volumeVO, host);
270270
} else {
271-
s_logger.error("revokeAccess: Invalid DataObjectType (" + dataObject.getType() + ") passed to grantAccess");
272-
throw new CloudRuntimeException("Invalid DataObjectType (" + dataObject.getType() + ") passed to grantAccess");
271+
s_logger.error("revokeAccess: Invalid DataObjectType (" + dataObject.getType() + ") passed to revokeAccess");
272+
throw new CloudRuntimeException("Invalid DataObjectType (" + dataObject.getType() + ") passed to revokeAccess");
273273
}
274274
} catch(Exception e){
275275
s_logger.error("revokeAccess: Failed for dataObject [{}]: {}", dataObject, e.getMessage());
@@ -305,7 +305,7 @@ private CloudStackVolume getCloudStackVolumeByName(StorageStrategy storageStrate
305305
getCloudStackVolumeMap.put(Constants.NAME, cloudStackVolumeName);
306306
getCloudStackVolumeMap.put(Constants.SVM_DOT_NAME, svmName);
307307
CloudStackVolume cloudStackVolume = storageStrategy.getCloudStackVolume(getCloudStackVolumeMap);
308-
if(cloudStackVolume == null ||cloudStackVolume.getLun() == null || cloudStackVolume.getLun().getName() == null) {
308+
if(cloudStackVolume == null || cloudStackVolume.getLun() == null || cloudStackVolume.getLun().getName() == null) {
309309
s_logger.error("getCloudStackVolumeByName: Failed to get LUN details [{}]", cloudStackVolumeName);
310310
throw new CloudRuntimeException("getCloudStackVolumeByName: Failed to get LUN [" + cloudStackVolumeName + "]");
311311
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
207207
AccessGroup accessGroupRequest = utils.createAccessGroupRequestByProtocol(storagePool, scope.getScopeId(), details, hostsIdentifier);
208208
strategy.createAccessGroup(accessGroupRequest);
209209
}
210-
logger.debug("attachCluster: Attaching the pool to each of the host in the cluster: %s", primaryStore.getClusterId());
210+
logger.debug("attachCluster: Attaching the pool to each of the host in the cluster: {}", primaryStore.getClusterId());
211211
for (HostVO host : hostsToConnect) {
212212
try {
213213
_storageMgr.connectHostToSharedPool(host, dataStore.getId());
@@ -237,7 +237,7 @@ public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.Hyper
237237
StoragePoolVO storagePool = storagePoolDao.findById(dataStore.getId());
238238
if(storagePool == null) {
239239
s_logger.error("attachZone : Storage Pool not found for id: " + dataStore.getId());
240-
throw new CloudRuntimeException("attachCluster : Storage Pool not found for id: " + dataStore.getId());
240+
throw new CloudRuntimeException("attachZone : Storage Pool not found for id: " + dataStore.getId());
241241
}
242242
List<HostVO> hostsToConnect = _resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(dataStore, scope.getScopeId(), Hypervisor.HypervisorType.KVM);
243243
// TODO- need to check if no host to connect then throw exception or just continue

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedSANStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ public void enableLogicalAccess(Map<String, String> values) {
213213
URI url = utils.generateURI(Constants.CREATE_LUNMAP);
214214
OntapResponse<LunMap> createdLunMap = sanFeignClient.createLunMap(url, authHeader, true, lunMapRequest);
215215
if (createdLunMap == null || createdLunMap.getRecords() == null || createdLunMap.getRecords().size() == 0) {
216-
s_logger.error("enableLogicalAccess: LunMap failed for Lun {} and igroup ", lunName, igroupName);
217-
throw new CloudRuntimeException("Failed to perform LunMap for Lun: " +lunName+ "and igroup: " + igroupName);
216+
s_logger.error("enableLogicalAccess: LunMap failed for Lun: {} and igroup: {}", lunName, igroupName);
217+
throw new CloudRuntimeException("Failed to perform LunMap for Lun: " +lunName+ " and igroup: " + igroupName);
218218
}
219219
LunMap lunMap = createdLunMap.getRecords().get(0);
220220
s_logger.debug("enableLogicalAccess: LunMap created successfully. LunMap: {}", lunMap);

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/Utility.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public CloudStackVolume createSANCloudStackVolumeRequest(String svmName, String
108108
CloudStackVolume cloudStackVolumeRequest = new CloudStackVolume();
109109
Lun lunRequest = new Lun();
110110

111-
if(svmName != null || !svmName.isEmpty()) {
111+
if(svmName != null && !svmName.isEmpty()) {
112112
Svm svm = new Svm();
113113
svm.setName(svmName);
114114
lunRequest.setSvm(svm);
@@ -121,7 +121,7 @@ public CloudStackVolume createSANCloudStackVolumeRequest(String svmName, String
121121
}
122122

123123
//Lun name is full path like in unified "/vol/VolumeName/LunName"
124-
if(lunName != null || !lunName.isEmpty()) {
124+
if(lunName != null && !lunName.isEmpty()) {
125125
String lunFullName = getLunName(volName, lunName);
126126
lunRequest.setName(lunFullName);
127127
}
@@ -139,7 +139,7 @@ public String getOSTypeFromHypervisor(String hypervisorType){
139139
case Constants.KVM:
140140
return Lun.OsTypeEnum.LINUX.getValue();
141141
default:
142-
String errMsg = "getOStypeFromHypervisorType : Unsupported hypervisor type " + hypervisorType + " for ONTAP storage";
142+
String errMsg = "getOSTypeFromHypervisor : Unsupported hypervisor type " + hypervisorType + " for ONTAP storage";
143143
s_logger.error(errMsg);
144144
throw new CloudRuntimeException(errMsg);
145145
}
@@ -184,13 +184,13 @@ public AccessGroup createSANAccessGroupRequest(String svmName, String igroupName
184184
AccessGroup accessGroupRequest = new AccessGroup();
185185
Igroup igroup = new Igroup();
186186

187-
if(svmName != null || !svmName.isEmpty()) {
187+
if(svmName != null && !svmName.isEmpty()) {
188188
Svm svm = new Svm();
189189
svm.setName(svmName);
190190
igroup.setSvm(svm);
191191
}
192192

193-
if(igroupName != null || !igroupName.isEmpty()) {
193+
if(igroupName != null && !igroupName.isEmpty()) {
194194
igroup.setName(igroupName);
195195
}
196196

@@ -208,6 +208,7 @@ public AccessGroup createSANAccessGroupRequest(String svmName, String igroupName
208208
}
209209
igroup.setInitiators(initiators);
210210
}
211+
accessGroupRequest.setIgroup(igroup);
211212
return accessGroupRequest;
212213
}
213214

0 commit comments

Comments
 (0)