Skip to content

Commit 142e0e6

Browse files
CSTACKEX-18_2: comments and some changes
1 parent 5f9e51c commit 142e0e6

File tree

8 files changed

+74
-215
lines changed

8 files changed

+74
-215
lines changed

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

Lines changed: 45 additions & 50 deletions
Large diffs are not rendered by default.

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
@@ -307,7 +307,7 @@ public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
307307
strategy.createAccessGroup(accessGroupRequest);
308308
} catch (Exception e) {
309309
s_logger.error("attachCluster: Failed to create access group on storage system for cluster: " + primaryStore.getClusterId() + ". Exception: " + e.getMessage());
310-
throw new CloudRuntimeException("attachCluster: Failed to create access group on storage system for cluster: " + primaryStore.getClusterId() + ". Exception: " + e.getMessage());
310+
throw new CloudRuntimeException("Failed to create access group on storage system for cluster: " + primaryStore.getClusterId() + ". Exception: " + e.getMessage());
311311
}
312312
}
313313
logger.debug("attachCluster: Attaching the pool to each of the host in the cluster: {}", primaryStore.getClusterId());
@@ -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
for (HostVO host : hostsToConnect) {

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ public SANStrategy(OntapStorage ontapStorage) {
2727
super(ontapStorage);
2828
}
2929

30-
/**
31-
* Returns the SAN Feign client for SAN-specific operations.
32-
*
33-
* @return the SANFeignClient instance
34-
*/
35-
public abstract SANFeignClient getSanFeignClient();
36-
3730
/**
3831
* Ensures the LUN is mapped to the specified access group (igroup).
3932
* If a mapping already exists, returns the existing LUN number.

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

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@
6262
*/
6363
public abstract class StorageStrategy {
6464
// Replace @Inject Feign clients with FeignClientFactory
65-
private final FeignClientFactory feignClientFactory;
66-
private final AggregateFeignClient aggregateFeignClient;
67-
private final VolumeFeignClient volumeFeignClient;
68-
private final SvmFeignClient svmFeignClient;
69-
private final JobFeignClient jobFeignClient;
70-
private final NetworkFeignClient networkFeignClient;
71-
private final SANFeignClient sanFeignClient;
72-
private final NASFeignClient nasFeignClient;
73-
private final SnapshotFeignClient snapshotFeignClient;
65+
protected final FeignClientFactory feignClientFactory;
66+
protected final AggregateFeignClient aggregateFeignClient;
67+
protected final VolumeFeignClient volumeFeignClient;
68+
protected final SvmFeignClient svmFeignClient;
69+
protected final JobFeignClient jobFeignClient;
70+
protected final NetworkFeignClient networkFeignClient;
71+
protected final SANFeignClient sanFeignClient;
72+
protected final NASFeignClient nasFeignClient;
73+
protected final SnapshotFeignClient snapshotFeignClient;
7474

7575
protected OntapStorage storage;
7676

@@ -512,18 +512,6 @@ public String getNetworkInterface() {
512512
*/
513513
abstract public CloudStackVolume getCloudStackVolume(Map<String, String> cloudStackVolumeMap);
514514

515-
/**
516-
* Method encapsulates the behavior based on the opted protocol in subclasses.
517-
* it is going to mimic
518-
* snapshotLun for iSCSI, FC protocols
519-
* snapshotFile for NFS3.0 and NFS4.1 protocols
520-
*
521-
*
522-
* @param cloudstackVolume the source CloudStack volume
523-
* @return the retrieved snapshot CloudStackVolume object
524-
*/
525-
public abstract CloudStackVolume snapshotCloudStackVolume(CloudStackVolume cloudstackVolume);
526-
527515
/**
528516
* Reverts a CloudStack volume to a snapshot using protocol-specific ONTAP APIs.
529517
*

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

Lines changed: 6 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,12 @@
6666
public class UnifiedNASStrategy extends NASStrategy {
6767

6868
private static final Logger s_logger = LogManager.getLogger(UnifiedNASStrategy.class);
69-
private final FeignClientFactory feignClientFactory;
70-
private final NASFeignClient nasFeignClient;
71-
private final VolumeFeignClient volumeFeignClient;
72-
private final JobFeignClient jobFeignClient;
7369
@Inject private VolumeDao volumeDao;
7470
@Inject private EndPointSelector epSelector;
7571
@Inject private StoragePoolDetailsDao storagePoolDetailsDao;
7672

7773
public UnifiedNASStrategy(OntapStorage ontapStorage) {
7874
super(ontapStorage);
79-
String baseURL = Constants.HTTPS + ontapStorage.getStorageIP();
80-
this.feignClientFactory = new FeignClientFactory();
81-
this.nasFeignClient = feignClientFactory.createClient(NASFeignClient.class, baseURL);
82-
this.volumeFeignClient = feignClientFactory.createClient(VolumeFeignClient.class, baseURL);
83-
this.jobFeignClient = feignClientFactory.createClient(JobFeignClient.class, baseURL );
8475
}
8576

8677
public void setOntapStorage(OntapStorage ontapStorage) {
@@ -152,59 +143,6 @@ public CloudStackVolume getCloudStackVolume(Map<String, String> cloudStackVolume
152143
return cloudStackVolume;
153144
}
154145

155-
@Override
156-
public CloudStackVolume snapshotCloudStackVolume(CloudStackVolume cloudstackVolumeArg) {
157-
s_logger.info("snapshotCloudStackVolume: Get cloudstack volume " + cloudstackVolumeArg);
158-
CloudStackVolume cloudStackVolume = null;
159-
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
160-
JobResponse jobResponse = null;
161-
162-
FileClone fileClone = new FileClone();
163-
VolumeConcise volumeConcise = new VolumeConcise();
164-
volumeConcise.setUuid(cloudstackVolumeArg.getFlexVolumeUuid());
165-
fileClone.setVolume(volumeConcise);
166-
167-
fileClone.setSourcePath(cloudstackVolumeArg.getFile().getPath());
168-
fileClone.setDestinationPath(cloudstackVolumeArg.getDestinationPath());
169-
170-
try {
171-
/** Clone file call to storage */
172-
jobResponse = nasFeignClient.cloneFile(authHeader, fileClone);
173-
if (jobResponse == null || jobResponse.getJob() == null) {
174-
throw new CloudRuntimeException("Failed to initiate file clone" + cloudstackVolumeArg.getFile().getPath());
175-
}
176-
String jobUUID = jobResponse.getJob().getUuid();
177-
178-
/** Create URI for GET Job API */
179-
Boolean jobSucceeded = jobPollForSuccess(jobUUID,3,2);
180-
if (!jobSucceeded) {
181-
s_logger.error("snapshotCloudStackVolume: File clone failed: " + cloudstackVolumeArg.getFile().getPath());
182-
throw new CloudRuntimeException("File clone failed: " + cloudstackVolumeArg.getFile().getPath());
183-
}
184-
s_logger.info("snapshotCloudStackVolume: File clone job completed successfully for file: " + cloudstackVolumeArg.getFile().getPath());
185-
186-
} catch (FeignException e) {
187-
s_logger.error("snapshotCloudStackVolume: Failed to clone file response: " + cloudstackVolumeArg.getFile().getPath(), e);
188-
throw new CloudRuntimeException("File not found: " + e.getMessage());
189-
} catch (Exception e) {
190-
s_logger.error("snapshotCloudStackVolume: Exception to get file: {}", cloudstackVolumeArg.getFile().getPath(), e);
191-
throw new CloudRuntimeException("Failed to get the file: " + e.getMessage());
192-
}
193-
194-
FileInfo clonedFileInfo = null;
195-
try {
196-
/** Get cloned file call from storage */
197-
clonedFileInfo = getFile(cloudstackVolumeArg.getFlexVolumeUuid(), cloudstackVolumeArg.getDestinationPath());
198-
} catch (Exception e) {
199-
s_logger.error("snapshotCloudStackVolume: Exception to get cloned file: {}", cloudstackVolumeArg.getDestinationPath(), e);
200-
throw new CloudRuntimeException("Failed to get the cloned file: " + e.getMessage());
201-
}
202-
cloudStackVolume = new CloudStackVolume();
203-
cloudStackVolume.setFlexVolumeUuid(cloudstackVolumeArg.getFlexVolumeUuid());
204-
cloudStackVolume.setFile(clonedFileInfo);
205-
return cloudStackVolume;
206-
}
207-
208146
@Override
209147
public AccessGroup createAccessGroup(AccessGroup accessGroup) {
210148
s_logger.info("createAccessGroup: Create access group {}: " , accessGroup);
@@ -237,13 +175,13 @@ public void deleteAccessGroup(AccessGroup accessGroup) {
237175
s_logger.info("deleteAccessGroup: Deleting export policy");
238176

239177
if (accessGroup == null) {
240-
throw new CloudRuntimeException("deleteAccessGroup: Invalid accessGroup object - accessGroup is null");
178+
throw new CloudRuntimeException("Invalid accessGroup object - accessGroup is null");
241179
}
242180

243181
// Get PrimaryDataStoreInfo from accessGroup
244182
PrimaryDataStoreInfo primaryDataStoreInfo = accessGroup.getPrimaryDataStoreInfo();
245183
if (primaryDataStoreInfo == null) {
246-
throw new CloudRuntimeException("deleteAccessGroup: PrimaryDataStoreInfo is null in accessGroup");
184+
throw new CloudRuntimeException("PrimaryDataStoreInfo is null in accessGroup");
247185
}
248186
s_logger.info("deleteAccessGroup: Deleting export policy for the storage pool {}", primaryDataStoreInfo.getName());
249187
try {
@@ -274,48 +212,9 @@ public AccessGroup updateAccessGroup(AccessGroup accessGroup) {
274212

275213
@Override
276214
public AccessGroup getAccessGroup(Map<String, String> values) {
277-
return null; //TODO: This method need to be rewritten according to the signature in StorageStrategy interface
215+
return null;
278216
}
279217

280-
// @Override
281-
// public AccessGroup getAccessGroup(AccessGroup accessGroup) {
282-
// s_logger.info("getAccessGroup: Get export policy");
283-
//
284-
// if (accessGroup == null) {
285-
// throw new CloudRuntimeException("getAccessGroup: Invalid accessGroup object - accessGroup is null");
286-
// }
287-
//
288-
// // Get PrimaryDataStoreInfo from accessGroup
289-
// PrimaryDataStoreInfo primaryDataStoreInfo = accessGroup.getPrimaryDataStoreInfo();
290-
// if (primaryDataStoreInfo == null) {
291-
// throw new CloudRuntimeException("getAccessGroup: PrimaryDataStoreInfo is null in accessGroup");
292-
// }
293-
// s_logger.info("getAccessGroup: Get export policy for the storage pool {}", primaryDataStoreInfo.getName());
294-
// try {
295-
// String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
296-
// // Determine export policy attached to the storage pool
297-
// String exportPolicyName = primaryDataStoreInfo.getDetails().get(Constants.EXPORT_POLICY_NAME);
298-
// String exportPolicyId = primaryDataStoreInfo.getDetails().get(Constants.EXPORT_POLICY_ID);
299-
//
300-
// try {
301-
// ExportPolicy exportPolicy = nasFeignClient.getExportPolicyById(authHeader,exportPolicyId);
302-
// if(exportPolicy==null){
303-
// s_logger.error("getAccessGroup: Failed to retrieve export policy for export policy");
304-
// throw new CloudRuntimeException("getAccessGroup: Failed to retrieve export policy for export policy");
305-
// }
306-
// accessGroup.setPolicy(exportPolicy);
307-
// s_logger.info("getAccessGroup: Successfully fetched export policy '{}'", exportPolicyName);
308-
// } catch (Exception e) {
309-
// s_logger.error("getAccessGroup: Failed to delete export policy. Exception: {}", e.getMessage(), e);
310-
// throw new CloudRuntimeException("Failed to delete export policy: " + e.getMessage(), e);
311-
// }
312-
// } catch (Exception e) {
313-
// s_logger.error("getAccessGroup: Failed to delete export policy. Exception: {}", e.getMessage(), e);
314-
// throw new CloudRuntimeException("Failed to delete export policy: " + e.getMessage(), e);
315-
// }
316-
// return accessGroup;
317-
// }
318-
319218
@Override
320219
public Map<String, String> enableLogicalAccess(Map<String, String> values) {
321220
//TODO
@@ -664,13 +563,13 @@ public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String
664563
volumePath, snapshotName, flexVolName);
665564

666565
if (snapshotName == null || snapshotName.isEmpty()) {
667-
throw new CloudRuntimeException("revertSnapshotForCloudStackVolume: Snapshot name is required for NFS snapshot revert");
566+
throw new CloudRuntimeException("Snapshot name is required for NFS snapshot revert");
668567
}
669568
if (volumePath == null || volumePath.isEmpty()) {
670-
throw new CloudRuntimeException("revertSnapshotForCloudStackVolume: File path is required for NFS snapshot revert");
569+
throw new CloudRuntimeException("File path is required for NFS snapshot revert");
671570
}
672571
if (flexVolName == null || flexVolName.isEmpty()) {
673-
throw new CloudRuntimeException("revertSnapshotForCloudStackVolume: FlexVolume name is required for NFS snapshot revert");
572+
throw new CloudRuntimeException("FlexVolume name is required for NFS snapshot revert");
674573
}
675574

676575
String authHeader = getAuthHeader();

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,10 @@
5050
public class UnifiedSANStrategy extends SANStrategy {
5151

5252
private static final Logger s_logger = LogManager.getLogger(UnifiedSANStrategy.class);
53-
// Replace @Inject Feign client with FeignClientFactory
54-
private final FeignClientFactory feignClientFactory;
55-
private final SANFeignClient sanFeignClient;
5653

5754
public UnifiedSANStrategy(OntapStorage ontapStorage) {
5855
super(ontapStorage);
5956
String baseURL = Constants.HTTPS + ontapStorage.getStorageIP();
60-
// Initialize FeignClientFactory and create SAN client
61-
this.feignClientFactory = new FeignClientFactory();
62-
this.sanFeignClient = feignClientFactory.createClient(SANFeignClient.class, baseURL);
63-
}
64-
65-
@Override
66-
public SANFeignClient getSanFeignClient() {
67-
return sanFeignClient;
6857
}
6958

7059
public void setOntapStorage(OntapStorage ontapStorage) {
@@ -184,11 +173,6 @@ public CloudStackVolume getCloudStackVolume(Map<String, String> values) {
184173
}
185174
}
186175

187-
@Override
188-
public CloudStackVolume snapshotCloudStackVolume(CloudStackVolume cloudstackVolume) {
189-
return null;
190-
}
191-
192176
@Override
193177
public AccessGroup createAccessGroup(AccessGroup accessGroup) {
194178
s_logger.info("createAccessGroup : Create Igroup");
@@ -296,13 +280,13 @@ public void deleteAccessGroup(AccessGroup accessGroup) {
296280
s_logger.info("deleteAccessGroup: Deleting iGroup");
297281

298282
if (accessGroup == null) {
299-
throw new CloudRuntimeException("deleteAccessGroup: Invalid accessGroup object - accessGroup is null");
283+
throw new CloudRuntimeException("Invalid accessGroup object - accessGroup is null");
300284
}
301285

302286
// Get PrimaryDataStoreInfo from accessGroup
303287
PrimaryDataStoreInfo primaryDataStoreInfo = accessGroup.getPrimaryDataStoreInfo();
304288
if (primaryDataStoreInfo == null) {
305-
throw new CloudRuntimeException("deleteAccessGroup: PrimaryDataStoreInfo is null in accessGroup");
289+
throw new CloudRuntimeException("PrimaryDataStoreInfo is null in accessGroup");
306290
}
307291

308292
try {
@@ -340,7 +324,7 @@ public void deleteAccessGroup(AccessGroup accessGroup) {
340324
String igroupUuid = igroup.getUuid();
341325

342326
if (igroupUuid == null || igroupUuid.isEmpty()) {
343-
throw new CloudRuntimeException("deleteAccessGroup: iGroup UUID is null or empty for iGroup: " + igroupName);
327+
throw new CloudRuntimeException("iGroup UUID is null or empty for iGroup: " + igroupName);
344328
}
345329

346330
s_logger.info("deleteAccessGroup: Deleting iGroup '{}' with UUID '{}'", igroupName, igroupUuid);
@@ -593,7 +577,7 @@ public String ensureLunMapped(String svmName, String lunName, String accessGroup
593577
);
594578
Map<String, String> response = enableLogicalAccess(enableMap);
595579
if (response == null || !response.containsKey(Constants.LOGICAL_UNIT_NUMBER)) {
596-
throw new CloudRuntimeException("ensureLunMapped: Failed to map LUN [" + lunName + "] to iGroup [" + accessGroupName + "]");
580+
throw new CloudRuntimeException("Failed to map LUN [" + lunName + "] to iGroup [" + accessGroupName + "]");
597581
}
598582
s_logger.info("ensureLunMapped: Successfully mapped LUN [{}] to igroup [{}] with LUN number [{}]", lunName, accessGroupName, response.get(Constants.LOGICAL_UNIT_NUMBER));
599583
return response.get(Constants.LOGICAL_UNIT_NUMBER);
@@ -656,13 +640,13 @@ public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String
656640
volumePath, snapshotName, flexVolName);
657641

658642
if (snapshotName == null || snapshotName.isEmpty()) {
659-
throw new CloudRuntimeException("revertSnapshotForCloudStackVolume: Snapshot name is required for iSCSI snapshot revert");
643+
throw new CloudRuntimeException("Snapshot name is required for iSCSI snapshot revert");
660644
}
661645
if (flexVolName == null || flexVolName.isEmpty()) {
662-
throw new CloudRuntimeException("revertSnapshotForCloudStackVolume: FlexVolume name is required for iSCSI snapshot revert");
646+
throw new CloudRuntimeException("FlexVolume name is required for iSCSI snapshot revert");
663647
}
664648
if (volumePath == null || volumePath.isEmpty()) {
665-
throw new CloudRuntimeException("revertSnapshotForCloudStackVolume: LUN path is required for iSCSI snapshot revert");
649+
throw new CloudRuntimeException("LUN path is required for iSCSI snapshot revert");
666650
}
667651

668652
String authHeader = getAuthHeader();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePo
9393
cloudStackVolumeRequest.setLun(lunRequest);
9494
break;
9595
default:
96-
throw new CloudRuntimeException("createCloudStackVolumeRequestByProtocol: Unsupported protocol " + protocol);
96+
throw new CloudRuntimeException("Unsupported protocol " + protocol);
9797

9898
}
9999
return cloudStackVolumeRequest;
@@ -122,7 +122,7 @@ public static String getOSTypeFromHypervisor(String hypervisorType){
122122
public static StorageStrategy getStrategyByStoragePoolDetails(Map<String, String> details) {
123123
if (details == null || details.isEmpty()) {
124124
s_logger.error("getStrategyByStoragePoolDetails: Storage pool details are null or empty");
125-
throw new CloudRuntimeException("getStrategyByStoragePoolDetails: Storage pool details are null or empty");
125+
throw new CloudRuntimeException("Storage pool details are null or empty");
126126
}
127127
String protocol = details.get(Constants.PROTOCOL);
128128
OntapStorage ontapStorage = new OntapStorage(details.get(Constants.USERNAME), details.get(Constants.PASSWORD),
@@ -135,7 +135,7 @@ public static StorageStrategy getStrategyByStoragePoolDetails(Map<String, String
135135
return storageStrategy;
136136
} else {
137137
s_logger.error("getStrategyByStoragePoolDetails: Connection to Ontap SVM [" + details.get(Constants.SVM_NAME) + "] failed");
138-
throw new CloudRuntimeException("getStrategyByStoragePoolDetails: Connection to Ontap SVM [" + details.get(Constants.SVM_NAME) + "] failed");
138+
throw new CloudRuntimeException("Connection to Ontap SVM [" + details.get(Constants.SVM_NAME) + "] failed");
139139
}
140140
}
141141

0 commit comments

Comments
 (0)