如何获取节点端口配置

2024-04-26 12:27:51 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的python项目中,我使用的是ncclient(用于联网的python模块)。 使用此模块,我可以获取机器的lldp详细信息,如mac_地址、IP地址、供应商、10gig、25gig、50gig端口数等。但我不知道如何知道10gig、25gig或50gig端口中的哪个端口处于上升或下降状态。任何帮助都将不胜感激。 使用paramiko模块连接到远程机器

from ncclient import manager

with manager.connect(host = hostname,
                            username = self.user,
                            password = self.password,
                            hostkey_verify=False, 
                            allow_agent=False,
                            look_for_keys=False) as netconf_manager:
print netconf_manager

filter_cmm = '''<cmmStackUnitTable></cmmStackUnitTable>'''

data_cmm = netconf_manager.get(('subtree', filter_cmm))
node.update({'_key': self.hostname, 'ModelName' : data['cmmStackUnitModelName']})
        node.update({'_key': self.hostname, 'MAC' : data['cmmStackUnitMacAddress']})
        node.update({'_key': self.hostname, 'SwitchChipRev' : data['cmmStackUnitSwitchChipRev']})
        node.update({'_key': self.hostname, 'VendorName' : data['cmmStackVendorName']})
        node.update({'_key': self.hostname, 'OnieVersion' : data['cmmStackOnieVersion']})
        node.update({'_key': self.hostname, 'Noof10G' : data['cmmStackUnitNum10GigEtherPorts']})
        node.update({'_key': self.hostname, 'Noof25G' : data['cmmStackUnitNum25GigEtherPorts']})
        node.update({'_key': self.hostname, 'Noof40G' : data['cmmStackUnitNum40GigEtherPorts']})
        node.update({'_key': self.hostname, 'Noof50G' : data['cmmStackUnitNum50GigEtherPorts']})
        node.update({'_key': self.hostname, 'Noof100G' : data['cmmStackUnitNum100GigEtherPorts']})
        node.update({'_key': self.hostname, 'TopologyKey' : self.topo_key})

这是大型代码的一部分。一切正常。但我需要一些以上提到的额外信息


Tags: 模块端口keyself机器nodefalsedata