From c66089509c8d60cfad1dfc41b0aeaaf5e682b78d Mon Sep 17 00:00:00 2001 From: "Srivastava, Piyush" Date: Tue, 17 Nov 2026 11:00:07 +0530 Subject: [PATCH 1/4] resolve conflicts --- .../driver/OntapPrimaryDatastoreDriver.java | 13 ++- .../cloudstack/storage/feign/model/Svm.java | 38 ++++++- .../OntapPrimaryDatastoreLifecycle.java | 20 ++-- .../storage/listener/OntapHostListener.java | 23 ++-- .../provider/StorageProviderFactory.java | 1 + .../storage/service/StorageStrategy.java | 21 +++- .../storage/service/UnifiedNASStrategy.java | 16 ++- .../service/model/NfsProtocolSpec.java | 100 ++++++++++++++++++ .../storage/service/model/ProtocolType.java | 1 + .../storage/utils/OntapStorageConstants.java | 18 +++- ui/src/views/infra/AddPrimaryStorage.vue | 2 +- .../infra/zone/ZoneWizardAddResources.vue | 3 +- 12 files changed, 225 insertions(+), 31 deletions(-) create mode 100644 plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/NfsProtocolSpec.java diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java index 2bc06c12ca6d..e655e8779894 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java @@ -18,6 +18,7 @@ */ package org.apache.cloudstack.storage.driver; +import org.apache.cloudstack.storage.service.model.NfsProtocolSpec; import org.apache.cloudstack.storage.utils.OntapStorageConstants; import com.cloud.agent.api.Answer; import com.cloud.agent.api.to.DataObjectType; @@ -80,6 +81,7 @@ import org.apache.cloudstack.storage.service.UnifiedSANStrategy; import org.apache.cloudstack.storage.service.model.AccessGroup; import org.apache.cloudstack.storage.service.model.CloudStackVolume; +import org.apache.cloudstack.storage.service.model.NfsProtocolSpec; import org.apache.cloudstack.storage.service.model.ProtocolType; import org.apache.cloudstack.storage.to.SnapshotObjectTO; import org.apache.cloudstack.storage.utils.OntapStorageUtils; @@ -277,7 +279,7 @@ private CreateCmdResult recordCreatedVolume(StoragePoolVO storagePool, VolumeInf logger.info("createAsync: Created LUN [{}] for volume [{}]. LUN mapping will occur during grantAccess() to per-host igroup.", lunName, volumeVO.getId()); createCmdResult = new CreateCmdResult(lunName, new Answer(null, true, null)); - } else if (ProtocolType.NFS3.name().equalsIgnoreCase(details.get(OntapStorageConstants.PROTOCOL))) { + }else if (NfsProtocolSpec.isNfs(details.get(OntapStorageConstants.PROTOCOL))) { createCmdResult = new CreateCmdResult(volInfo.getUuid(), new Answer(null, true, null)); logger.info("createAsync: Managed NFS volume [{}] with path [{}] associated with pool {}", volumeVO.getId(), volInfo.getUuid(), storagePool.getId()); @@ -1279,8 +1281,8 @@ public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore if (ProtocolType.ISCSI.name().equalsIgnoreCase(details.get(OntapStorageConstants.PROTOCOL))) { // Only retrieve LUN name for iSCSI volumes grantAccessIscsi(host, volumeVO, details, svmName, storagePool); - } else if (ProtocolType.NFS3.name().equalsIgnoreCase(details.get(OntapStorageConstants.PROTOCOL))) { - // For NFS, no access grant needed - file is accessible via mount + } else if (NfsProtocolSpec.isNfs(details.get(OntapStorageConstants.PROTOCOL))) { + // For NFS (v3 or v4.1), no access grant needed - file is accessible via mount logger.debug("grantAccess: NFS volume [{}], no igroup mapping required", volumeVO.getUuid()); return true; } @@ -1948,8 +1950,8 @@ public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback poolDetails) { - if (ProtocolType.NFS3.name().equalsIgnoreCase(protocol)) { - // For NFS, use the volume's file path + if (NfsProtocolSpec.isNfs(protocol)) { + // For NFS (v3 or v4.1), use the volume's file path return volumeVO.getPath(); } else if (ProtocolType.ISCSI.name().equalsIgnoreCase(protocol)) { // For iSCSI, retrieve the LUN name from volume details @@ -2134,6 +2136,7 @@ private CloudStackVolume createDeleteCloudStackVolumeRequest(StoragePool storage ProtocolType protocolType = ProtocolType.valueOf(protocol); switch (protocolType) { case NFS3: + case NFS4_1: cloudStackVolumeDeleteRequest = new CloudStackVolume(); cloudStackVolumeDeleteRequest.setDatastoreId(String.valueOf(storagePool.getId())); cloudStackVolumeDeleteRequest.setVolumeInfo(volumeInfo); diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java index b1422ef9d333..83a974e2c615 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java @@ -47,6 +47,12 @@ public class Svm { @JsonIgnore private Boolean nfsEnabled = null; + @JsonIgnore + private Boolean nfsV41Enabled = null; + + @JsonIgnore + private String nfsV4IdDomain = null; + @JsonProperty("aggregates") private List aggregates = null; @@ -84,8 +90,38 @@ public void setNfsEnabled(Boolean nfsEnabled) { } @JsonSetter("nfs") + @SuppressWarnings("unchecked") public void setNfs(Map nfs) { - this.nfsEnabled = nfs != null ? Boolean.TRUE.equals(nfs.get("enabled")) : false; + if (nfs == null) { + this.nfsEnabled = false; + return; + } + this.nfsEnabled = Boolean.TRUE.equals(nfs.get("enabled")); + Object protocol = nfs.get("protocol"); + if (protocol instanceof Map) { + Map proto = (Map) protocol; + this.nfsV41Enabled = Boolean.TRUE.equals(proto.get("v41_enabled")); + } + Object idDomain = nfs.get("v4_id_domain"); + if (idDomain instanceof String) { + this.nfsV4IdDomain = (String) idDomain; + } + } + + public Boolean getNfsV41Enabled() { + return Boolean.TRUE.equals(nfsV41Enabled); + } + + public void setNfsV41Enabled(Boolean nfsV41Enabled) { + this.nfsV41Enabled = nfsV41Enabled; + } + + public String getNfsV4IdDomain() { + return nfsV4IdDomain; + } + + public void setNfsV4IdDomain(String nfsV4IdDomain) { + this.nfsV4IdDomain = nfsV4IdDomain; } public Boolean getIscsiEnabled() { diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java index 83b0c0223ea0..b5da9dc83ad7 100755 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java @@ -48,6 +48,7 @@ import org.apache.cloudstack.storage.provider.StorageProviderFactory; import org.apache.cloudstack.storage.service.StorageStrategy; import org.apache.cloudstack.storage.service.model.AccessGroup; +import org.apache.cloudstack.storage.service.model.NfsProtocolSpec; import org.apache.cloudstack.storage.service.model.ProtocolType; import org.apache.cloudstack.storage.utils.OntapStorageConstants; import org.apache.cloudstack.storage.utils.OntapStorageUtils; @@ -191,13 +192,16 @@ public DataStore initialize(Map dsInfos) { int port; switch (protocol) { case NFS3: + case NFS4_1: { + NfsProtocolSpec spec = NfsProtocolSpec.forProtocol(protocol); parameters.setType(Storage.StoragePoolType.NetworkFilesystem); path = OntapStorageConstants.SLASH + storagePoolName; - port = OntapStorageConstants.NFS3_PORT; - // Force NFSv3 for ONTAP managed storage to avoid NFSv4 ID mapping issues - details.put(ApiConstants.NFS_MOUNT_OPTIONS, OntapStorageConstants.NFS3_MOUNT_OPTIONS_VER_3); - logger.info("Setting NFS path for storage pool: " + path + ", port: " + port + " with mount option: vers=3"); + port = OntapStorageConstants.NFS_PORT; + details.put(ApiConstants.NFS_MOUNT_OPTIONS, spec.mountOptions()); + logger.info("Setting NFS path for storage pool: " + path + ", port: " + port + + " with mount option: " + spec.mountOptions()); break; + } case ISCSI: parameters.setType(Storage.StoragePoolType.OntapiSCSI); path = storageStrategy.getStoragePath(); @@ -431,6 +435,7 @@ private boolean validateProtocolSupportAndFetchHostsIdentifier(List host } break; case NFS3: + case NFS4_1: String ip = ""; for (HostVO host : hosts) { if (host != null) { @@ -453,13 +458,14 @@ private boolean validateProtocolSupportAndFetchHostsIdentifier(List host } /** - * Creates an NFS export policy (access group) on the ONTAP storage if the protocol is NFS3 - * and there are eligible hosts. Skipped for iSCSI (igroups are created per-host in grantAccess). + * Creates an NFS export policy (access group) on the ONTAP storage for any NFS pool + * (NFSv3 or NFSv4.1) when there are eligible hosts. Skipped for iSCSI (igroups are + * created per-host in grantAccess). */ private void createNfsAccessGroupIfNeeded(Map details, List hostsIdentifier, List hostsToConnect, Scope scope, StoragePoolVO storagePool, StorageStrategy strategy) { - if (!ProtocolType.NFS3.name().equalsIgnoreCase(details.get(OntapStorageConstants.PROTOCOL))) { + if (!NfsProtocolSpec.isNfs(details.get(OntapStorageConstants.PROTOCOL))) { return; } if (hostsIdentifier.isEmpty()) { diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java index f750e2904023..0090db9dce30 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java @@ -30,7 +30,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.service.StorageStrategy; import org.apache.cloudstack.storage.service.model.AccessGroup; -import org.apache.cloudstack.storage.service.model.ProtocolType; +import org.apache.cloudstack.storage.service.model.NfsProtocolSpec; import org.apache.cloudstack.storage.utils.OntapStorageConstants; import org.apache.cloudstack.storage.utils.OntapStorageUtils; import org.apache.commons.lang3.StringUtils; @@ -101,7 +101,7 @@ public boolean hostConnect(long hostId, long poolId) { return false; } - // Update NFS export policy for this connected host when the pool protocol is NFS3. + // Update NFS export policy for this connected host when the pool protocol is NFS (v3 or v4.1). updateNfsExportPolicyForConnectedHostIfNeeded(poolId, hostId, host, detailsMap); // Create the ModifyStoragePoolCommand to send to the agent @@ -173,11 +173,11 @@ public boolean hostConnect(long hostId, long poolId) { } private void updateNfsExportPolicyForConnectedHostIfNeeded(long poolId, long hostId, Host host, Map detailsMap) { - if (!ProtocolType.NFS3.name().equalsIgnoreCase(detailsMap.get(OntapStorageConstants.PROTOCOL))) { + if (!NfsProtocolSpec.isNfs(detailsMap.get(OntapStorageConstants.PROTOCOL))) { return; } - if (!isNfs3EnabledOnHost(host)) { + if (!isNfsEnabledOnHost(host)) { throw new CloudRuntimeException("NFS protocol is not enabled on host with id: " + hostId); } @@ -190,14 +190,19 @@ private void updateNfsExportPolicyForConnectedHostIfNeeded(long poolId, long hos logger.info("hostConnect: updateNfsExportPolicyForConnectedHostIfNeeded: Updated NFS export policy rules for host {} on storage pool {}", host.getName(), poolId); } - private boolean isNfs3EnabledOnHost(Host host) { + /** + * The eligibility check is identical for NFSv3 and NFSv4.1 — presence of a storage or + * private IP the SVM export rule can match on. Kernel version negotiation happens + * at mount time on the KVM host. + */ + private boolean isNfsEnabledOnHost(Host host) { if (host == null) { return false; } String storageIp = host.getStorageIpAddress() != null ? host.getStorageIpAddress().trim() : ""; if (storageIp.isEmpty() && StringUtils.isBlank(host.getPrivateIpAddress())) { - logger.warn("isNfs3EnabledOnHost: Host {} is not eligible for NFS3 protocol: both storage IP and private IP are empty", + logger.warn("isNfsEnabledOnHost: Host {} is not eligible for NFS: both storage IP and private IP are empty", host.getId()); return false; } @@ -252,13 +257,13 @@ private void removeHostFromOntapPoolIfNeeded(StoragePoolVO pool, Host host) { return; } - // Skip non-NFS3 pools; Currently, for iSCSI type, iGroup rules are being handled as part of revokeAccess in OntapPrimaryDataStoreDriver, so no need to handle here. - if (!ProtocolType.NFS3.name().equalsIgnoreCase(detailsMap.get(OntapStorageConstants.PROTOCOL))) { + // Skip non-NFS pools; for iSCSI, iGroup rules are handled in revokeAccess inside the driver. + if (!NfsProtocolSpec.isNfs(detailsMap.get(OntapStorageConstants.PROTOCOL))) { return; } logger.info("hostAboutToBeRemoved: removeHostFromOntapPoolIfNeeded: Removing export policy rule for host {} from storage pool {}", host.getName(), pool.getName()); - if (!isNfs3EnabledOnHost(host)) { + if (!isNfsEnabledOnHost(host)) { logger.warn("hostAboutToBeRemoved: removeHostFromOntapPoolIfNeeded: Skipping NFS export policy removal for host {} on pool {} as host is not NFS-enabled", host.getId(), pool.getId()); return; diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/provider/StorageProviderFactory.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/provider/StorageProviderFactory.java index 935e1284de42..1e7089610ce2 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/provider/StorageProviderFactory.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/provider/StorageProviderFactory.java @@ -49,6 +49,7 @@ public static StorageStrategy getStrategy(OntapStorage ontapStorage) { protocol); switch (protocol) { case NFS3: + case NFS4_1: UnifiedNASStrategy unifiedNASStrategy = new UnifiedNASStrategy(ontapStorage); ComponentContext.inject(unifiedNASStrategy); return unifiedNASStrategy; diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index a19a90c59641..853b59399ab6 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -306,9 +306,14 @@ public boolean connect(boolean validateAggregatesForVolumeCreation) { // Call the SVM API to check if the SVM exists Svm svm = new Svm(); logger.info("Fetching the SVM details..."); + // Request both the top-level nfs.enabled flag and the nested v41 flag so a single + // SVM GET gates NFSv3 and NFSv4.1 pool creation without a second REST round-trip. Map queryParams = Map.of(OntapStorageConstants.NAME, svmName, OntapStorageConstants.FIELDS, OntapStorageConstants.AGGREGATES + OntapStorageConstants.COMMA + OntapStorageConstants.STATE + - OntapStorageConstants.COMMA + OntapStorageConstants.NFS_ENABLED + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI_ENABLED); + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_ENABLED + + OntapStorageConstants.COMMA + OntapStorageConstants.SVM_FIELD_NFS_V41_ENABLED + + OntapStorageConstants.COMMA + OntapStorageConstants.SVM_FIELD_NFS_V4_ID_DOMAIN + + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI_ENABLED); OntapResponse svms = svmFeignClient.getSvmResponse(queryParams, authHeader); if (svms != null && svms.getRecords() != null && !svms.getRecords().isEmpty()) { svm = svms.getRecords().get(0); @@ -325,6 +330,16 @@ public boolean connect(boolean validateAggregatesForVolumeCreation) { if (Objects.equals(storage.getProtocol(), ProtocolType.NFS3) && !svm.getNfsEnabled()) { logger.error("NFS protocol is not enabled on SVM " + svmName); throw new CloudRuntimeException("NFS protocol is not enabled on SVM " + svmName); + } else if (Objects.equals(storage.getProtocol(), ProtocolType.NFS4_1)) { + if (!svm.getNfsEnabled()) { + logger.error("NFS protocol is not enabled on SVM " + svmName); + throw new CloudRuntimeException("NFS protocol is not enabled on SVM " + svmName); + } + if (!svm.getNfsV41Enabled()) { + logger.error("NFSv4.1 is not enabled on SVM " + svmName + + " (nfs.protocol.v41_enabled=false). Enable it via PATCH /protocols/nfs/services/{uuid}."); + throw new CloudRuntimeException("NFSv4.1 is not enabled on SVM " + svmName); + } } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { logger.error("ISCSI protocol is not enabled on SVM " + svmName); throw new CloudRuntimeException("ISCSI protocol is not enabled on SVM " + svmName); @@ -717,7 +732,8 @@ public String getStoragePath() { logger.info("Retrieved iSCSI target IQN: {}", targetIqn); return targetIqn; - } else if (storage.getProtocol() == ProtocolType.NFS3) { + } else if (storage.getProtocol() == ProtocolType.NFS3 + || storage.getProtocol() == ProtocolType.NFS4_1) { // TODO: Implement NFS path retrieval logic } else { throw new CloudRuntimeException("Unsupported protocol for path retrieval: " + storage.getProtocol()); @@ -761,6 +777,7 @@ public Map getNetworkInterface(Aggregate aggregate) { if (storage.getProtocol() != null) { switch (storage.getProtocol()) { case NFS3: + case NFS4_1: queryParams.put(OntapStorageConstants.SERVICES, OntapStorageConstants.DATA_NFS); break; case ISCSI: diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java index 7973412feb5e..c0bc0c428954 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java @@ -51,6 +51,8 @@ import org.apache.cloudstack.storage.feign.model.response.OntapResponse; import org.apache.cloudstack.storage.service.model.AccessGroup; import org.apache.cloudstack.storage.service.model.CloudStackVolume; +import org.apache.cloudstack.storage.service.model.NfsProtocolSpec; +import org.apache.cloudstack.storage.service.model.ProtocolType; import org.apache.cloudstack.storage.utils.OntapStorageConstants; import org.apache.cloudstack.storage.utils.OntapStorageUtils; import org.apache.cloudstack.storage.volume.VolumeObject; @@ -617,10 +619,16 @@ private ExportPolicy createExportPolicyRequest(AccessGroup accessGroup,String sv exportClients.add(exportClient); } exportRule.setClients(exportClients); - exportRule.setProtocols(List.of(ExportRule.ProtocolsEnum.NFS3)); - exportRule.setRoRule(List.of("sys")); - exportRule.setRwRule(List.of("sys")); - exportRule.setSuperuser(List.of("sys")); + NfsProtocolSpec nfsSpec = NfsProtocolSpec.forProtocol(storage.getProtocol()); + exportRule.setProtocols(List.of(nfsSpec.exportToken())); + exportRule.setRoRule(List.of(OntapStorageConstants.EXPORT_AUTH_SYS)); + exportRule.setRwRule(List.of(OntapStorageConstants.EXPORT_AUTH_SYS)); + exportRule.setSuperuser(List.of(OntapStorageConstants.EXPORT_AUTH_SYS)); + if (storage.getProtocol() == ProtocolType.NFS4_1) { + // Safety net when the SVM does not have v4_numeric_ids on and KVM-host idmapd + // domain does not match: root (uid 0) continues to work on the mount. + exportRule.setAnonymousUser(OntapStorageConstants.EXPORT_ANONYMOUS_ROOT); + } rules.add(exportRule); Svm svm = new Svm(); diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/NfsProtocolSpec.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/NfsProtocolSpec.java new file mode 100644 index 000000000000..eb5d3e408832 --- /dev/null +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/NfsProtocolSpec.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cloudstack.storage.service.model; + +import org.apache.cloudstack.storage.feign.model.ExportRule; + +/** + * Three-way translation for a single CloudStack NFS {@link ProtocolType}: + * the ONTAP REST export-rule token, the Linux mount option, and the SVM + * capability field that gates pool creation. + * + *

One place to change when adding a new NFS variant (v4.2, Kerberized v4.1, + * etc.) so the driver, lifecycle, host listener, and export-policy builder all + * stay in agreement.

+ */ +public final class NfsProtocolSpec { + + public static final NfsProtocolSpec NFS3 = new NfsProtocolSpec( + ProtocolType.NFS3, + ExportRule.ProtocolsEnum.NFS3, + "vers=3", + "nfs.enabled"); + + public static final NfsProtocolSpec NFS4_1 = new NfsProtocolSpec( + ProtocolType.NFS4_1, + ExportRule.ProtocolsEnum.NFS4, + "vers=4.1", + "nfs.protocol.v41_enabled"); + + private final ProtocolType protocol; + private final ExportRule.ProtocolsEnum exportToken; + private final String mountOptions; + private final String svmCapabilityField; + + private NfsProtocolSpec(ProtocolType protocol, + ExportRule.ProtocolsEnum exportToken, + String mountOptions, + String svmCapabilityField) { + this.protocol = protocol; + this.exportToken = exportToken; + this.mountOptions = mountOptions; + this.svmCapabilityField = svmCapabilityField; + } + + public ProtocolType protocol() { + return protocol; + } + + public ExportRule.ProtocolsEnum exportToken() { + return exportToken; + } + + public String mountOptions() { + return mountOptions; + } + + public String svmCapabilityField() { + return svmCapabilityField; + } + + public static NfsProtocolSpec forProtocol(ProtocolType protocol) { + switch (protocol) { + case NFS3: + return NFS3; + case NFS4_1: + return NFS4_1; + default: + throw new IllegalArgumentException("Not an NFS protocol: " + protocol); + } + } + + public static boolean isNfs(ProtocolType protocol) { + return protocol == ProtocolType.NFS3 || protocol == ProtocolType.NFS4_1; + } + + public static boolean isNfs(String protocolName) { + if (protocolName == null) { + return false; + } + return ProtocolType.NFS3.name().equalsIgnoreCase(protocolName) + || ProtocolType.NFS4_1.name().equalsIgnoreCase(protocolName); + } +} diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/ProtocolType.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/ProtocolType.java index 00dca62480dc..a09d2b6ee860 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/ProtocolType.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/model/ProtocolType.java @@ -21,5 +21,6 @@ public enum ProtocolType { NFS3, + NFS4_1, ISCSI } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java index c12fe7325761..8b878e86ccbe 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java @@ -25,7 +25,11 @@ public class OntapStorageConstants { /** Same as {@link DataStoreProvider#ONTAP_PLUGIN_NAME}; retained for existing ONTAP plugin call sites. */ public static final String ONTAP_PLUGIN_NAME = DataStoreProvider.ONTAP_PLUGIN_NAME; - public static final int NFS3_PORT = 2049; + /** NFS wire port — identical for v3 and v4.1. */ + public static final int NFS_PORT = 2049; + /** @deprecated use {@link #NFS_PORT}; kept for source compatibility. */ + @Deprecated + public static final int NFS3_PORT = NFS_PORT; public static final int ISCSI_PORT = 3260; public static final String NFS = "nfs"; @@ -49,6 +53,18 @@ public class OntapStorageConstants { public static final String RUNNING = "running"; public static final String EXPORT = "export"; public static final String NFS3_MOUNT_OPTIONS_VER_3 = "vers=3"; + public static final String NFS4_1_MOUNT_OPTIONS = "vers=4.1"; + + /** SVM REST field: top-level NFS enabled flag (any version). */ + public static final String SVM_FIELD_NFS_ENABLED = "nfs.enabled"; + /** SVM REST field: NFSv4.1 protocol enablement nested under {@code nfs.protocol}. */ + public static final String SVM_FIELD_NFS_V41_ENABLED = "nfs.protocol.v41_enabled"; + /** SVM REST field: ID-mapping domain used when numeric-ids is off. */ + public static final String SVM_FIELD_NFS_V4_ID_DOMAIN = "nfs.v4_id_domain"; + /** Export rule superuser/ro/rw auth value. */ + public static final String EXPORT_AUTH_SYS = "sys"; + /** Export rule anonymous-user fallback for NFSv4.1 pools (root). */ + public static final String EXPORT_ANONYMOUS_ROOT = "0"; public static final int ONTAP_PORT = 443; diff --git a/ui/src/views/infra/AddPrimaryStorage.vue b/ui/src/views/infra/AddPrimaryStorage.vue index e5d9e6aa81af..b045f411d9db 100644 --- a/ui/src/views/infra/AddPrimaryStorage.vue +++ b/ui/src/views/infra/AddPrimaryStorage.vue @@ -839,7 +839,7 @@ export default { this.protocols = ['FiberChannel'] this.form.protocol = 'FiberChannel' } else if (value === 'NetApp ONTAP') { - this.protocols = ['NFS3', 'ISCSI'] + this.protocols = ['NFS3', 'NFS4_1', 'ISCSI'] this.form.protocol = 'NFS3' } else { this.fetchHypervisor(value) diff --git a/ui/src/views/infra/zone/ZoneWizardAddResources.vue b/ui/src/views/infra/zone/ZoneWizardAddResources.vue index faf9a10679f6..075f64ad3ccc 100644 --- a/ui/src/views/infra/zone/ZoneWizardAddResources.vue +++ b/ui/src/views/infra/zone/ZoneWizardAddResources.vue @@ -1059,9 +1059,10 @@ export default { if (provider === 'NetApp ONTAP') { this.primaryStorageProtocols = [ { id: 'NFS3', description: 'NFS3' }, + { id: 'NFS4_1', description: 'NFS 4.1' }, { id: 'ISCSI', description: 'ISCSI' } ] - if (!['NFS3', 'ISCSI'].includes(this.prefillContent?.primaryStorageProtocol)) { + if (!['NFS3', 'NFS4_1', 'ISCSI'].includes(this.prefillContent?.primaryStorageProtocol)) { this.$emit('fieldsChanged', { primaryStorageProtocol: 'NFS3' }) } return From daca336c02f8947e30beb4a9bcebb4d35623a3e9 Mon Sep 17 00:00:00 2001 From: "Srivastava, Piyush" Date: Tue, 17 Nov 2026 11:07:38 +0530 Subject: [PATCH 2/4] resolve conflicts 1 --- .../storage/driver/OntapPrimaryDatastoreDriver.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java index e655e8779894..df1ddeeb4724 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java @@ -18,7 +18,6 @@ */ package org.apache.cloudstack.storage.driver; -import org.apache.cloudstack.storage.service.model.NfsProtocolSpec; import org.apache.cloudstack.storage.utils.OntapStorageConstants; import com.cloud.agent.api.Answer; import com.cloud.agent.api.to.DataObjectType; @@ -1079,7 +1078,7 @@ private CopyCommandResult copySnapshotToTemporaryVolume(DataObject srcData, Volu logger.info("copySnapshotToTemporaryVolume: Cloning CS snapshot [{}] into temporary volume [{}] on pool [{}] for template creation", srcData.getId(), volInfo.getId(), storagePool.getId()); CloudStackVolume cloned = cloneCloudStackVolumeFromSnapshot(storagePool, volInfo, details, srcData.getId(), false); - if (ProtocolType.NFS3.name().equalsIgnoreCase(details.get(OntapStorageConstants.PROTOCOL))) { + if (NfsProtocolSpec.isNfs(details.get(OntapStorageConstants.PROTOCOL))) { volumeVO.setPath(volInfo.getUuid()); } recordCreatedVolume(storagePool, volInfo, volumeVO, details, cloned); @@ -2185,6 +2184,7 @@ private CloudStackVolume resizeCloudStackVolumeRequest(Map detai ProtocolType protocolType = ProtocolType.valueOf(protocol); switch (protocolType) { case NFS3: + case NFS4_1: FileInfo fileInfo = new FileInfo(); fileInfo.setQosPolicy(qosPolicyReference); resizeRequest.setFile(fileInfo); @@ -2222,6 +2222,7 @@ private CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePoolVO s ProtocolType protocolType = ProtocolType.valueOf(protocol); switch (protocolType) { case NFS3: + case NFS4_1: CloudStackVolume nfsRequest = new CloudStackVolume(); nfsRequest.setDatastoreId(String.valueOf(storagePool.getId())); nfsRequest.setFlexVolumeUuid(details.get(OntapStorageConstants.VOLUME_UUID)); From 0b74f1330b15066a0eed6634ccb393b4394c9614 Mon Sep 17 00:00:00 2001 From: "Srivastava, Piyush" Date: Mon, 23 Nov 2026 11:27:52 +0530 Subject: [PATCH 3/4] correctng the right v4 api for svm --- .../storage/feign/client/NASFeignClient.java | 9 ++ .../storage/feign/model/NfsService.java | 109 ++++++++++++++++++ .../cloudstack/storage/feign/model/Svm.java | 38 +----- .../storage/service/StorageStrategy.java | 55 +++++++-- .../storage/utils/OntapStorageConstants.java | 12 +- 5 files changed, 172 insertions(+), 51 deletions(-) create mode 100644 plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/NfsService.java diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java index ba38f57ef1c7..74af9b3e0e48 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.storage.feign.model.ExportPolicy; import org.apache.cloudstack.storage.feign.model.FileCloneRequest; import org.apache.cloudstack.storage.feign.model.FileInfo; +import org.apache.cloudstack.storage.feign.model.NfsService; import org.apache.cloudstack.storage.feign.model.response.JobResponse; import org.apache.cloudstack.storage.feign.model.response.OntapResponse; import feign.Headers; @@ -94,4 +95,12 @@ void deleteExportPolicyById(@Param("authHeader") String authHeader, OntapResponse updateExportPolicy(@Param("authHeader") String authHeader, @Param("id") String id, ExportPolicy request); + + // NFS Service Operations — v4.x enablement / ID mapping config lives here, + // NOT on /api/svm/svms (which only exposes nfs.enabled). + @RequestLine("GET /api/protocols/nfs/services/{svmUuid}") + @Headers({"Authorization: {authHeader}"}) + NfsService getNfsService(@Param("authHeader") String authHeader, + @Param("svmUuid") String svmUuid, + @QueryMap Map queryMap); } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/NfsService.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/NfsService.java new file mode 100644 index 000000000000..22449356e4da --- /dev/null +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/NfsService.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cloudstack.storage.feign.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represents ONTAP REST {@code /api/protocols/nfs/services/{svm.uuid}}: the per-SVM + * NFS service document. Carries v4.x enablement and ID-mapping configuration that + * is NOT addressable on the {@code /api/svm/svms} endpoint. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NfsService { + + @JsonProperty("enabled") + private Boolean enabled; + + @JsonProperty("protocol") + private Protocol protocol; + + public Boolean getEnabled() { + return Boolean.TRUE.equals(enabled); + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Protocol getProtocol() { + return protocol; + } + + public void setProtocol(Protocol protocol) { + this.protocol = protocol; + } + + public boolean isV41Enabled() { + return protocol != null && Boolean.TRUE.equals(protocol.v41Enabled); + } + + public boolean isV4NumericIds() { + return protocol != null && Boolean.TRUE.equals(protocol.v4NumericIds); + } + + public String getV4IdDomain() { + return protocol != null ? protocol.v4IdDomain : null; + } + + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Protocol { + + @JsonProperty("v3_enabled") + private Boolean v3Enabled; + + @JsonProperty("v40_enabled") + private Boolean v40Enabled; + + @JsonProperty("v41_enabled") + private Boolean v41Enabled; + + @JsonProperty("v41_pnfs_enabled") + private Boolean v41PnfsEnabled; + + @JsonProperty("v4_id_domain") + private String v4IdDomain; + + @JsonProperty("v4_numeric_ids") + private Boolean v4NumericIds; + + public Boolean getV3Enabled() { return v3Enabled; } + public void setV3Enabled(Boolean v3Enabled) { this.v3Enabled = v3Enabled; } + + public Boolean getV40Enabled() { return v40Enabled; } + public void setV40Enabled(Boolean v40Enabled) { this.v40Enabled = v40Enabled; } + + public Boolean getV41Enabled() { return v41Enabled; } + public void setV41Enabled(Boolean v41Enabled) { this.v41Enabled = v41Enabled; } + + public Boolean getV41PnfsEnabled() { return v41PnfsEnabled; } + public void setV41PnfsEnabled(Boolean v41PnfsEnabled) { this.v41PnfsEnabled = v41PnfsEnabled; } + + public String getV4IdDomain() { return v4IdDomain; } + public void setV4IdDomain(String v4IdDomain) { this.v4IdDomain = v4IdDomain; } + + public Boolean getV4NumericIds() { return v4NumericIds; } + public void setV4NumericIds(Boolean v4NumericIds) { this.v4NumericIds = v4NumericIds; } + } +} diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java index 83a974e2c615..b1422ef9d333 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java @@ -47,12 +47,6 @@ public class Svm { @JsonIgnore private Boolean nfsEnabled = null; - @JsonIgnore - private Boolean nfsV41Enabled = null; - - @JsonIgnore - private String nfsV4IdDomain = null; - @JsonProperty("aggregates") private List aggregates = null; @@ -90,38 +84,8 @@ public void setNfsEnabled(Boolean nfsEnabled) { } @JsonSetter("nfs") - @SuppressWarnings("unchecked") public void setNfs(Map nfs) { - if (nfs == null) { - this.nfsEnabled = false; - return; - } - this.nfsEnabled = Boolean.TRUE.equals(nfs.get("enabled")); - Object protocol = nfs.get("protocol"); - if (protocol instanceof Map) { - Map proto = (Map) protocol; - this.nfsV41Enabled = Boolean.TRUE.equals(proto.get("v41_enabled")); - } - Object idDomain = nfs.get("v4_id_domain"); - if (idDomain instanceof String) { - this.nfsV4IdDomain = (String) idDomain; - } - } - - public Boolean getNfsV41Enabled() { - return Boolean.TRUE.equals(nfsV41Enabled); - } - - public void setNfsV41Enabled(Boolean nfsV41Enabled) { - this.nfsV41Enabled = nfsV41Enabled; - } - - public String getNfsV4IdDomain() { - return nfsV4IdDomain; - } - - public void setNfsV4IdDomain(String nfsV4IdDomain) { - this.nfsV4IdDomain = nfsV4IdDomain; + this.nfsEnabled = nfs != null ? Boolean.TRUE.equals(nfs.get("enabled")) : false; } public Boolean getIscsiEnabled() { diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index 853b59399ab6..80e31a97e589 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -49,6 +49,7 @@ import org.apache.cloudstack.storage.feign.model.IscsiService; import org.apache.cloudstack.storage.feign.model.Job; import org.apache.cloudstack.storage.feign.model.Nas; +import org.apache.cloudstack.storage.feign.model.NfsService; import org.apache.cloudstack.storage.feign.model.OntapStorage; import org.apache.cloudstack.storage.feign.model.Svm; import org.apache.cloudstack.storage.feign.model.Version; @@ -303,16 +304,15 @@ public boolean connect(boolean validateAggregatesForVolumeCreation) { String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword()); String svmName = storage.getSvmName(); try { - // Call the SVM API to check if the SVM exists + // Call the SVM API to check if the SVM exists. + // Only enablement summary + aggregates/state live here; v4.x detail (v41_enabled, + // v4_id_domain, pNFS) is on /api/protocols/nfs/services/{svm.uuid} and is queried + // separately when the pool protocol is NFSv4.1. Svm svm = new Svm(); logger.info("Fetching the SVM details..."); - // Request both the top-level nfs.enabled flag and the nested v41 flag so a single - // SVM GET gates NFSv3 and NFSv4.1 pool creation without a second REST round-trip. Map queryParams = Map.of(OntapStorageConstants.NAME, svmName, OntapStorageConstants.FIELDS, OntapStorageConstants.AGGREGATES + OntapStorageConstants.COMMA + OntapStorageConstants.STATE + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_ENABLED + - OntapStorageConstants.COMMA + OntapStorageConstants.SVM_FIELD_NFS_V41_ENABLED + - OntapStorageConstants.COMMA + OntapStorageConstants.SVM_FIELD_NFS_V4_ID_DOMAIN + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI_ENABLED); OntapResponse svms = svmFeignClient.getSvmResponse(queryParams, authHeader); if (svms != null && svms.getRecords() != null && !svms.getRecords().isEmpty()) { @@ -335,11 +335,7 @@ public boolean connect(boolean validateAggregatesForVolumeCreation) { logger.error("NFS protocol is not enabled on SVM " + svmName); throw new CloudRuntimeException("NFS protocol is not enabled on SVM " + svmName); } - if (!svm.getNfsV41Enabled()) { - logger.error("NFSv4.1 is not enabled on SVM " + svmName - + " (nfs.protocol.v41_enabled=false). Enable it via PATCH /protocols/nfs/services/{uuid}."); - throw new CloudRuntimeException("NFSv4.1 is not enabled on SVM " + svmName); - } + validateNfs41OnSvm(authHeader, svmName, svm.getUuid()); } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { logger.error("ISCSI protocol is not enabled on SVM " + svmName); throw new CloudRuntimeException("ISCSI protocol is not enabled on SVM " + svmName); @@ -384,6 +380,45 @@ public void setAggregates(List aggregates) { this.aggregates = aggregates; } + /** + * Validates that NFSv4.1 is enabled on the SVM's NFS service. The v4.x enablement flag + * is NOT addressable on {@code /api/svm/svms}; it lives on + * {@code /api/protocols/nfs/services/{svm.uuid}}, so this is a second REST hop made + * only when the pool protocol is NFSv4.1. + * + *

Also surfaces the ID-mapping posture (numeric-ids on/off, v4_id_domain) in logs + * so support can read it back without a round-trip to ONTAP.

+ */ + private void validateNfs41OnSvm(String authHeader, String svmName, String svmUuid) { + if (svmUuid == null) { + throw new CloudRuntimeException("Cannot validate NFSv4.1 on SVM " + svmName + ": SVM UUID is null"); + } + Map queryParams = Map.of(OntapStorageConstants.FIELDS, + OntapStorageConstants.NFS_SERVICE_FIELD_ENABLED + + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_SERVICE_FIELD_V41_ENABLED + + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_SERVICE_FIELD_V4_ID_DOMAIN + + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_SERVICE_FIELD_V4_NUMERIC_IDS); + NfsService nfsService; + try { + nfsService = nasFeignClient.getNfsService(authHeader, svmUuid, queryParams); + } catch (FeignException e) { + logger.error("Failed to fetch NFS service for SVM " + svmName + " (uuid=" + svmUuid + "): " + e.getMessage(), e); + throw new CloudRuntimeException("Failed to fetch NFS service for SVM " + svmName + ": " + e.getMessage(), e); + } + if (nfsService == null || !nfsService.isV41Enabled()) { + logger.error("NFSv4.1 is not enabled on SVM " + svmName + + " (protocol.v41_enabled=false). Enable it via PATCH /protocols/nfs/services/" + svmUuid + "."); + throw new CloudRuntimeException("NFSv4.1 is not enabled on SVM " + svmName); + } + logger.info("NFSv4.1 enabled on SVM {} (uuid={}); v4_numeric_ids={}, v4_id_domain={}", + svmName, svmUuid, nfsService.isV4NumericIds(), nfsService.getV4IdDomain()); + if (!nfsService.isV4NumericIds()) { + logger.warn("SVM {} has v4_numeric_ids=false; verify that each KVM host's /etc/idmapd.conf Domain " + + "matches v4_id_domain='{}' or files will land as nobody:nobody.", + svmName, nfsService.getV4IdDomain()); + } + } + private void validateAndSelectAggregatesForVolumeCreation(String authHeader, String svmName, List aggrs) { if (aggrs == null || aggrs.isEmpty()) { logger.error("No aggregates are assigned to SVM " + svmName); diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java index 8b878e86ccbe..6ee4728c6dc9 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java @@ -57,10 +57,14 @@ public class OntapStorageConstants { /** SVM REST field: top-level NFS enabled flag (any version). */ public static final String SVM_FIELD_NFS_ENABLED = "nfs.enabled"; - /** SVM REST field: NFSv4.1 protocol enablement nested under {@code nfs.protocol}. */ - public static final String SVM_FIELD_NFS_V41_ENABLED = "nfs.protocol.v41_enabled"; - /** SVM REST field: ID-mapping domain used when numeric-ids is off. */ - public static final String SVM_FIELD_NFS_V4_ID_DOMAIN = "nfs.v4_id_domain"; + /** NFS service REST field (/api/protocols/nfs/services): service enablement. */ + public static final String NFS_SERVICE_FIELD_ENABLED = "enabled"; + /** NFS service REST field: NFSv4.1 protocol enablement. */ + public static final String NFS_SERVICE_FIELD_V41_ENABLED = "protocol.v41_enabled"; + /** NFS service REST field: ID-mapping domain used when numeric-ids is off. */ + public static final String NFS_SERVICE_FIELD_V4_ID_DOMAIN = "protocol.v4_id_domain"; + /** NFS service REST field: numeric-ids mode (bypasses idmapd). */ + public static final String NFS_SERVICE_FIELD_V4_NUMERIC_IDS = "protocol.v4_numeric_ids"; /** Export rule superuser/ro/rw auth value. */ public static final String EXPORT_AUTH_SYS = "sys"; /** Export rule anonymous-user fallback for NFSv4.1 pools (root). */ From 057cde83d5abc0ac26266410d3f8ce7c816ab256 Mon Sep 17 00:00:00 2001 From: "Srivastava, Piyush" Date: Mon, 23 Nov 2026 11:37:39 +0530 Subject: [PATCH 4/4] correctng the right v4 api for svm 1 --- .../storage/service/StorageStrategy.java | 15 ++++++--------- .../storage/utils/OntapStorageConstants.java | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index 80e31a97e589..e0d2a9a8499b 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -393,11 +393,13 @@ private void validateNfs41OnSvm(String authHeader, String svmName, String svmUui if (svmUuid == null) { throw new CloudRuntimeException("Cannot validate NFSv4.1 on SVM " + svmName + ": SVM UUID is null"); } + // v4_numeric_ids is not an addressable field on every ONTAP version (see swagger for the + // target cluster). The plugin validates v41_enabled only; numeric-ids posture is an + // operator-side choice, documented in the design spec and surfaced via `vserver nfs show`. Map queryParams = Map.of(OntapStorageConstants.FIELDS, OntapStorageConstants.NFS_SERVICE_FIELD_ENABLED + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_SERVICE_FIELD_V41_ENABLED - + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_SERVICE_FIELD_V4_ID_DOMAIN - + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_SERVICE_FIELD_V4_NUMERIC_IDS); + + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_SERVICE_FIELD_V4_ID_DOMAIN); NfsService nfsService; try { nfsService = nasFeignClient.getNfsService(authHeader, svmUuid, queryParams); @@ -410,13 +412,8 @@ private void validateNfs41OnSvm(String authHeader, String svmName, String svmUui + " (protocol.v41_enabled=false). Enable it via PATCH /protocols/nfs/services/" + svmUuid + "."); throw new CloudRuntimeException("NFSv4.1 is not enabled on SVM " + svmName); } - logger.info("NFSv4.1 enabled on SVM {} (uuid={}); v4_numeric_ids={}, v4_id_domain={}", - svmName, svmUuid, nfsService.isV4NumericIds(), nfsService.getV4IdDomain()); - if (!nfsService.isV4NumericIds()) { - logger.warn("SVM {} has v4_numeric_ids=false; verify that each KVM host's /etc/idmapd.conf Domain " - + "matches v4_id_domain='{}' or files will land as nobody:nobody.", - svmName, nfsService.getV4IdDomain()); - } + logger.info("NFSv4.1 enabled on SVM {} (uuid={}); v4_id_domain={}", + svmName, svmUuid, nfsService.getV4IdDomain()); } private void validateAndSelectAggregatesForVolumeCreation(String authHeader, String svmName, List aggrs) { diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java index 6ee4728c6dc9..21f92b170a1f 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java @@ -63,8 +63,6 @@ public class OntapStorageConstants { public static final String NFS_SERVICE_FIELD_V41_ENABLED = "protocol.v41_enabled"; /** NFS service REST field: ID-mapping domain used when numeric-ids is off. */ public static final String NFS_SERVICE_FIELD_V4_ID_DOMAIN = "protocol.v4_id_domain"; - /** NFS service REST field: numeric-ids mode (bypasses idmapd). */ - public static final String NFS_SERVICE_FIELD_V4_NUMERIC_IDS = "protocol.v4_numeric_ids"; /** Export rule superuser/ro/rw auth value. */ public static final String EXPORT_AUTH_SYS = "sys"; /** Export rule anonymous-user fallback for NFSv4.1 pools (root). */