migration: add default configuration for ietf-interfaces
The current state of startup datastore for ietf-interfaces model did not
correspond to the real state of the box (its systemd-networkd
configuration). The datastore was empty, but its configuration was, by
default, set to "bridge all links" and set DHCP for both IPv4 and IPv6
for br0 (the bridge).
This migration should fix that. It overwrites the current networking
content in startup datastore with the values of the default
configuration described in the previous paragraph.
Change-Id: I0b809a39044bf6bcba4135a3456c684d94ef8b86
diff --git a/package/czechlight-cfg-fs/czechlight-migration-list.sh b/package/czechlight-cfg-fs/czechlight-migration-list.sh
index 9b5a49d..84d26a0 100644
--- a/package/czechlight-cfg-fs/czechlight-migration-list.sh
+++ b/package/czechlight-cfg-fs/czechlight-migration-list.sh
@@ -1,5 +1,4 @@
MIGRATION_FILES=(
'0001_initial-data.sh'
+ '0002_default_startup_configuration_for_ietf-interfaces.sh'
)
-
-
diff --git a/package/czechlight-cfg-fs/migrations/0002_default_startup_configuration_for_ietf-interfaces.sh b/package/czechlight-cfg-fs/migrations/0002_default_startup_configuration_for_ietf-interfaces.sh
new file mode 100644
index 0000000..b21251c
--- /dev/null
+++ b/package/czechlight-cfg-fs/migrations/0002_default_startup_configuration_for_ietf-interfaces.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# setup default configuration for ietf-interfaces in startup DS
+# This overwrites current networking setup
+
+set -x
+set -e
+
+if [[ ${YANG_INLINE} == 1 ]]; then
+ sysrepocfg --datastore=startup --format=json --module=ietf-interfaces --import="${MIGRATIONS_DIRECTORY}/0002_ietf-interfaces_default-startup-config_sdn-inline.json"
+else
+ sysrepocfg --datastore=startup --format=json --module=ietf-interfaces --import="${MIGRATIONS_DIRECTORY}/0002_ietf-interfaces_default-startup-config.json"
+fi
diff --git a/package/czechlight-cfg-fs/migrations/0002_ietf-interfaces_default-startup-config.json b/package/czechlight-cfg-fs/migrations/0002_ietf-interfaces_default-startup-config.json
new file mode 100644
index 0000000..25dc77e
--- /dev/null
+++ b/package/czechlight-cfg-fs/migrations/0002_ietf-interfaces_default-startup-config.json
@@ -0,0 +1,34 @@
+{
+ "ietf-interfaces:interfaces": {
+ "interface": [
+ {
+ "name": "br0",
+ "type": "iana-if-type:bridge",
+ "ietf-ip:ipv4": {
+ "czechlight-network:dhcp-client": true
+ },
+ "ietf-ip:ipv6": {
+ "enabled": true,
+ "autoconf": {
+ "create-global-addresses": true
+ }
+ }
+ },
+ {
+ "name": "eth1",
+ "type": "iana-if-type:ethernetCsmacd",
+ "czechlight-network:bridge": "br0"
+ },
+ {
+ "name": "eth0",
+ "type": "iana-if-type:ethernetCsmacd",
+ "czechlight-network:bridge": "br0"
+ },
+ {
+ "name": "osc",
+ "type": "iana-if-type:ethernetCsmacd",
+ "czechlight-network:bridge": "br0"
+ }
+ ]
+ }
+}
diff --git a/package/czechlight-cfg-fs/migrations/0002_ietf-interfaces_default-startup-config_sdn-inline.json b/package/czechlight-cfg-fs/migrations/0002_ietf-interfaces_default-startup-config_sdn-inline.json
new file mode 100644
index 0000000..58babdd
--- /dev/null
+++ b/package/czechlight-cfg-fs/migrations/0002_ietf-interfaces_default-startup-config_sdn-inline.json
@@ -0,0 +1,39 @@
+{
+ "ietf-interfaces:interfaces": {
+ "interface": [
+ {
+ "name": "br0",
+ "type": "iana-if-type:bridge",
+ "ietf-ip:ipv4": {
+ "czechlight-network:dhcp-client": true
+ },
+ "ietf-ip:ipv6": {
+ "enabled": true,
+ "autoconf": {
+ "create-global-addresses": true
+ }
+ }
+ },
+ {
+ "name": "eth1",
+ "type": "iana-if-type:ethernetCsmacd",
+ "czechlight-network:bridge": "br0"
+ },
+ {
+ "name": "eth0",
+ "type": "iana-if-type:ethernetCsmacd",
+ "czechlight-network:bridge": "br0"
+ },
+ {
+ "name": "oscE",
+ "type": "iana-if-type:ethernetCsmacd",
+ "czechlight-network:bridge": "br0"
+ },
+ {
+ "name": "oscW",
+ "type": "iana-if-type:ethernetCsmacd",
+ "czechlight-network:bridge": "br0"
+ }
+ ]
+ }
+}