mirror of
https://github.com/gryf/wicd.git
synced 2025-12-24 23:22:27 +01:00
merged dhcp-hostnames
This commit is contained in:
@@ -27,6 +27,7 @@ import wicd.misc as misc
|
||||
from wicd.misc import noneToString, stringToNone, noneToBlankString, to_bool
|
||||
|
||||
from wicd.translations import language
|
||||
import sys
|
||||
|
||||
daemon = None
|
||||
wired = None
|
||||
@@ -57,7 +58,9 @@ class AdvancedSettingsDialog(urwid.WidgetWrap):
|
||||
dns1_t = ('editcp',language['dns']+ ' 1'+':'+' '*8)
|
||||
dns2_t = ('editcp',language['dns']+ ' 2'+':'+' '*8)
|
||||
dns3_t = ('editcp',language['dns']+ ' 3'+':'+' '*8)
|
||||
|
||||
|
||||
dhcp_h_t = ('editcp',"DHCP Hostname:")
|
||||
|
||||
cancel_t = 'Cancel'
|
||||
ok_t = 'OK'
|
||||
|
||||
@@ -80,6 +83,8 @@ class AdvancedSettingsDialog(urwid.WidgetWrap):
|
||||
self.dns2 = DynWrap(urwid.Edit(dns2_t) ,False)
|
||||
self.dns3 = DynWrap(urwid.Edit(dns3_t) ,False)
|
||||
|
||||
self.dhcp_h = urwid.AttrWrap(urwid.Edit(dhcp_h_t),'editbx','editfc')
|
||||
|
||||
_blank = urwid.Text('')
|
||||
|
||||
walker = urwid.SimpleListWalker([self.static_ip_cb,
|
||||
@@ -89,7 +94,10 @@ class AdvancedSettingsDialog(urwid.WidgetWrap):
|
||||
_blank,
|
||||
self.checkb_cols,
|
||||
self.dns_dom_edit,self.search_dom_edit,
|
||||
self.dns1,self.dns2,self.dns3
|
||||
self.dns1,self.dns2,self.dns3,
|
||||
_blank,
|
||||
self.dhcp_h,
|
||||
_blank
|
||||
])
|
||||
|
||||
|
||||
@@ -164,6 +172,7 @@ class AdvancedSettingsDialog(urwid.WidgetWrap):
|
||||
self.set_net_prop("dns1", '')
|
||||
self.set_net_prop("dns2", '')
|
||||
self.set_net_prop("dns3", '')
|
||||
self.set_net_prop('dhcphostname',self.dhcp_h.get_edit_text())
|
||||
# Prevent comboboxes from dying.
|
||||
def ready_widgets(self,ui,body):
|
||||
pass
|
||||
@@ -203,6 +212,12 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||
|
||||
self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))
|
||||
|
||||
dhcphname = wired.GetWiredProperty("dhcphostname")
|
||||
if dhcphname is None:
|
||||
dhcphname = os.uname()[1]
|
||||
|
||||
self.dhcp_h.set_edit_text(unicode(dhcphname))
|
||||
|
||||
def save_settings(self):
|
||||
AdvancedSettingsDialog.save_settings(self)
|
||||
if self.set_default.get_state():
|
||||
@@ -304,6 +319,10 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
||||
self.encryption_combo.set_focus(0)
|
||||
|
||||
self.change_encrypt_method()
|
||||
dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
|
||||
if dhcphname is None:
|
||||
dhcphname = os.uname()[1]
|
||||
self.dhcp_h.set_edit_text(unicode(dhcphname))
|
||||
|
||||
|
||||
def set_net_prop(self, option, value):
|
||||
|
||||
@@ -33,7 +33,7 @@ wired = None
|
||||
from wicd.translations import language
|
||||
|
||||
class PrefsDialog(urwid.WidgetWrap):
|
||||
def __init__(self,body,pos,ui,dbus=None):
|
||||
def __init__(self, body, pos, ui, dbus=None):
|
||||
global daemon, wireless, wired
|
||||
|
||||
daemon = dbus['daemon']
|
||||
@@ -49,9 +49,9 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
header0_t = language["gen_settings"]
|
||||
header1_t = language["ext_programs"]
|
||||
header2_t = language["advanced_settings"]
|
||||
self.header0 = urwid.AttrWrap(SelText(header0_t),'tab active','focus')
|
||||
self.header1 = urwid.AttrWrap(SelText(header1_t),'body','focus')
|
||||
self.header2 = urwid.AttrWrap(SelText(header2_t),'body','focus')
|
||||
self.header0 = urwid.AttrWrap(SelText(header0_t), 'tab active', 'focus')
|
||||
self.header1 = urwid.AttrWrap(SelText(header1_t), 'body', 'focus')
|
||||
self.header2 = urwid.AttrWrap(SelText(header2_t), 'body', 'focus')
|
||||
title = language['preferences']
|
||||
|
||||
# Blank line
|
||||
@@ -62,64 +62,61 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
####
|
||||
|
||||
# General Settings
|
||||
net_cat_t = ('header',language['network_interfaces'])
|
||||
wired_t = ('editcp',language['wired_interface']+': ')
|
||||
wless_t = ('editcp',language['wireless_interface']+':')
|
||||
net_cat_t = ('header', language['network_interfaces'])
|
||||
wired_t = ('editcp', language['wired_interface']+': ')
|
||||
wless_t = ('editcp', language['wireless_interface']+':')
|
||||
always_show_wired_t = language['wired_always_on']
|
||||
prefer_wired_t = language['always_switch_to_wired']
|
||||
|
||||
global_dns_cat_t = ('header',language['global_dns_servers'])
|
||||
global_dns_t = ('editcp',language['use_global_dns'])
|
||||
dns_dom_t = ('editcp',' '+language['dns_domain']+': ')
|
||||
search_dom_t = ('editcp',' '+language['search_domain']+':')
|
||||
dns1_t = ('editcp',' DNS server 1: ')
|
||||
dns2_t = ('editcp',' DNS server 2: ')
|
||||
dns3_t = ('editcp',' DNS server 3: ')
|
||||
global_dns_cat_t = ('header', language['global_dns_servers'])
|
||||
global_dns_t = ('editcp', language['use_global_dns'])
|
||||
dns_dom_t = ('editcp', ' '+language['dns_domain']+': ')
|
||||
search_dom_t = ('editcp', ' '+language['search_domain']+':')
|
||||
dns1_t = ('editcp', ' DNS server 1: ')
|
||||
dns2_t = ('editcp', ' DNS server 2: ')
|
||||
dns3_t = ('editcp', ' DNS server 3: ')
|
||||
|
||||
|
||||
wired_auto_cat_t= ('header',language['wired_autoconnect_settings'])
|
||||
wired_auto_cat_t= ('header', language['wired_autoconnect_settings'])
|
||||
wired_auto_1_t = language['use_default_profile']
|
||||
wired_auto_2_t = language['show_wired_list']
|
||||
wired_auto_3_t = language['use_last_used_profile']
|
||||
|
||||
auto_reconn_cat_t = ('header',language['automatic_reconnection'])
|
||||
auto_reconn_cat_t = ('header', language['automatic_reconnection'])
|
||||
auto_reconn_t = language['auto_reconnect']
|
||||
|
||||
#### External Programs
|
||||
automatic_t = language['wicd_auto_config']
|
||||
|
||||
dhcp_header_t = ('header',language["dhcp_client"])
|
||||
dhcp_header_t = ('header', language["dhcp_client"])
|
||||
# Automatic
|
||||
dhcp1_t = 'dhclient'
|
||||
dhcp2_t = 'dhcpcd'
|
||||
dhcp3_t = 'pump'
|
||||
dhcp4_t = 'udhcpc'
|
||||
|
||||
wired_detect_header_t = ('header',language["wired_detect"])
|
||||
wired_detect_header_t = ('header', language["wired_detect"])
|
||||
wired1_t = 'ethtool'
|
||||
wired2_t = 'mii-tool'
|
||||
|
||||
flush_header_t = ('header',language["route_flush"])
|
||||
flush_header_t = ('header', language["route_flush"])
|
||||
flush1_t = 'ip'
|
||||
flush2_t = 'route'
|
||||
|
||||
#### Advanced Settings
|
||||
#wpa_t=('editcp',language['wpa_supplicant_driver']+':')
|
||||
wpa_cat_t=('header',language['wpa_supplicant'])
|
||||
wpa_cat_t=('header', language['wpa_supplicant'])
|
||||
wpa_t=('editcp','Driver:')
|
||||
wpa_list = ['spam','double spam','triple spam','quadruple spam']
|
||||
wpa_warn_t = ('important',language['always_use_wext'])
|
||||
wpa_list = []
|
||||
wpa_warn_t = ('important', language['always_use_wext'])
|
||||
|
||||
backend_cat_t = ('header',language['backend'])
|
||||
backend_cat_t = ('header', language['backend'])
|
||||
backend_t = language['backend']+':'
|
||||
backend_list = ['spam','double spam','triple spam','quadruple spam']
|
||||
#backend_warn_t = ('important',
|
||||
# 'Changes to the backend (probably) requires a daemon restart')
|
||||
backend_list = []
|
||||
|
||||
debug_cat_t = ('header',language['debugging'])
|
||||
debug_cat_t = ('header', language['debugging'])
|
||||
debug_mode_t = language['use_debug_mode']
|
||||
|
||||
wless_cat_t = ('header',language['wireless_interface'])
|
||||
wless_cat_t = ('header', language['wireless_interface'])
|
||||
use_dbm_t = language['display_type_dialog']
|
||||
|
||||
|
||||
@@ -129,7 +126,7 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
####
|
||||
|
||||
# General Settings
|
||||
self.net_cat = urwid.Text(net_cat_t)
|
||||
self.net_cat = urwid.Text(net_cat_t)
|
||||
self.wired_edit = urwid.AttrWrap(urwid.Edit(wired_t),'editbx','editfc')
|
||||
self.wless_edit = urwid.AttrWrap(urwid.Edit(wless_t),'editbx','editfc')
|
||||
self.prefer_wired_chkbx = urwid.CheckBox(prefer_wired_t)
|
||||
@@ -137,13 +134,13 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
# Default the global DNS settings to off. They will be reenabled later
|
||||
# if so required.
|
||||
global_dns_state = False
|
||||
self.global_dns_checkb = urwid.CheckBox(global_dns_t,global_dns_state,
|
||||
self.global_dns_checkb = urwid.CheckBox(global_dns_t, global_dns_state,
|
||||
on_state_change=self.global_dns_trigger)
|
||||
self.search_dom = DynWrap(urwid.Edit(search_dom_t),global_dns_state)
|
||||
self.dns_dom = DynWrap(urwid.Edit(dns_dom_t),global_dns_state)
|
||||
self.dns1 = DynWrap(urwid.Edit(dns1_t),global_dns_state)
|
||||
self.dns2 = DynWrap(urwid.Edit(dns2_t),global_dns_state)
|
||||
self.dns3 = DynWrap(urwid.Edit(dns3_t),global_dns_state)
|
||||
self.search_dom = DynWrap(urwid.Edit(search_dom_t), global_dns_state)
|
||||
self.dns_dom = DynWrap(urwid.Edit(dns_dom_t), global_dns_state)
|
||||
self.dns1 = DynWrap(urwid.Edit(dns1_t), global_dns_state)
|
||||
self.dns2 = DynWrap(urwid.Edit(dns2_t), global_dns_state)
|
||||
self.dns3 = DynWrap(urwid.Edit(dns3_t), global_dns_state)
|
||||
|
||||
|
||||
self.always_show_wired_checkb = urwid.CheckBox(always_show_wired_t)
|
||||
@@ -182,19 +179,19 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
# Order of these is flipped in the actual interface,
|
||||
# (2,3,1 -> dhcpcd, pump, dhclient), because dhclient often doesn't like
|
||||
# to work on several distros.
|
||||
self.dhcp0 = urwid.RadioButton(self.dhcp_l,automatic_t)
|
||||
self.dhcp1 = DynRadioButton(self.dhcp_l,dhcp1_t)
|
||||
self.dhcp2 = DynRadioButton(self.dhcp_l,dhcp2_t)
|
||||
self.dhcp3 = DynRadioButton(self.dhcp_l,dhcp3_t)
|
||||
self.dhcp4 = DynRadioButton(self.dhcp_l,dhcp4_t)
|
||||
self.dhcp0 = urwid.RadioButton(self.dhcp_l ,automatic_t)
|
||||
self.dhcp1 = DynRadioButton(self.dhcp_l, dhcp1_t)
|
||||
self.dhcp2 = DynRadioButton(self.dhcp_l, dhcp2_t)
|
||||
self.dhcp3 = DynRadioButton(self.dhcp_l, dhcp3_t)
|
||||
self.dhcp4 = DynRadioButton(self.dhcp_l, dhcp4_t)
|
||||
self.dhcp_l = [self.dhcp0,self.dhcp1,self.dhcp2,self.dhcp3,self.dhcp4]
|
||||
|
||||
self.wired_l = []
|
||||
self.wired_detect_header = urwid.Text(wired_detect_header_t)
|
||||
self.wired0 = urwid.RadioButton(self.wired_l,automatic_t)
|
||||
self.wired1 = DynRadioButton(self.wired_l,wired1_t)
|
||||
self.wired2 = DynRadioButton(self.wired_l,wired2_t)
|
||||
self.wired_l = [self.wired0,self.wired1,self.wired2]
|
||||
self.wired0 = urwid.RadioButton(self.wired_l, automatic_t)
|
||||
self.wired1 = DynRadioButton(self.wired_l, wired1_t)
|
||||
self.wired2 = DynRadioButton(self.wired_l, wired2_t)
|
||||
self.wired_l = [self.wired0, self.wired1, self.wired2]
|
||||
|
||||
self.flush_l = []
|
||||
self.flush_header = urwid.Text(flush_header_t)
|
||||
@@ -204,7 +201,8 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
self.flush_l = [self.flush0,self.flush1,self.flush2]
|
||||
|
||||
externalLB = urwid.ListBox([self.dhcp_header,
|
||||
self.dhcp0,self.dhcp2,self.dhcp3,self.dhcp1,self.dhcp4,
|
||||
self.dhcp0,self.dhcp2,self.dhcp3,self.dhcp1,
|
||||
self.dhcp4,
|
||||
_blank,
|
||||
self.wired_detect_header,
|
||||
self.wired0,self.wired1,self.wired2,
|
||||
|
||||
@@ -192,9 +192,9 @@ def about_dialog(body):
|
||||
('green',"\\|| \\\\")," |+| ",('green',"// ||/ \n"),
|
||||
('green'," \\\\\\")," |+| ",('green',"///")," http://wicd.net\n",
|
||||
('green'," \\\\\\")," |+| ",('green',"///")," ",language["brought_to_you"],"\n",
|
||||
('green'," \\\\\\")," |+| ",('green',"///")," Adam Blackburn (wicd)\n",
|
||||
" ___|+|___ Dan O'Reilly (wicd)\n",
|
||||
" |---------| Andrew Psaltis (this ui)\n",
|
||||
('green'," \\\\\\")," |+| ",('green',"///")," Adam Blackburn\n",
|
||||
" ___|+|___ Dan O'Reilly\n",
|
||||
" |---------| Andrew Psaltis\n",
|
||||
"-----------------------------------------------------"]
|
||||
about = TextDialog(theText,16,55,header=('header','About Wicd'))
|
||||
about.run(ui,body)
|
||||
|
||||
@@ -307,7 +307,7 @@ class appGui(object):
|
||||
dialog = gtk.AboutDialog()
|
||||
dialog.set_name("Wicd")
|
||||
dialog.set_version(daemon.Hello())
|
||||
dialog.set_authors([ "Adam Blackburn", "Dan O'Reilly" ])
|
||||
dialog.set_authors([ "Adam Blackburn", "Dan O'Reilly", "Andrew Psaltis" ])
|
||||
dialog.set_website("http://wicd.sourceforge.net")
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
@@ -8,6 +8,7 @@ contained within them.
|
||||
#
|
||||
# Copyright (C) 2008-2009 Adam Blackburn
|
||||
# Copyright (C) 2008-2009 Dan O'Reilly
|
||||
# Copyright (C) 2009 Andrew Psaltis
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License Version 2 as
|
||||
@@ -73,6 +74,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
||||
self.txt_dns_1 = LabelEntry(language['dns'] + ' 1')
|
||||
self.txt_dns_2 = LabelEntry(language['dns'] + ' 2')
|
||||
self.txt_dns_3 = LabelEntry(language['dns'] + ' 3')
|
||||
self.txt_dhcp_hostname = LabelEntry("DHCP Hostname")
|
||||
self.chkbox_static_ip = gtk.CheckButton(language['use_static_ip'])
|
||||
self.chkbox_static_dns = gtk.CheckButton(language['use_static_dns'])
|
||||
self.chkbox_global_dns = gtk.CheckButton(language['use_global_dns'])
|
||||
@@ -104,6 +106,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
||||
self.vbox.pack_start(self.txt_dns_1, fill=False, expand=False)
|
||||
self.vbox.pack_start(self.txt_dns_2, fill=False, expand=False)
|
||||
self.vbox.pack_start(self.txt_dns_3, fill=False, expand=False)
|
||||
self.vbox.pack_start(self.txt_dhcp_hostname, fill=False, expand=False)
|
||||
self.vbox.pack_end(self.button_hbox, fill=False, expand=False, padding=5)
|
||||
|
||||
|
||||
@@ -238,6 +241,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
||||
self.set_net_prop("dns1", '')
|
||||
self.set_net_prop("dns2", '')
|
||||
self.set_net_prop("dns3", '')
|
||||
self.set_net_prop("dhcphostname",noneToString(self.txt_dhcp_hostname.get_text()))
|
||||
|
||||
|
||||
class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||
@@ -279,6 +283,12 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||
self.txt_domain.set_text(self.format_entry("dns_domain"))
|
||||
self.txt_search_dom.set_text(self.format_entry("search_domain"))
|
||||
self.chkbox_global_dns.set_active(bool(wired.GetWiredProperty("use_global_dns")))
|
||||
|
||||
dhcphname = wired.GetWiredProperty("dhcphostname")
|
||||
if dhcphname is None:
|
||||
dhcphname = os.uname()[1]
|
||||
|
||||
self.txt_dhcp_hostname.set_text(dhcphname)
|
||||
self.reset_static_checkboxes()
|
||||
|
||||
def save_settings(self):
|
||||
@@ -395,6 +405,11 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
||||
self.chkbox_global_settings.set_active(bool(wireless.GetWirelessProperty(networkID,
|
||||
'use_settings_globally')))
|
||||
|
||||
dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
|
||||
if dhcphname is None:
|
||||
dhcphname = os.uname()[1]
|
||||
self.txt_dhcp_hostname.set_text(dhcphname)
|
||||
|
||||
activeID = -1 # Set the menu to this item when we are done
|
||||
user_enctype = wireless.GetWirelessProperty(networkID, "enctype")
|
||||
for x, enc_type in enumerate(self.encrypt_types):
|
||||
|
||||
@@ -22,6 +22,7 @@ class WiredConnectThread() -- Connection thread for wired
|
||||
# Copyright (C) 2007 - 2009 Adam Blackburn
|
||||
# Copyright (C) 2007 - 2009 Dan O'Reilly
|
||||
# Copyright (C) 2007 - 2009 Byron Hillis
|
||||
# Copyright (C) 2009 Andrew Psaltis
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License Version 2 as
|
||||
@@ -290,7 +291,8 @@ class ConnectThread(threading.Thread):
|
||||
|
||||
def __init__(self, network, interface_name, before_script, after_script,
|
||||
pre_disconnect_script, post_disconnect_script, gdns1,
|
||||
gdns2, gdns3, gdns_dom, gsearch_dom, iface, debug):
|
||||
gdns2, gdns3, gdns_dom, gsearch_dom, iface,
|
||||
debug):
|
||||
""" Initialise the required object variables and the thread.
|
||||
|
||||
Keyword arguments:
|
||||
@@ -325,7 +327,7 @@ class ConnectThread(threading.Thread):
|
||||
self.global_dns_3 = gdns3
|
||||
self.global_dns_dom = gdns_dom
|
||||
self.global_search_dom = gsearch_dom
|
||||
|
||||
|
||||
self.iface = iface
|
||||
|
||||
self.connecting_message = None
|
||||
@@ -446,8 +448,8 @@ class ConnectThread(threading.Thread):
|
||||
else:
|
||||
# Run dhcp...
|
||||
self.SetStatus('running_dhcp')
|
||||
print "Running DHCP"
|
||||
dhcp_status = iface.StartDHCP()
|
||||
print "Running DHCP with hostname",self.network["dhcphostname"]
|
||||
dhcp_status = iface.StartDHCP(self.network["dhcphostname"])
|
||||
if dhcp_status in ['no_dhcp_offers', 'dhcp_failed']:
|
||||
if self.connect_result != "aborted":
|
||||
self.abort_connection(dhcp_status)
|
||||
@@ -1059,7 +1061,8 @@ class WiredConnectThread(ConnectThread):
|
||||
ConnectThread.__init__(self, network, wired, before_script,
|
||||
after_script, pre_disconnect_script,
|
||||
post_disconnect_script, gdns1, gdns2,
|
||||
gdns3, gdns_dom, gsearch_dom, liface, debug)
|
||||
gdns3, gdns_dom, gsearch_dom, liface,
|
||||
debug)
|
||||
|
||||
def _connect(self):
|
||||
""" The main function of the connection thread.
|
||||
|
||||
@@ -18,6 +18,7 @@ class WirelessDaemon() -- DBus interface to managed the wireless network.
|
||||
# Copyright (C) 2007 - 2009 Adam Blackburn
|
||||
# Copyright (C) 2007 - 2009 Dan O'Reilly
|
||||
# Copyright (C) 2007 - 2009 Byron Hillis
|
||||
# Copyright (C) 2009 Andrew Psaltis
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License Version 2 as
|
||||
@@ -1459,6 +1460,7 @@ class WiredDaemon(dbus.service.Object):
|
||||
"postdisconnectscript"]:
|
||||
self.config.set(profilename, option, None)
|
||||
self.config.set(profilename, "default", default)
|
||||
self.config.set(profilename,"dhcphostname",os.uname()[1])
|
||||
self.config.write()
|
||||
return True
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class BaseWirelessInterface() -- Control a wireless network interface.
|
||||
# Copyright (C) 2007 - 2009 Adam Blackburn
|
||||
# Copyright (C) 2007 - 2009 Dan O'Reilly
|
||||
# Copyright (C) 2007 - 2009 Byron Hillis
|
||||
# Copyright (C) 2009 Andrew Psaltis
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License Version 2 as
|
||||
@@ -241,7 +242,7 @@ class BaseInterface(object):
|
||||
return path
|
||||
|
||||
|
||||
def _get_dhcp_command(self, flavor=None):
|
||||
def _get_dhcp_command(self, flavor=None, hostname=None):
|
||||
""" Returns the correct DHCP client command.
|
||||
|
||||
Given a type of DHCP request (create or release a lease),
|
||||
@@ -277,17 +278,17 @@ class BaseInterface(object):
|
||||
'id' : misc.DHCLIENT,
|
||||
},
|
||||
"pump" :
|
||||
{ 'connect' : r"%(cmd)s -i %(iface)s",
|
||||
{ 'connect' : r"%(cmd)s -i %(iface)s -h %(hostname)s",
|
||||
'release' : r"%(cmd)s -r -i %(iface)s",
|
||||
'id' : misc.PUMP,
|
||||
},
|
||||
"dhcpcd" :
|
||||
{'connect' : r"%(cmd)s %(iface)s",
|
||||
{'connect' : r"%(cmd)s %(iface)s -h %(hostname)s ",
|
||||
'release' : r"%(cmd)s -k %(iface)s",
|
||||
'id' : misc.DHCPCD,
|
||||
},
|
||||
"udhcpc":
|
||||
{'connect' : r"%(cmd)s -n -i %(iface)s",
|
||||
{'connect' : r"%(cmd)s -n -i %(iface)s -H %(hostname)s ",
|
||||
'release' : r"killall -SIGUSR2 %(cmd)s",
|
||||
'id' : misc.UDHCPC,
|
||||
},
|
||||
@@ -298,7 +299,7 @@ class BaseInterface(object):
|
||||
return ""
|
||||
|
||||
if flavor == "connect":
|
||||
return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface}
|
||||
return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface, "hostname":hostname}
|
||||
elif flavor == "release":
|
||||
return client_dict[client_name]['release'] % {"cmd":cmd, "iface":self.iface}
|
||||
else:
|
||||
@@ -549,7 +550,7 @@ class BaseInterface(object):
|
||||
return 'dhcp_failed'
|
||||
|
||||
@neediface(False)
|
||||
def StartDHCP(self):
|
||||
def StartDHCP(self,hostname):
|
||||
""" Start the DHCP client to obtain an IP address.
|
||||
|
||||
Returns:
|
||||
@@ -557,7 +558,7 @@ class BaseInterface(object):
|
||||
_check_dhcp_result for the possible values.
|
||||
|
||||
"""
|
||||
cmd = self._get_dhcp_command('connect')
|
||||
cmd = self._get_dhcp_command('connect',hostname)
|
||||
if self.verbose: print cmd
|
||||
self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True)
|
||||
pipe = self.dhcp_object.stdout
|
||||
|
||||
Reference in New Issue
Block a user