Skip to content

Commit 6f266fe

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
feature/CSTACKEX-122: remove method name from exception
1 parent 36db8ae commit 6f266fe

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,16 @@ public DataStore initialize(Map<String, Object> dsInfos) {
268268
public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
269269
logger.debug("In attachCluster for ONTAP primary storage");
270270
if (dataStore == null) {
271-
throw new InvalidParameterValueException("attachCluster: dataStore should not be null");
271+
throw new InvalidParameterValueException(" dataStore should not be null");
272272
}
273273
if (scope == null) {
274-
throw new InvalidParameterValueException("attachCluster: scope should not be null");
274+
throw new InvalidParameterValueException(" scope should not be null");
275275
}
276276
List<String> hostsIdentifier = new ArrayList<>();
277277
StoragePoolVO storagePool = storagePoolDao.findById(dataStore.getId());
278278
if (storagePool == null) {
279279
s_logger.error("attachCluster : Storage Pool not found for id: " + dataStore.getId());
280-
throw new CloudRuntimeException("attachCluster : Storage Pool not found for id: " + dataStore.getId());
280+
throw new CloudRuntimeException(" Storage Pool not found for id: " + dataStore.getId());
281281
}
282282
PrimaryDataStoreInfo primaryStore = (PrimaryDataStoreInfo)dataStore;
283283
List<HostVO> hostsToConnect = _resourceMgr.getEligibleUpAndEnabledHostsInClusterForStorageConnection(primaryStore);
@@ -305,7 +305,7 @@ public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
305305
strategy.createAccessGroup(accessGroupRequest);
306306
} catch (Exception e) {
307307
s_logger.error("attachCluster: Failed to create access group on storage system for cluster: " + primaryStore.getClusterId() + ". Exception: " + e.getMessage());
308-
throw new CloudRuntimeException("attachCluster: Failed to create access group on storage system for cluster: " + primaryStore.getClusterId() + ". Exception: " + e.getMessage());
308+
throw new CloudRuntimeException("Failed to create access group on storage system for cluster: " + primaryStore.getClusterId() + ". Exception: " + e.getMessage());
309309
}
310310
}
311311
}
@@ -332,16 +332,16 @@ public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo exis
332332
public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.HypervisorType hypervisorType) {
333333
logger.debug("In attachZone for ONTAP primary storage");
334334
if (dataStore == null) {
335-
throw new InvalidParameterValueException("attachZone: dataStore should not be null");
335+
throw new InvalidParameterValueException("dataStore should not be null");
336336
}
337337
if (scope == null) {
338-
throw new InvalidParameterValueException("attachZone: scope should not be null");
338+
throw new InvalidParameterValueException("scope should not be null");
339339
}
340340
List<String> hostsIdentifier = new ArrayList<>();
341341
StoragePoolVO storagePool = storagePoolDao.findById(dataStore.getId());
342342
if (storagePool == null) {
343343
s_logger.error("attachZone : Storage Pool not found for id: " + dataStore.getId());
344-
throw new CloudRuntimeException("attachZone : Storage Pool not found for id: " + dataStore.getId());
344+
throw new CloudRuntimeException("Storage Pool not found for id: " + dataStore.getId());
345345
}
346346

347347
PrimaryDataStoreInfo primaryStore = (PrimaryDataStoreInfo)dataStore;
@@ -370,7 +370,7 @@ public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.Hyper
370370
strategy.createAccessGroup(accessGroupRequest);
371371
} catch (Exception e) {
372372
s_logger.error("attachZone: Failed to create access group on storage system for zone with Exception: " + e.getMessage());
373-
throw new CloudRuntimeException("attachZone: Failed to create access group on storage system for zone with Exception: " + e.getMessage());
373+
throw new CloudRuntimeException(" Failed to create access group on storage system for zone with Exception: " + e.getMessage());
374374
}
375375
}
376376
}
@@ -393,7 +393,8 @@ private boolean validateProtocolSupportAndFetchHostsIdentifier(List<HostVO> host
393393
for (HostVO host : hosts) {
394394
if (host == null || host.getStorageUrl() == null || host.getStorageUrl().trim().isEmpty()
395395
|| !host.getStorageUrl().startsWith(protocolPrefix)) {
396-
return false;
396+
// TODO we will inform customer through alert for excluded host because of protocol enabled on host
397+
continue;
397398
}
398399
hostIdentifiers.add(host.getStorageUrl());
399400
}
@@ -404,7 +405,8 @@ private boolean validateProtocolSupportAndFetchHostsIdentifier(List<HostVO> host
404405
if (host != null) {
405406
ip = host.getStorageIpAddress() != null ? host.getStorageIpAddress().trim() : "";
406407
if (ip.isEmpty() && host.getPrivateIpAddress() != null || host.getPrivateIpAddress().trim().isEmpty()) {
407-
return false;
408+
// TODO we will inform customer through alert for excluded host because of protocol enabled on host
409+
continue;
408410
} else {
409411
ip = ip.isEmpty() ? host.getPrivateIpAddress().trim() : ip;
410412
}
@@ -413,7 +415,7 @@ private boolean validateProtocolSupportAndFetchHostsIdentifier(List<HostVO> host
413415
}
414416
break;
415417
default:
416-
throw new CloudRuntimeException("validateProtocolSupportAndFetchHostsIdentifier : Unsupported protocol: " + protocolType.name());
418+
throw new CloudRuntimeException("Unsupported protocol: " + protocolType.name());
417419
}
418420
logger.info("validateProtocolSupportAndFetchHostsIdentifier: All hosts support the protocol: " + protocolType.name());
419421
return true;

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

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
import com.cloud.utils.exception.CloudRuntimeException;
2424
import feign.FeignException;
2525
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
26-
import org.apache.cloudstack.storage.feign.FeignClientFactory;
27-
import org.apache.cloudstack.storage.feign.client.SANFeignClient;
28-
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
2926
import org.apache.cloudstack.storage.feign.model.Igroup;
3027
import org.apache.cloudstack.storage.feign.model.Initiator;
3128
import org.apache.cloudstack.storage.feign.model.Svm;
@@ -67,7 +64,7 @@ public CloudStackVolume createCloudStackVolume(CloudStackVolume cloudstackVolume
6764
s_logger.info("createCloudStackVolume : Creating Lun with cloudstackVolume request {} ", cloudstackVolume);
6865
if (cloudstackVolume == null || cloudstackVolume.getLun() == null) {
6966
s_logger.error("createCloudStackVolume: LUN creation failed. Invalid request: {}", cloudstackVolume);
70-
throw new CloudRuntimeException("createCloudStackVolume : Failed to create Lun, invalid request");
67+
throw new CloudRuntimeException(" Failed to create Lun, invalid request");
7168
}
7269
try {
7370
// Get AuthHeader
@@ -106,7 +103,7 @@ CloudStackVolume updateCloudStackVolume(CloudStackVolume cloudstackVolume) {
106103
public void deleteCloudStackVolume(CloudStackVolume cloudstackVolume) {
107104
if (cloudstackVolume == null || cloudstackVolume.getLun() == null) {
108105
s_logger.error("deleteCloudStackVolume: Lun deletion failed. Invalid request: {}", cloudstackVolume);
109-
throw new CloudRuntimeException("deleteCloudStackVolume : Failed to delete Lun, invalid request");
106+
throw new CloudRuntimeException(" Failed to delete Lun, invalid request");
110107
}
111108
s_logger.info("deleteCloudStackVolume : Deleting Lun: {}", cloudstackVolume.getLun().getName());
112109
try {
@@ -139,13 +136,13 @@ public CloudStackVolume getCloudStackVolume(Map<String, String> values) {
139136
s_logger.debug("getCloudStackVolume : fetching Lun with params {} ", values);
140137
if (values == null || values.isEmpty()) {
141138
s_logger.error("getCloudStackVolume: get Lun failed. Invalid request: {}", values);
142-
throw new CloudRuntimeException("getCloudStackVolume : get Lun Failed, invalid request");
139+
throw new CloudRuntimeException(" get Lun Failed, invalid request");
143140
}
144141
String svmName = values.get(Constants.SVM_DOT_NAME);
145142
String lunName = values.get(Constants.NAME);
146143
if (svmName == null || lunName == null || svmName.isEmpty() || lunName.isEmpty()) {
147144
s_logger.error("getCloudStackVolume: get Lun failed. Invalid svm:{} or Lun name: {}", svmName, lunName);
148-
throw new CloudRuntimeException("getCloudStackVolume : Failed to get Lun, invalid request");
145+
throw new CloudRuntimeException("Failed to get Lun, invalid request");
149146
}
150147
try {
151148
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
@@ -180,14 +177,14 @@ public AccessGroup createAccessGroup(AccessGroup accessGroup) {
180177
s_logger.debug("createAccessGroup : Creating Igroup with access group request {} ", accessGroup);
181178
if (accessGroup == null) {
182179
s_logger.error("createAccessGroup: Igroup creation failed. Invalid request: {}", accessGroup);
183-
throw new CloudRuntimeException("createAccessGroup : Failed to create Igroup, invalid request");
180+
throw new CloudRuntimeException(" Failed to create Igroup, invalid request");
184181
}
185182
// Get StoragePool details
186183
if (accessGroup.getStoragePoolId() == null) {
187-
throw new CloudRuntimeException("createAccessGroup : Failed to create Igroup, invalid datastore details in the request");
184+
throw new CloudRuntimeException(" Failed to create Igroup, invalid datastore details in the request");
188185
}
189186
if (accessGroup.getHostsToConnect() == null || accessGroup.getHostsToConnect().isEmpty()) {
190-
throw new CloudRuntimeException("createAccessGroup : Failed to create Igroup, no hosts to connect provided in the request");
187+
throw new CloudRuntimeException(" Failed to create Igroup, no hosts to connect provided in the request");
191188
}
192189

193190
String igroupName = null;
@@ -202,7 +199,7 @@ public AccessGroup createAccessGroup(AccessGroup accessGroup) {
202199

203200
// Check if all hosts support the protocol
204201
if (!validateProtocolSupport(accessGroup.getHostsToConnect(), protocol)) {
205-
String errMsg = "createAccessGroup: Not all hosts " + " support the protocol: " + protocol.name();
202+
String errMsg = " Not all hosts " + " support the protocol: " + protocol.name();
206203
throw new CloudRuntimeException(errMsg);
207204
}
208205

@@ -268,14 +265,14 @@ public void deleteAccessGroup(AccessGroup accessGroup) {
268265

269266
if (accessGroup == null) {
270267
s_logger.error("deleteAccessGroup: Igroup deletion failed. Invalid request: {}", accessGroup);
271-
throw new CloudRuntimeException("deleteAccessGroup : Failed to delete Igroup, invalid request");
268+
throw new CloudRuntimeException(" Failed to delete Igroup, invalid request");
272269
}
273270
// Get StoragePool details
274271
if (accessGroup.getStoragePoolId() == null) {
275-
throw new CloudRuntimeException("deleteAccessGroup : Failed to delete Igroup, invalid datastore details in the request");
272+
throw new CloudRuntimeException(" Failed to delete Igroup, invalid datastore details in the request");
276273
}
277274
if (accessGroup.getHostsToConnect() == null || accessGroup.getHostsToConnect().isEmpty()) {
278-
throw new CloudRuntimeException("deleteAccessGroup : Failed to delete Igroup, no hosts to connect provided in the request");
275+
throw new CloudRuntimeException(" Failed to delete Igroup, no hosts to connect provided in the request");
279276
}
280277

281278
try {
@@ -303,7 +300,7 @@ public void deleteAccessGroup(AccessGroup accessGroup) {
303300
String igroupUuid = igroup.getUuid();
304301

305302
if (igroupUuid == null || igroupUuid.isEmpty()) {
306-
throw new CloudRuntimeException("deleteAccessGroup: iGroup UUID is null or empty for iGroup: " + igroupName);
303+
throw new CloudRuntimeException(" iGroup UUID is null or empty for iGroup: " + igroupName);
307304
}
308305

309306
s_logger.info("deleteAccessGroup: Deleting iGroup '{}' with UUID '{}'", igroupName, igroupUuid);
@@ -357,13 +354,13 @@ public AccessGroup getAccessGroup(Map<String, String> values) {
357354
s_logger.debug("getAccessGroup : fetching Igroup with params {} ", values);
358355
if (values == null || values.isEmpty()) {
359356
s_logger.error("getAccessGroup: get Igroup failed. Invalid request: {}", values);
360-
throw new CloudRuntimeException("getAccessGroup : get Igroup Failed, invalid request");
357+
throw new CloudRuntimeException(" get Igroup Failed, invalid request");
361358
}
362359
String svmName = values.get(Constants.SVM_DOT_NAME);
363360
String igroupName = values.get(Constants.NAME);
364361
if (svmName == null || igroupName == null || svmName.isEmpty() || igroupName.isEmpty()) {
365362
s_logger.error("getAccessGroup: get Igroup failed. Invalid svm:{} or igroup name: {}", svmName, igroupName);
366-
throw new CloudRuntimeException("getAccessGroup : Failed to get Igroup, invalid request");
363+
throw new CloudRuntimeException(" Failed to get Igroup, invalid request");
367364
}
368365
try {
369366
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
@@ -396,14 +393,14 @@ public Map<String, String> enableLogicalAccess(Map<String, String> values) {
396393
Map<String, String> response = null;
397394
if (values == null) {
398395
s_logger.error("enableLogicalAccess: LunMap creation failed. Invalid request values: null");
399-
throw new CloudRuntimeException("enableLogicalAccess : Failed to create LunMap, invalid request");
396+
throw new CloudRuntimeException(" Failed to create LunMap, invalid request");
400397
}
401398
String svmName = values.get(Constants.SVM_DOT_NAME);
402399
String lunName = values.get(Constants.LUN_DOT_NAME);
403400
String igroupName = values.get(Constants.IGROUP_DOT_NAME);
404401
if (svmName == null || lunName == null || igroupName == null || svmName.isEmpty() || lunName.isEmpty() || igroupName.isEmpty()) {
405402
s_logger.error("enableLogicalAccess: LunMap creation failed. Invalid request values: {}", values);
406-
throw new CloudRuntimeException("enableLogicalAccess : Failed to create LunMap, invalid request");
403+
throw new CloudRuntimeException(" Failed to create LunMap, invalid request");
407404
}
408405
try {
409406
// Get AuthHeader
@@ -463,13 +460,13 @@ public void disableLogicalAccess(Map<String, String> values) {
463460
s_logger.debug("disableLogicalAccess : Deleting LunMap with values {} ", values);
464461
if (values == null) {
465462
s_logger.error("disableLogicalAccess: LunMap deletion failed. Invalid request values: null");
466-
throw new CloudRuntimeException("disableLogicalAccess : Failed to delete LunMap, invalid request");
463+
throw new CloudRuntimeException(" Failed to delete LunMap, invalid request");
467464
}
468465
String lunUUID = values.get(Constants.LUN_DOT_UUID);
469466
String igroupUUID = values.get(Constants.IGROUP_DOT_UUID);
470467
if (lunUUID == null || igroupUUID == null || lunUUID.isEmpty() || igroupUUID.isEmpty()) {
471468
s_logger.error("disableLogicalAccess: LunMap deletion failed. Invalid request values: {}", values);
472-
throw new CloudRuntimeException("disableLogicalAccess : Failed to delete LunMap, invalid request");
469+
throw new CloudRuntimeException(" Failed to delete LunMap, invalid request");
473470
}
474471
try {
475472
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
@@ -494,14 +491,14 @@ public Map<String, String> getLogicalAccess(Map<String, String> values) {
494491
s_logger.debug("getLogicalAccess : Fetching LunMap with values {} ", values);
495492
if (values == null) {
496493
s_logger.error("getLogicalAccess: Invalid request values: null");
497-
throw new CloudRuntimeException("getLogicalAccess : Invalid request");
494+
throw new CloudRuntimeException(" Invalid request");
498495
}
499496
String svmName = values.get(Constants.SVM_DOT_NAME);
500497
String lunName = values.get(Constants.LUN_DOT_NAME);
501498
String igroupName = values.get(Constants.IGROUP_DOT_NAME);
502499
if (svmName == null || lunName == null || igroupName == null || svmName.isEmpty() || lunName.isEmpty() || igroupName.isEmpty()) {
503500
s_logger.error("getLogicalAccess: Invalid request values: {}", values);
504-
throw new CloudRuntimeException("getLogicalAccess : Invalid request");
501+
throw new CloudRuntimeException(" Invalid request");
505502
}
506503
try {
507504
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
@@ -553,7 +550,6 @@ public String ensureLunMapped(String svmName, String lunName, String accessGroup
553550
s_logger.info("ensureLunMapped: Successfully mapped LUN [{}] to igroup [{}] with LUN number [{}]", lunName, accessGroupName, response.get(Constants.LOGICAL_UNIT_NUMBER));
554551
return response.get(Constants.LOGICAL_UNIT_NUMBER);
555552
}
556-
557553
/**
558554
* Reverts a LUN to a snapshot using the ONTAP CLI-based snapshot file restore API.
559555
*

0 commit comments

Comments
 (0)