public inbox for network@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Add recipe to reset network configuration
@ 2018-07-28 11:59 Jonatan Schlag
  2018-07-28 11:59 ` [PATCH 2/4] Add recipe to set network settings Jonatan Schlag
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jonatan Schlag @ 2018-07-28 11:59 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]

We use --force here to avoid the y/n question.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 Makefile.am                      | 7 +++++--
 test/nitsi/include/network-reset | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)
 create mode 100644 test/nitsi/include/network-reset

diff --git a/Makefile.am b/Makefile.am
index e56d0fb..2574a2e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -586,13 +586,16 @@ VIRTUAL_ENVIRONMENT_IMAGES_DOWNLOAD_URL = \
 	https://people.ipfire.org/~jschlag/nitsi-ipfire/virtual-environment/basic/
 
 NITSI_INCLUDE_RECIPES = \
-	test/nitsi/include/make-install
+	test/nitsi/include/make-install \
+	test/nitsi/include/network-reset
 
 EXTRA_DIST += \
 	test/nitsi/include/make-install.in
+	test/nitsi/include/network-reset
 
 CLEANFILES += \
-	test/nitsi/include/make-install
+	test/nitsi/include/make-install \
+
 
 NITSI_TESTS = \
 	test/nitsi/test/hello-world \
diff --git a/test/nitsi/include/network-reset b/test/nitsi/include/network-reset
new file mode 100644
index 0000000..d82e2b1
--- /dev/null
+++ b/test/nitsi/include/network-reset
@@ -0,0 +1 @@
+all: network reset --force
-- 
2.11.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/4] Add recipe to set network settings
  2018-07-28 11:59 [PATCH 1/4] Add recipe to reset network configuration Jonatan Schlag
@ 2018-07-28 11:59 ` Jonatan Schlag
  2018-07-28 11:59 ` [PATCH 3/4] Add new function device_get_by_mac_address() Jonatan Schlag
  2018-07-28 11:59 ` [PATCH 4/4] Add test for command raw device-get-by-mac-address Jonatan Schlag
  2 siblings, 0 replies; 4+ messages in thread
From: Jonatan Schlag @ 2018-07-28 11:59 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1110 bytes --]

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 Makefile.am                         | 6 ++++--
 test/nitsi/include/network-settings | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
 create mode 100644 test/nitsi/include/network-settings

diff --git a/Makefile.am b/Makefile.am
index 2574a2e..d90391e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -587,11 +587,13 @@ VIRTUAL_ENVIRONMENT_IMAGES_DOWNLOAD_URL = \
 
 NITSI_INCLUDE_RECIPES = \
 	test/nitsi/include/make-install \
-	test/nitsi/include/network-reset
+	test/nitsi/include/network-reset \
+	test/nitsi/include/network-settings
 
 EXTRA_DIST += \
 	test/nitsi/include/make-install.in
-	test/nitsi/include/network-reset
+	test/nitsi/include/network-reset \
+	test/nitsi/include/network-settings
 
 CLEANFILES += \
 	test/nitsi/include/make-install \
diff --git a/test/nitsi/include/network-settings b/test/nitsi/include/network-settings
new file mode 100644
index 0000000..535fe4c
--- /dev/null
+++ b/test/nitsi/include/network-settings
@@ -0,0 +1 @@
+all: network settings DEBUG=1
-- 
2.11.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/4] Add new function device_get_by_mac_address()
  2018-07-28 11:59 [PATCH 1/4] Add recipe to reset network configuration Jonatan Schlag
  2018-07-28 11:59 ` [PATCH 2/4] Add recipe to set network settings Jonatan Schlag
@ 2018-07-28 11:59 ` Jonatan Schlag
  2018-07-28 11:59 ` [PATCH 4/4] Add test for command raw device-get-by-mac-address Jonatan Schlag
  2 siblings, 0 replies; 4+ messages in thread
From: Jonatan Schlag @ 2018-07-28 11:59 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]

We need this function and the command to identify ports in a nitsi test.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/functions/functions.device | 18 ++++++++++++++++++
 src/network                    |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/src/functions/functions.device b/src/functions/functions.device
index 0cd6e4e..ace4022 100644
--- a/src/functions/functions.device
+++ b/src/functions/functions.device
@@ -1111,3 +1111,21 @@ device_get_by_assigned_ip_address() {
 	print "${device}"
 	return ${EXIT_OK}
 }
+
+device_get_by_mac_address() {
+	local mac=${1}
+
+	assert isset mac
+
+	local device
+
+	for device in $(device_list); do
+		if [ "${mac}" = "$(device_get_address ${device})" ]; then
+			print "${device}"
+			return ${EXIT_OK}
+		fi
+	done
+
+	# We could not found a port to the given mac address so we return exit error
+	return ${EXIT_ERROR}
+}
diff --git a/src/network b/src/network
index b28ecdb..f26c0dc 100644
--- a/src/network
+++ b/src/network
@@ -1286,6 +1286,9 @@ cli_raw() {
 		db-dump)
 			db_dump
 			;;
+		device-get-by-mac-address)
+			device_get_by_mac_address "$@"
+			;;
 		ipsec-connection-exists)
 			ipsec_connection_exists "$@"
 			;;
-- 
2.11.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 4/4] Add test for command raw device-get-by-mac-address
  2018-07-28 11:59 [PATCH 1/4] Add recipe to reset network configuration Jonatan Schlag
  2018-07-28 11:59 ` [PATCH 2/4] Add recipe to set network settings Jonatan Schlag
  2018-07-28 11:59 ` [PATCH 3/4] Add new function device_get_by_mac_address() Jonatan Schlag
@ 2018-07-28 11:59 ` Jonatan Schlag
  2 siblings, 0 replies; 4+ messages in thread
