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"
+      }
+    ]
+  }
+}
diff --git a/tests/czechlight-cfg-fs/data/v0_sdn-inline_empty/expected.json b/tests/czechlight-cfg-fs/data/v0_sdn-inline_empty/expected.json
index 0967ef4..a31986c 100644
--- a/tests/czechlight-cfg-fs/data/v0_sdn-inline_empty/expected.json
+++ b/tests/czechlight-cfg-fs/data/v0_sdn-inline_empty/expected.json
@@ -1 +1,39 @@
-{}
+{
+  "ietf-interfaces:interfaces": {
+    "interface": [
+      {
+        "ietf-ip:ipv4": {
+          "czechlight-network:dhcp-client": true
+        },
+        "ietf-ip:ipv6": {
+          "autoconf": {
+            "create-global-addresses": true
+          },
+          "enabled": true
+        },
+        "name": "br0",
+        "type": "iana-if-type:bridge"
+      },
+      {
+        "czechlight-network:bridge": "br0",
+        "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"
+      }
+    ]
+  }
+}
diff --git a/tests/czechlight-cfg-fs/data/v0_sdn-inline_somedata/expected.json b/tests/czechlight-cfg-fs/data/v0_sdn-inline_somedata/expected.json
index 52a1f53..ff070e2 100644
--- a/tests/czechlight-cfg-fs/data/v0_sdn-inline_somedata/expected.json
+++ b/tests/czechlight-cfg-fs/data/v0_sdn-inline_somedata/expected.json
@@ -23,6 +23,16 @@
         "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"
       }
     ]
   },
diff --git a/tests/czechlight-cfg-fs/data/v0_sdn-roadm-line_empty/expected.json b/tests/czechlight-cfg-fs/data/v0_sdn-roadm-line_empty/expected.json
index 4ab1a31..20975b2 100644
--- a/tests/czechlight-cfg-fs/data/v0_sdn-roadm-line_empty/expected.json
+++ b/tests/czechlight-cfg-fs/data/v0_sdn-roadm-line_empty/expected.json
@@ -1,4 +1,36 @@
 {
+  "ietf-interfaces:interfaces": {
+    "interface": [
+      {
+        "ietf-ip:ipv4": {
+          "czechlight-network:dhcp-client": true
+        },
+        "ietf-ip:ipv6": {
+          "autoconf": {
+            "create-global-addresses": true
+          },
+          "enabled": true
+        },
+        "name": "br0",
+        "type": "iana-if-type:bridge"
+      },
+      {
+        "czechlight-network:bridge": "br0",
+        "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-roadm-device:channel-plan": {
     "channel": [
       {
diff --git a/tests/czechlight-cfg-fs/data/v0_sdn-roadm-line_with_altered_initial_data/expected.json b/tests/czechlight-cfg-fs/data/v0_sdn-roadm-line_with_altered_initial_data/expected.json
index 4ab1a31..20975b2 100644
--- a/tests/czechlight-cfg-fs/data/v0_sdn-roadm-line_with_altered_initial_data/expected.json
+++ b/tests/czechlight-cfg-fs/data/v0_sdn-roadm-line_with_altered_initial_data/expected.json
@@ -1,4 +1,36 @@
 {
+  "ietf-interfaces:interfaces": {
+    "interface": [
+      {
+        "ietf-ip:ipv4": {
+          "czechlight-network:dhcp-client": true
+        },
+        "ietf-ip:ipv6": {
+          "autoconf": {
+            "create-global-addresses": true
+          },
+          "enabled": true
+        },
+        "name": "br0",
+        "type": "iana-if-type:bridge"
+      },
+      {
+        "czechlight-network:bridge": "br0",
+        "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-roadm-device:channel-plan": {
     "channel": [
       {
diff --git a/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/cmdline b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/cmdline
new file mode 100644
index 0000000..17d977e
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/cmdline
@@ -0,0 +1 @@
+czechlight=sdn-inline
diff --git a/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/expected.json b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/expected.json
new file mode 100644
index 0000000..58babdd
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/expected.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"
+      }
+    ]
+  }
+}
diff --git a/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/startup.json b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/startup.json
new file mode 100644
index 0000000..baca11f
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/startup.json
@@ -0,0 +1,37 @@
+{
+  "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",
+        "ietf-ip:ipv4": {
+          "czechlight-network:dhcp-client": true
+        },
+        "ietf-ip:ipv6": {
+          "enabled": true,
+          "autoconf": {
+            "create-global-addresses": true
+          }
+        }
+      }
+    ]
+  }
+}
diff --git a/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/version b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/version
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/version
@@ -0,0 +1 @@
+1
diff --git a/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/xpath b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/xpath
new file mode 100644
index 0000000..a745562
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_inline_eth0_explicit_ip/xpath
@@ -0,0 +1 @@
+/ietf-interfaces:interfaces
diff --git a/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/cmdline b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/cmdline
new file mode 100644
index 0000000..6b1d906
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/cmdline
@@ -0,0 +1 @@
+czechlight=sdn-roadm-line
diff --git a/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/expected.json b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/expected.json
new file mode 100644
index 0000000..25dc77e
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/expected.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/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/startup.json b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/startup.json
new file mode 100644
index 0000000..2c63c08
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/startup.json
@@ -0,0 +1,2 @@
+{
+}
diff --git a/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/version b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/version
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/version
@@ -0,0 +1 @@
+1
diff --git a/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/xpath b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/xpath
new file mode 100644
index 0000000..a745562
--- /dev/null
+++ b/tests/czechlight-cfg-fs/data/v1_sdn-roadm-line_empty/xpath
@@ -0,0 +1 @@
+/ietf-interfaces:interfaces