本文整理匯總了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