From 4d30c6493bb746c03cbf7a8b9268b628a6c6dddd Mon Sep 17 00:00:00 2001 From: "gasperfele@fri1.uni-lj.si" Date: Thu, 13 Oct 2016 09:27:10 +0000 Subject: Fixed the dhcp task git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@367 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/tasks/isc_dhcp_live_boot/task.py | 31 +++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'kpov_judge') diff --git a/kpov_judge/tasks/isc_dhcp_live_boot/task.py b/kpov_judge/tasks/isc_dhcp_live_boot/task.py index c4775f1..22d0e79 100644 --- a/kpov_judge/tasks/isc_dhcp_live_boot/task.py +++ b/kpov_judge/tasks/isc_dhcp_live_boot/task.py @@ -120,10 +120,12 @@ def task(IP_DHCP, IP_GW, MAC_BOOT, BOOT_FNAME): # and ip arguments. You can simply feed it MAC_BOOT and IP_BOOT. # dhcping -h MAC_BOOT -c IP_BOOT -V -r # could work (but you should test it) - dhcpdump = pexpect.spawn("sudo dhcpdump -i eth1") - mac_str = pexpect.run("ip link show eth1") - mac_re = re.search(r"(([0-9a-f]{2}:){5}[0-9a-f]{2})", mac_str) - mac_SA = mac_re.group(1) + ip_str = pexpect.run('ip addr show') + eth_re_str = "ether (([0-9a-f]{{2}}:){{5}}[0-9a-f]{{2}})(.*)\r\n(.*){}(.*)\s(\w*)\r\n" + ip_re = re.search(eth_re_str.format(DHCP_IP), ip_str) + mac_SA = ip_re.group(1) + eth_dev_SA = ip_re.group(6) + dhcpdump = pexpect.spawn("sudo dhcpdump -i {}".format(eth_dev_SA)) results['dhcping_other'] = pexpect.run('sudo dhcping -s {} -h {}'.format( IP_DHCP, MAC_BOOT)) dhcpdump.expect('---------------------------------------------------------------------------') @@ -210,12 +212,21 @@ timeout 0 s = """auto lo iface lo inet loopback -auto eth0 -iface eth0 inet dhcp +auto ens3 +iface ens3 inet dhcp -iface eth1 inet static - address {} +auto enp0s3 +iface enp0s3 inet dhcp + +auto ens4 +iface ens4 inet static + address {IP_GW} + netmask 255.192.0.0 + +auto enp0s8 +iface enp0s8 inet static + address {IP_GW} netmask 255.192.0.0 -""".format(task_params['IP_GW']) - d.write("/etc/interfaces", s) +""".format(IP_GW = task_params['IP_GW']) + d.write("/etc/network/interfaces", s) write_default_config(templates['simpleArbiterGW'], global_params) -- cgit v1.2.1