Skip to content

Commit 516b553

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
testing and review comments fix
1 parent 409d28f commit 516b553

File tree

8 files changed

+48
-26
lines changed

8 files changed

+48
-26
lines changed

plugins/storage/volume/ontap/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<swagger-annotations.version>1.6.2</swagger-annotations.version>
3636
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
3737
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
38+
<jackson-databind.version>2.13.4</jackson-databind.version>
3839
</properties>
3940
<dependencyManagement>
4041
<dependencies>
@@ -76,7 +77,7 @@
7677
<dependency>
7778
<groupId>com.fasterxml.jackson.core</groupId>
7879
<artifactId>jackson-databind</artifactId>
79-
<version>2.13.4</version>
80+
<version>${jackson-databind.version}</version>
8081
</dependency>
8182
<dependency>
8283
<groupId>org.apache.httpcomponents</groupId>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
103103
s_logger.info("createAsync: Started for data store [{}] and data object [{}] of type [{}]",
104104
dataStore, dataObject, dataObject.getType());
105105
if (dataObject.getType() == DataObjectType.VOLUME) {
106-
path = createCloudStackVolumeForTypeVolume(dataStore, (VolumeInfo)dataObject);
106+
VolumeInfo volumeInfo = (VolumeInfo) dataObject;
107+
path = createCloudStackVolumeForTypeVolume(dataStore, volumeInfo);
107108
createCmdResult = new CreateCmdResult(path, new Answer(null, true, null));
108109
} else {
109110
errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to createAsync";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
195195
parameters.setType(Storage.StoragePoolType.NetworkFilesystem);
196196
path = "/" + storagePoolName;
197197
s_logger.info("Setting NFS path for storage pool: " + path);
198-
host = "10.193.192.136"; // TODO hardcoded for now
198+
// host = "10.193.192.136"; // TODO hardcoded for now,uncomment and replace it with data lif
199199
break;
200200
case ISCSI:
201201
parameters.setType(Storage.StoragePoolType.Iscsi);

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public boolean hostConnect(long hostId, long poolId) {
5757
logger.info("Connect to host " + hostId + " from pool " + poolId);
5858
Host host = _hostDao.findById(hostId);
5959
if (host == null) {
60-
logger.error("Failed to add host by HostListener as host was not found with id : {}", hostId);
60+
logger.error("host was not found with id : {}", hostId);
6161
return false;
6262
}
6363

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/provider/StorageProviderFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.cloudstack.storage.provider;
2121

22+
import com.cloud.utils.component.ComponentContext;
2223
import com.cloud.utils.exception.CloudRuntimeException;
2324
import org.apache.cloudstack.storage.feign.model.OntapStorage;
2425
import org.apache.cloudstack.storage.service.StorageStrategy;
@@ -39,13 +40,15 @@ public static StorageStrategy getStrategy(OntapStorage ontapStorage) {
3940
case NFS:
4041
if (!ontapStorage.getIsDisaggregated()) {
4142
UnifiedNASStrategy unifiedNASStrategy = new UnifiedNASStrategy(ontapStorage);
43+
ComponentContext.inject(unifiedNASStrategy);
4244
unifiedNASStrategy.setOntapStorage(ontapStorage);
4345
return unifiedNASStrategy;
4446
}
4547
throw new CloudRuntimeException("Unsupported configuration: Disaggregated ONTAP is not supported.");
4648
case ISCSI:
4749
if (!ontapStorage.getIsDisaggregated()) {
4850
UnifiedSANStrategy unifiedSANStrategy = new UnifiedSANStrategy(ontapStorage);
51+
ComponentContext.inject(unifiedSANStrategy);
4952
unifiedSANStrategy.setOntapStorage(ontapStorage);
5053
return unifiedSANStrategy;
5154
}

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

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import com.cloud.storage.dao.VolumeDao;
2727
import com.cloud.utils.exception.CloudRuntimeException;
2828
import feign.FeignException;
29+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2930
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
3031
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
31-
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
3232
import org.apache.cloudstack.storage.command.CreateObjectCommand;
3333
import org.apache.cloudstack.storage.feign.FeignClientFactory;
3434
import org.apache.cloudstack.storage.feign.client.JobFeignClient;
@@ -48,6 +48,7 @@
4848
import org.apache.cloudstack.storage.service.model.CloudStackVolume;
4949
import org.apache.cloudstack.storage.utils.Constants;
5050
import org.apache.cloudstack.storage.utils.Utility;
51+
import org.apache.cloudstack.storage.volume.VolumeObject;
5152
import org.apache.logging.log4j.LogManager;
5253
import org.apache.logging.log4j.Logger;
5354

@@ -82,16 +83,21 @@ public void setOntapStorage(OntapStorage ontapStorage) {
8283
@Override
8384
public CloudStackVolume createCloudStackVolume(CloudStackVolume cloudstackVolume) {
8485
s_logger.info("createCloudStackVolume: Create cloudstack volume " + cloudstackVolume);
85-
// Step 1: set cloudstack volume metadata
86-
String volumeUuid = updateCloudStackVolumeMetadata(cloudstackVolume.getDatastoreId(), cloudstackVolume.getVolumeInfo());
87-
// Step 2: Send command to KVM host to create qcow2 file using qemu-img
88-
Answer answer = createVolumeOnKVMHost(cloudstackVolume.getVolumeInfo());
86+
try {
87+
// Step 1: set cloudstack volume metadata
88+
String volumeUuid = updateCloudStackVolumeMetadata(cloudstackVolume.getDatastoreId(), cloudstackVolume.getVolumeInfo());
89+
// Step 2: Send command to KVM host to create qcow2 file using qemu-img
90+
Answer answer = createVolumeOnKVMHost(cloudstackVolume.getVolumeInfo());
8991
if (answer == null || !answer.getResult()) {
9092
String errMsg = answer != null ? answer.getDetails() : "Failed to create qcow2 on KVM host";
9193
s_logger.error("createCloudStackVolumeForTypeVolume: " + errMsg);
9294
throw new CloudRuntimeException(errMsg);
9395
}
9496
return cloudstackVolume;
97+
}catch (Exception e) {
98+
s_logger.error("createCloudStackVolumeForTypeVolume: error occured " + e);
99+
throw new CloudRuntimeException(e);
100+
}
95101
}
96102

97103
@Override
@@ -374,18 +380,29 @@ private ExportPolicy createExportPolicyRequest(AccessGroup accessGroup,String sv
374380
return exportPolicy;
375381
}
376382

377-
private String updateCloudStackVolumeMetadata(String dataStoreId, VolumeInfo volumeInfo) {
378-
s_logger.info("createManagedNfsVolume called with datastoreID: {} volumeInfo: {} ", dataStoreId, volumeInfo );
379-
VolumeVO volume = volumeDao.findById(volumeInfo.getId());
380-
String volumeUuid = volumeInfo.getUuid();
381-
volume.setPoolType(Storage.StoragePoolType.NetworkFilesystem);
382-
volume.setPoolId(Long.parseLong(dataStoreId)); //need to check if volume0 already has this data filled
383-
volume.setPath(volumeUuid); // Filename for qcow2 file
384-
volumeDao.update(volume.getId(), volume);
385-
return volumeUuid;
383+
private String updateCloudStackVolumeMetadata(String dataStoreId, DataObject volumeInfo) {
384+
s_logger.info("updateCloudStackVolumeMetadata called with datastoreID: {} volumeInfo: {} ", dataStoreId, volumeInfo );
385+
try {
386+
VolumeObject volumeObject = (VolumeObject) volumeInfo;
387+
long volumeId = volumeObject.getId();
388+
s_logger.info("VolumeInfo ID from VolumeObject: {}", volumeId);
389+
VolumeVO volume = volumeDao.findById(volumeId);
390+
if (volume == null) {
391+
throw new CloudRuntimeException("Volume not found with id: " + volumeId);
392+
}
393+
String volumeUuid = volumeInfo.getUuid();
394+
volume.setPoolType(Storage.StoragePoolType.NetworkFilesystem);
395+
volume.setPoolId(Long.parseLong(dataStoreId));
396+
volume.setPath(volumeUuid); // Filename for qcow2 file
397+
volumeDao.update(volume.getId(), volume);
398+
return volumeUuid;
399+
}catch (Exception e){
400+
s_logger.error("Exception while updating volumeInfo: {} in volume: {}", dataStoreId, volumeInfo.getUuid(), e);
401+
throw new CloudRuntimeException("Exception while updating volumeInfo: " + e.getMessage());
402+
}
386403
}
387404

388-
private Answer createVolumeOnKVMHost(VolumeInfo volumeInfo) {
405+
private Answer createVolumeOnKVMHost(DataObject volumeInfo) {
389406
s_logger.info("createVolumeOnKVMHost called with volumeInfo: {} ", volumeInfo);
390407

391408
try {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.apache.cloudstack.storage.service.model;
2121

22-
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
22+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2323
import org.apache.cloudstack.storage.feign.model.FileInfo;
2424
import org.apache.cloudstack.storage.feign.model.Lun;
2525

@@ -28,7 +28,7 @@ public class CloudStackVolume {
2828
private FileInfo file;
2929
private Lun lun;
3030
private String datastoreId;
31-
private VolumeInfo volumeInfo;
31+
private DataObject volumeInfo; // This is needed as we need DataObject to be passed to agent to create volume
3232
public FileInfo getFile() {
3333
return file;
3434
}
@@ -50,10 +50,10 @@ public String getDatastoreId() {
5050
public void setDatastoreId(String datastoreId) {
5151
this.datastoreId = datastoreId;
5252
}
53-
public VolumeInfo getVolumeInfo() {
53+
public DataObject getVolumeInfo() {
5454
return volumeInfo;
5555
}
56-
public void setVolumeInfo(VolumeInfo volumeInfot) {
57-
this.volumeInfo = volumeInfot;
56+
public void setVolumeInfo(DataObject volumeInfo) {
57+
this.volumeInfo = volumeInfo;
5858
}
5959
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import com.cloud.utils.StringUtils;
2323
import com.cloud.utils.exception.CloudRuntimeException;
24-
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
24+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2525
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
2626
import org.apache.cloudstack.storage.feign.model.Lun;
2727
import org.apache.cloudstack.storage.feign.model.LunSpace;
@@ -56,7 +56,7 @@ public static String generateAuthHeader (String username, String password) {
5656
return BASIC + StringUtils.SPACE + new String(encodedBytes);
5757
}
5858

59-
public static CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePoolVO storagePool, Map<String, String> details, VolumeInfo volumeObject) {
59+
public static CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePoolVO storagePool, Map<String, String> details, DataObject volumeObject) {
6060
CloudStackVolume cloudStackVolumeRequest = null;
6161

6262
String protocol = details.get(Constants.PROTOCOL);

0 commit comments

Comments
 (0)