Skip to content

Commit 982843b

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
"Update code as per coding principle"
1 parent 0064390 commit 982843b

File tree

9 files changed

+110
-372
lines changed

9 files changed

+110
-372
lines changed

plugins/storage/volume/ontap/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<parent>
2525
<groupId>org.apache.cloudstack</groupId>
2626
<artifactId>cloudstack-plugins</artifactId>
27-
<version>4.22.0.0-SNAPSHOT</version>
27+
<version>4.23.0.0-SNAPSHOT</version>
2828
<relativePath>../../../pom.xml</relativePath>
2929
</parent>
3030
<properties>

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

Lines changed: 19 additions & 236 deletions
Large diffs are not rendered by default.

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/FeignConfiguration.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,9 @@ public Object decode(Response response, Type type) throws IOException, DecodeExc
144144
try (InputStream bodyStream = response.body().asInputStream()) {
145145
json = new String(bodyStream.readAllBytes(), StandardCharsets.UTF_8);
146146
logger.debug("Decoding JSON response: {}", json);
147-
logger.debug("Target type: {}", type);
148-
logger.debug("About to call jsonMapper.readValue()...");
149-
150147
Object result = null;
151148
try {
152-
logger.debug("Calling jsonMapper.constructType()...");
153149
var javaType = jsonMapper.getTypeFactory().constructType(type);
154-
logger.debug("constructType() returned: {}", javaType);
155-
156-
logger.debug("Calling jsonMapper.readValue() with json and javaType...");
157150
result = jsonMapper.readValue(json, javaType);
158151
logger.debug("jsonMapper.readValue() completed successfully");
159152
} catch (Throwable ex) {

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,7 @@ 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 (not ManagedNFS) with managed=true
196-
// This routes to LibvirtStorageAdaptor which has full qemu-img support
197-
// Same pattern as CloudByte/Elastistor plugin
198195
parameters.setType(Storage.StoragePoolType.NetworkFilesystem);
199-
// Path should be just the NFS export path (junction path), NOT host:path
200-
// CloudStack will construct the full mount path as: hostAddress + ":" + path
201196
path = "/" + storagePoolName;
202197
s_logger.info("Setting NFS path for storage pool: " + path);
203198
host = "10.193.192.136"; // TODO hardcoded for now
@@ -233,9 +228,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
233228
s_logger.error("createStorageVolume returned null for volume: " + storagePoolName);
234229
throw new CloudRuntimeException("Failed to create ONTAP volume: " + storagePoolName);
235230
}
236-
237231
s_logger.info("Volume object retrieved successfully. UUID: " + volume.getUuid() + ", Name: " + volume.getName());
238-
239232
details.putIfAbsent(Constants.VOLUME_UUID, volume.getUuid());
240233
details.putIfAbsent(Constants.VOLUME_NAME, volume.getName());
241234
} catch (Exception e) {
@@ -246,10 +239,6 @@ public DataStore initialize(Map<String, Object> dsInfos) {
246239
throw new CloudRuntimeException("ONTAP details validation failed, cannot create primary storage");
247240
}
248241

249-
// Add mountpoint detail for ManagedNFS - required by KVM agent's ManagedNfsStorageAdaptor
250-
// The 'mountpoint' key is used by connectPhysicalDisk() to mount NFS export
251-
details.put("mountpoint", path);
252-
253242
// Set parameters for primary data store
254243
parameters.setPort(Constants.ONTAP_PORT);
255244
parameters.setHost(host);
@@ -293,7 +282,6 @@ public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
293282

294283
logger.debug("attachCluster: Attaching the pool to each of the host in the cluster: {}", primaryStore.getClusterId());
295284
for (HostVO host : hostsToConnect) {
296-
// TODO: Fetch the host IQN and add to the initiator group on ONTAP cluster
297285
try {
298286
_storageMgr.connectHostToSharedPool(host, dataStore.getId());
299287
} catch (Exception e) {
@@ -330,7 +318,6 @@ public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.Hyper
330318
strategy.createAccessGroup(accessGroupRequest);
331319

332320
for (HostVO host : hostsToConnect) {
333-
// TODO: Fetch the host IQN and add to the initiator group on ONTAP cluster
334321
try {
335322
_storageMgr.connectHostToSharedPool(host, dataStore.getId());
336323
} catch (Exception e) {

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
3939
import com.cloud.host.dao.HostDao;
4040

41-
/**
42-
* HypervisorHostListener implementation for ONTAP storage.
43-
* Handles connecting/disconnecting hosts to/from ONTAP-backed storage pools.
44-
*/
4541
public class OntapHostListener implements HypervisorHostListener {
4642
protected Logger logger = LogManager.getLogger(getClass());
4743

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,15 @@ public Volume createStorageVolume(String volumeName, Long size) {
150150
Volume volumeRequest = new Volume();
151151
Svm svm = new Svm();
152152
svm.setName(svmName);
153-
154153
Nas nas = new Nas();
155-
nas.setPath("/" + volumeName);
154+
nas.setPath(Constants.PATH_SEPARATOR + volumeName);
156155

157156
volumeRequest.setName(volumeName);
158157
volumeRequest.setSvm(svm);
159158
volumeRequest.setAggregates(aggregates);
160159
volumeRequest.setSize(size);
161-
volumeRequest.setNas(nas); // be default if we don't set path , ONTAP create a volume with mount/junction path // TODO check if we need to append svm name or not
162-
// since storage pool also cannot be duplicate so junction path can also be not duplicate so /volumeName will always be unique
163-
// Make the POST API call to create the volume
160+
volumeRequest.setNas(nas);
164161
try {
165-
/*
166-
ONTAP created a default rule of 0.0.0.0 if no export rule are defined while creating volume
167-
and since in storage pool creation, cloudstack is not aware of the host , we can either create default or
168-
permissive rule and later update it as part of attachCluster or attachZone implementation
169-
*/
170162
JobResponse jobResponse = volumeFeignClient.createVolumeWithJob(authHeader, volumeRequest);
171163
if (jobResponse == null || jobResponse.getJob() == null) {
172164
throw new CloudRuntimeException("Failed to initiate volume creation for " + volumeName);
@@ -201,7 +193,6 @@ public Volume createStorageVolume(String volumeName, Long size) {
201193
throw new CloudRuntimeException("Failed to create volume: " + e.getMessage());
202194
}
203195
s_logger.info("Volume created successfully: " + volumeName);
204-
// Below code is to update volume uuid to storage pool mapping once and used for all other workflow saving get volume call
205196
try {
206197
Map<String, Object> queryParams = Map.of(Constants.NAME, volumeName);
207198
s_logger.debug("Fetching volume details for: " + volumeName);

0 commit comments

Comments
 (0)