Merge lp://staging/~nacl/wicd/1.6-dhcp-hostnames into lp://staging/wicd/1.6

Proposed by Andrew Psaltis
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~nacl/wicd/1.6-dhcp-hostnames
Merge into: lp://staging/wicd/1.6
Diff against target: 490 lines (+104/-66)
8 files modified
curses/netentry_curses.py (+21/-2)
curses/prefs_curses.py (+46/-48)
curses/wicd-curses.py (+3/-3)
wicd/gui.py (+1/-1)
wicd/netentry.py (+15/-0)
wicd/networking.py (+8/-5)
wicd/wicd-daemon.py (+2/-0)
wicd/wnettools.py (+8/-7)
To merge this branch: bzr merge lp://staging/~nacl/wicd/1.6-dhcp-hostnames
Reviewer Review Type Date Requested Status
Adam Blackburn Needs Information
Dan O'Reilly Needs Information
Review via email: mp+10602@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrew Psaltis (nacl) wrote :

This provides DHCP hostname support for all clients except dhclient. The field is ignored in that case.

To use it with dhclient, one simply adds "send hostname 'hostname';" to the /etc/dhclient.conf

Modifying this branch to support automatically editing that should be simple enough, if wanted.

Revision history for this message
Dan O'Reilly (oreilldf) wrote :

> dhcphname = wired.GetWiredProperty("dhcphostname")
> if dhcphname is None:
> dhcphname = os.uname()[1]

Is the idea here that we always fill in the dhcp hostname field? Do we actually want to do that, or might there be a use case for someone wanting to leave that blank? Also, the check should probably be "if not dhcphname:", just in case you get an empty string back instead of None.

138 + self.set_net_prop("dhcphostname",noneToString(self.txt_dhcp_hostname.get_text()))
159 + dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
235 + self.config.set(profilename,"dhcphostname",os.uname()[1])
295 + def StartDHCP(self,hostname):
304 + cmd = self._get_dhcp_command('connect',hostname)

Put spaces after commas. (I'm nitpicking, sorry :)

Also, it'd be nice if we could do it for dhclient as well. Even if we created our own dhclient.conf file and used that. Something to think about at least.

review: Needs Information
Revision history for this message
Adam Blackburn (adamblackburn) wrote :

We debated adding support for dhclient, and in the end came to this conclusion:

Because, currently, when dhclient is run, the default configuration file (/etc/dhcp3/dhclient.conf) will be used. In order to change the hostname with dhclient, we would need to write out a configuration file of some sort. This leaves us with two options: either a) write a one line configuration file that contains only the send host-name line, or b) read the current dhclient.conf, do some processing (ie, grep -v "send host-name"; echo "send host-name randomhostname" >> /tmp/wicddhclient.conf) and then use the newly created file.

The disadvantage to writing a one line configuration file is that currently, dhclient reads /etc/dhcp3/dhclient.conf when run. This would mean that enabling sending the hostname in Wicd could result in radically different behavior then not sending the hostname.

The disadvantage to rewriting the existing file is that a) there might be some syntactical thing I haven't seen/thought of that would mess up my proposed method of rewriting, and b) would require a bit more code in the daemon.

If we were to enable support for this in dhclient, I'd recommend rewriting the existing configuration file.

review: Needs Information
459. By Andrew Psaltis

Fixed some spacing issues in the code itself, probably not all of them.

460. By Andrew Psaltis

Merge r463 of mainline 1.6.

461. By Andrew Psaltis

Merge r464 of mainline 1.6.

462. By Andrew Psaltis

