Skip to content

Commit 65a03a2

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
vm instance creation test3
1 parent d772df1 commit 65a03a2

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,20 @@ private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObje
134134
// KVM will mount this subdirectory separately as: storage-ip:/vol/volumename/subdir -> /mnt/{volume-uuid}
135135
if (ProtocolType.NFS.name().equalsIgnoreCase(details.get(Constants.PROTOCOL))) {
136136
StorageStrategy storageStrategy = getStrategyByStoragePoolDetails(details);
137-
s_logger.info("createCloudStackVolumeForTypeVolume: NFS - creating subdirectory on ONTAP for volume: {}", ((VolumeInfo) dataObject).getName());
137+
String volumeName = ((VolumeInfo) dataObject).getName();
138+
s_logger.info("createCloudStackVolumeForTypeVolume: NFS - creating subdirectory on ONTAP for volume: {}", volumeName);
138139
CloudStackVolume cloudStackVolumeRequest = Utility.createCloudStackVolumeRequestByProtocol(storagePool, details, (VolumeInfo) dataObject);
139-
storageStrategy.createCloudStackVolume(cloudStackVolumeRequest); // Creates subdirectory on ONTAP via REST API
140+
CloudStackVolume cloudStackVolume = storageStrategy.createCloudStackVolume(cloudStackVolumeRequest); // Creates subdirectory on ONTAP via REST API
141+
String subdirectoryName = cloudStackVolume.getFile().getPath();
142+
String subdirectoryPath = "/" + subdirectoryName;
140143
// Store the subdirectory path for KVM to mount separately
141-
String subdirectoryPath = "/" + ((VolumeInfo) dataObject).getName();
142144
VolumeVO volume = volumeDao.findById(((VolumeInfo) dataObject).getId());
143145
volume.set_iScsiName(subdirectoryPath); // Used as MOUNT_POINT for NFS managed storage
144146
volume.setFolder(((VolumeInfo) dataObject).getUuid());
145147
volume.setPoolId(dataStore.getId());
146148
volume.setPath(null); // Path is null for managed storage - KVM creates files in mounted subdir
147149
volumeDao.update(volume.getId(), volume);
148-
s_logger.info("createCloudStackVolumeForTypeVolume: NFS subdirectory created, path stored: {}", subdirectoryPath);
150+
s_logger.info("createCloudStackVolumeForTypeVolume: NFS subdirectory created on ONTAP: {}, path stored in DB: {}", subdirectoryName, subdirectoryPath);
149151
return null; // Return null - backend work done, KVM will handle file creation
150152
}
151153
// For iSCSI and other protocols, use ONTAP REST API

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ public void setOntapStorage(OntapStorage ontapStorage) {
7878
public CloudStackVolume createCloudStackVolume(CloudStackVolume cloudstackVolume) {
7979
s_logger.info("createCloudStackVolume: Create cloudstack volume " + cloudstackVolume);
8080
try {
81-
createFile(cloudstackVolume.getVolume().getUuid(),cloudstackVolume.getCloudstackVolName(), cloudstackVolume.getFile());
82-
s_logger.debug("Successfully created file in ONTAP under volume with path {} or name {} ", cloudstackVolume.getVolume().getUuid(), cloudstackVolume.getCloudstackVolName());
81+
boolean success = createFile(cloudstackVolume.getVolume().getUuid(), cloudstackVolume.getCloudstackVolName(), cloudstackVolume.getFile());
82+
if (!success) {
83+
throw new CloudRuntimeException("Failed to create directory on ONTAP: " + cloudstackVolume.getCloudstackVolName());
84+
}
85+
s_logger.debug("Successfully created file in ONTAP under volume with path {} or name {}", cloudstackVolume.getVolume().getUuid(), cloudstackVolume.getCloudstackVolName());
8386
FileInfo responseFile = cloudstackVolume.getFile();
8487
responseFile.setPath(cloudstackVolume.getCloudstackVolName());
85-
}catch (Exception e) {
88+
} catch (Exception e) {
8689
s_logger.error("Exception occurred while creating file or dir: {}. Exception: {}", cloudstackVolume.getCloudstackVolName(), e.getMessage());
8790
throw new CloudRuntimeException("Failed to create file: " + e.getMessage());
8891
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePo
6969
cloudStackVolumeRequest = new CloudStackVolume();
7070
FileInfo file = new FileInfo();
7171
//file.setName("test1"); // to be replaced with volume name // this should not be passed for dir
72-
file.setName(volumeObject.getName()); // to check whether this needs to be sent or not
72+
// file.setName(volumeObject.getName()); // to check whether this needs to be sent or not
7373
//file.setSize(Long.parseLong("10000"));
7474
//file.setSize(volumeObject.getSize());
7575
file.setUnixPermissions(755); // check if it is needed only for dir ? it is needed for dir

0 commit comments

Comments
 (0)