From e29722c8a1a892dd269108d70400e6e2ba3a2286 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 23 May 2023 18:56:29 +0200
Subject: [PATCH] extensions/nbft: add post-up script
References: bsc#1211647,https://github.com/openSUSE/wicked/pull/973
Upstream: yes

In multipath scenarios, not all NBFT interfaces and respective
connections may have been brought up during initramfs processing.
If wicked brings up some NBFT interfaces after switching to the
root file system, run a post-up script to initiate the NVMe
connections.

Signed-off-by: Marius Tomaschewski <mt@suse.com>

diff --git a/extensions/nbft b/extensions/nbft
index 7871d0a9..22af2276 100644
--- a/extensions/nbft
+++ b/extensions/nbft
@@ -239,6 +239,11 @@ nbft_parse_hfi() {
 		EOF
 	fi
 	cat <<-EOF
+	  <scripts>
+	    <post-up>
+	      <script>systemd:nvmf-connect-nbft.service</script>
+	    </post-up>
+	  </scripts>
 	</interface>
 	EOF
 }
diff --git a/testing/nbft/dhcp-routed/nbft.out b/testing/nbft/dhcp-routed/nbft.out
index bd22fc9f..d9c64808 100644
--- a/testing/nbft/dhcp-routed/nbft.out
+++ b/testing/nbft/dhcp-routed/nbft.out
@@ -8,4 +8,9 @@
     <enabled>true</enabled>
     <!-- no host name -->
   </ipv4:dhcp>
+  <scripts>
+    <post-up>
+      <script>systemd:nvmf-connect-nbft.service</script>
+    </post-up>
+  </scripts>
 </interface>
diff --git a/testing/nbft/dhcp-simple/nbft.out b/testing/nbft/dhcp-simple/nbft.out
index bd22fc9f..d9c64808 100644
--- a/testing/nbft/dhcp-simple/nbft.out
+++ b/testing/nbft/dhcp-simple/nbft.out
@@ -8,4 +8,9 @@
     <enabled>true</enabled>
     <!-- no host name -->
   </ipv4:dhcp>
+  <scripts>
+    <post-up>
+      <script>systemd:nvmf-connect-nbft.service</script>
+    </post-up>
+  </scripts>
 </interface>
diff --git a/testing/nbft/dhcp-vlan/nbft.out b/testing/nbft/dhcp-vlan/nbft.out
index f3b5d568..b44801b4 100644
--- a/testing/nbft/dhcp-vlan/nbft.out
+++ b/testing/nbft/dhcp-vlan/nbft.out
@@ -20,4 +20,9 @@
     <enabled>true</enabled>
     <hostname>nvmepoc-wicked</hostname>
   </ipv4:dhcp>
+  <scripts>
+    <post-up>
+      <script>systemd:nvmf-connect-nbft.service</script>
+    </post-up>
+  </scripts>
 </interface>
diff --git a/testing/nbft/static-bad-gateway/nbft.out b/testing/nbft/static-bad-gateway/nbft.out
index 775b5ec5..552f835a 100644
--- a/testing/nbft/static-bad-gateway/nbft.out
+++ b/testing/nbft/static-bad-gateway/nbft.out
@@ -11,4 +11,9 @@
     <hostname>nvmepoc-wicked</hostname>
     <enabled>true</enabled>
   </ipv4:static>
+  <scripts>
+    <post-up>
+      <script>systemd:nvmf-connect-nbft.service</script>
+    </post-up>
+  </scripts>
 </interface>
diff --git a/testing/nbft/static-no-prefix/nbft.out b/testing/nbft/static-no-prefix/nbft.out
index 83d4c1f1..e4928ea1 100644
--- a/testing/nbft/static-no-prefix/nbft.out
+++ b/testing/nbft/static-no-prefix/nbft.out
@@ -11,4 +11,9 @@
     <hostname>nvmepoc-wicked</hostname>
     <enabled>true</enabled>
   </ipv4:static>
+  <scripts>
+    <post-up>
+      <script>systemd:nvmf-connect-nbft.service</script>
+    </post-up>
+  </scripts>
 </interface>
diff --git a/testing/nbft/static-routed-vlan/nbft.out b/testing/nbft/static-routed-vlan/nbft.out
index 3d2a0054..3f27d330 100644
--- a/testing/nbft/static-routed-vlan/nbft.out
+++ b/testing/nbft/static-routed-vlan/nbft.out
@@ -23,4 +23,9 @@
     <hostname>nvmepoc-wicked</hostname>
     <enabled>true</enabled>
   </ipv4:static>
+  <scripts>
+    <post-up>
+      <script>systemd:nvmf-connect-nbft.service</script>
+    </post-up>
+  </scripts>
 </interface>
diff --git a/testing/nbft/static-routed/nbft.out b/testing/nbft/static-routed/nbft.out
index e8aa6bef..214b0334 100644
--- a/testing/nbft/static-routed/nbft.out
+++ b/testing/nbft/static-routed/nbft.out
@@ -11,4 +11,9 @@
     <hostname>nvmepoc-wicked</hostname>
     <enabled>true</enabled>
   </ipv4:static>
+  <scripts>
+    <post-up>
+      <script>systemd:nvmf-connect-nbft.service</script>
+    </post-up>
+  </scripts>
 </interface>
diff --git a/testing/nbft/static-vlan/nbft.out b/testing/nbft/static-vlan/nbft.out
index 779a7531..7b3c72ba 100644
--- a/testing/nbft/static-vlan/nbft.out
+++ b/testing/nbft/static-vlan/nbft.out
@@ -23,4 +23,9 @@
     <hostname>nvmepoc-wicked</hostname>
     <enabled>true</enabled>
   </ipv4:static>
+  <scripts>
+    <post-up>
+      <script>systemd:nvmf-connect-nbft.service</script>
+    </post-up>
+  </scripts>
 </interface>
-- 
2.35.3

