本文整理汇总了Python中Db.Db.get_topology方法的典型用法代码示例。如果您正苦于以下问题:Python Db.get_topology方法的具体用法?Python Db.get_topology怎么用?Python Db.get_topology使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db.Db
的用法示例。
在下文中一共展示了Db.get_topology方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LldpCtl
# 需要导入模块: from Db import Db [as 别名]
# 或者: from Db.Db import get_topology [as 别名]
class LldpCtl(lldpy.Watcher):
""" A custom class to hook into llpdctl utility. """
def __init__(self, interface):
super(LldpCtl, self).__init__()
self.location = socket.gethostname().upper()
self.interface = interface
self.db = Db()
self.is_alive = True
def on_add(self, local, remote):
if local.interface_name == self.interface:
self.location = self.db.get_topology(remote.chassis_name)[-1][3]
self.location = self.location.upper()
def on_delete(self, local, remote):
if local.interface_name == self.interface:
self.location = socket.gethostname()
self.location = self.location.upper()
def on_update(self, local, remote):
if local.interface_name == self.interface:
self.location = self.db.get_topology(remote.chassis_name)[-1][3]
self.location = self.location.upper()
def get_location(self):
return self.location