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 <[email protected]>
  • Loading branch information
qinqon committed Mar 21, 2023
1 parent 56d26da commit 1437b71
Show file tree
Hide file tree
Showing 12 changed files with 101 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 @@ -34,3 +34,8 @@ packages:
metadata:
reason: https://github.com/coreos/fedora-coreos-tracker/issues/1441
type: pin
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
23 changes: 23 additions & 0 deletions tests/kola/networking/nmstate/data/nmstate-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
. $KOLA_EXT_DATA/commonlib.sh

main() {
nmstatectl show
journalctl -u nmstate

local prefix="first boot"
if [ "${AUTOPKGTEST_REBOOT_MARK:-}" == rebooted ]; then
prefix="second boot"
fi

if ! nmcli c show br-ex; then
fatal "${prefix}: bridge not configured"
fi

if ! ls /etc/nmstate/*applied; then
fatal "${prefix}: nmstate yamls files not marked as applied"
fi

if [ "${AUTOPKGTEST_REBOOT_MARK:-}" == "" ]; then
/tmp/autopkgtest-reboot rebooted
fi
}
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 1437b71

Please sign in to comment.