* network plugin displays mac address
This commit is contained in:
parent
e6965127e8
commit
247b188aec
|
@ -89,6 +89,11 @@
|
||||||
</legend>
|
</legend>
|
||||||
<?cs call:print_form_header("network_address", "network") ?>
|
<?cs call:print_form_header("network_address", "network") ?>
|
||||||
<?cs call:show_help(Lang.Plugins.network.Help.DHCP) ?>
|
<?cs call:show_help(Lang.Plugins.network.Help.DHCP) ?>
|
||||||
|
<p>
|
||||||
|
<?cs var:html_escape(Lang.Plugins.network.Text.Interface) ?>:
|
||||||
|
<?cs var:html_escape(Data.Plugins.network.mac) ?>
|
||||||
|
(<?cs var:html_escape(Data.Plugins.network.interface) ?>)
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="checkbox" name="confirm_dhcp" value="1" id="confirm_dhcp"
|
<input type="checkbox" name="confirm_dhcp" value="1" id="confirm_dhcp"
|
||||||
<?cs if:Data.Plugins.network.dhcp == "use" ?>checked<?cs /if ?>
|
<?cs if:Data.Plugins.network.dhcp == "use" ?>checked<?cs /if ?>
|
||||||
|
|
|
@ -13,6 +13,7 @@ Text {
|
||||||
NM = Netmask
|
NM = Netmask
|
||||||
GW = Gateway
|
GW = Gateway
|
||||||
DHCP = Configure the network interface automatically (Caution, please read help!)
|
DHCP = Configure the network interface automatically (Caution, please read help!)
|
||||||
|
Interface = Network device
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
|
|
@ -229,6 +229,8 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
self.hdf[self.hdf_prefix + "gw.oc4"] = oc4
|
self.hdf[self.hdf_prefix + "gw.oc4"] = oc4
|
||||||
if self.prefs.has_key("_dhcp"):
|
if self.prefs.has_key("_dhcp"):
|
||||||
self.hdf[self.hdf_prefix + "dhcp"] = str(self.prefs["_dhcp"])
|
self.hdf[self.hdf_prefix + "dhcp"] = str(self.prefs["_dhcp"])
|
||||||
|
self.hdf[self.hdf_prefix + "interface"] = str(self.__get_interface())
|
||||||
|
self.hdf[self.hdf_prefix + "mac"] = str(self.__get_interface_mac(self.__get_interface()))
|
||||||
|
|
||||||
|
|
||||||
def __get_current_ip(self, address_type="ip"):
|
def __get_current_ip(self, address_type="ip"):
|
||||||
|
@ -372,6 +374,24 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
else:
|
else:
|
||||||
return DEFAULT_INTERFACE
|
return DEFAULT_INTERFACE
|
||||||
|
|
||||||
|
def __get_interface_mac(self, interface="None"):
|
||||||
|
"""Return the MAC address of the given network interface
|
||||||
|
"""
|
||||||
|
import re, string
|
||||||
|
proc = subprocess.Popen(
|
||||||
|
stdout = subprocess.PIPE,
|
||||||
|
stderr = subprocess.PIPE,
|
||||||
|
shell = False,
|
||||||
|
args = ["ip", "link", "show", interface] )
|
||||||
|
proc.wait()
|
||||||
|
if proc.returncode != 0:
|
||||||
|
self.cbox.log.warn("[network] error from ip command: %s" % str(proc.stderr.read()))
|
||||||
|
self.cbox.log.warn("[network] failed to determine MAC address on: %s" % interface)
|
||||||
|
output = str(proc.stdout.read())
|
||||||
|
regex = re.compile('[0-9a-f][0-9a-f]:+')
|
||||||
|
mac = regex.findall(output)
|
||||||
|
mac = string.join(mac[:5], "")
|
||||||
|
return mac
|
||||||
|
|
||||||
def __IP_is_valid(self, ip1, ip2, ip3, ip4):
|
def __IP_is_valid(self, ip1, ip2, ip3, ip4):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue