DladmIface¶
- class getmac.getmac.DladmIface[source]¶
Bases:
MethodUse the
dladmcommand to get the MAC address of a network interface on Solaris 11 and illumos (e.g. OmniOS, OpenIndiana, SmartOS). Unlikeifconfig, which only shows the MAC to root, this works for any user.The type of datalink is from
dladm show-link, and the MAC is fromdladm show-phys -mfor physical links (NICs),dladm show-vnicfor virtual NICs (VNICs, which zones usually have), anddladm show-aggr -xfor link aggregations. A VLAN has the MAC of the link it’s on.Other types of datalinks (e.g. etherstubs and IP tunnels) don’t have a MAC, and neither do IPMP groups (e.g.
ipmp0), which aren’t datalinks, so they’reNone.ifconfigdoesn’t show a MAC for any of them either.Solaris 10’s
dladmdoesn’t have-o, so this is marked unusable there.Documentation: Oracle Solaris, illumos
Attributes Summary
The type of method, e.g. does it get the MAC of a interface.
Platforms supported by a method.
Methods Summary
get(arg)Core logic of the method that performs the lookup.
test()Low-impact test that the method is feasible, e.g. a command exists.
Attributes Documentation
- method_type: str = 'iface'¶
The type of method, e.g. does it get the MAC of a interface.
Allowed values:
ip
ip4
ip6
iface
default_iface
Methods Documentation
- get(arg)[source]¶
Core logic of the method that performs the lookup.
Warning
If the method itself fails to function an exception will be raised! (for instance, if some command arguments are invalid, or there’s an internal error with the command, or a bug in the code).
- Parameters:
arg (
str) – What the method should get, such as an IP address or interface name. In the case ofdefault_ifacemethods, this is not used and defaults to an empty string.- Return type:
- Returns:
The raw value the technique found, or
Noneif nothing was found. It isn’t cleaned up, so it may not be a lowercase colon-separated MAC (get_mac_address()runs it throughclean_mac()). Fordefault_ifacemethods, it’s the name of an interface instead of a MAC.