Skip to content

Commit 592c009

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
vm instance creation test15
1 parent 5f86b64 commit 592c009

File tree

4 files changed

+27
-56
lines changed

4 files changed

+27
-56
lines changed

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

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,18 @@ private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObje
136136
// For managed NFS: Use flat structure (no subdirectories) like other managed storage providers
137137
// KVM expects volumes to be in the root of the NFS mount with unique names
138138
if (ProtocolType.NFS.name().equalsIgnoreCase(details.get(Constants.PROTOCOL))) {
139+
// ManagedNFS semantics: libvirt (ManagedNfsStorageAdaptor) will create qcow2 backing file automatically.
139140
VolumeVO volume = volumeDao.findById(((VolumeInfo) dataObject).getId());
140-
volume.setPoolType(Storage.StoragePoolType.NetworkFilesystem);
141141
String volumeUuid = ((VolumeInfo) dataObject).getUuid();
142-
CloudStackVolume cloudStackVolumeRequest = Utility.createCloudStackVolumeRequestByProtocol(storagePool, details, (VolumeInfo) dataObject);
143-
CloudStackVolume created = storageStrategy.createCloudStackVolume(cloudStackVolumeRequest);
144-
String rawFileName = created.getCloudstackVolName(); // <uuid>.raw
145-
volume.setPath(rawFileName);
146-
volume.setFormat(Storage.ImageFormat.RAW);
142+
// Pool type should reflect ManagedNFS now (lifecycle set it). Still set explicitly for safety.
143+
volume.setPoolType(Storage.StoragePoolType.ManagedNFS);
144+
// For ManagedNfsStorageAdaptor the volume name (uuid) is used and qcow2 is created without extension necessity.
145+
volume.setPath(volumeUuid); // no extension; adaptor creates qcow2 libvirt volume with this name
146+
volume.setFormat(Storage.ImageFormat.QCOW2);
147147
volume.setPoolId(dataStore.getId());
148148
volumeDao.update(volume.getId(), volume);
149-
s_logger.info("ONTAP RAW managed NFS volume created: uuid={} path={} format=RAW", volumeUuid, rawFileName);
150-
return rawFileName;
149+
s_logger.info("ONTAP ManagedNFS volume registered: uuid={} path={} format=QCOW2", volumeUuid, volumeUuid);
150+
return volumeUuid;
151151
}
152152

