Skip to content

Commit 723561b

Browse files
CSTACKEX-18_2: Incorporate review comments
1 parent 3f18c11 commit 723561b

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCm
564564
cloudStackVolumeRequestMap.put(Constants.FILE_PATH, volumeVO.getPath());
565565
cloudStackVolume = storageStrategy.getCloudStackVolume(cloudStackVolumeRequestMap);
566566
if (cloudStackVolume == null || cloudStackVolume.getFile() == null) {
567-
throw new CloudRuntimeException("takeSnapshot: Failed to get source file to take snapshot");
567+
throw new CloudRuntimeException("Failed to get source file to take snapshot");
568568
}
569569
s_logger.info("takeSnapshot : entered after getting cloudstack volume with file path: " + cloudStackVolume.getFile().getPath() + " and size: " + cloudStackVolume.getFile().getSize());
570570
fileSize = cloudStackVolume.getFile().getSize();

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

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,16 @@ public CloudStackVolume snapshotCloudStackVolume(CloudStackVolume cloudstackVolu
177177
/** Create URI for GET Job API */
178178
Boolean jobSucceeded = jobPollForSuccess(jobUUID,3,2);
179179
if (!jobSucceeded) {
180-
s_logger.error("File clone failed: " + cloudstackVolumeArg.getFile().getPath());
180+
s_logger.error("snapshotCloudStackVolume: File clone failed: " + cloudstackVolumeArg.getFile().getPath());
181181
throw new CloudRuntimeException("File clone failed: " + cloudstackVolumeArg.getFile().getPath());
182182
}
183-
s_logger.info("File clone job completed successfully for file: " + cloudstackVolumeArg.getFile().getPath());
183+
s_logger.info("snapshotCloudStackVolume: File clone job completed successfully for file: " + cloudstackVolumeArg.getFile().getPath());
184184

185185
} catch (FeignException e) {
186-
s_logger.error("Failed to clone file response: " + cloudstackVolumeArg.getFile().getPath(), e);
186+
s_logger.error("snapshotCloudStackVolume: Failed to clone file response: " + cloudstackVolumeArg.getFile().getPath(), e);
187187
throw new CloudRuntimeException("File not found: " + e.getMessage());
188188
} catch (Exception e) {
189-
s_logger.error("Exception to get file: {}", cloudstackVolumeArg.getFile().getPath(), e);
189+
s_logger.error("snapshotCloudStackVolume: Exception to get file: {}", cloudstackVolumeArg.getFile().getPath(), e);
190190
throw new CloudRuntimeException("Failed to get the file: " + e.getMessage());
191191
}
192192