Swapped the order of the command line arguments for the dhcp clients and removed the
quotes around the hostnames.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'curses/netentry_curses.py'
2--- curses/netentry_curses.py 2009-07-19 02:18:21 +0000
3+++ curses/netentry_curses.py 2009-11-18 14:47:09 +0000
4@@ -27,6 +27,7 @@
5 from wicd.misc import noneToString, stringToNone, noneToBlankString, to_bool
6
7 from wicd.translations import language
8+import sys
9
10 daemon = None
11 wired = None
12@@ -57,7 +58,9 @@
13 dns1_t = ('editcp',language['dns']+ ' 1'+':'+' '*8)
14 dns2_t = ('editcp',language['dns']+ ' 2'+':'+' '*8)
15 dns3_t = ('editcp',language['dns']+ ' 3'+':'+' '*8)
16-
17+
18+ dhcp_h_t = ('editcp',"DHCP Hostname:")
19+
20 cancel_t = 'Cancel'
21 ok_t = 'OK'
22
23@@ -80,6 +83,8 @@
24 self.dns2 = DynWrap(urwid.Edit(dns2_t) ,False)
25 self.dns3 = DynWrap(urwid.Edit(dns3_t) ,False)
26
27+ self.dhcp_h = urwid.AttrWrap(urwid.Edit(dhcp_h_t),'editbx','editfc')
28+
29 _blank = urwid.Text('')
30
31 walker = urwid.SimpleListWalker([self.static_ip_cb,
32@@ -89,7 +94,10 @@
33 _blank,
34 self.checkb_cols,
35 self.dns_dom_edit,self.search_dom_edit,
36- self.dns1,self.dns2,self.dns3
37+ self.dns1,self.dns2,self.dns3,
38+ _blank,
39+ self.dhcp_h,
40+ _blank
41 ])
42
43
44@@ -164,6 +172,7 @@
45 self.set_net_prop("dns1", '')
46 self.set_net_prop("dns2", '')
47 self.set_net_prop("dns3", '')
48+ self.set_net_prop('dhcphostname',self.dhcp_h.get_edit_text())
49 # Prevent comboboxes from dying.
50 def ready_widgets(self,ui,body):
51 pass
52@@ -203,6 +212,12 @@
53
54 self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))
55
56+ dhcphname = wired.GetWiredProperty("dhcphostname")
57+ if dhcphname is None:
58+ dhcphname = os.uname()[1]
59+
60+ self.dhcp_h.set_edit_text(unicode(dhcphname))
61+
62 def save_settings(self):
63 AdvancedSettingsDialog.save_settings(self)
64 if self.set_default.get_state():
65@@ -304,6 +319,10 @@
66 self.encryption_combo.set_focus(0)
67
68 self.change_encrypt_method()
69+ dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
70+ if dhcphname is None:
71+ dhcphname = os.uname()[1]
72+ self.dhcp_h.set_edit_text(unicode(dhcphname))
73
74
75 def set_net_prop(self, option, value):
76
77=== modified file 'curses/prefs_curses.py'
78--- curses/prefs_curses.py 2009-10-31 03:52:30 +0000
79+++ curses/prefs_curses.py 2009-11-18 14:47:09 +0000
80@@ -33,7 +33,7 @@
81 from wicd.translations import language
82
83 class PrefsDialog(urwid.WidgetWrap):
84- def __init__(self,body,pos,ui,dbus=None):
85+ def __init__(self, body, pos, ui, dbus=None):
86 global daemon, wireless, wired
87
88 daemon = dbus['daemon']
89@@ -49,9 +49,9 @@
90 header0_t = language["gen_settings"]
91 header1_t = language["ext_programs"]
92 header2_t = language["advanced_settings"]
93- self.header0 = urwid.AttrWrap(SelText(header0_t),'tab active','focus')
94- self.header1 = urwid.AttrWrap(SelText(header1_t),'body','focus')
95- self.header2 = urwid.AttrWrap(SelText(header2_t),'body','focus')
96+ self.header0 = urwid.AttrWrap(SelText(header0_t), 'tab active', 'focus')
97+ self.header1 = urwid.AttrWrap(SelText(header1_t), 'body', 'focus')
98+ self.header2 = urwid.AttrWrap(SelText(header2_t), 'body', 'focus')
99 title = language['preferences']
100
101 # Blank line
102@@ -62,64 +62,61 @@
103 ####
104
105 # General Settings
106- net_cat_t = ('header',language['network_interfaces'])
107- wired_t = ('editcp',language['wired_interface']+': ')
108- wless_t = ('editcp',language['wireless_interface']+':')
109+ net_cat_t = ('header', language['network_interfaces'])
110+ wired_t = ('editcp', language['wired_interface']+': ')
111+ wless_t = ('editcp', language['wireless_interface']+':')
112 always_show_wired_t = language['wired_always_on']
113 prefer_wired_t = language['always_switch_to_wired']
114
115- global_dns_cat_t = ('header',language['global_dns_servers'])
116- global_dns_t = ('editcp',language['use_global_dns'])
117- dns_dom_t = ('editcp',' '+language['dns_domain']+': ')
118- search_dom_t = ('editcp',' '+language['search_domain']+':')
119- dns1_t = ('editcp',' DNS server 1: ')
120- dns2_t = ('editcp',' DNS server 2: ')
121- dns3_t = ('editcp',' DNS server 3: ')
122-
123-
124- wired_auto_cat_t= ('header',language['wired_autoconnect_settings'])
125+ global_dns_cat_t = ('header', language['global_dns_servers'])
126+ global_dns_t = ('editcp', language['use_global_dns'])
127+ dns_dom_t = ('editcp', ' '+language['dns_domain']+': ')
128+ search_dom_t = ('editcp', ' '+language['search_domain']+':')
129+ dns1_t = ('editcp', ' DNS server 1: ')
130+ dns2_t = ('editcp', ' DNS server 2: ')
131+ dns3_t = ('editcp', ' DNS server 3: ')
132+
133+
134+ wired_auto_cat_t= ('header', language['wired_autoconnect_settings'])
135 wired_auto_1_t = language['use_default_profile']
136 wired_auto_2_t = language['show_wired_list']
137 wired_auto_3_t = language['use_last_used_profile']
138
139- auto_reconn_cat_t = ('header',language['automatic_reconnection'])
140+ auto_reconn_cat_t = ('header', language['automatic_reconnection'])
141 auto_reconn_t = language['auto_reconnect']
142
143 #### External Programs
144 automatic_t = language['wicd_auto_config']
145
146- dhcp_header_t = ('header',language["dhcp_client"])
147+ dhcp_header_t = ('header', language["dhcp_client"])
148 # Automatic
149 dhcp1_t = 'dhclient'
150 dhcp2_t = 'dhcpcd'
151 dhcp3_t = 'pump'
152 dhcp4_t = 'udhcpc'
153
154- wired_detect_header_t = ('header',language["wired_detect"])
155+ wired_detect_header_t = ('header', language["wired_detect"])
156 wired1_t = 'ethtool'
157 wired2_t = 'mii-tool'
158
159- flush_header_t = ('header',language["route_flush"])
160+ flush_header_t = ('header', language["route_flush"])
161 flush1_t = 'ip'
162 flush2_t = 'route'
163
164 #### Advanced Settings
165- #wpa_t=('editcp',language['wpa_supplicant_driver']+':')
166- wpa_cat_t=('header',language['wpa_supplicant'])
167+ wpa_cat_t=('header', language['wpa_supplicant'])
168 wpa_t=('editcp','Driver:')
169- wpa_list = ['spam','double spam','triple spam','quadruple spam']
170- wpa_warn_t = ('important',language['always_use_wext'])
171+ wpa_list = []
172+ wpa_warn_t = ('important', language['always_use_wext'])
173
174- backend_cat_t = ('header',language['backend'])
175+ backend_cat_t = ('header', language['backend'])
176 backend_t = language['backend']+':'
177- backend_list = ['spam','double spam','triple spam','quadruple spam']
178- #backend_warn_t = ('important',
179- # 'Changes to the backend (probably) requires a daemon restart')
180+ backend_list = []
181
182- debug_cat_t = ('header',language['debugging'])
183+ debug_cat_t = ('header', language['debugging'])
184 debug_mode_t = language['use_debug_mode']
185
186- wless_cat_t = ('header',language['wireless_interface'])
187+ wless_cat_t = ('header', language['wireless_interface'])
188 use_dbm_t = language['display_type_dialog']
189
190
191@@ -129,7 +126,7 @@
192 ####
193
194 # General Settings
195- self.net_cat = urwid.Text(net_cat_t)
196+ self.net_cat = urwid.Text(net_cat_t)
197 self.wired_edit = urwid.AttrWrap(urwid.Edit(wired_t),'editbx','editfc')
198 self.wless_edit = urwid.AttrWrap(urwid.Edit(wless_t),'editbx','editfc')
199 self.prefer_wired_chkbx = urwid.CheckBox(prefer_wired_t)
200@@ -137,13 +134,13 @@
201 # Default the global DNS settings to off. They will be reenabled later
202 # if so required.
203 global_dns_state = False
204- self.global_dns_checkb = urwid.CheckBox(global_dns_t,global_dns_state,
205+ self.global_dns_checkb = urwid.CheckBox(global_dns_t, global_dns_state,
206 on_state_change=self.global_dns_trigger)
207- self.search_dom = DynWrap(urwid.Edit(search_dom_t),global_dns_state)
208- self.dns_dom = DynWrap(urwid.Edit(dns_dom_t),global_dns_state)
209- self.dns1 = DynWrap(urwid.Edit(dns1_t),global_dns_state)
210- self.dns2 = DynWrap(urwid.Edit(dns2_t),global_dns_state)
211- self.dns3 = DynWrap(urwid.Edit(dns3_t),global_dns_state)
212+ self.search_dom = DynWrap(urwid.Edit(search_dom_t), global_dns_state)
213+ self.dns_dom = DynWrap(urwid.Edit(dns_dom_t), global_dns_state)
214+ self.dns1 = DynWrap(urwid.Edit(dns1_t), global_dns_state)
215+ self.dns2 = DynWrap(urwid.Edit(dns2_t), global_dns_state)
216+ self.dns3 = DynWrap(urwid.Edit(dns3_t), global_dns_state)
217
218
219 self.always_show_wired_checkb = urwid.CheckBox(always_show_wired_t)
220@@ -182,19 +179,19 @@
221 # Order of these is flipped in the actual interface,
222 # (2,3,1 -> dhcpcd, pump, dhclient), because dhclient often doesn't like
223 # to work on several distros.
224- self.dhcp0 = urwid.RadioButton(self.dhcp_l,automatic_t)
225- self.dhcp1 = DynRadioButton(self.dhcp_l,dhcp1_t)
226- self.dhcp2 = DynRadioButton(self.dhcp_l,dhcp2_t)
227- self.dhcp3 = DynRadioButton(self.dhcp_l,dhcp3_t)
228- self.dhcp4 = DynRadioButton(self.dhcp_l,dhcp4_t)
229+ self.dhcp0 = urwid.RadioButton(self.dhcp_l ,automatic_t)
230+ self.dhcp1 = DynRadioButton(self.dhcp_l, dhcp1_t)
231+ self.dhcp2 = DynRadioButton(self.dhcp_l, dhcp2_t)
232+ self.dhcp3 = DynRadioButton(self.dhcp_l, dhcp3_t)
233+ self.dhcp4 = DynRadioButton(self.dhcp_l, dhcp4_t)
234 self.dhcp_l = [self.dhcp0,self.dhcp1,self.dhcp2,self.dhcp3,self.dhcp4]
235
236 self.wired_l = []
237 self.wired_detect_header = urwid.Text(wired_detect_header_t)
238- self.wired0 = urwid.RadioButton(self.wired_l,automatic_t)
239- self.wired1 = DynRadioButton(self.wired_l,wired1_t)
240- self.wired2 = DynRadioButton(self.wired_l,wired2_t)
241- self.wired_l = [self.wired0,self.wired1,self.wired2]
242+ self.wired0 = urwid.RadioButton(self.wired_l, automatic_t)
243+ self.wired1 = DynRadioButton(self.wired_l, wired1_t)
244+ self.wired2 = DynRadioButton(self.wired_l, wired2_t)
245+ self.wired_l = [self.wired0, self.wired1, self.wired2]
246
247 self.flush_l = []
248 self.flush_header = urwid.Text(flush_header_t)
249@@ -204,7 +201,8 @@
250 self.flush_l = [self.flush0,self.flush1,self.flush2]
251
252 externalLB = urwid.ListBox([self.dhcp_header,
253- self.dhcp0,self.dhcp2,self.dhcp3,self.dhcp1,self.dhcp4,
254+ self.dhcp0,self.dhcp2,self.dhcp3,self.dhcp1,
255+ self.dhcp4,
256 _blank,
257 self.wired_detect_header,
258 self.wired0,self.wired1,self.wired2,
259
260=== modified file 'curses/wicd-curses.py'
261--- curses/wicd-curses.py 2009-09-29 16:38:11 +0000
262+++ curses/wicd-curses.py 2009-11-18 14:47:09 +0000
263@@ -192,9 +192,9 @@
264 ('green',"\\|| \\\\")," |+| ",('green',"// ||/ \n"),
265 ('green'," \\\\\\")," |+| ",('green',"///")," http://wicd.net\n",
266 ('green'," \\\\\\")," |+| ",('green',"///")," ",language["brought_to_you"],"\n",
267-('green'," \\\\\\")," |+| ",('green',"///")," Adam Blackburn (wicd)\n",
268-" ___|+|___ Dan O'Reilly (wicd)\n",
269-" |---------| Andrew Psaltis (this ui)\n",
270+('green'," \\\\\\")," |+| ",('green',"///")," Adam Blackburn\n",
271+" ___|+|___ Dan O'Reilly\n",
272+" |---------| Andrew Psaltis\n",
273 "-----------------------------------------------------"]
274 about = TextDialog(theText,16,55,header=('header','About Wicd'))
275 about.run(ui,body)
276
277=== modified file 'wicd/gui.py'
278--- wicd/gui.py 2009-07-19 02:26:18 +0000
279+++ wicd/gui.py 2009-11-18 14:47:09 +0000
280@@ -298,7 +298,7 @@
281 dialog = gtk.AboutDialog()
282 dialog.set_name("Wicd")
283 dialog.set_version(daemon.Hello())
284- dialog.set_authors([ "Adam Blackburn", "Dan O'Reilly" ])
285+ dialog.set_authors([ "Adam Blackburn", "Dan O'Reilly", "Andrew Psaltis" ])
286 dialog.set_website("http://wicd.sourceforge.net")
287 dialog.run()
288 dialog.destroy()
289
290=== modified file 'wicd/netentry.py'
291--- wicd/netentry.py 2009-08-13 17:11:55 +0000
292+++ wicd/netentry.py 2009-11-18 14:47:09 +0000
293@@ -8,6 +8,7 @@
294 #
295 # Copyright (C) 2008-2009 Adam Blackburn
296 # Copyright (C) 2008-2009 Dan O'Reilly
297+# Copyright (C) 2009 Andrew Psaltis
298 #
299 # This program is free software; you can redistribute it and/or modify
300 # it under the terms of the GNU General Public License Version 2 as
301@@ -73,6 +74,7 @@
302 self.txt_dns_1 = LabelEntry(language['dns'] + ' 1')
303 self.txt_dns_2 = LabelEntry(language['dns'] + ' 2')
304 self.txt_dns_3 = LabelEntry(language['dns'] + ' 3')
305+ self.txt_dhcp_hostname = LabelEntry("DHCP Hostname")
306 self.chkbox_static_ip = gtk.CheckButton(language['use_static_ip'])
307 self.chkbox_static_dns = gtk.CheckButton(language['use_static_dns'])
308 self.chkbox_global_dns = gtk.CheckButton(language['use_global_dns'])
309@@ -104,6 +106,7 @@
310 self.vbox.pack_start(self.txt_dns_1, fill=False, expand=False)
311 self.vbox.pack_start(self.txt_dns_2, fill=False, expand=False)
312 self.vbox.pack_start(self.txt_dns_3, fill=False, expand=False)
313+ self.vbox.pack_start(self.txt_dhcp_hostname, fill=False, expand=False)
314 self.vbox.pack_end(self.button_hbox, fill=False, expand=False, padding=5)
315
316
317@@ -238,6 +241,7 @@
318 self.set_net_prop("dns1", '')
319 self.set_net_prop("dns2", '')
320 self.set_net_prop("dns3", '')
321+ self.set_net_prop("dhcphostname",noneToString(self.txt_dhcp_hostname.get_text()))
322
323
324 class WiredSettingsDialog(AdvancedSettingsDialog):
325@@ -279,6 +283,12 @@
326 self.txt_domain.set_text(self.format_entry("dns_domain"))
327 self.txt_search_dom.set_text(self.format_entry("search_domain"))
328 self.chkbox_global_dns.set_active(bool(wired.GetWiredProperty("use_global_dns")))
329+
330+ dhcphname = wired.GetWiredProperty("dhcphostname")
331+ if dhcphname is None:
332+ dhcphname = os.uname()[1]
333+
334+ self.txt_dhcp_hostname.set_text(dhcphname)
335 self.reset_static_checkboxes()
336
337 def save_settings(self):
338@@ -395,6 +405,11 @@
339 self.chkbox_global_settings.set_active(bool(wireless.GetWirelessProperty(networkID,
340 'use_settings_globally')))
341
342+ dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
343+ if dhcphname is None:
344+ dhcphname = os.uname()[1]
345+ self.txt_dhcp_hostname.set_text(dhcphname)
346+
347 activeID = -1 # Set the menu to this item when we are done
348 user_enctype = wireless.GetWirelessProperty(networkID, "enctype")
349 for x, enc_type in enumerate(self.encrypt_types):
350
351=== modified file 'wicd/networking.py'
352--- wicd/networking.py 2009-11-01 20:22:45 +0000
353+++ wicd/networking.py 2009-11-18 14:47:09 +0000
354@@ -22,6 +22,7 @@
355 # Copyright (C) 2007 - 2009 Adam Blackburn
356 # Copyright (C) 2007 - 2009 Dan O'Reilly
357 # Copyright (C) 2007 - 2009 Byron Hillis
358+# Copyright (C) 2009 Andrew Psaltis
359 #
360 # This program is free software; you can redistribute it and/or modify
361 # it under the terms of the GNU General Public License Version 2 as
362@@ -281,7 +282,8 @@
363
364 def __init__(self, network, interface_name, before_script, after_script,
365 pre_disconnect_script, post_disconnect_script, gdns1,
366- gdns2, gdns3, gdns_dom, gsearch_dom, iface, debug):
367+ gdns2, gdns3, gdns_dom, gsearch_dom, iface,
368+ debug):
369 """ Initialise the required object variables and the thread.
370
371 Keyword arguments:
372@@ -316,7 +318,7 @@
373 self.global_dns_3 = gdns3
374 self.global_dns_dom = gdns_dom
375 self.global_search_dom = gsearch_dom
376-
377+
378 self.iface = iface
379
380 self.connecting_message = None
381@@ -436,8 +438,8 @@
382 else:
383 # Run dhcp...
384 self.SetStatus('running_dhcp')
385- print "Running DHCP"
386- dhcp_status = iface.StartDHCP()
387+ print "Running DHCP with hostname",self.network["dhcphostname"]
388+ dhcp_status = iface.StartDHCP(self.network["dhcphostname"])
389 if dhcp_status in ['no_dhcp_offers', 'dhcp_failed']:
390 if self.connect_result != "aborted":
391 self.abort_connection(dhcp_status)
392@@ -1041,7 +1043,8 @@
393 ConnectThread.__init__(self, network, wired, before_script,
394 after_script, pre_disconnect_script,
395 post_disconnect_script, gdns1, gdns2,
396- gdns3, gdns_dom, gsearch_dom, liface, debug)
397+ gdns3, gdns_dom, gsearch_dom, liface,
398+ debug)
399
400 def _connect(self):
401 """ The main function of the connection thread.
402
403=== modified file 'wicd/wicd-daemon.py'
404--- wicd/wicd-daemon.py 2009-10-31 03:52:30 +0000
405+++ wicd/wicd-daemon.py 2009-11-18 14:47:09 +0000
406@@ -18,6 +18,7 @@
407 # Copyright (C) 2007 - 2009 Adam Blackburn
408 # Copyright (C) 2007 - 2009 Dan O'Reilly
409 # Copyright (C) 2007 - 2009 Byron Hillis
410+# Copyright (C) 2009 Andrew Psaltis
411 #
412 # This program is free software; you can redistribute it and/or modify
413 # it under the terms of the GNU General Public License Version 2 as
414@@ -1459,6 +1460,7 @@
415 "postdisconnectscript"]:
416 self.config.set(profilename, option, None)
417 self.config.set(profilename, "default", default)
418+ self.config.set(profilename,"dhcphostname",os.uname()[1])
419 self.config.write()
420 return True
421
422
423=== modified file 'wicd/wnettools.py'
424--- wicd/wnettools.py 2009-10-31 03:52:30 +0000
425+++ wicd/wnettools.py 2009-11-18 14:47:09 +0000
426@@ -16,6 +16,7 @@
427 # Copyright (C) 2007 - 2009 Adam Blackburn
428 # Copyright (C) 2007 - 2009 Dan O'Reilly
429 # Copyright (C) 2007 - 2009 Byron Hillis
430+# Copyright (C) 2009 Andrew Psaltis
431 #
432 # This program is free software; you can redistribute it and/or modify
433 # it under the terms of the GNU General Public License Version 2 as
434@@ -241,7 +242,7 @@
435 return path
436
437
438- def _get_dhcp_command(self, flavor=None):
439+ def _get_dhcp_command(self, flavor=None, hostname=None):
440 """ Returns the correct DHCP client command.
441
442 Given a type of DHCP request (create or release a lease),
443@@ -277,17 +278,17 @@
444 'id' : misc.DHCLIENT,
445 },
446 "pump" :
447- { 'connect' : r"%(cmd)s -i %(iface)s",
448+ { 'connect' : r"%(cmd)s -i %(iface)s -h %(hostname)s",
449 'release' : r"%(cmd)s -r -i %(iface)s",
450 'id' : misc.PUMP,
451 },
452 "dhcpcd" :
453- {'connect' : r"%(cmd)s %(iface)s",
454+ {'connect' : r"%(cmd)s %(iface)s -h %(hostname)s ",
455 'release' : r"%(cmd)s -k %(iface)s",
456 'id' : misc.DHCPCD,
457 },
458 "udhcpc":
459- {'connect' : r"%(cmd)s -n -i %(iface)s",
460+ {'connect' : r"%(cmd)s -n -i %(iface)s -H %(hostname)s ",
461 'release' : r"killall -SIGUSR2 %(cmd)s",
462 'id' : misc.UDHCPC,
463 },
464@@ -298,7 +299,7 @@
465 return ""
466
467 if flavor == "connect":
468- return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface}
469+ return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface, "hostname":hostname}
470 elif flavor == "release":
471 return client_dict[client_name]['release'] % {"cmd":cmd, "iface":self.iface}
472 else:
473@@ -549,7 +550,7 @@
474 return 'dhcp_failed'
475
476 @neediface(False)
477- def StartDHCP(self):
478+ def StartDHCP(self,hostname):
479 """ Start the DHCP client to obtain an IP address.
480
481 Returns:
482@@ -557,7 +558,7 @@
483 _check_dhcp_result for the possible values.
484
485 """
486- cmd = self._get_dhcp_command('connect')
487+ cmd = self._get_dhcp_command('connect',hostname)
488 if self.verbose: print cmd
489 self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True)
490 pipe = self.dhcp_object.stdout

Subscribers

People subscribed via source and target branches

to status/vote changes: