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
=== modified file 'lava/dispatcher/client.py'
--- lava/dispatcher/client.py 2011-04-11 21:00:19 +0000
+++ lava/dispatcher/client.py 2011-04-21 06:47:19 +0000
@@ -99,6 +99,34 @@
99 return99 return
100 raise NetworkError100 raise NetworkError
101101
102 def bring_up_network(self, response_str=MASTER_STR):
103 """
104 Need to check if network is up by check_network_up by caller first
105 Assume default image is master
106 """
107 for iface_str in ["eth", "usb"]:
108 iface_list = []
109 for i in range(10):
110 iface_list.append("%s%i" % (iface_str, i))
111 iface_list.append(pexpect.TIMEOUT)
112 # Get network interface
113 self.proc.sendline("LC_ALL=C ifconfig -a")
114 id = self.proc.expect(iface_list, timeout=5)
115 self.proc.expect(response_str)
116 if id < 10:
117 iface = iface_str + str(id)
118 break
119 elif id > 10:
120 raise NetworkError("Ethernet interface index is too large")
121
122 try:
123 iface
124 except NameError:
125 raise NetworkError("Ethernet interface not found")
126
127 #TODO: bring up ethernet manually, not by DHCP
128
129
102 def export_display(self):130 def export_display(self):
103 #export the display, ignore errors on non-graphical images131 #export the display, ignore errors on non-graphical images
104 self.run_shell_command("su - linaro -c 'DISPLAY=:0 xhost local:'",132 self.run_shell_command("su - linaro -c 'DISPLAY=:0 xhost local:'",
@@ -115,4 +143,3 @@
115143
116class OperationFailed(Exception):144class OperationFailed(Exception):
117 pass145 pass
118

Subscribers

People subscribed via source and target branches