From 07ce64462c63c5253226a733f5686e78eb7223a1 Mon Sep 17 00:00:00 2001
From: Sylvan Le Deunff <sylvan.le-deunff@ovhcloud.com>
Date: Wed, 3 May 2023 10:49:12 +0200
Subject: [PATCH] Fix export locations update when subnet is added

Export locations of active share replicas was updated
but not those of the share itself.

Closes-Bug: #2017501
Change-Id: I33204657401f3eadd490fc50fedaef899dcff297
---
 .../drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py | 3 ++-
 .../bug-2017501-fix-share-export-location-update.yaml      | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100644 releasenotes/notes/bug-2017501-fix-share-export-location-update.yaml

diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py
index e4ddeee4e4..4dca84741f 100644
--- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py
+++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py
@@ -2362,7 +2362,8 @@ class NetAppCmodeMultiSVMFileStorageLibrary(
 
         updated_export_locations = {}
         for share in shares:
-            if share['replica_state'] == constants.REPLICA_STATE_ACTIVE:
+            if share["replica_state"] in (None,
+                                          constants.REPLICA_STATE_ACTIVE):
                 host = share['host']
                 export_locations = self._create_export(
                     share, share_server, vserver_name, vserver_client,
diff --git a/releasenotes/notes/bug-2017501-fix-share-export-location-update.yaml b/releasenotes/notes/bug-2017501-fix-share-export-location-update.yaml
new file mode 100644
index 0000000000..643d4b1847
--- /dev/null
+++ b/releasenotes/notes/bug-2017501-fix-share-export-location-update.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    Fixed share export location update when subnet is added to a network
+    containing shares. Please refer to the
+    `Launchpad bug #2017501 <https://bugs.launchpad.net/manila/+bug/2017501>`_
+    for more details.