Skip to content

Commit 89ed044

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
Commit 14
1 parent 70d127a commit 89ed044

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/OntapNfsStorageAdaptor.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,11 @@ public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<S
134134
// For ONTAP NFS, volumeUuid is actually the junction path (e.g., "/cloudstack_vol_ROOT_7")
135135
// This comes from managedStoreTarget set by OntapPrimaryDatastoreDriver
136136
String junctionPath = volumeUuid;
137-
138137
// Validate junction path
139138
if (junctionPath == null || junctionPath.isEmpty()) {
140139
logger.error("Invalid junction path for volume: " + volumeUuid);
141140
return false;
142141
}
143-
144142
// Create a sanitized mount point name (remove leading slash, replace special chars)
145143
String sanitizedPath = junctionPath.startsWith("/") ? junctionPath.substring(1) : junctionPath;
146144
sanitizedPath = sanitizedPath.replace("/", "_");
@@ -288,6 +286,15 @@ public KVMPhysicalDisk getPhysicalDisk(String volumeUuid, KVMStoragePool pool) {
288286
String mountPoint = _mountPoint + "/" + volumeUuid;
289287
String diskPath = mountPoint + "/" + volumeUuid;
290288

289+
// Check if file exists - if not, this might be a new disk that needs to be created
290+
// For ONTAP managed storage, the disk file doesn't exist until we create it
291+
if (!_storageLayer.exists(diskPath)) {
292+
logger.info("Disk file does not exist: " + diskPath + ". This is expected for new ONTAP managed volumes. Returning disk object with default format.");
293+
// Return a basic disk object - size will be set during creation
294+
KVMPhysicalDisk disk = new KVMPhysicalDisk(diskPath, volumeUuid, pool);
295+
disk.setFormat(PhysicalDiskFormat.QCOW2); // Default format for new disks
296+
return disk;
297+
}
291298
KVMPhysicalDisk disk = new KVMPhysicalDisk(diskPath, volumeUuid, pool);
292299

293300
try {
@@ -311,6 +318,8 @@ public KVMPhysicalDisk getPhysicalDisk(String volumeUuid, KVMStoragePool pool) {
311318

312319
} catch (QemuImgException | LibvirtException e) {
313320
logger.warn("Failed to get qemu-img info for: " + diskPath + ", " + e.getMessage());
321+
// Set default format if qemu-img fails
322+
disk.setFormat(PhysicalDiskFormat.QCOW2);
314323
}
315324

316325
return disk;

0 commit comments

Comments
 (0)