153153
s_logger.info("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest", details.get(Constants.SVM_NAME));
@@ -173,18 +173,8 @@ public void deleteAsync(DataStore store, DataObject data, AsyncCompletionCallbac
173173
StoragePoolVO storagePool = storagePoolDao.findById(store.getId());
174174
Map<String, String> details = storagePoolDetailsDao.listDetailsKeyPairs(store.getId());
175175
if (ProtocolType.NFS.name().equalsIgnoreCase(details.get(Constants.PROTOCOL))) {
176-
VolumeVO volume = volumeDao.findById(data.getId());
177-
if (volume != null && volume.getPath() != null) {
178-
StorageStrategy strategy = getStrategyByStoragePoolDetails(details);
179-
if (strategy instanceof org.apache.cloudstack.storage.service.UnifiedNASStrategy) {
180-
boolean deleted = ((org.apache.cloudstack.storage.service.UnifiedNASStrategy) strategy)
181-
.deleteManagedFile(details.get(Constants.VOLUME_UUID), volume.getPath());
182-
if (!deleted) {
183-
throw new CloudRuntimeException("Failed to delete RAW file " + volume.getPath());
184-
}
185-
s_logger.info("Deleted RAW managed file {} for volume id {}", volume.getPath(), volume.getId());
186-
}
187-
}
176+
// ManagedNFS qcow2 backing file deletion handled by KVM host/libvirt; nothing to do via ONTAP REST.
177+
s_logger.info("deleteAsync: ManagedNFS volume {} no-op ONTAP deletion", data.getId());
188178
}
189179
}
190180
} catch (Exception e) {

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,12 @@ public DataStore initialize(Map<String, Object> dsInfos) {
192192
ProtocolType protocol = ProtocolType.valueOf(details.get(Constants.PROTOCOL));
193193
switch (protocol) {
194194
case NFS:
195-
// Use NetworkFilesystem like CloudByte - volume pool type will be set per volume
196-
// This allows managed storage to work with standard NFS pools
197-
parameters.setType(Storage.StoragePoolType.NetworkFilesystem);
198-
// Path should be just the NFS export path (junction path), NOT host:path
199-
// CloudStack will construct the full mount path as: hostAddress + ":" + path
195+
// Switch to ManagedNFS so KVM agent selects ManagedNfsStorageAdaptor
196+
parameters.setType(Storage.StoragePoolType.ManagedNFS);
197+
// Path remains the exported junction; ManagedNfsStorageAdaptor will mount per-volume using details
200198
path = "/" + storagePoolName;
201-
s_logger.info("Setting NetworkFilesystem path for storage pool: " + path);
202-
host = "10.193.192.136"; // TODO hardcoded for now
199+
s_logger.info("Setting ManagedNFS path for storage pool: " + path);
200+
host = "10.193.192.136"; // TODO replace hardcoded host lookup
203201
break;
204202
case ISCSI:
205203
parameters.setType(Storage.StoragePoolType.Iscsi);

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,17 @@ public void setOntapStorage(OntapStorage ontapStorage) {
7676

7777
@Override
7878
public CloudStackVolume createCloudStackVolume(CloudStackVolume cloudstackVolume) {
79-
s_logger.info("createCloudStackVolume: Creating RAW managed file for CloudStack volume: " + cloudstackVolume.getCloudstackVolName());
80-
try {
81-
FileInfo fileInfo = cloudstackVolume.getFile();
82-
fileInfo.setPath(cloudstackVolume.getCloudstackVolName());
83-
fileInfo.setType(FileInfo.TypeEnum.FILE);
84-
fileInfo.setUnixPermissions(644);
85-
boolean success = createFile(cloudstackVolume.getVolume().getUuid(), cloudstackVolume.getCloudstackVolName(), fileInfo);
86-
if (!success) {
87-
throw new CloudRuntimeException("Failed to create RAW file on ONTAP: " + cloudstackVolume.getCloudstackVolName());
88-
}
89-
s_logger.debug("RAW file created in FlexVol UUID={} filename={}", cloudstackVolume.getVolume().getUuid(), cloudstackVolume.getCloudstackVolName());
90-
return cloudstackVolume;
91-
} catch (Exception e) {
92-
s_logger.error("Exception occurred while creating RAW file {}. Exception: {}", cloudstackVolume.getCloudstackVolName(), e.getMessage());
93-
throw new CloudRuntimeException("Failed to create RAW file: " + e.getMessage());
94-
}
79+
// ManagedNFS refactor: no file creation via ONTAP; libvirt ManagedNfsStorageAdaptor will create qcow2.
80+
s_logger.info("createCloudStackVolume: ManagedNFS metadata only, no ONTAP file creation for volume name=" + cloudstackVolume.getCloudstackVolName());
81+
return cloudstackVolume;
9582
}
9683

9784
/**
98-
* Public wrapper for deleting managed RAW file.
85+
* Public wrapper for deleting managed file (legacy RAW mode). Not used in ManagedNFS qcow2 flow.
9986
*/
10087
public boolean deleteManagedFile(String volumeUuid, String fileName) {
101-
return deleteFile(volumeUuid, fileName);
88+
s_logger.debug("deleteManagedFile called for volumeUuid={} fileName={} but ManagedNFS qcow2 file was not created via ONTAP; skipping.", volumeUuid, fileName);
89+
return true; // nothing to do
10290
}
10391

10492
@Override

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.cloud.utils.exception.CloudRuntimeException;
2424
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
2525
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
26-
import org.apache.cloudstack.storage.feign.model.FileInfo;
2726
import org.apache.cloudstack.storage.feign.model.Lun;
2827
import org.apache.cloudstack.storage.feign.model.LunSpace;
2928
import org.apache.cloudstack.storage.feign.model.OntapStorage;
@@ -65,17 +64,13 @@ public static CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePo
6564
ProtocolType protocolType = ProtocolType.valueOf(protocol);
6665
switch (protocolType) {
6766
case NFS:
68-
// RAW managed NFS: create a regular file <uuid>.raw via ONTAP API
67+
// ManagedNFS qcow2 (libvirt creates file) – just set metadata; no '.raw' extension
6968
cloudStackVolumeRequest = new CloudStackVolume();
70-
FileInfo file = new FileInfo();
71-
file.setUnixPermissions(644);
72-
file.setType(FileInfo.TypeEnum.FILE);
73-
Volume poolVolume = new Volume();
74-
poolVolume.setName(details.get(Constants.VOLUME_NAME));
75-
poolVolume.setUuid(details.get(Constants.VOLUME_UUID));
76-
cloudStackVolumeRequest.setVolume(poolVolume);
77-
cloudStackVolumeRequest.setFile(file);
78-
cloudStackVolumeRequest.setCloudstackVolName(volumeObject.getUuid() + ".raw");
69+
Volume poolVol = new Volume();
70+
poolVol.setName(details.get(Constants.VOLUME_NAME));
71+
poolVol.setUuid(details.get(Constants.VOLUME_UUID));
72+
cloudStackVolumeRequest.setVolume(poolVol);
73+
cloudStackVolumeRequest.setCloudstackVolName(volumeObject.getUuid());
7974
break;
8075
case ISCSI:
8176
cloudStackVolumeRequest = new CloudStackVolume();

0 commit comments

Comments
 (0)