summaryrefslogtreecommitdiff
diff options
authordann frazier <dann.frazier@canonical.com>2018-08-14 17:19:51 -0600
committerdann frazier <dann.frazier@canonical.com>2018-08-14 17:19:51 -0600
commit0de3567b5c8e640351efd66c306bae8bf2f7538d (patch)
treed1854db68c2e503f4da90b897552ea114f6f6956
parent9199e7e87ea8bdf20bca79ea50f77189cdc0ea9f (diff)
Add test for predictable network names
Fixes: LP:#1783133 Signed-off-by: dann frazier <dann.frazier@canonical.com>
-rwxr-xr-xbin/network_predictable_names45
-rw-r--r--units/networking/jobs.pxu6
2 files changed, 51 insertions, 0 deletions
diff --git a/bin/network_predictable_names b/bin/network_predictable_names
new file mode 100755
index 00000000..a3c3e5b4
--- /dev/null
+++ b/bin/network_predictable_names
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+set -e
+
+# Script to verify that all network interfaces have predictable names
+#
+# Copyright (c) 2018 Canonical Ltd.
+#
+# Authors
+# dann frazier <dann.frazier@canonical.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3,
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# The purpose of this script is to identify any network interfaces
+# that do not have a predictable name. See:
+# https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
+#
+# Usage:
+# network_predictable_names
+#
+# Parameters:
+# None
+
+failed=0
+
+for iface in /sys/class/net/*; do
+ iface=${iface##*/}
+
+ if [ "${iface}" != "${iface#eth}" ]; then
+ echo "** Error: Network interface $iface is not a predictable name"
+ failed=1
+ fi
+done
+
+exit $failed
diff --git a/units/networking/jobs.pxu b/units/networking/jobs.pxu
index 92eadd4e..0efefa2c 100644
--- a/units/networking/jobs.pxu
+++ b/units/networking/jobs.pxu
@@ -77,3 +77,9 @@ requires: package.name == 'cups-client'
command: network_printer_test -s $CHECKBOX_SERVER
_description: Try to enable a remote printer on the network and print a test page.
+plugin: shell
+category_id: com.canonical.plainbox::networking
+id: networking/predictable_names
+command: network_predictable_names
+_description: Verify that all network interfaces have predictable names.
+