コード例 #1
0
    def print_neighbor_info(self):
        """
        :return: cli output of netshow neighbor
        """
        _header = [
            _('local'),
            _('speed'),
            _('mode'), '',
            _('remote'),
            _('sw/hostname'),
            _('summary')
        ]
        _table = []
        for _iface in self.ifacelist.values():
            _table.append([
                _iface.name, _iface.speed, _iface.port_category, '====',
                _iface.iface.lldp[0].get('adj_port'),
                _iface.iface.lldp[0].get('adj_hostname'),
                ', '.join(_iface.summary)
            ])
            del _iface.iface.lldp[0]
            if _iface.iface.lldp:
                for _entry in _iface.iface.lldp:
                    _table.append([
                        '', '', '', '====',
                        _entry.get('adj_port'),
                        _entry.get('adj_hostname')
                    ])

        return legend_wrapped_cli_output(tabulate(_table, _header),
                                         self.show_legend)
コード例 #2
0
 def print_counters(self):
     """
     :return: cli output of netshow counters
     """
     _header = ['', _('port'), _('speed'), _('mode'), '',
                _('ucast'), _('mcast'), _('bcast'), _('errors')]
     _table = []
     for _piface in self.ifacelist.values():
         if not _piface.iface.counters.rx:
             return "This is probably Cumulus VX, or ethtool -S doesn't work for this user. " \
                 "Cannot produce valid counters yet"
         _rx_counters = _piface.iface.counters.rx
         _tx_counters = _piface.iface.counters.tx
         _table.append([_piface.linkstate, _piface.name,
                        _piface.speed, _piface.port_category,
                        _('rx'), _rx_counters.get('unicast'),
                        _rx_counters.get('multicast'),
                        _rx_counters.get('broadcast'),
                        _rx_counters.get('errors')])
         _table.append(['', '', '', '', _('tx'),
                        _tx_counters.get('unicast'),
                        _tx_counters.get('multicast'),
                        _tx_counters.get('broadcast'),
                        _tx_counters.get('errors')])
     return legend_wrapped_cli_output(tabulate(_table, _header,
       floatfmt='.0f'))
コード例 #3
0
 def print_cli_many_ifaces(self, port_type):
     """
     :return: 'netshow interface' of many interfaces in terminal output
     """
     _headers = self.summary_header
     _table = []
     for _piface in self.ifacelist.get(port_type).values():
         if self.oneline:
             _table += self.cli_append_oneline(_piface)
         else:
             _table += self.cli_append_multiline(_piface)
     return legend_wrapped_cli_output(tabulate(_table, _headers), self.show_legend)
コード例 #4
0
 def print_cli_many_ifaces(self, port_type):
     """
     :return: 'netshow interface' of many interfaces in terminal output
     """
     _headers = self.summary_header
     _table = []
     for _piface in self.ifacelist.get(port_type).values():
         if self.oneline:
             _table += self.cli_append_oneline(_piface)
         else:
             _table += self.cli_append_multiline(_piface)
     return legend_wrapped_cli_output(tabulate(_table, _headers), self.show_legend)
コード例 #5
0
    def print_single_iface(self):
        """
        :return: netshow terminal output or JSON of a single iface
        """
        feature_cache = self.cache.Cache()
        feature_cache.run()
        _printiface = self.print_iface.iface(self.single_iface, feature_cache)
        if not _printiface:
            return _('interface_does_not_exist')

        if self.use_json:
            return json.dumps(_printiface,
                              cls=NetEncoder, indent=4)
        else:
            return legend_wrapped_cli_output(_printiface.cli_output(),
                self.show_legend)
コード例 #6
0
    def print_neighbor_info(self):
        """
        :return: cli output of netshow neighbor
        """
        _header = [_('local'), _('speed'), _('mode'), '',
                   _('remote'), _('sw/hostname'), _('summary')]
        _table = []
        for _iface in self.ifacelist.values():
            _table.append([_iface.name, _iface.speed,
                           _iface.port_category,
                           '====',
                           _iface.iface.lldp[0].get('adj_port'),
                           _iface.iface.lldp[0].get('adj_hostname'),
                           ', '.join(_iface.summary)])
            del _iface.iface.lldp[0]
            if _iface.iface.lldp:
                for _entry in _iface.iface.lldp:
                    _table.append(['', '', '', '====',
                                   _entry.get('adj_port'),
                                   _entry.get('adj_hostname')])

        return legend_wrapped_cli_output(tabulate(_table, _header), self.show_legend)
コード例 #7
0
 def print_counters(self):
     """
     :return: cli output of netshow counters
     """
     _header = ['', _('port'), _('speed'), _('mode'), '',
                _('ucast'), _('mcast'), _('bcast'), _('errors')]
     _table = []
     for _piface in self.ifacelist.values():
         _rx_counters = _piface.iface.counters.rx
         _tx_counters = _piface.iface.counters.tx
         _table.append([_piface.linkstate, _piface.name,
                        _piface.speed, _piface.port_category,
                        _('rx'), _rx_counters.get('unicast'),
                        _rx_counters.get('multicast'),
                        _rx_counters.get('broadcast'),
                        _rx_counters.get('errors')])
         _table.append(['', '', '', '', _('tx'),
                        _tx_counters.get('unicast'),
                        _tx_counters.get('multicast'),
                        _tx_counters.get('broadcast'),
                        _tx_counters.get('errors')])
     return legend_wrapped_cli_output(tabulate(_table, _header,
       floatfmt='.0f'))
コード例 #8
0
 def print_counters(self):
     """
     :return: cli output of netshow counters
     """
     _header = [
         '',
         _('port'),
         _('speed'),
         _('mode'), '',
         _('ucast'),
         _('mcast'),
         _('bcast'),
         _('errors')
     ]
     _table = []
     for _piface in self.ifacelist.values():
         _rx_counters = _piface.iface.counters.rx
         _tx_counters = _piface.iface.counters.tx
         _table.append([
             _piface.linkstate, _piface.name, _piface.speed,
             _piface.port_category,
             _('rx'),
             _rx_counters.get('unicast'),
             _rx_counters.get('multicast'),
             _rx_counters.get('broadcast'),
             _rx_counters.get('errors')
         ])
         _table.append([
             '', '', '', '',
             _('tx'),
             _tx_counters.get('unicast'),
             _tx_counters.get('multicast'),
             _tx_counters.get('broadcast'),
             _tx_counters.get('errors')
         ])
     return legend_wrapped_cli_output(
         tabulate(_table, _header, floatfmt='.0f'))