当前位置: 首页>>代码示例>>Python>>正文


Python IOSXR.open方法代码示例

本文整理汇总了Python中pyIOSXR.IOSXR.open方法的典型用法代码示例。如果您正苦于以下问题:Python IOSXR.open方法的具体用法?Python IOSXR.open怎么用?Python IOSXR.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyIOSXR.IOSXR的用法示例。


在下文中一共展示了IOSXR.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_lock_raises_LockError

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [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()
开发者ID:courtsmith,项目名称:pyiosxr,代码行数:34,代码来源:test.py

示例2: test_load_candidate_config

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_load_candidate_config(self, mock_rpc, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class load_candidate_config
     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.load_candidate_config(config='config'))
开发者ID:runborg,项目名称:pyiosxr,代码行数:11,代码来源:test.py

示例3: test_getattr_AttributeError

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_getattr_AttributeError(self, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class getattr
     Should return AttributeError
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
     mock_spawn.return_value = None
     device.open()
     self.assertRaises(AttributeError, getattr, device, 'foo')
开发者ID:runborg,项目名称:pyiosxr,代码行数:11,代码来源:test.py

示例4: test_execute_config_show

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_execute_config_show(self, mock_rpc, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr helper __execute_config_show__
     Should return True
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
     mock_spawn.return_value = None
     device.open()
     self.assertTrue(__execute_config_show__(device=device, show_command='show interfaces', timeout=10))
开发者ID:runborg,项目名称:pyiosxr,代码行数:11,代码来源:test.py

示例5: IOSXRDriver

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
class IOSXRDriver(NetworkDriver):
    def __init__(self, hostname, username, password):
        self.hostname = hostname
        self.username = username
        self.password = password
        self.device = IOSXR(hostname, username, password)
        self.pending_changes = False

    def open(self):
        self.device.open()

    def close(self):
        self.device.close()

    def load_replace_candidate(self, filename=None, config=None):
        self.pending_changes = True
        self.replace = True

        try:
            self.device.load_candidate_config(filename=filename, config=config)
        except InvalidInputError as e:
            self.pending_changes = False
            self.replace = False
            raise ReplaceConfigException(e.message)

    def load_merge_candidate(self, filename=None, config=None):
        self.pending_changes = True
        self.replace = False

        try:
            self.device.load_candidate_config(filename=filename, config=config)
        except InvalidInputError as e:
            self.pending_changes = False
            self.replace = False
            raise MergeConfigException(e.message)

    def compare_config(self):
        if not self.pending_changes:
            return ""
        elif self.replace:
            return self.device.compare_replace_config()
        else:
            return self.device.compare_config()

    def commit_config(self):
        if self.replace:
            self.device.commit_replace_config()
        else:
            self.device.commit_config()
        self.pending_changes = False

    def discard_config(self):
        self.device.discard_config()
        self.pending_changes = False

    def rollback(self):
        self.device.rollback()
开发者ID:irom77,项目名称:napalm,代码行数:59,代码来源:iosxr.py

示例6: test_commit_config

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_commit_config(self, mock_rpc, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class commit_config
     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.commit_config(label='label', comment='comment', confirmed=30))
开发者ID:runborg,项目名称:pyiosxr,代码行数:11,代码来源:test.py

示例7: test_commit_replace_config_InvalidInputError

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_commit_replace_config_InvalidInputError(self, mock_rpc, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class commit_replace_config
     Should return InvalidInputError
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
     mock_spawn.return_value = None
     device.open()
     self.assertRaises(InvalidInputError, device.commit_replace_config, label='label', comment='comment', confirmed=900)
开发者ID:runborg,项目名称:pyiosxr,代码行数:11,代码来源:test.py

示例8: test_rollback

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_rollback(self, mock_rpc, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class rollback
     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.rollback())
开发者ID:mygoda,项目名称:pyiosxr,代码行数:11,代码来源:test.py

示例9: test_close_locked

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_close_locked(self, mock_rpc, mock_lock, mock_close, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class close with lock
     Should return None
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=True)
     mock_spawn.return_value = None
     device.open()
     self.assertIsNone(device.close())
开发者ID:runborg,项目名称:pyiosxr,代码行数:11,代码来源:test.py

示例10: test_getattr_show_config

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_getattr_show_config(self, mock_show, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class getattr
     Should return True
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
     mock_spawn.return_value = None
     device.open()
     mock_show.return_value = '!! IOS XR Configuration [email protected]#$ </Exec>'
     self.assertTrue(device.show_configuration_merge(config=True))
开发者ID:runborg,项目名称:pyiosxr,代码行数:12,代码来源:test.py

示例11: provision_iosxr

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
def provision_iosxr(port, username, password):
    device = IOSXR(hostname='127.0.0.1', username=username, password=password, port=port)
    device.open()
    device.load_candidate_config(filename='../iosxr/initial.conf')

    try:
        device.commit_replace_config()
    except pexpect.TIMEOUT:
        # This actually means everything went fine
        print_info_message()
开发者ID:DiogoAndre,项目名称:napalm,代码行数:12,代码来源:provision.py

示例12: test_compare_replace_config

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_compare_replace_config(self, mock_show, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class compare_replace_config
     Should return True
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
     mock_spawn.return_value = None
     device.open()
     mock_show.return_value = ''
     self.assertEqual('', device.compare_replace_config())
开发者ID:runborg,项目名称:pyiosxr,代码行数:12,代码来源:test.py

示例13: test_make_rpc_call

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_make_rpc_call(self, mock_rpc, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class make_rpc_call
     Should return True
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
     mock_spawn.return_value = None
     mock_rpc.return_value = ElementTree.fromstring('<xml></xml>')
     device.open()
     self.assertTrue(device.make_rpc_call("<Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get>"))
开发者ID:runborg,项目名称:pyiosxr,代码行数:12,代码来源:test.py

示例14: test_get_candidate_config

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_get_candidate_config(self, mock_show, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class get_candidate_config
     Should return True
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
     mock_spawn.return_value = None
     device.open()
     mock_show.return_value = '!! IOS XR Configuration'
     self.assertTrue(device.get_candidate_config(merge=True, formal=True))
开发者ID:runborg,项目名称:pyiosxr,代码行数:12,代码来源:test.py

示例15: test_load_candidate_config_InvalidInputError

# 需要导入模块: from pyIOSXR import IOSXR [as 别名]
# 或者: from pyIOSXR.IOSXR import open [as 别名]
 def test_load_candidate_config_InvalidInputError(self, mock_rpc, mock_discard, mock_sendline, mock_expect, mock_spawn):
     '''
     Test pyiosxr class load_candidate_config
     Should return InvalidInputError
     '''
     device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
     mock_spawn.return_value = None
     mock_rpc.side_effect = InvalidInputError('error')
     device.open()
     self.assertRaises(InvalidInputError, device.load_candidate_config, config='config')
开发者ID:runborg,项目名称:pyiosxr,代码行数:12,代码来源:test.py


注:本文中的pyIOSXR.IOSXR.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。