Skip to content

Commit 63addcd

Browse files
Locharla, SandeepLocharla, Sandeep
authored andcommitted
CSTACKEX-46: Fixed a couple of issues observed while testing NFS3 storagePool create and delete
1 parent 3eea5c4 commit 63addcd

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,20 @@ private boolean validateProtocolSupportAndFetchHostsIdentifier(List<HostVO> host
415415
hostIdentifiers.add(host.getStorageUrl());
416416
}
417417
break;
418+
case NFS3:
419+
String ip = "";
420+
for (HostVO host : hosts) {
421+
if (host != null) {
422+
ip = host.getStorageIpAddress() != null ? host.getStorageIpAddress().trim() : "";
423+
if (ip.isEmpty() && host.getPrivateIpAddress() != null || host.getPrivateIpAddress().trim().isEmpty()) {
424+
return false;
425+
} else {
426+
ip = ip.isEmpty() ? host.getPrivateIpAddress().trim() : ip;
427+
}
428+
}
429+
hostIdentifiers.add(ip);
430+
}
431+
break;
418432
default:
419433
throw new CloudRuntimeException("validateProtocolSupportAndFetchHostsIdentifier : Unsupported protocol: " + protocolType.name());
420434
}
@@ -471,15 +485,6 @@ public boolean deleteDataStore(DataStore store) {
471485
PrimaryDataStoreInfo primaryDataStoreInfo = (PrimaryDataStoreInfo) store;
472486
primaryDataStoreInfo.setDetails(details);
473487

474-
// Create AccessGroup object with PrimaryDataStoreInfo
475-
AccessGroup accessGroup = new AccessGroup();
476-
accessGroup.setPrimaryDataStoreInfo(primaryDataStoreInfo);
477-
478-
// Call deleteAccessGroup - it will figure out scope, protocol, and all details internally
479-
storageStrategy.deleteAccessGroup(accessGroup);
480-
481-
s_logger.info("deleteDataStore: Successfully deleted access groups for storage pool '{}'", storagePool.getName());
482-
483488
// Call deleteStorageVolume to delete the underlying ONTAP volume
484489
s_logger.info("deleteDataStore: Deleting ONTAP volume for storage pool '{}'", storagePool.getName());
485490
Volume volume = new Volume();
@@ -497,6 +502,11 @@ public boolean deleteDataStore(DataStore store) {
497502
s_logger.error("deleteDataStore: Exception while retrieving volume UUID for storage pool id: {}. Error: {}",
498503
storagePoolId, e.getMessage(), e);
499504
}
505+
AccessGroup accessGroup = new AccessGroup();
506+
accessGroup.setPrimaryDataStoreInfo(primaryDataStoreInfo);
507+
// Delete access groups associated with this storage pool
508+
storageStrategy.deleteAccessGroup(accessGroup);
509+
s_logger.info("deleteDataStore: Successfully deleted access groups for storage pool '{}'", storagePool.getName());
500510

501511
} catch (Exception e) {
502512
s_logger.error("deleteDataStore: Failed to delete access groups for storage pool id: {}. Error: {}",

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,19 @@ public String getNetworkInterface() {
447447
OntapResponse<IpInterface> response =
448448
networkFeignClient.getNetworkIpInterfaces(authHeader, queryParams);
449449
if (response != null && response.getRecords() != null && !response.getRecords().isEmpty()) {
450-
// For simplicity, return the first interface's name
451-
IpInterface ipInterface = response.getRecords().get(0);
450+
IpInterface ipInterface = null;
451+
// For simplicity, return the first interface's name (Of IPv4 type for NFS3)
452+
if (storage.getProtocol() == ProtocolType.ISCSI) {
453+
ipInterface = response.getRecords().get(0);
454+
} else if (storage.getProtocol() == ProtocolType.NFS3) {
455+
for (IpInterface iface : response.getRecords()) {
456+
if (iface.getIp().getAddress().contains(".")) {
457+
ipInterface = iface;
458+
break;
459+
}
460+
}
461+
}
462+
452463
s_logger.info("Retrieved network interface: " + ipInterface.getIp().getAddress());
453464
return ipInterface.getIp().getAddress();
454465
} else {

0 commit comments

Comments
 (0)