Merge lp:~qzhang/lava-dispatcher/bringup-network into lp:lava-dispatcher

Proposed by Spring Zhang
Status: Rejected
Rejected by: Neil Williams
Proposed branch: lp:~qzhang/lava-dispatcher/bringup-network
Merge into: lp:lava-dispatcher
Diff against target: 43 lines (+28/-1)
1 file modified
lava/dispatcher/client.py (+28/-1)
To merge this branch: bzr merge lp:~qzhang/lava-dispatcher/bringup-network
Reviewer Review Type Date Requested Status
Paul Larson (community) Needs Fixing
Review via email: mp+58278@code.launchpad.net

Description of the change

Try to bring up the network if necessary:
1. meet a strange behavior of pexpect
2. I met timeout issue in pexpect
Will check if my pexpect library error.

Detecting if network is ok is already done by check_network_up.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

15 + if self.board.type == "vexpress":
16 + iface_str = "usb"
vexpress is not the only board with a usb network interface. I think we can take a simpler approach to this. Search for ethX first, and use it if we find it. If not, search for usbX. Maybe do it in a bit cleaner way if possible too.

18 + self.proc.sendline(
19 + "LC_ALL=C ifconfig -a | grep -i '^%s. ' | wc -l"
20 + % iface_str)
21 + id = self.proc.expect(["1", "0"], timeout=5)
22 + self.proc.expect(response_str)
23 + # fix it, strange: id will be 1 when eth0 is found
24 + if id == 1:
25 + raise NetworkError("Ethernet interface not found")
26 + elif id > 1:
27 + raise NetworkError("Ethernet interfaces are not unique")
The 'id' returned matches which entry in the list it found, not the exact text that it found.

42 + #bring up ethernet
43 + self.run_shell_command("ifconfig %s up" % iface,
44 + response = response_str)
45 + self.run_shell_command("dhclient %s" % iface,
46 + response = response_str)
We don't want to bring up the network like this. DHCP is not going to be reliable for us in the long run, as we need a predictable ip address on the board. We don't even have a predictable mac address in all cases, so dhcp is not an option.

review: Needs Fixing
45. By Spring Zhang

match network interface ethX then usbX

46. By Spring Zhang

delete DHCP network probe up code, add a TODO for adding manual network probing up code

Revision history for this message
Spring Zhang (qzhang) wrote :

Thanks for the comments.

> 15 + if self.board.type == "vexpress":
> 16 + iface_str = "usb"
> vexpress is not the only board with a usb network interface. I think we can
> take a simpler approach to this. Search for ethX first, and use it if we find
> it. If not, search for usbX. Maybe do it in a bit cleaner way if possible
> too.
I have done that in this way, it will search eth0...eth9 and then usb0...usb9

>
> 18 + self.proc.sendline(
> 19 + "LC_ALL=C ifconfig -a | grep -i '^%s. ' | wc -l"
> 20 + % iface_str)
> 21 + id = self.proc.expect(["1", "0"], timeout=5)
> 22 + self.proc.expect(response_str)
> 23 + # fix it, strange: id will be 1 when eth0 is found
> 24 + if id == 1:
> 25 + raise NetworkError("Ethernet interface not found")
> 26 + elif id > 1:
> 27 + raise NetworkError("Ethernet interfaces are not unique")
> The 'id' returned matches which entry in the list it found, not the exact text
> that it found.
I've got the answer why it confused me.

>
> 42 + #bring up ethernet
> 43 + self.run_shell_command("ifconfig %s up" % iface,
> 44 + response = response_str)
> 45 + self.run_shell_command("dhclient %s" % iface,
> 46 + response = response_str)
> We don't want to bring up the network like this. DHCP is not going to be
> reliable for us in the long run, as we need a predictable ip address on the
> board. We don't even have a predictable mac address in all cases, so dhcp is
> not an option.

I deleted DHCP code and add an TODO for Dave to add manual probing up code.

Unmerged revisions

46. By Spring Zhang

delete DHCP network probe up code, add a TODO for adding manual network probing up code

45. By Spring Zhang

match network interface ethX then usbX

44. By Spring Zhang

remove network checking for it can be done by caller

43. By Spring Zhang

remove simple test

42. By Spring Zhang

meet a strange behaviour of pexpect

41. By Spring Zhang

avoid private address iface like eth0:avahi after dhclient when no network

40. By Spring Zhang

add network bring up

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava/dispatcher/client.py'
2--- lava/dispatcher/client.py 2011-04-11 21:00:19 +0000
3+++ lava/dispatcher/client.py 2011-04-21 06:47:19 +0000
4@@ -99,6 +99,34 @@
5 return
6 raise NetworkError
7
8+ def bring_up_network(self, response_str=MASTER_STR):
9+ """
10+ Need to check if network is up by check_network_up by caller first
11+ Assume default image is master
12+ """
13+ for iface_str in ["eth", "usb"]:
14+ iface_list = []
15+ for i in range(10):
16+ iface_list.append("%s%i" % (iface_str, i))
17+ iface_list.append(pexpect.TIMEOUT)
18+ # Get network interface
19+ self.proc.sendline("LC_ALL=C ifconfig -a")
20+ id = self.proc.expect(iface_list, timeout=5)
21+ self.proc.expect(response_str)
22+ if id < 10:
23+ iface = iface_str + str(id)
24+ break
25+ elif id > 10:
26+ raise NetworkError("Ethernet interface index is too large")
27+
28+ try:
29+ iface
30+ except NameError:
31+ raise NetworkError("Ethernet interface not found")
32+
33+ #TODO: bring up ethernet manually, not by DHCP
34+
35+
36 def export_display(self):
37 #export the display, ignore errors on non-graphical images
38 self.run_shell_command("su - linaro -c 'DISPLAY=:0 xhost local:'",
39@@ -115,4 +143,3 @@
40
41 class OperationFailed(Exception):
42 pass
43-

Subscribers

People subscribed via source and target branches