Change in osmo-ci[master]: ansible: gsm-tester: Install osmo-gsm-tester_netns_setup.sh

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Apr 4 14:38:45 UTC 2019


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/13524


Change subject: ansible: gsm-tester: Install osmo-gsm-tester_netns_setup.sh
......................................................................

ansible: gsm-tester: Install osmo-gsm-tester_netns_setup.sh

Change-Id: Iaa8802b86429abfaf84fc0f20bd207737dbc9812
---
A ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh
M ansible/roles/gsm-tester/tasks/main.yml
2 files changed, 35 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/24/13524/1

diff --git a/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh b/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh
new file mode 100755
index 0000000..1600c44
--- /dev/null
+++ b/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -e
+
+ifname="$1"
+netns="$2"
+shift
+shift
+
+
+
+if [ -f "/var/run/netns/${netns}" ]; then
+    echo "netns $netns already exists"
+else
+    echo "Creating netns $netns"
+    ip netns add "$netns"
+fi
+
+if [ -d "/sys/class/net/${ifname}" ]; then
+    echo "Moving iface $ifname to netns $netns"
+    ip link set $ifname netns $netns
+else
+    ip netns exec $netns ls "/sys/class/net/${ifname}" >/dev/null && echo "iface $ifname already in netns $netns"
+fi
diff --git a/ansible/roles/gsm-tester/tasks/main.yml b/ansible/roles/gsm-tester/tasks/main.yml
index c9b7429..34846a5 100644
--- a/ansible/roles/gsm-tester/tasks/main.yml
+++ b/ansible/roles/gsm-tester/tasks/main.yml
@@ -254,6 +254,19 @@
     dest: /etc/sudoers.d/osmo-gsm-tester_netns_exec
     mode: 0440
 
+- name: create a wrapper script to move modem net iface into its own netns
+  copy:
+    src: osmo-gsm-tester_netns_setup.sh
+    dest: /usr/local/bin/osmo-gsm-tester_netns_setup.sh
+    mode: 755
+
+- name: allow osmo-gsm-tester sudo osmo-gsm-tester_netns_setup.sh
+  copy:
+    content: |
+      %osmo-gsm-tester ALL=(root) NOPASSWD: /usr/local/bin/osmo-gsm-tester_netns_setup.sh
+    dest: /etc/sudoers.d/osmo-gsm-tester_netns_setup
+    mode: 0440
+
 - name: logrotate limit filesizes to 10M
   copy:
     content: "maxsize 10M"

-- 
To view, visit https://gerrit.osmocom.org/13524
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa8802b86429abfaf84fc0f20bd207737dbc9812
Gerrit-Change-Number: 13524
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190404/82bb30fd/attachment.html>


More information about the gerrit-log mailing list