@@ -195,7 +195,7 @@ public CloudStackVolume snapshotCloudStackVolume(CloudStackVolume cloudstackVolu
195195
/** Get cloned file call from storage */
196196
clonedFileInfo = getFile(cloudstackVolumeArg.getFlexVolumeUuid(), cloudstackVolumeArg.getDestinationPath());
197197
} catch (Exception e) {
198-
s_logger.error("Exception to get cloned file: {}", cloudstackVolumeArg.getDestinationPath(), e);
198+
s_logger.error("snapshotCloudStackVolume: Exception to get cloned file: {}", cloudstackVolumeArg.getDestinationPath(), e);
199199
throw new CloudRuntimeException("Failed to get the cloned file: " + e.getMessage());
200200
}
201201
cloudStackVolume = new CloudStackVolume();
@@ -216,17 +216,17 @@ public AccessGroup createAccessGroup(AccessGroup accessGroup) {
216216
ExportPolicy policyRequest = createExportPolicyRequest(accessGroup,svmName,volumeName);
217217
try {
218218
ExportPolicy createdPolicy = createExportPolicy(svmName, policyRequest);
219-
s_logger.info("ExportPolicy created: {}, now attaching this policy to storage pool volume", createdPolicy.getName());
219+
s_logger.info("createAccessGroup: ExportPolicy created: {}, now attaching this policy to storage pool volume", createdPolicy.getName());
220220
// attach export policy to volume of storage pool
221221
assignExportPolicyToVolume(volumeUUID,createdPolicy.getName());
222222
// save the export policy details in storage pool details
223223
storagePoolDetailsDao.addDetail(accessGroup.getPrimaryDataStoreInfo().getId(), Constants.EXPORT_POLICY_ID, String.valueOf(createdPolicy.getId()), true);
224224
storagePoolDetailsDao.addDetail(accessGroup.getPrimaryDataStoreInfo().getId(), Constants.EXPORT_POLICY_NAME, createdPolicy.getName(), true);
225-
s_logger.info("Successfully assigned exportPolicy {} to volume {}", policyRequest.getName(), volumeName);
225+
s_logger.info("createAccessGroup: Successfully assigned exportPolicy {} to volume {}", policyRequest.getName(), volumeName);
226226
accessGroup.setPolicy(policyRequest);
227227
return accessGroup;
228228
}catch(Exception e){
229-
s_logger.error("Exception occurred while creating access group: " + e);
229+
s_logger.error("createAccessGroup: Exception occurred while creating access group: " + e);
230230
throw new CloudRuntimeException("Failed to create access group: " + e);
231231
}
232232
}
@@ -333,7 +333,7 @@ public Map<String, String> getLogicalAccess(Map<String, String> values) {
333333

334334

335335
private ExportPolicy createExportPolicy(String svmName, ExportPolicy policy) {
336-
s_logger.info("Creating export policy: {} for SVM: {}", policy, svmName);
336+
s_logger.info("createExportPolicy: Creating export policy: {} for SVM: {}", policy, svmName);
337337

338338
try {
339339
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
@@ -346,18 +346,18 @@ private ExportPolicy createExportPolicy(String svmName, ExportPolicy policy) {
346346
throw new CloudRuntimeException("Export policy " + policy.getName() + " was not created on ONTAP. " +
347347
"Received successful response but policy does not exist.");
348348
}
349-
s_logger.info("Export policy created and verified successfully: " + policy.getName());
349+
s_logger.info("createExportPolicy: Export policy created and verified successfully: " + policy.getName());
350350
} catch (FeignException e) {
351-
s_logger.error("Failed to verify export policy creation: " + policy.getName(), e);
351+
s_logger.error("createExportPolicy: Failed to verify export policy creation: " + policy.getName(), e);
352352
throw new CloudRuntimeException("Export policy creation verification failed: " + e.getMessage());
353353
}
354-
s_logger.info("Export policy created successfully with name {}", policy.getName());
354+
s_logger.info("createExportPolicy: Export policy created successfully with name {}", policy.getName());
355355
return policiesResponse.getRecords().get(0);
356356
} catch (FeignException e) {
357-
s_logger.error("Failed to create export policy: {}", policy, e);
357+
s_logger.error("createExportPolicy: Failed to create export policy: {}", policy, e);
358358
throw new CloudRuntimeException("Failed to create export policy: " + e.getMessage());
359359
} catch (Exception e) {
360-
s_logger.error("Exception while creating export policy: {}", policy, e);
360+
s_logger.error("createExportPolicy: Exception while creating export policy: {}", policy, e);
361361
throw new CloudRuntimeException("Failed to create export policy: " + e.getMessage());
362362
}
363363
}
@@ -369,20 +369,20 @@ private void deleteExportPolicy(String svmName, String policyName) {
369369
OntapResponse<ExportPolicy> policiesResponse = nasFeignClient.getExportPolicyResponse(authHeader, queryParams);
370370

371371
if (policiesResponse == null ) {
372-
s_logger.warn("Export policy not found for deletion: {}", policyName);
372+
s_logger.warn("deleteExportPolicy: Export policy not found for deletion: {}", policyName);
373373
throw new CloudRuntimeException("Export policy not found : " + policyName);
374374
}
375375
String policyId = String.valueOf(policiesResponse.getRecords().get(0).getId());
376376
nasFeignClient.deleteExportPolicyById(authHeader, policyId);
377-
s_logger.info("Export policy deleted successfully: {}", policyName);
377+
s_logger.info("deleteExportPolicy: Export policy deleted successfully: {}", policyName);
378378
} catch (Exception e) {
379-
s_logger.error("Failed to delete export policy: {}", policyName, e);
379+
s_logger.error("deleteExportPolicy: Failed to delete export policy: {}", policyName, e);
380380
throw new CloudRuntimeException("Failed to delete export policy: " + policyName);
381381
}
382382
}
383383

