diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-06-14 16:02:07 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:04:00 -0800 |
commit | 3bd01c27a3e878fbf9d8e9e97529c000608878f1 (patch) | |
tree | 98bb4168f5cd31329343d7d9f31449c696bf8a05 /mpm/python | |
parent | 0347dc8b4b564b7ff720d403959c34f60ecbbf15 (diff) | |
download | uhd-3bd01c27a3e878fbf9d8e9e97529c000608878f1.tar.gz uhd-3bd01c27a3e878fbf9d8e9e97529c000608878f1.tar.bz2 uhd-3bd01c27a3e878fbf9d8e9e97529c000608878f1.zip |
mpm/n310: Moved eth dispatcher setup into __init__
Diffstat (limited to 'mpm/python')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 13 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/n310.py | 15 |
2 files changed, 13 insertions, 15 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index fb06ae351..96770139d 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -149,7 +149,8 @@ class PeriphManagerBase(object): self._init_dboards(args.override_db_pids) self._available_endpoints = list(range(256)) self._init_args = {} - self._chdr_interfaces = [] + self.log.info("Identifying available network interfaces...") + self._chdr_interfaces = self._init_interfaces(self.chdr_interfaces) def _init_mboard_with_eeprom(self): """ @@ -283,19 +284,19 @@ class PeriphManagerBase(object): self.dboards.append(db_class(dboard_idx, **dboard_info)) self.log.info("Found {} daughterboard(s).".format(len(self.dboards))) - def _init_interfaces(self): + def _init_interfaces(self, possible_ifaces): """ Initialize the list of network interfaces """ self.log.trace("Testing available interfaces out of `{}'".format( - self.chdr_interfaces + possible_ifaces )) - valid_ifaces = net.get_valid_interfaces(self.chdr_interfaces) + valid_ifaces = net.get_valid_interfaces(possible_ifaces) if len(valid_ifaces): self.log.debug("Found CHDR interfaces: `{}'".format(valid_ifaces)) else: self.log.warning("No CHDR interfaces found!") - self._chdr_interfaces = { + return { x: net.get_iface_info(x) for x in valid_ifaces } @@ -321,8 +322,6 @@ class PeriphManagerBase(object): ",".join(['{}={}'.format(x, args[x]) for x in args]) )) self._init_args = args - self.log.info("Identifying available network interfaces...") - self._init_interfaces() self.log.debug("Initializing dboards...") return all((dboard.init(args) for dboard in self.dboards)) diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py index 7b403a830..6ab151454 100644 --- a/mpm/python/usrp_mpm/periph_manager/n310.py +++ b/mpm/python/usrp_mpm/periph_manager/n310.py @@ -139,8 +139,12 @@ class n310(PeriphManagerBase): ) ) self.log.info("mboard info: {}".format(self.mboard_info)) - # Define some attributes so PyLint stays quiet - self._eth_dispatchers = None + self._eth_dispatchers = { + x: EthDispatcherTable(self.eth_tables.get(x)) + for x in list(self._chdr_interfaces.keys()) + } + for ifname, table in iteritems(self._eth_dispatchers): + table.set_ipv4_addr(self._chdr_interfaces[ifname]['ip_addr']) def init(self, args): """ @@ -148,12 +152,7 @@ class n310(PeriphManagerBase): dispatchers accordingly. """ result = super(n310, self).init(args) - self._eth_dispatchers = { - x: EthDispatcherTable(self.eth_tables.get(x)) - for x in list(self._chdr_interfaces.keys()) - } - for ifname, table in iteritems(self._eth_dispatchers): - table.set_ipv4_addr(self._chdr_interfaces[ifname]['ip_addr']) + for _, table in iteritems(self._eth_dispatchers): if 'forward_eth' in args or 'forward_bcast' in args: table.set_forward_policy( args.get('forward_eth', False), |