From: Jonatan Schlag @ 2018-07-28 11:59 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 2780 bytes --]

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 Makefile.am                                       | 9 +++++++--
 test/nitsi/test/raw-device-get-by-mac/.gitignore  | 3 +++
 test/nitsi/test/raw-device-get-by-mac/recipe      | 6 ++++++
 test/nitsi/test/raw-device-get-by-mac/settings.in | 8 ++++++++
 4 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 test/nitsi/test/raw-device-get-by-mac/.gitignore
 create mode 100644 test/nitsi/test/raw-device-get-by-mac/recipe
 create mode 100644 test/nitsi/test/raw-device-get-by-mac/settings.in

diff --git a/Makefile.am b/Makefile.am
index d90391e..05e7c8c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -601,17 +601,22 @@ CLEANFILES += \
 
 NITSI_TESTS = \
 	test/nitsi/test/hello-world \
-	test/nitsi/test/make-check
+	test/nitsi/test/make-check \
+	test/nitsi/test/raw-device-get-by-mac
 
 EXTRA_DIST += \
 	test/nitsi/test/hello-world/recipe \
 	test/nitsi/test/hello-world/settings \
 	test/nitsi/test/make-check/recipe.in \
 	test/nitsi/test/make-check/settings.in
+	test/nitsi/test/raw-device-get-by-mac/recipe\
+	test/nitsi/test/raw-device-get-by-mac/settings.in
+
 
 CLEANFILES += \
 	test/nitsi/test/make-check/recipe \
-	test/nitsi/test/make-check/settings
+	test/nitsi/test/make-check/settings \
+	test/nitsi/test/raw-device-get-by-mac/settings
 
 NITSI_ENVIRONMENT =
 
diff --git a/test/nitsi/test/raw-device-get-by-mac/.gitignore b/test/nitsi/test/raw-device-get-by-mac/.gitignore
new file mode 100644
index 0000000..8a9bd77
--- /dev/null
+++ b/test/nitsi/test/raw-device-get-by-mac/.gitignore
@@ -0,0 +1,3 @@
+/log
+/recipe.log
+/settings
diff --git a/test/nitsi/test/raw-device-get-by-mac/recipe b/test/nitsi/test/raw-device-get-by-mac/recipe
new file mode 100644
index 0000000..e22454e
--- /dev/null
+++ b/test/nitsi/test/raw-device-get-by-mac/recipe
@@ -0,0 +1,6 @@
+include: ../../include/make-install
+include: ../../include/network-settings
+include: ../../include/network-reset
+alice: port="$(network raw device-get-by-mac-address "52:54:00:8a:b8:b5")"
+alice: echo $port
+alice: [ "52:54:00:8a:b8:b5" = "$(cat /sys/class/net/${port}/address)" ]
diff --git a/test/nitsi/test/raw-device-get-by-mac/settings.in b/test/nitsi/test/raw-device-get-by-mac/settings.in
new file mode 100644
index 0000000..e0bc141
--- /dev/null
+++ b/test/nitsi/test/raw-device-get-by-mac/settings.in
@@ -0,0 +1,8 @@
+[GENERAL]
+name = raw-device-get-by-mac
+description = This test checks if 'network raw device-get-by-mac' return the correct device for a given mac
+copy_from = ../../../../@PACKAGE_NAME(a)-@PACKAGE_VERSION(a).tar.gz
+copy_to = /root/
+
+[VIRTUAL_ENVIRONMENT]
+path = ../../virtual-environment/basic
-- 
2.11.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-28 11:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-28 11:59 [PATCH 1/4] Add recipe to reset network configuration Jonatan Schlag
2018-07-28 11:59 ` [PATCH 2/4] Add recipe to set network settings Jonatan Schlag
2018-07-28 11:59 ` [PATCH 3/4] Add new function device_get_by_mac_address() Jonatan Schlag
2018-07-28 11:59 ` [PATCH 4/4] Add test for command raw device-get-by-mac-address Jonatan Schlag

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox