system: Configure eth1 interface (on running system)
This commit is a part of implementation of network configuration for eth1
interface through Sysrepo and velia-system. It implements
/czechlight-system:networking/standalone-eth1 presence container in
running datastore.
If the presence container is missing, the network configuration for eth1
interface resets to the "old" default configuration of eth1, i.e., add
it to the br0 bridge.
If the container is present, the interface is removed from the bridge and
its IP address is obtained via DHCP.
The network is managed by systemd-networkd thus we implement the changes
via systemd-networkd network files [1]. The files can be placed in /etc,
/run and /usr directories (and they take precedence in this order). We
place the new network file in the /run directory and reload network
configuration via networkctl reload.
There is a slight catch in removing the interface from a bridge.
Apparently, systemd-networkd does not remove an interface from a bridge
if the new configuration does not contain Bridge settings [2].
However, bringing the interface down and then reloading the new
configuration apparently works.
[1] https://www.freedesktop.org/software/systemd/man/systemd.network.html
[2] https://github.com/systemd/systemd/issues/8190
Change-Id: I8940985a88903c17ea61e55aced67b17fba4656a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 857499e..a627405 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,6 +150,9 @@
if(NOT SYSTEMCTL_EXECUTABLE)
find_program(SYSTEMCTL_EXECUTABLE systemctl)
endif()
+if(NOT NETWORKCTL_EXECUTABLE)
+ find_program(NETWORKCTL_EXECUTABLE networkctl)
+endif()
set(VELIA_AUTHORIZED_KEYS_FORMAT "{HOME}/.ssh/authorized_keys" CACHE STRING "pattern for determining path to users' SSH authorized_keys file. Must at least one of '{USER}' or '{HOME}' which will get replaced by the name of the user and the home directory of the user respectively.")
if(NOT VELIA_AUTHORIZED_KEYS_FORMAT)
@@ -188,6 +191,8 @@
src/system/IETFSystem.h
src/system/Authentication.cpp
src/system/Authentication.h
+ src/system/Network.cpp
+ src/system/Network.h
)
target_link_libraries(velia-system
PUBLIC
@@ -384,6 +389,14 @@
RESOURCE_LOCK sysrepo
)
+ velia_test(sysrepo_system-network velia-system)
+ target_link_libraries(test-sysrepo_system-network FsTestUtils)
+ set_tests_properties(
+ test-sysrepo_system-network
+ PROPERTIES FIXTURES_REQUIRED sysrepo:env:sysrepo-czechlight-system
+ RESOURCE_LOCK sysrepo
+ )
+
sysrepo_fixture_env(sysrepo-ietf-hardware YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/iana-hardware@2018-03-13.yang YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-hardware@2018-03-13.yang FEATURE hardware-sensor)
velia_test(hardware_ietf-hardware velia-ietf-hardware velia-ietf-hardware-sysrepo)
set_tests_properties(