-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor code to choose aggregate, network interface and creating storage volume; Also, the corresponding UT changes #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; | ||
| import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; | ||
| import org.apache.cloudstack.storage.datastore.lifecycle.BasePrimaryDataStoreLifeCycleImpl; | ||
| import org.apache.cloudstack.storage.feign.model.Aggregate; | ||
| import org.apache.cloudstack.storage.feign.model.OntapStorage; | ||
| import org.apache.cloudstack.storage.feign.model.Volume; | ||
| import org.apache.cloudstack.storage.provider.StorageProviderFactory; | ||
|
|
@@ -67,7 +68,6 @@ | |
| import com.cloud.storage.StorageManager; | ||
| import com.cloud.storage.StoragePool; | ||
| import com.cloud.storage.StoragePoolAutomation; | ||
| import com.cloud.utils.Pair; | ||
| import com.cloud.utils.exception.CloudRuntimeException; | ||
| import com.google.common.base.Preconditions; | ||
|
|
||
|
|
@@ -143,10 +143,30 @@ public DataStore initialize(Map<String, Object> dsInfos) { | |
| if (storageStrategy.getResolvedSvmUuid() != null && !storageStrategy.getResolvedSvmUuid().isEmpty()) { | ||
| details.put(OntapStorageConstants.SVM_UUID, storageStrategy.getResolvedSvmUuid()); | ||
| } | ||
| Aggregate aggregate; | ||
| try { | ||
| aggregate = storageStrategy.chooseAggregate(capacityBytes); | ||
| } catch (Exception e) { | ||
| logger.error("Exception occurred while choosing aggregate for pool: " + storagePoolName, e); | ||
| throw new CloudRuntimeException("Failed to choose ONTAP aggregate for pool: " + storagePoolName | ||
| + ". Error: " + e.getMessage(), e); | ||
| } | ||
|
|
||
| Map<String, String> lifResult; | ||
| try { | ||
| lifResult = storageStrategy.getNetworkInterface(aggregate); | ||
| } catch (Exception e) { | ||
| logger.error("Exception occurred while retrieving network interface for pool: " + storagePoolName, e); | ||
| throw new CloudRuntimeException("Failed to retrieve Data LIF from ONTAP: " + e.getMessage(), e); | ||
| } | ||
| String dataLif = lifResult.get(OntapStorageConstants.DATA_LIF); | ||
| String lifWarning = lifResult.get(OntapStorageConstants.LIF_WARNING); | ||
| processDataLifSelection(dataLif, lifWarning, details, storagePoolName, zoneId, podId); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Execute this workflow using the direct SVM scenario as well and validate the behaviour. We need to confirm whether aggregate-related operations are handled correctly and whether the same set of APIs can be used without any issues.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, Rajiv. |
||
| logger.info("Creating ONTAP volume '" + storagePoolName + "' with size: " + capacityBytes + " bytes (" + | ||
| (capacityBytes / (1024 * 1024 * 1024)) + " GB)"); | ||
| try { | ||
| Volume volume = storageStrategy.createStorageVolume(storagePoolName, capacityBytes); | ||
| Volume volume = storageStrategy.createStorageVolume(storagePoolName, capacityBytes, aggregate); | ||
| if (volume == null) { | ||
| logger.error("createStorageVolume returned null for volume: " + storagePoolName); | ||
| throw new CloudRuntimeException("Failed to create ONTAP volume: " + storagePoolName); | ||
|
|
@@ -158,15 +178,6 @@ public DataStore initialize(Map<String, Object> dsInfos) { | |
| logger.error("Exception occurred while creating ONTAP volume: " + storagePoolName, e); | ||
| throw new CloudRuntimeException("Failed to create ONTAP volume: " + storagePoolName + ". Error: " + e.getMessage(), e); | ||
| } | ||
|
|
||
| Pair<String, String> lifResult; | ||
| try { | ||
| lifResult = storageStrategy.getNetworkInterface(); | ||
| } catch (Exception e) { | ||
| logger.error("Exception occurred while retrieving network interface for pool: " + storagePoolName, e); | ||
| throw new CloudRuntimeException("Failed to retrieve Data LIF from ONTAP: " + e.getMessage(), e); | ||
| } | ||
| processDataLifSelection(lifResult, details, storagePoolName, zoneId, podId); | ||
| } else { | ||
| throw new CloudRuntimeException("ONTAP details validation failed, cannot create primary storage"); | ||
| } | ||
|
|
@@ -282,18 +293,16 @@ private long validateInitializeInputs(Long capacityBytes, Long podId, Long clust | |
| return capacityBytes; | ||
| } | ||
|
|
||
| private void processDataLifSelection(Pair<String, String> lifResult, Map<String, String> details, | ||
| private void processDataLifSelection(String dataLIF, String lifWarning, Map<String, String> details, | ||
| String storagePoolName, Long zoneId, Long podId) { | ||
| String dataLIF = lifResult.first(); | ||
| if (dataLIF == null || dataLIF.isEmpty()) { | ||
| throw new CloudRuntimeException("Failed to retrieve Data LIF from ONTAP, cannot create primary storage"); | ||
| } | ||
| logger.info("Using Data LIF for storage access: " + dataLIF); | ||
| details.put(OntapStorageConstants.DATA_LIF, dataLIF); | ||
|
|
||
| // Persist LIF warning as a pool detail and fire a storage alert so the user is informed | ||
| if (lifResult.second() != null) { | ||
| String lifWarning = lifResult.second(); | ||
| if (lifWarning != null) { | ||
| details.put(OntapStorageConstants.LIF_WARNING, lifWarning); | ||
| logger.warn("LIF selection warning for pool '" + storagePoolName + "': " + lifWarning); | ||
| String alertSubject = "ONTAP Storage Pool '" + storagePoolName + "': " | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have getAggrs method in strategy and have a selection logic here, same as getNetworkInterface