Skip to content

Commit 42b3d88

Browse files
Refactor code to choose aggregate, network interface and creating storage volume; Also, the corresponding UT changes (#89)
### Description This PR has changes to refactor choosing an aggregate and its corresponding network interface and also creation of storage volume. Also, with this, volume creation would be done at the end, avoiding volume creation cleanup if in case there's a chance of failure during aggregate or network interface selection. <!--- ******************************************************************************* --> <!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. --> <!--- PLEASE PUT AN 'X' in only **ONE** box --> <!--- ******************************************************************************* --> ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [X] Bug fix (non-breaking change which fixes an issue) - [ ] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) - [ ] Build/CI - [ ] Test (unit or integration test code) ### Feature/Enhancement Scale or Bug Severity #### Feature/Enhancement Scale - [ ] Major - [ ] Minor #### Bug Severity - [ ] BLOCKER - [ ] Critical - [X] Major - [ ] Minor - [ ] Trivial ### Screenshots (if appropriate): ### How Has This Been Tested? ================================================================= LATEST: [iSCSI] <img width="1052" height="361" alt="Screenshot 2026-10-07 at 11 47 36 PM" src="https://github.com/user-attachments/assets/7e24be99-c0bf-450e-8ef0-de9390a20e76" /> <img width="575" height="663" alt="Screenshot 2026-10-07 at 11 48 39 PM" src="https://github.com/user-attachments/assets/7af15681-9fbd-4f85-8b6a-f683701062c1" /> <img width="575" height="389" alt="Screenshot 2026-10-07 at 11 48 59 PM" src="https://github.com/user-attachments/assets/bf8ca9f6-f245-4530-a172-0fdbd45b9796" /> <img width="451" height="666" alt="Screenshot 2026-10-07 at 11 49 25 PM" src="https://github.com/user-attachments/assets/ca53cddb-1626-481e-acb3-226d74e42352" /> <img width="1306" height="71" alt="Screenshot 2026-10-07 at 11 51 14 PM" src="https://github.com/user-attachments/assets/11609207-fc4b-4b9b-a6f2-aee2b049730c" /> [NFS3] <img width="1042" height="418" alt="Screenshot 2026-10-07 at 11 53 41 PM" src="https://github.com/user-attachments/assets/632bc4a5-c1fa-4476-b063-66b3221f4640" /> <img width="1103" height="354" alt="Screenshot 2026-10-07 at 11 53 57 PM" src="https://github.com/user-attachments/assets/ff5ba193-2dd2-4a7a-a4ac-791abfc72548" /> <img width="580" height="658" alt="Screenshot 2026-10-07 at 11 54 23 PM" src="https://github.com/user-attachments/assets/2eada67e-a835-4c3a-803c-614e4f7e0a72" /> <img width="580" height="373" alt="Screenshot 2026-10-07 at 11 54 39 PM" src="https://github.com/user-attachments/assets/bada67dd-4c55-4c1d-a7d1-739928c40b80" /> <img width="1306" height="39" alt="Screenshot 2026-10-07 at 11 53 22 PM" src="https://github.com/user-attachments/assets/8650c275-d7e0-4bb3-94d7-4d5fe3e93eba" /> ================================================================= <img width="1042" height="359" alt="Screenshot 2026-08-10 at 7 23 42 AM" src="https://github.com/user-attachments/assets/c7f08ec8-b84e-471c-af39-5e701973ecf3" /> <img width="1098" height="550" alt="Screenshot 2026-08-10 at 7 24 42 AM" src="https://github.com/user-attachments/assets/be0d77de-be40-4415-b9b0-0870db557b46" /> <img width="1098" height="550" alt="Screenshot 2026-08-10 at 7 25 06 AM" src="https://github.com/user-attachments/assets/347aeb2d-5127-4105-8972-ddc1a029458f" /> <img width="1306" height="250" alt="Screenshot 2026-08-10 at 7 27 30 AM" src="https://github.com/user-attachments/assets/db1c04ba-ede3-4c1e-915b-a7b098040b68" /> [ChoosingAggregateRefactorLogs_iSCSi.rtf](https://github.com/user-attachments/files/30884333/ChoosingAggregateRefactorLogs_iSCSi.rtf) <img width="1035" height="315" alt="Screenshot 2026-08-10 at 7 33 52 AM" src="https://github.com/user-attachments/assets/7eb12479-b705-4d00-9443-6851e0aa66f4" /> <img width="1100" height="668" alt="Screenshot 2026-08-10 at 7 34 48 AM" src="https://github.com/user-attachments/assets/db760e61-1bfa-47c8-8123-1e2db21971ca" /> <img width="1100" height="437" alt="Screenshot 2026-08-10 at 7 35 01 AM" src="https://github.com/user-attachments/assets/90f259bd-fcae-4073-909f-d74e38537a4f" /> <img width="1306" height="255" alt="Screenshot 2026-08-10 at 7 36 07 AM" src="https://github.com/user-attachments/assets/1d8b677f-8e9a-4597-a921-0e4c77914112" /> [choosingAggregateRefactorLogs_NFS3.rtf](https://github.com/user-attachments/files/30884337/choosingAggregateRefactorLogs_NFS3.rtf) Choosing LIFs and aggregates might need further enhancement and a backlog story has been created for it https://netapp.atlassian.net/browse/CSTACKEX-343
1 parent 698008f commit 42b3d88

4 files changed

Lines changed: 423 additions & 247 deletions

File tree

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

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
4343
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
4444
import org.apache.cloudstack.storage.datastore.lifecycle.BasePrimaryDataStoreLifeCycleImpl;
45+
import org.apache.cloudstack.storage.feign.model.Aggregate;
4546
import org.apache.cloudstack.storage.feign.model.OntapStorage;
4647
import org.apache.cloudstack.storage.feign.model.Volume;
4748
import org.apache.cloudstack.storage.provider.StorageProviderFactory;
@@ -68,7 +69,6 @@
6869
import com.cloud.storage.StorageManager;
6970
import com.cloud.storage.StoragePool;
7071
import com.cloud.storage.StoragePoolAutomation;
71-
import com.cloud.utils.Pair;
7272
import com.cloud.utils.exception.CloudRuntimeException;
7373
import com.google.common.base.Preconditions;
7474

@@ -147,10 +147,30 @@ public DataStore initialize(Map<String, Object> dsInfos) {
147147
if (storageStrategy.getResolvedSvmUuid() != null && !storageStrategy.getResolvedSvmUuid().isEmpty()) {
148148
details.put(OntapStorageConstants.SVM_UUID, storageStrategy.getResolvedSvmUuid());
149149
}
150+
Aggregate aggregate;
151+
try {
152+
aggregate = storageStrategy.chooseAggregate(storageStrategy.getAggregates(), capacityBytes);
153+
} catch (Exception e) {
154+
logger.error("Exception occurred while choosing aggregate for pool: " + storagePoolName, e);
155+
throw new CloudRuntimeException("Failed to choose ONTAP aggregate for pool: " + storagePoolName
156+
+ ". Error: " + e.getMessage(), e);
157+
}
158+
159+
Map<String, String> lifResult;
160+
try {
161+
lifResult = storageStrategy.getNetworkInterface(aggregate);
162+
} catch (Exception e) {
163+
logger.error("Exception occurred while retrieving network interface for pool: " + storagePoolName, e);
164+
throw new CloudRuntimeException("Failed to retrieve Data LIF from ONTAP: " + e.getMessage(), e);
165+
}
166+
String dataLif = lifResult.get(OntapStorageConstants.DATA_LIF);
167+
String lifWarning = lifResult.get(OntapStorageConstants.LIF_WARNING);
168+
processDataLifSelection(dataLif, lifWarning, details, storagePoolName, zoneId, podId);
169+
150170
logger.info("Creating ONTAP volume '" + storagePoolName + "' with size: " + capacityBytes + " bytes (" +
151171
(capacityBytes / (1024 * 1024 * 1024)) + " GB)");
152172
try {
153-
Volume volume = storageStrategy.createStorageVolume(storagePoolName, capacityBytes);
173+
Volume volume = storageStrategy.createStorageVolume(storagePoolName, capacityBytes, aggregate);
154174
if (volume == null) {
155175
logger.error("createStorageVolume returned null for volume: " + storagePoolName);
156176
throw new CloudRuntimeException("Failed to create ONTAP volume: " + storagePoolName);
@@ -162,15 +182,6 @@ public DataStore initialize(Map<String, Object> dsInfos) {
162182
logger.error("Exception occurred while creating ONTAP volume: " + storagePoolName, e);
163183
throw new CloudRuntimeException("Failed to create ONTAP volume: " + storagePoolName + ". Error: " + e.getMessage(), e);
164184
}
165-
166-
Pair<String, String> lifResult;
167-
try {
168-
lifResult = storageStrategy.getNetworkInterface();
169-
} catch (Exception e) {
170-
logger.error("Exception occurred while retrieving network interface for pool: " + storagePoolName, e);
171-
throw new CloudRuntimeException("Failed to retrieve Data LIF from ONTAP: " + e.getMessage(), e);
172-
}
173-
processDataLifSelection(lifResult, details, storagePoolName, zoneId, podId);
174185
} else {
175186
throw new CloudRuntimeException("ONTAP details validation failed, cannot create primary storage");
176187
}
@@ -289,18 +300,16 @@ private void validateInitializeInputs(Long capacityBytes, Long capacityIops, Lon
289300
}
290301
}
291302

292-
private void processDataLifSelection(Pair<String, String> lifResult, Map<String, String> details,
303+
private void processDataLifSelection(String dataLIF, String lifWarning, Map<String, String> details,
293304
String storagePoolName, Long zoneId, Long podId) {
294-
String dataLIF = lifResult.first();
295305
if (dataLIF == null || dataLIF.isEmpty()) {
296306
throw new CloudRuntimeException("Failed to retrieve Data LIF from ONTAP, cannot create primary storage");
297307
}
298308
logger.info("Using Data LIF for storage access: " + dataLIF);
299309
details.put(OntapStorageConstants.DATA_LIF, dataLIF);
300310

301311
// Persist LIF warning as a pool detail and fire a storage alert so the user is informed
302-
if (lifResult.second() != null) {
303-
String lifWarning = lifResult.second();
312+
if (lifWarning != null) {
304313
details.put(OntapStorageConstants.LIF_WARNING, lifWarning);
305314
logger.warn("LIF selection warning for pool '" + storagePoolName + "': " + lifWarning);
306315
String alertSubject = "ONTAP Storage Pool '" + storagePoolName + "': "

0 commit comments

Comments
 (0)