summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-03-02 13:22:01 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-03-02 13:22:01 +0100
commit7efdc4d945855b6fe17efa16c4cbac9a94a4108e (patch)
treef6c1b5d553768843fb3743e4f569850c9c546b62
parenta8c842b0f97bafedf483c102e38ce53849cc6eb2 (diff)
tasks.isc_dhcp_live_boot: add parameter encoding to pexpect calls
-rw-r--r--tasks/isc_dhcp_live_boot/task.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/tasks/isc_dhcp_live_boot/task.py b/tasks/isc_dhcp_live_boot/task.py
index a6f4c5c..aa8d61f 100644
--- a/tasks/isc_dhcp_live_boot/task.py
+++ b/tasks/isc_dhcp_live_boot/task.py
@@ -93,7 +93,6 @@ def task(IP_DHCP, IP_GW, MAC_BOOT, BOOT_FNAME):
# TODO (polz): Do not use tabs instead of spaces!
import pexpect
import re
- import tftpy
import io
import time
results={}
@@ -109,23 +108,25 @@ 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)
- ip_str = pexpect.run('ip addr show')
+ ip_str = pexpect.run('ip addr show', encoding='utf-8')
eth_re_str = r"ether (([0-9a-f]{{2}}:){{5}}[0-9a-f]{{2}})(.*)\r\n(.*){}(.*)\s(\w*)\r\n"
ip_re = re.search(eth_re_str.format(IP_GW), 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))
+ dhcpdump = pexpect.spawn("sudo dhcpdump -i {}".format(eth_dev_SA), encoding='utf-8')
time.sleep(2)
- results['dhcping_other'] = pexpect.run('sudo dhcping -s {} -h {} -c {}'.format(
- IP_DHCP, MAC_BOOT, IP_GW))
+ results['dhcping_other'] = pexpect.run(
+ 'sudo dhcping -s {} -h {} -c {}'.format(IP_DHCP, MAC_BOOT, IP_GW),
+ encoding='utf-8')
dhcpdump.expect('---------------------------------------------------------------------------')
results['dhcpdump_other_req'] = dhcpdump.before
dhcpdump.expect('---------------------------------------------------------------------------')
results['dhcpdump_other_reply'] = dhcpdump.before
dhcpdump.expect('---------------------------------------------------------------------------')
results['dhcpdump_other_release'] = dhcpdump.before
- results['dhcping_SA'] = pexpect.run('sudo dhcping -s {} -h {} -c {}'.format(
- IP_DHCP, mac_SA, IP_GW))
+ results['dhcping_SA'] = pexpect.run(
+ 'sudo dhcping -s {} -h {} -c {}'.format(IP_DHCP, mac_SA, IP_GW),
+ encoding='utf-8')
dhcpdump.expect('---------------------------------------------------------------------------')
results['dhcpdump_SA_req'] = dhcpdump.before
dhcpdump.expect('---------------------------------------------------------------------------')
@@ -133,7 +134,7 @@ def task(IP_DHCP, IP_GW, MAC_BOOT, BOOT_FNAME):
dhcpdump.expect('---------------------------------------------------------------------------')
results['dhcpdump_SA_release'] = dhcpdump.before
dhcpdump.sendintr()
- tftp_client = pexpect.spawn('tftp {}'.format(IP_DHCP))
+ tftp_client = pexpect.spawn('tftp {}'.format(IP_DHCP), encoding='utf-8')
tftp_client.expect(r'tftp>')
tftp_client.sendline('get pxelinux.cfg/default /dev/stdout')
tftp_client.expect(r'tftp>')