本文整理汇总了Python中pyIOSXR.IOSXR.lock方法的典型用法代码示例。如果您正苦于以下问题:Python IOSXR.lock方法的具体用法?Python IOSXR.lock怎么用?Python IOSXR.lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyIOSXR.IOSXR
的用法示例。
在下文中一共展示了IOSXR.lock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lock_raises_LockError
# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import lock [as 别名]
def test_lock_raises_LockError(self):
"""Tests if DB already locked raises LockError"""
if self.MOCK:
self.assertRaises(
LockError,
self.device.lock
)
self.assertFalse(self.device.locked)
else:
self.device.unlock() # make sure the config is not locked
same_device = IOSXR(self.HOSTNAME,
self.USERNAME,
self.PASSWORD,
port=self.PORT,
lock=self.LOCK,
logfile=self.LOG,
timeout=self.TIMEOUT)
same_device.open()
same_device.lock()
# the other instance locks the config DB
try:
# trying to acquire the config DB
self.device.lock()
except LockError:
self.assertFalse(self.device.locked)
else:
self.assertTrue(self.device.locked)
same_device.close()
示例2: test_lock
# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import lock [as 别名]
def test_lock(self, mock_rpc, mock_sendline, mock_expect, mock_spawn):
'''
Test pyiosxr class lock
Should return None
'''
device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
mock_spawn.return_value = None
device.open()
self.assertIsNone(device.lock())