本文整理汇总了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)
示例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')
示例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')