From bd943b320711367dd15ef574eab5d95eaaa83585 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Wed, 3 Aug 2016 14:04:56 -0500 Subject: [PATCH 1/2] Improve reliablity of debian based device resets Signed-off-by: Eric Schultz --- devices/debian.py | 7 ++++--- devices/non_root_debian.py | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/devices/debian.py b/devices/debian.py index 8a31ea23..84b78719 100644 --- a/devices/debian.py +++ b/devices/debian.py @@ -69,13 +69,13 @@ def __init__(self, def reset(self): self.sendline('reboot') - self.expect(['going down','disconnected']) + self.expect(['going down','disconnected', 'closed']) try: self.expect(self.prompt, timeout=10) except: pass time.sleep(15) # Wait for the network to go down. - for i in range(0, 20): + for i in range(0, 50): try: pexpect.spawn('ping -w 1 -c 1 ' + self.name).expect('64 bytes', timeout=1) except: @@ -85,8 +85,9 @@ def reset(self): time.sleep(15) break self.__init__(self.name, self.color, - self.output, self.username, + self.username, self.password, self.port, + output=self.output, reboot=False) def get_ip_addr(self, interface): diff --git a/devices/non_root_debian.py b/devices/non_root_debian.py index 8332dc2b..e096638e 100644 --- a/devices/non_root_debian.py +++ b/devices/non_root_debian.py @@ -76,7 +76,7 @@ def __init__(self, def reset(self): self.sendline('sudo reboot') - self.expect(['going down','disconnected']) + self.expect(['going down','disconnected', 'closed']) try: self.expect(self.prompt, timeout=10) except: @@ -86,14 +86,16 @@ def reset(self): try: pexpect.spawn('ping -w 1 -c 1 ' + self.name).expect('64 bytes', timeout=1) except: - print(self.name + " not up yet, after %s seconds." % (i + 15)) + time.sleep(1) + print(self.name + " not up yet, after %s tries." % (i)) else: - print("%s is back after %s seconds, waiting for network daemons to spawn." % (self.name, i + 14)) + print("%s is back after %s tries, waiting for network daemons to spawn." % (self.name, i)) time.sleep(15) break self.__init__(self.name, self.color, - self.output, self.username, + self.username, self.password, self.port, + output=self.output, reboot=False) def get_ip_addr(self, interface): From bf6a616037ed37d5c09ed548e938f2d39bf1ab72 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Wed, 3 Aug 2016 14:08:19 -0500 Subject: [PATCH 2/2] make debian consistent on the reboot fixes Signed-off-by: Eric Schultz --- devices/debian.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devices/debian.py b/devices/debian.py index 84b78719..b27ccd89 100644 --- a/devices/debian.py +++ b/devices/debian.py @@ -75,13 +75,14 @@ def reset(self): except: pass time.sleep(15) # Wait for the network to go down. - for i in range(0, 50): + for i in range(0, 20): try: pexpect.spawn('ping -w 1 -c 1 ' + self.name).expect('64 bytes', timeout=1) except: - print(self.name + " not up yet, after %s seconds." % (i + 15)) + time.sleep(1) + print(self.name + " not up yet, after %s tries." % (i)) else: - print("%s is back after %s seconds, waiting for network daemons to spawn." % (self.name, i + 14)) + print("%s is back after %s tries, waiting for network daemons to spawn." % (self.name, i)) time.sleep(15) break self.__init__(self.name, self.color,