Skip to content

Commit 175d9ef

Browse files
rebase from Apache/main to Netapp/main
1 parent f2b2a06 commit 175d9ef

File tree

7 files changed

+728
-425
lines changed

7 files changed

+728
-425
lines changed

plugins/storage/volume/ontap/pom.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
under the License.
1818
-->
1919
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2120
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2221
<modelVersion>4.0.0</modelVersion>
2322
<artifactId>cloud-plugin-storage-volume-ontap</artifactId>
@@ -52,9 +51,6 @@
5251
</dependency>
5352
</dependencies>
5453
</dependencyManagement>
55-
<version>4.22.0.0-SNAPSHOT</version>
56-
<relativePath>../../../pom.xml</relativePath>
57-
</parent>
5854
<dependencies>
5955
<dependency>
6056
<groupId>org.apache.cloudstack</groupId>
@@ -85,10 +81,11 @@
8581
<groupId>org.apache.httpcomponents</groupId>
8682
<artifactId>httpclient</artifactId>
8783
<version>${httpclient.version}</version>
84+
</dependency>
85+
<dependency>
8886
<groupId>org.json</groupId>
8987
<artifactId>json</artifactId>
9088
<version>20230227</version>
91-
9289
</dependency>
9390
<dependency>
9491
<groupId>org.apache.cloudstack</groupId>
@@ -172,13 +169,6 @@
172169
<includes>
173170
<include>**/*Test.java</include>
174171
</includes>
175-
</dependencies>
176-
<build>
177-
<plugins>
178-
<plugin>
179-
<artifactId>maven-surefire-plugin</artifactId>
180-
<configuration>
181-
<skipTests>true</skipTests>
182172
</configuration>
183173
<executions>
184174
<execution>

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportPolicy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ public int hashCode() {
101101
return Objects.hash( id, name);
102102
}
103103

104+
}

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

Lines changed: 179 additions & 185 deletions
Large diffs are not rendered by default.

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

Lines changed: 95 additions & 66 deletions
Large diffs are not rendered by default.

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

Lines changed: 430 additions & 147 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public static StorageStrategy getStrategyByStoragePoolDetails(Map<String, String
5353
String protocol = details.get(OntapStorageConstants.PROTOCOL);
5454
OntapStorage ontapStorage = new OntapStorage(details.get(OntapStorageConstants.USERNAME), details.get(OntapStorageConstants.PASSWORD),
5555
details.get(OntapStorageConstants.MANAGEMENT_LIF), details.get(OntapStorageConstants.SVM_NAME), Long.parseLong(details.get(OntapStorageConstants.SIZE)),
56-
ProtocolType.valueOf(protocol),
57-
Boolean.parseBoolean(details.get(OntapStorageConstants.IS_DISAGGREGATED)));
56+
ProtocolType.valueOf(protocol));
5857
StorageStrategy storageStrategy = StorageProviderFactory.getStrategy(ontapStorage);
5958
boolean isValid = storageStrategy.connect();
6059
if (isValid) {

plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/UnifiedNASStrategyTest.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.apache.cloudstack.storage.service;
2121

2222
import com.cloud.agent.api.Answer;
23+
import com.cloud.agent.api.to.DataTO;
2324
import com.cloud.host.HostVO;
2425
import com.cloud.storage.VolumeVO;
2526
import com.cloud.storage.dao.VolumeDao;
@@ -28,6 +29,7 @@
2829
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
2930
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
3031
import org.apache.cloudstack.storage.command.CreateObjectCommand;
32+
import org.apache.cloudstack.storage.command.DeleteCommand;
3133
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
3234
import org.apache.cloudstack.storage.feign.client.JobFeignClient;
3335
import org.apache.cloudstack.storage.feign.client.NASFeignClient;
@@ -181,7 +183,8 @@ public void testCreateCloudStackVolume_Success() throws Exception {
181183
when(cloudStackVolume.getVolumeInfo()).thenReturn(volumeObject);
182184
when(volumeObject.getId()).thenReturn(100L);
183185
when(volumeObject.getUuid()).thenReturn("volume-uuid-123");
184-
when(volumeDao.findById(100L)).thenReturn(volumeVO);
186+
when(volumeObject.getTO()).thenReturn(mock(DataTO.class));
187+
when(volumeDao.findById(anyLong())).thenReturn(volumeVO);
185188
when(volumeDao.update(anyLong(), any(VolumeVO.class))).thenReturn(true);
186189
when(epSelector.select(volumeObject)).thenReturn(endPoint);
187190
when(endPoint.sendMessage(any(CreateObjectCommand.class))).thenReturn(answer);
@@ -205,7 +208,8 @@ public void testCreateCloudStackVolume_VolumeNotFound() {
205208
when(cloudStackVolume.getDatastoreId()).thenReturn("1");
206209
when(cloudStackVolume.getVolumeInfo()).thenReturn(volumeObject);
207210
when(volumeObject.getId()).thenReturn(100L);
208-
when(volumeDao.findById(100L)).thenReturn(null);
211+
when(volumeObject.getTO()).thenReturn(mock(DataTO.class));
212+
when(volumeDao.findById(anyLong())).thenReturn(null);
209213

210214
assertThrows(CloudRuntimeException.class, () -> {
211215
strategy.createCloudStackVolume(cloudStackVolume);
@@ -225,7 +229,8 @@ public void testCreateCloudStackVolume_KVMHostFailed() {
225229
when(cloudStackVolume.getVolumeInfo()).thenReturn(volumeObject);
226230
when(volumeObject.getId()).thenReturn(100L);
227231
when(volumeObject.getUuid()).thenReturn("volume-uuid-123");
228-
when(volumeDao.findById(100L)).thenReturn(volumeVO);
232+
when(volumeObject.getTO()).thenReturn(mock(DataTO.class));
233+
when(volumeDao.findById(anyLong())).thenReturn(volumeVO);
229234
when(volumeDao.update(anyLong(), any(VolumeVO.class))).thenReturn(true);
230235
when(epSelector.select(volumeObject)).thenReturn(endPoint);
231236
when(endPoint.sendMessage(any(CreateObjectCommand.class))).thenReturn(answer);
@@ -246,7 +251,8 @@ public void testCreateCloudStackVolume_NoEndpoint() {
246251
when(cloudStackVolume.getVolumeInfo()).thenReturn(volumeObject);
247252
when(volumeObject.getId()).thenReturn(100L);
248253
when(volumeObject.getUuid()).thenReturn("volume-uuid-123");
249-
when(volumeDao.findById(100L)).thenReturn(volumeVO);
254+
when(volumeObject.getTO()).thenReturn(mock(DataTO.class));
255+
when(volumeDao.findById(anyLong())).thenReturn(volumeVO);
250256
when(volumeDao.update(anyLong(), any(VolumeVO.class))).thenReturn(true);
251257
when(epSelector.select(volumeObject)).thenReturn(null);
252258

@@ -519,19 +525,19 @@ public void testDeleteCloudStackVolume_Success() throws Exception {
519525
CloudStackVolume cloudStackVolume = mock(CloudStackVolume.class);
520526
VolumeInfo volumeInfo = mock(VolumeInfo.class);
521527
EndPoint endpoint = mock(EndPoint.class);
522-
Answer answer = mock(Answer.class);
528+
Answer answer = new Answer(null, true, "Success");
523529

524530
when(cloudStackVolume.getVolumeInfo()).thenReturn(volumeInfo);
531+
when(volumeInfo.getTO()).thenReturn(mock(DataTO.class));
525532
when(epSelector.select(volumeInfo)).thenReturn(endpoint);
526-
when(endpoint.sendMessage(any())).thenReturn(answer);
527-
when(answer.getResult()).thenReturn(true);
533+
when(endpoint.sendMessage(any(DeleteCommand.class))).thenReturn(answer);
528534

529535
// Execute - should not throw exception
530536
strategy.deleteCloudStackVolume(cloudStackVolume);
531537

532538
// Verify endpoint was selected and message sent
533539
verify(epSelector).select(volumeInfo);
534-
verify(endpoint).sendMessage(any());
540+
verify(endpoint).sendMessage(any(DeleteCommand.class));
535541
}
536542

537543
// Test deleteCloudStackVolume - Endpoint Not Found
@@ -541,6 +547,7 @@ public void testDeleteCloudStackVolume_EndpointNotFound() {
541547
VolumeInfo volumeInfo = mock(VolumeInfo.class);
542548

543549
when(cloudStackVolume.getVolumeInfo()).thenReturn(volumeInfo);
550+
when(volumeInfo.getTO()).thenReturn(mock(DataTO.class));
544551
when(epSelector.select(volumeInfo)).thenReturn(null);
545552

546553
assertThrows(CloudRuntimeException.class, () -> {
@@ -554,13 +561,12 @@ public void testDeleteCloudStackVolume_AnswerResultFalse() throws Exception {
554561
CloudStackVolume cloudStackVolume = mock(CloudStackVolume.class);
555562
VolumeInfo volumeInfo = mock(VolumeInfo.class);
556563
EndPoint endpoint = mock(EndPoint.class);
557-
Answer answer = mock(Answer.class);
564+
Answer answer = new Answer(null, false, "Failed to delete volume file");
558565

559566
when(cloudStackVolume.getVolumeInfo()).thenReturn(volumeInfo);
567+
when(volumeInfo.getTO()).thenReturn(mock(DataTO.class));
560568
when(epSelector.select(volumeInfo)).thenReturn(endpoint);
561-
when(endpoint.sendMessage(any())).thenReturn(answer);
562-
when(answer.getResult()).thenReturn(false);
563-
when(answer.getDetails()).thenReturn("Failed to delete volume file");
569+
when(endpoint.sendMessage(any(DeleteCommand.class))).thenReturn(answer);
564570

565571
assertThrows(CloudRuntimeException.class, () -> {
566572
strategy.deleteCloudStackVolume(cloudStackVolume);
@@ -575,8 +581,9 @@ public void testDeleteCloudStackVolume_AnswerNull() throws Exception {
575581
EndPoint endpoint = mock(EndPoint.class);
576582

577583
when(cloudStackVolume.getVolumeInfo()).thenReturn(volumeInfo);
584+
when(volumeInfo.getTO()).thenReturn(mock(DataTO.class));
578585
when(epSelector.select(volumeInfo)).thenReturn(endpoint);
579-
when(endpoint.sendMessage(any())).thenReturn(null);
586+
when(endpoint.sendMessage(any(DeleteCommand.class))).thenReturn(null);
580587

581588
assertThrows(CloudRuntimeException.class, () -> {
582589
strategy.deleteCloudStackVolume(cloudStackVolume);

0 commit comments

Comments
 (0)