Skip to content

Commit 512f72d

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
vm instance creation test6
1 parent 006ac3f commit 512f72d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,24 @@ private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObje
142142
CloudStackVolume cloudStackVolumeRequest = Utility.createCloudStackVolumeRequestByProtocol(storagePool, details, (VolumeInfo) dataObject);
143143
CloudStackVolume cloudStackVolume = storageStrategy.createCloudStackVolume(cloudStackVolumeRequest); // Creates subdirectory on ONTAP via REST API
144144
String subdirectoryName = cloudStackVolume.getFile().getPath();
145-
String subdirectoryPath = "/" + subdirectoryName;
146-
// Store metadata in CloudStack database
145+
String subdirectoryPath = subdirectoryName; // No leading slash to avoid double slash
146+
// Store metadata in CloudStack database (following CloudByte pattern)
147147
VolumeVO volume = volumeDao.findById(((VolumeInfo) dataObject).getId());
148-
volume.set_iScsiName(subdirectoryPath); // Subdirectory path for reference
149-
volume.setPoolType(Storage.StoragePoolType.NetworkFilesystem); // Set volume pool type for KVM adaptor selection
148+
// CRITICAL: Set poolType at VOLUME level (like CloudByte does)
149+
// This tells KVM to use LibvirtStorageAdaptor (NFS) instead of IscsiAdmStorageAdaptor
150+
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
153+
volume.set_iScsiName(subdirectoryName);
150154
volume.setFolder(volumeUuid); // Store UUID in folder field
151155
volume.setPoolId(dataStore.getId());
152-
// CRITICAL: Set path to point to file INSIDE the subdirectory, not the subdirectory itself
153-
// Subdirectory exists at: /mnt/{pool-uuid}/{volume-uuid}/
154-
// We want hypervisor to create file at: /mnt/{pool-uuid}/{volume-uuid}/{volume-uuid}.{format}
155-
// So path should be: /{volume-uuid}/{volume-uuid} (hypervisor adds extension)
156-
String volumePath = subdirectoryPath + "/" + volumeUuid; // e.g., /9c2e59a8.../9c2e59a8...
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;
157160
volume.setPath(volumePath);
158161
volumeDao.update(volume.getId(), volume);
159-
s_logger.info("createCloudStackVolumeForTypeVolume: NFS subdirectory '{}' created on ONTAP, volume will be created at path: {}", subdirectoryPath, volumePath);
162+
s_logger.info("createCloudStackVolumeForTypeVolume: NFS subdirectory '{}' created on ONTAP, volume path: {}", subdirectoryPath, volumePath);
160163
return null; // Return null - backend work done, hypervisor will handle file creation
161164
}
162165
// For iSCSI and other protocols, use ONTAP REST API

0 commit comments

Comments
 (0)