Skip to content

Commit

Permalink
networking-tools: Add nmstate
Browse files Browse the repository at this point in the history
As discussed at [1] the nmstatectl tool is going to be added to FCOS, it
will allow to declare the network configuration at boot time

[1] coreos/fedora-coreos-tracker#1175

Signed-off-by: Enrique Llorente <ellorent@redhat.com>
  • Loading branch information
qinqon committed Mar 17, 2023
1 parent 7205d41 commit c7ab8d2
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 0 deletions.
5 changes: 5 additions & 0 deletions manifest-lock.overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ packages:
metadata:
bodhi: https://bodhi.fedoraproject.org/updates/FEDORA-2023-5a7c2a5c5b
type: fast-track
nmstate:
evr: 2.2.8-2.fc37
metadata:
bodhi: https://bodhi.fedoraproject.org/updates/FEDORA-2023-59543876eb
type: fast-track
3 changes: 3 additions & 0 deletions manifests/networking-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ packages:
- iptables nftables
# Interactive network tools for admins
- socat net-tools bind-utils
# Declarative network configuration
# https://github.com/coreos/fedora-coreos-tracker/issues/1175
- nmstate
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ enable rtas_errd.service
enable clevis-luks-askpass.path
# Provide status information about the Ignition run
enable coreos-ignition-write-issues.service
# Apply network configuration from /etc/nmstate/*.yml
# We can drop this after merging https://src.fedoraproject.org/rpms/fedora-release/pull-request/255
enable nmstate.service
28 changes: 28 additions & 0 deletions tests/kola/networking/nmstate/data/nmstate-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
. $KOLA_EXT_DATA/commonlib.sh

run-checks() {
local prefix=$1
if ! nmcli c show br-ex ; then
nmstatectl show
journalctl -u nmstate
fatal "${prefix}: bridge not configured"
fi
ok "${prefix}: bridge configured correctly"
}

main() {
case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
run-checks "first boot"
/tmp/autopkgtest-reboot rebooted
;;

rebooted)
run-checks "second boot"
if ! ls /etc/nmstate/*applied; then
fatal "nmstate yamls files not marked as applied"
fi
;;
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";;
esac
}
24 changes: 24 additions & 0 deletions tests/kola/networking/nmstate/policy/config.bu
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/br-ex-policy.yml
contents:
inline: |
capture:
default-gw-route: routes.running.destination=="0.0.0.0/0"
default-gw-iface: interfaces.name==capture.default-gw-route.routes.running.0.next-hop-interface
desiredState:
interfaces:
- name: "{{ capture.default-gw-iface.interfaces.0.name }}"
type: ethernet
state: up
- name: br-ex
type: linux-bridge
copy-mac-from: "{{ capture.default-gw-iface.interfaces.0.name }}"
state: up
ipv4: "{{ capture.default-gw-iface.interfaces.0.ipv4 }}"
ipv6: "{{ capture.default-gw-iface.interfaces.0.ipv6 }}"
bridge:
port:
- name: "{{ capture.default-gw-iface.interfaces.0.name }}"
1 change: 1 addition & 0 deletions tests/kola/networking/nmstate/policy/data/commonlib.sh
11 changes: 11 additions & 0 deletions tests/kola/networking/nmstate/policy/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
## kola:
## tags: "platform-independent"
#
# Configure a DHCP linux bridge using butane and nmstate service with policy

set -xeuo pipefail

. $KOLA_EXT_DATA/nmstate-common.sh

main
17 changes: 17 additions & 0 deletions tests/kola/networking/nmstate/state/config.bu
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/br-ex.yml
contents:
inline: |
interfaces:
- name: br-ex
type: linux-bridge
state: up
ipv4:
enabled: false
ipv6:
enabled: false
bridge:
port: []
1 change: 1 addition & 0 deletions tests/kola/networking/nmstate/state/data/commonlib.sh
1 change: 1 addition & 0 deletions tests/kola/networking/nmstate/state/data/nmstate-common.sh
11 changes: 11 additions & 0 deletions tests/kola/networking/nmstate/state/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
## kola:
## tags: "platform-independent"
#
# Configure a DHCP linux bridge using butane and nmstate service with state

set -xeuo pipefail

. $KOLA_EXT_DATA/nmstate-common.sh

main

0 comments on commit c7ab8d2

Please sign in to comment.