Skip to content

Commit 7ea09ce

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
vm instance creation test7
1 parent 512f72d commit 7ea09ce

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,37 +130,40 @@ private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObje
130130
throw new CloudRuntimeException("createCloudStackVolume : Storage Pool not found for id: " + dataStore.getId());
131131
}
132132
Map<String, String> details = storagePoolDetailsDao.listDetailsKeyPairs(dataStore.getId());
133-
// For managed NFS: create subdirectory via ONTAP REST API
133+
// For managed NFS: create subdirectory on ONTAP for volume isolation
134134
// Use readable name combining volume name and UUID for subdirectory
135135
if (ProtocolType.NFS.name().equalsIgnoreCase(details.get(Constants.PROTOCOL))) {
136136
StorageStrategy storageStrategy = getStrategyByStoragePoolDetails(details);
137137
String volumeName = ((VolumeInfo) dataObject).getName();
138138
String volumeUuid = ((VolumeInfo) dataObject).getUuid();
139-
// Create readable subdirectory name: "ROOT-15_9c2e59a8-ee14-4f80-9db4-e279a12e0d7b"
139+
// Create readable subdirectory name: "ROOT-17_5d11c615-3142-494c-ac48-96517adbecff"
140140
String readableSubdirName = volumeName + "_" + volumeUuid;
141-
s_logger.info("createCloudStackVolumeForTypeVolume: NFS - creating subdirectory on ONTAP: {}", readableSubdirName);
141+
s_logger.info("createCloudStackVolumeForTypeVolume: NFS - Creating subdirectory on ONTAP: {}", readableSubdirName);
142142
CloudStackVolume cloudStackVolumeRequest = Utility.createCloudStackVolumeRequestByProtocol(storagePool, details, (VolumeInfo) dataObject);
143-
CloudStackVolume cloudStackVolume = storageStrategy.createCloudStackVolume(cloudStackVolumeRequest); // Creates subdirectory on ONTAP via REST API
143+
CloudStackVolume cloudStackVolume = storageStrategy.createCloudStackVolume(cloudStackVolumeRequest); // Creates subdirectory on ONTAP
144144
String subdirectoryName = cloudStackVolume.getFile().getPath();
145-
String subdirectoryPath = subdirectoryName; // No leading slash to avoid double slash
146-
// Store metadata in CloudStack database (following CloudByte pattern)
145+
// Store metadata in CloudStack database
147146
VolumeVO volume = volumeDao.findById(((VolumeInfo) dataObject).getId());
148-
// CRITICAL: Set poolType at VOLUME level (like CloudByte does)
147+
// CRITICAL: Set poolType at VOLUME level
149148
// This tells KVM to use LibvirtStorageAdaptor (NFS) instead of IscsiAdmStorageAdaptor
150149
volume.setPoolType(Storage.StoragePoolType.NetworkFilesystem);
151-
// Set _iScsiName for NFS (CloudByte also sets this for NFS paths)
152-
// This field stores the subdirectory path for reference
150+
// For managed NFS with subdirectories, set path to point to file INSIDE the subdirectory
151+
// Path format: ROOT-17_5d11c615.../5d11c615...
152+
// Full path on KVM will be: /mnt/{pool-uuid}/ROOT-17_5d11c615.../5d11c615....qcow2
153+
// The subdirectory already exists (created by ONTAP), qemu-img will create the file inside
154+
String volumePath = subdirectoryName + "/" + volumeUuid;
155+
volume.setPath(volumePath);
156+
// Set _iScsiName to subdirectory path for managed storage tracking
157+
// This field is used during cleanup operations
153158
volume.set_iScsiName(subdirectoryName);
154159
volume.setFolder(volumeUuid); // Store UUID in folder field
155160
volume.setPoolId(dataStore.getId());
156-
// Set path to file inside the subdirectory (no leading slash to avoid double slash)
157-
// Path format: ROOT-16_865446e6.../865446e6...
158-
// Full path will be: /mnt/{pool-uuid}/ROOT-16_865446e6.../865446e6....qcow2
159-
String volumePath = subdirectoryPath + "/" + volumeUuid;
160-
volume.setPath(volumePath);
161161
volumeDao.update(volume.getId(), volume);
162-
s_logger.info("createCloudStackVolumeForTypeVolume: NFS subdirectory '{}' created on ONTAP, volume path: {}", subdirectoryPath, volumePath);
163-
return null; // Return null - backend work done, hypervisor will handle file creation
162+
// Re-read from database to confirm the path was saved correctly
163+
VolumeVO updatedVolume = volumeDao.findById(volume.getId());
164+
s_logger.info("createCloudStackVolumeForTypeVolume: NFS subdirectory '{}' created on ONTAP", subdirectoryName);
165+
s_logger.info("createCloudStackVolumeForTypeVolume: Volume {} - Path set to: {}, _iScsiName: {}, Folder: {}, PoolType: {}", updatedVolume.getName(), updatedVolume.getPath(), updatedVolume.get_iScsiName(), updatedVolume.getFolder(), updatedVolume.getPoolType());
166+
return null; // Return null - hypervisor will create the qcow2 file inside the subdirectory
164167
}
165168
// For iSCSI and other protocols, use ONTAP REST API
166169
StorageStrategy storageStrategy = getStrategyByStoragePoolDetails(details);

0 commit comments

Comments
 (0)