384384
private void assignExportPolicyToVolume(String volumeUuid, String policyName) {
385-
s_logger.info("Assigning export policy: {} to volume: {}", policyName, volumeUuid);
385+
s_logger.info("assignExportPolicyToVolume: Assigning export policy: {} to volume: {}", policyName, volumeUuid);
386386

387387
try {
388388
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
@@ -405,13 +405,13 @@ private void assignExportPolicyToVolume(String volumeUuid, String policyName) {
405405
Job createVolumeJob = null;
406406
while(createVolumeJob == null || !createVolumeJob.getState().equals(Constants.JOB_SUCCESS)) {
407407
if(jobRetryCount >= Constants.JOB_MAX_RETRIES) {
408-
s_logger.error("Job to update volume " + volumeUuid + " did not complete within expected time.");
408+
s_logger.error("assignExportPolicyToVolume: Job to update volume " + volumeUuid + " did not complete within expected time.");
409409
throw new CloudRuntimeException("Job to update volume " + volumeUuid + " did not complete within expected time.");
410410
}
411411
try {
412412
createVolumeJob = jobFeignClient.getJobByUUID(authHeader, jobUUID);
413413
if (createVolumeJob == null) {
414-
s_logger.warn("Job with UUID " + jobUUID + " not found. Retrying...");
414+
s_logger.warn("assignExportPolicyToVolume: Job with UUID " + jobUUID + " not found. Retrying...");
415415
} else if (createVolumeJob.getState().equals(Constants.JOB_FAILURE)) {
416416
throw new CloudRuntimeException("Job to update volume " + volumeUuid + " failed with error: " + createVolumeJob.getMessage());
417417
}
@@ -422,83 +422,83 @@ private void assignExportPolicyToVolume(String volumeUuid, String policyName) {
422422
Thread.sleep(Constants.CREATE_VOLUME_CHECK_SLEEP_TIME); // Sleep for 2 seconds before polling again
423423
}
424424
} catch (Exception e) {
425-
s_logger.error("Exception while updating volume: ", e);
425+
s_logger.error("assignExportPolicyToVolume: Exception while updating volume: ", e);
426426
throw new CloudRuntimeException("Failed to update volume: " + e.getMessage());
427427
}
428-
s_logger.info("Export policy successfully assigned to volume: {}", volumeUuid);
428+
s_logger.info("assignExportPolicyToVolume: Export policy successfully assigned to volume: {}", volumeUuid);
429429
} catch (FeignException e) {
430-
s_logger.error("Failed to assign export policy to volume: {}", volumeUuid, e);
430+
s_logger.error("assignExportPolicyToVolume: Failed to assign export policy to volume: {}", volumeUuid, e);
431431
throw new CloudRuntimeException("Failed to assign export policy: " + e.getMessage());
432432
} catch (Exception e) {
433-
s_logger.error("Exception while assigning export policy to volume: {}", volumeUuid, e);
433+
s_logger.error("assignExportPolicyToVolume: Exception while assigning export policy to volume: {}", volumeUuid, e);
434434
throw new CloudRuntimeException("Failed to assign export policy: " + e.getMessage());
435435
}
436436
}
437437

438438
private boolean createFile(String volumeUuid, String filePath, FileInfo fileInfo) {
439-
s_logger.info("Creating file: {} in volume: {}", filePath, volumeUuid);
439+
s_logger.info("createFile: Creating file: {} in volume: {}", filePath, volumeUuid);
440440
try {
441441
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
442442
nasFeignClient.createFile(authHeader, volumeUuid, filePath, fileInfo);
443-
s_logger.info("File created successfully: {} in volume: {}", filePath, volumeUuid);
443+
s_logger.info("createFile: File created successfully: {} in volume: {}", filePath, volumeUuid);
444444
return true;
445445
} catch (FeignException e) {
446-
s_logger.error("Failed to create file: {} in volume: {}", filePath, volumeUuid, e);
446+
s_logger.error("createFile: Failed to create file: {} in volume: {}", filePath, volumeUuid, e);
447447
return false;
448448
} catch (Exception e) {
449-
s_logger.error("Exception while creating file: {} in volume: {}", filePath, volumeUuid, e);
449+
s_logger.error("createFile: Exception while creating file: {} in volume: {}", filePath, volumeUuid, e);
450450
return false;
451451
}
452452
}
453453

454454
private boolean deleteFile(String volumeUuid, String filePath) {
455-
s_logger.info("Deleting file: {} from volume: {}", filePath, volumeUuid);
455+
s_logger.info("deleteFile: Deleting file: {} from volume: {}", filePath, volumeUuid);
456456
try {
457457
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
458458
nasFeignClient.deleteFile(authHeader, volumeUuid, filePath);
459-
s_logger.info("File deleted successfully: {} from volume: {}", filePath, volumeUuid);
459+
s_logger.info("deleteFile: File deleted successfully: {} from volume: {}", filePath, volumeUuid);
460460
return true;
461461
} catch (FeignException e) {
462-
s_logger.error("Failed to delete file: {} from volume: {}", filePath, volumeUuid, e);
462+
s_logger.error("deleteFile: Failed to delete file: {} from volume: {}", filePath, volumeUuid, e);
463463
return false;
464464
} catch (Exception e) {
465-
s_logger.error("Exception while deleting file: {} from volume: {}", filePath, volumeUuid, e);
465+
s_logger.error("deleteFile: Exception while deleting file: {} from volume: {}", filePath, volumeUuid, e);
466466
return false;
467467
}
468468
}
469469

470470
private OntapResponse<FileInfo> getFileInfo(String volumeUuid, String filePath) {
471-
s_logger.debug("Getting file info for: {} in volume: {}", filePath, volumeUuid);
471+
s_logger.debug("getFileInfo: Getting file info for: {} in volume: {}", filePath, volumeUuid);
472472
try {
473473
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
474474
OntapResponse<FileInfo> response = nasFeignClient.getFileResponse(authHeader, volumeUuid, filePath);
475-
s_logger.debug("Retrieved file info for: {} in volume: {}", filePath, volumeUuid);
475+
s_logger.debug("getFileInfo: Retrieved file info for: {} in volume: {}", filePath, volumeUuid);
476476
return response;
477477
} catch (FeignException e){
478478
if (e.status() == 404) {
479-
s_logger.debug("File not found: {} in volume: {}", filePath, volumeUuid);
479+
s_logger.debug("getFileInfo: File not found: {} in volume: {}", filePath, volumeUuid);
480480
return null;
481481
}
482-
s_logger.error("Failed to get file info: {} in volume: {}", filePath, volumeUuid, e);
482+
s_logger.error("getFileInfo: Failed to get file info: {} in volume: {}", filePath, volumeUuid, e);
483483
throw new CloudRuntimeException("Failed to get file info: " + e.getMessage());
484484
} catch (Exception e){
485-
s_logger.error("Exception while getting file info: {} in volume: {}", filePath, volumeUuid, e);
485+
s_logger.error("getFileInfo: Exception while getting file info: {} in volume: {}", filePath, volumeUuid, e);
486486
throw new CloudRuntimeException("Failed to get file info: " + e.getMessage());
487487
}
488488
}
489489

490490
private boolean updateFile(String volumeUuid, String filePath, FileInfo fileInfo) {
491-
s_logger.info("Updating file: {} in volume: {}", filePath, volumeUuid);
491+
s_logger.info("updateFile: Updating file: {} in volume: {}", filePath, volumeUuid);
492492
try {
493493
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
494494
nasFeignClient.updateFile( authHeader, volumeUuid, filePath, fileInfo);
495-
s_logger.info("File updated successfully: {} in volume: {}", filePath, volumeUuid);
495+
s_logger.info("updateFile: File updated successfully: {} in volume: {}", filePath, volumeUuid);
496496
return true;
497497
} catch (FeignException e) {
498-
s_logger.error("Failed to update file: {} in volume: {}", filePath, volumeUuid, e);
498+
s_logger.error("updateFile: Failed to update file: {} in volume: {}", filePath, volumeUuid, e);
499499
return false;
500500
} catch (Exception e){
501-
s_logger.error("Exception while updating file: {} in volume: {}", filePath, volumeUuid, e);
501+
s_logger.error("updateFile: Exception while updating file: {} in volume: {}", filePath, volumeUuid, e);
502502
return false;
503503
}
504504
}
@@ -545,7 +545,7 @@ private String updateCloudStackVolumeMetadata(String dataStoreId, DataObject vol
545545
try {
546546
VolumeObject volumeObject = (VolumeObject) volumeInfo;
547547
long volumeId = volumeObject.getId();
548-
s_logger.info("VolumeInfo ID from VolumeObject: {}", volumeId);
548+
s_logger.info("updateCloudStackVolumeMetadata: VolumeInfo ID from VolumeObject: {}", volumeId);
549549
VolumeVO volume = volumeDao.findById(volumeId);
550550
if (volume == null) {
551551
throw new CloudRuntimeException("Volume not found with id: " + volumeId);
@@ -557,7 +557,7 @@ private String updateCloudStackVolumeMetadata(String dataStoreId, DataObject vol
557557
volumeDao.update(volume.getId(), volume);
558558
return volumeUuid;
559559
}catch (Exception e){
560-
s_logger.error("Exception while updating volumeInfo: {} in volume: {}", dataStoreId, volumeInfo.getUuid(), e);
560+
s_logger.error("updateCloudStackVolumeMetadata: Exception while updating volumeInfo: {} in volume: {}", dataStoreId, volumeInfo.getUuid(), e);
561561
throw new CloudRuntimeException("Exception while updating volumeInfo: " + e.getMessage());
562562
}
563563
}
@@ -624,17 +624,17 @@ private FileInfo getFile(String volumeUuid, String filePath) {
624624
try {
625625
fileResponse = nasFeignClient.getFileResponse(authHeader, volumeUuid, filePath);
626626
if (fileResponse == null || fileResponse.getRecords().isEmpty()) {
627-
throw new CloudRuntimeException("File " + filePath + " not not found on ONTAP. " +
627+
throw new CloudRuntimeException("File " + filePath + " not found on ONTAP. " +
628628
"Received successful response but file does not exist.");
629629
}
630630
} catch (FeignException e) {
631-
s_logger.error("Failed to get file response: " + filePath, e);
631+
s_logger.error("getFile: Failed to get file response: " + filePath, e);
632632
throw new CloudRuntimeException("File not found: " + e.getMessage());
633633
} catch (Exception e) {
634-
s_logger.error("Exception to get file: {}", filePath, e);
634+
s_logger.error("getFile: Exception to get file: {}", filePath, e);
635635
throw new CloudRuntimeException("Failed to get the file: " + e.getMessage());
636636
}
637-
s_logger.info("File retrieved successfully with name {}", filePath);
637+
s_logger.info("getFile: File retrieved successfully with name {}", filePath);
638638
return fileResponse.getRecords().get(0);
639639
}
640640
}

0 commit comments

Comments
 (0)