-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Considering adding support for darwin. Broken due to sanketsudake/ifc…
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ifparser | ||
|
||
from .base import BaseManager | ||
|
||
|
||
def if_config(): | ||
cfg = subprocess.check_output(['ifconfig']) | ||
return ifparser.Ifcfg(cfg) | ||
|
||
|
||
class Manager(BaseManager): | ||
def get_host_mac_addresses(self): | ||
return map(operator.attrgetter('hwaddr'), self._get_ifaces()) | ||
|
||
def get_host_ip_addresses(self): | ||
return map(operator.attrgetter('ip'), self._get_ifaces()) | ||
|
||
@staticmethod | ||
def _get_ifaces(): | ||
cfg = if_config() | ||
return map(cfg.get_interface, cfg.interfaces) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters