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


Python PlayContext.network_os方法代码示例

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


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

示例1: test_network_cli__invalid_os

# 需要导入模块: from ansible.playbook.play_context import PlayContext [as 别名]
# 或者: from ansible.playbook.play_context.PlayContext import network_os [as 别名]
    def test_network_cli__invalid_os(self, mocked_super):
        pc = PlayContext()
        new_stdin = StringIO()

        conn = network_cli.Connection(pc, new_stdin)
        conn.ssh = MagicMock()
        conn.receive = MagicMock()
        conn._terminal = MagicMock()
        pc.network_os = None
        self.assertRaises(AnsibleConnectionFailure, conn._connect)
开发者ID:awiddersheim,项目名称:ansible,代码行数:12,代码来源:test_network_cli.py

示例2: test_network_cli__connect

# 需要导入模块: from ansible.playbook.play_context import PlayContext [as 别名]
# 或者: from ansible.playbook.play_context.PlayContext import network_os [as 别名]
    def test_network_cli__connect(self, mocked_super, mocked_terminal_loader):
        pc = PlayContext()
        new_stdin = StringIO()

        conn = network_cli.Connection(pc, new_stdin)
        pc.network_os = 'ios'

        conn.ssh = MagicMock()
        conn.receive = MagicMock()
        conn._terminal = MagicMock()

        conn._connect()
        self.assertTrue(conn._terminal.on_open_shell.called)
        self.assertFalse(conn._terminal.on_become.called)

        conn._play_context.become = True
        conn._play_context.become_method = 'enable'
        conn._play_context.become_pass = 'password'
        conn._connected = False

        conn._connect()
        conn._terminal.on_become.assert_called_with(passwd='password')
开发者ID:awiddersheim,项目名称:ansible,代码行数:24,代码来源:test_network_cli.py

示例3: test_network_cli__connect

# 需要导入模块: from ansible.playbook.play_context import PlayContext [as 别名]
# 或者: from ansible.playbook.play_context.PlayContext import network_os [as 别名]
    def test_network_cli__connect(self, mocked_super, mocked_terminal_loader):
        pc = PlayContext()
        new_stdin = StringIO()

        conn = network_cli.Connection(pc, new_stdin)
        conn.ssh = None

        self.assertRaises(AnsibleConnectionFailure, conn._connect)
        mocked_terminal_loader.all.assert_called_with(class_only=True)

        mocked_terminal_loader.reset_mock()
        mocked_terminal_loader.get.return_value = None

        pc.network_os = 'invalid'
        self.assertRaises(AnsibleConnectionFailure, conn._connect)
        self.assertFalse(mocked_terminal_loader.all.called)

        mocked_terminal_loader.reset_mock()
        mocked_terminal_loader.get.return_value = 'valid'

        conn._connect()
        self.assertEqual(conn._terminal, 'valid')
开发者ID:2ndQuadrant,项目名称:ansible,代码行数:24,代码来源:test_network_cli.py


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