本文整理汇总了Python中units.modules.utils.set_module_args函数的典型用法代码示例。如果您正苦于以下问题:Python set_module_args函数的具体用法?Python set_module_args怎么用?Python set_module_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_module_args函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_graceful_nitro_error_on_login
def test_graceful_nitro_error_on_login(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
))
from ansible.modules.network.netscaler import netscaler_lb_monitor
class MockException(Exception):
def __init__(self, *args, **kwargs):
self.errorcode = 0
self.message = ''
client_mock = Mock()
client_mock.login = Mock(side_effect=MockException)
m = Mock(return_value=client_mock)
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_lb_monitor',
get_nitro_client=m,
nitro_exception=MockException,
):
self.module = netscaler_lb_monitor
result = self.failed()
self.assertTrue(result['msg'].startswith('nitro exception'), msg='nitro exception during login not handled properly')
开发者ID:awiddersheim,项目名称:ansible,代码行数:25,代码来源:test_netscaler_lb_monitor.py
示例2: test_save_config_not_called_on_state_absent
def test_save_config_not_called_on_state_absent(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='absent',
save_config=False,
))
from ansible.modules.network.netscaler import netscaler_gslb_site
client_mock = Mock()
m = Mock(return_value=client_mock)
gslb_site_proxy_mock = Mock()
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_gslb_site',
get_nitro_client=m,
gslb_site_exists=Mock(side_effect=[True, False]),
nitro_exception=self.MockException,
ensure_feature_is_enabled=Mock(),
ConfigProxy=Mock(return_value=gslb_site_proxy_mock),
):
self.module = netscaler_gslb_site
self.exited()
self.assertNotIn(call.save_config(), client_mock.mock_calls)
开发者ID:awiddersheim,项目名称:ansible,代码行数:27,代码来源:test_netscaler_gslb_site.py
示例3: test_absent_gslb_site_failed_delete
def test_absent_gslb_site_failed_delete(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='absent',
))
from ansible.modules.network.netscaler import netscaler_gslb_site
client_mock = Mock()
m = Mock(return_value=client_mock)
glsb_site_proxy_attrs = {
'diff_object.return_value': {},
}
gslb_site_proxy_mock = Mock()
gslb_site_proxy_mock.configure_mock(**glsb_site_proxy_attrs)
config_proxy_mock = Mock(return_value=gslb_site_proxy_mock)
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_gslb_site',
nitro_exception=self.MockException,
get_nitro_client=m,
diff_list=Mock(return_value={}),
get_immutables_intersection=Mock(return_value=[]),
gslb_site_exists=Mock(side_effect=[True, True]),
gslb_site_identical=Mock(side_effect=[False, False]),
ensure_feature_is_enabled=Mock(),
ConfigProxy=config_proxy_mock,
):
self.module = netscaler_gslb_site
result = self.failed()
self.assertEqual(result['msg'], 'GSLB site still exists')
self.assertTrue(result['failed'])
开发者ID:awiddersheim,项目名称:ansible,代码行数:35,代码来源:test_netscaler_gslb_site.py
示例4: test_bgp_add_network
def test_bgp_add_network(self):
neighbors = [dict(remote_as=173, neighbor='10.2.3.4')]
set_module_args(dict(as_number=172, router_id='1.2.3.4',
neighbors=neighbors,
networks=['172.16.1.0/24', '172.16.2.0/24']))
commands = ['router bgp 172 network 172.16.2.0 /24']
self.execute_module(changed=True, commands=commands)
开发者ID:awiddersheim,项目名称:ansible,代码行数:7,代码来源:test_onyx_bgp.py
示例5: test_graceful_login_error
def test_graceful_login_error(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
))
from ansible.modules.network.netscaler import netscaler_gslb_site
if sys.version_info[:2] == (2, 6):
self.skipTest('requests library not available under python2.6')
class MockException(Exception):
pass
client_mock = Mock()
attrs = {'login.side_effect': requests.exceptions.SSLError}
client_mock.configure_mock(**attrs)
m = Mock(return_value=client_mock)
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_gslb_site',
get_nitro_client=m,
nitro_exception=MockException,
):
self.module = netscaler_gslb_site
result = self.failed()
self.assertTrue(result['msg'].startswith('SSL Error'), msg='SSL Error was not handled gracefully')
开发者ID:awiddersheim,项目名称:ansible,代码行数:26,代码来源:test_netscaler_gslb_site.py
示例6: test_save_config_not_called_on_state_absent
def test_save_config_not_called_on_state_absent(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='absent',
save_config=False,
))
from ansible.modules.network.netscaler import netscaler_ssl_certkey
client_mock = Mock()
m = Mock(return_value=client_mock)
ssl_certkey_proxy_mock = Mock()
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_ssl_certkey',
get_nitro_client=m,
key_exists=Mock(side_effect=[True, False]),
ConfigProxy=Mock(return_value=ssl_certkey_proxy_mock),
):
self.module = netscaler_ssl_certkey
self.exited()
self.assertNotIn(call.save_config(), client_mock.mock_calls)
开发者ID:awiddersheim,项目名称:ansible,代码行数:25,代码来源:test_netscaler_ssl_certkey.py
示例7: test_absent_server_noop_flow
def test_absent_server_noop_flow(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='absent',
))
from ansible.modules.network.netscaler import netscaler_ssl_certkey
client_mock = Mock()
m = Mock(return_value=client_mock)
ssl_certkey_proxy_attrs = {
'diff_object.return_value': {},
}
ssl_certkey_proxy_mock = Mock()
ssl_certkey_proxy_mock.configure_mock(**ssl_certkey_proxy_attrs)
config_proxy_mock = Mock(return_value=ssl_certkey_proxy_mock)
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_ssl_certkey',
get_nitro_client=m,
diff_list=Mock(return_value={}),
get_immutables_intersection=Mock(return_value=[]),
key_exists=Mock(side_effect=[False, False]),
key_identical=Mock(side_effect=[False, False]),
ConfigProxy=config_proxy_mock,
):
self.module = netscaler_ssl_certkey
self.exited()
ssl_certkey_proxy_mock.assert_not_called()
开发者ID:awiddersheim,项目名称:ansible,代码行数:32,代码来源:test_netscaler_ssl_certkey.py
示例8: test_save_config_not_called_on_state_present
def test_save_config_not_called_on_state_present(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
save_config=False,
))
from ansible.modules.network.netscaler import netscaler_server
client_mock = Mock()
m = Mock(return_value=client_mock)
server_proxy_mock = Mock()
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_server',
get_nitro_client=m,
server_exists=Mock(side_effect=[False, True]),
ConfigProxy=Mock(return_value=server_proxy_mock),
diff_list=Mock(return_value={}),
do_state_change=Mock(return_value=Mock(errorcode=0))
):
self.module = netscaler_server
self.exited()
self.assertNotIn(call.save_config(), client_mock.mock_calls)
开发者ID:awiddersheim,项目名称:ansible,代码行数:27,代码来源:test_netscaler_server.py
示例9: test_do_state_change_fail
def test_do_state_change_fail(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
))
from ansible.modules.network.netscaler import netscaler_server
client_mock = Mock()
m = Mock(return_value=client_mock)
server_proxy_mock = Mock()
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_server',
nitro_exception=self.MockException,
get_nitro_client=m,
server_exists=Mock(side_effect=[True, False]),
ConfigProxy=Mock(return_value=server_proxy_mock),
diff_list=Mock(return_value={}),
do_state_change=Mock(return_value=Mock(errorcode=1, message='Failed on purpose'))
):
self.module = netscaler_server
result = self.failed()
self.assertEqual(result['msg'], 'Error when setting disabled state. errorcode: 1 message: Failed on purpose')
开发者ID:awiddersheim,项目名称:ansible,代码行数:27,代码来源:test_netscaler_server.py
示例10: test_update_agent_status_traps
def test_update_agent_status_traps(self, *args):
set_module_args(dict(
sync_device_to_group='yes',
device_group="foo",
password='passsword',
server='localhost',
user='admin'
))
client = AnsibleF5Client(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
)
mm = ModuleManager(client)
# Override methods to force specific logic in the module to happen
mm._device_group_exists = Mock(return_value=True)
mm._sync_to_group_required = Mock(return_value=False)
mm.execute_on_device = Mock(return_value=True)
mm.read_current_from_device = Mock(return_value=None)
mm._get_status_from_resource = Mock()
mm._get_status_from_resource.side_effect = [
'Changes Pending', 'Awaiting Initial Sync', 'In Sync'
]
results = mm.exec_module()
assert results['changed'] is True
开发者ID:awiddersheim,项目名称:ansible,代码行数:30,代码来源:test_bigip_configsync_actions.py
示例11: test_iosxr_config_match_exact
def test_iosxr_config_match_exact(self):
lines = ['ip address 1.2.3.4 255.255.255.0', 'description test string',
'shutdown']
parents = ['interface GigabitEthernet0/0']
set_module_args(dict(lines=lines, parents=parents, match='exact'))
commands = parents + lines
self.execute_module(changed=True, commands=commands, sort=False)
开发者ID:awiddersheim,项目名称:ansible,代码行数:7,代码来源:test_iosxr_config.py
示例12: test_new_gslb_vserver_execution_flow
def test_new_gslb_vserver_execution_flow(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
))
from ansible.modules.network.netscaler import netscaler_gslb_vserver
client_mock = Mock()
m = Mock(return_value=client_mock)
glsb_service_proxy_attrs = {
'diff_object.return_value': {},
}
gslb_service_proxy_mock = Mock()
gslb_service_proxy_mock.configure_mock(**glsb_service_proxy_attrs)
config_proxy_mock = Mock(return_value=gslb_service_proxy_mock)
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_gslb_vserver',
get_nitro_client=m,
gslb_vserver_exists=Mock(side_effect=[False, True]),
gslb_vserver_identical=Mock(side_effect=[True]),
nitro_exception=self.MockException,
do_state_change=Mock(return_value=Mock(errorcode=0)),
ensure_feature_is_enabled=Mock(),
ConfigProxy=config_proxy_mock,
):
self.module = netscaler_gslb_vserver
self.exited()
gslb_service_proxy_mock.assert_has_calls([call.add()])
开发者ID:awiddersheim,项目名称:ansible,代码行数:33,代码来源:test_netscaler_gslb_vserver.py
示例13: test_save_config_called_on_state_present
def test_save_config_called_on_state_present(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
))
from ansible.modules.network.netscaler import netscaler_gslb_vserver
client_mock = Mock()
m = Mock(return_value=client_mock)
gslb_service_proxy_mock = Mock()
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_gslb_vserver',
get_nitro_client=m,
gslb_vserver_exists=Mock(side_effect=[False, True]),
gslb_vserver_identical=Mock(side_effect=[True]),
do_state_change=Mock(return_value=Mock(errorcode=0)),
nitro_exception=self.MockException,
ensure_feature_is_enabled=Mock(),
ConfigProxy=Mock(return_value=gslb_service_proxy_mock),
):
self.module = netscaler_gslb_vserver
self.exited()
self.assertIn(call.save_config(), client_mock.mock_calls)
开发者ID:awiddersheim,项目名称:ansible,代码行数:28,代码来源:test_netscaler_gslb_vserver.py
示例14: test_dellos10_config_match_exact
def test_dellos10_config_match_exact(self):
lines = ['ip address 1.2.3.4/24', 'description test string',
'shutdown']
parents = ['interface ethernet1/1/2']
set_module_args(dict(lines=lines, parents=parents, match='exact'))
commands = parents + lines
self.execute_module(changed=True, commands=commands, sort=False)
开发者ID:awiddersheim,项目名称:ansible,代码行数:7,代码来源:test_dellos10_config.py
示例15: test_port_channel_add
def test_port_channel_add(self):
set_module_args(dict(name='Po23', state='present',
members=['Eth1/8']))
self.load_port_channel_fixture()
commands = ['interface port-channel 23', 'exit',
'interface ethernet 1/8 channel-group 23 mode on']
self.execute_module(changed=True, commands=commands)
开发者ID:awiddersheim,项目名称:ansible,代码行数:7,代码来源:test_onyx_linkagg.py
示例16: test_disable_server_graceful
def test_disable_server_graceful(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
disabled=True,
graceful=True
))
from ansible.modules.network.netscaler import netscaler_server
client_mock = Mock()
m = Mock(return_value=client_mock)
server_proxy_mock = Mock()
d = {
'graceful': True,
'delay': 20,
}
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_server',
nitro_exception=self.MockException,
get_nitro_client=m,
diff_list=Mock(return_value=d),
get_immutables_intersection=Mock(return_value=[]),
server_exists=Mock(side_effect=[True, True]),
ConfigProxy=Mock(return_value=server_proxy_mock),
do_state_change=Mock(return_value=Mock(errorcode=0))
):
self.module = netscaler_server
result = self.exited()
self.assertEqual(d, {}, 'Graceful disable options were not discarded from the diff_list with the actual object')
开发者ID:awiddersheim,项目名称:ansible,代码行数:34,代码来源:test_netscaler_server.py
示例17: test_mlag_port_channel_add
def test_mlag_port_channel_add(self):
set_module_args(dict(name='Mpo34', state='present',
members=['Eth1/9']))
self.load_mlag_port_channel_fixture()
commands = ['interface mlag-port-channel 34', 'exit',
'interface ethernet 1/9 mlag-channel-group 34 mode on']
self.execute_module(changed=True, commands=commands)
开发者ID:awiddersheim,项目名称:ansible,代码行数:7,代码来源:test_onyx_linkagg.py
示例18: test_present_server_identical_flow
def test_present_server_identical_flow(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
))
from ansible.modules.network.netscaler import netscaler_server
client_mock = Mock()
m = Mock(return_value=client_mock)
server_proxy_attrs = {
'diff_object.return_value': {},
}
server_proxy_mock = Mock()
server_proxy_mock.configure_mock(**server_proxy_attrs)
config_proxy_mock = Mock(return_value=server_proxy_mock)
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_server',
get_nitro_client=m,
diff_list=Mock(return_value={}),
get_immutables_intersection=Mock(return_value=[]),
server_exists=Mock(side_effect=[True, True]),
server_identical=Mock(side_effect=[True, True]),
ConfigProxy=config_proxy_mock,
do_state_change=Mock(return_value=Mock(errorcode=0))
):
self.module = netscaler_server
self.exited()
server_proxy_mock.assert_not_called()
开发者ID:awiddersheim,项目名称:ansible,代码行数:33,代码来源:test_netscaler_server.py
示例19: test_new_ssl_certkey_execution_flow
def test_new_ssl_certkey_execution_flow(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
))
from ansible.modules.network.netscaler import netscaler_ssl_certkey
client_mock = Mock()
m = Mock(return_value=client_mock)
ssl_certkey_proxy_attrs = {
'diff_object.return_value': {},
}
ssl_certkey_proxy_mock = Mock()
ssl_certkey_proxy_mock.configure_mock(**ssl_certkey_proxy_attrs)
config_proxy_mock = Mock(return_value=ssl_certkey_proxy_mock)
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_ssl_certkey',
get_nitro_client=m,
key_exists=Mock(side_effect=[False, True]),
key_identical=Mock(side_effect=[True]),
ConfigProxy=config_proxy_mock,
):
self.module = netscaler_ssl_certkey
self.exited()
ssl_certkey_proxy_mock.assert_has_calls([call.add()])
开发者ID:awiddersheim,项目名称:ansible,代码行数:30,代码来源:test_netscaler_ssl_certkey.py
示例20: test_absent_server_failed_delete
def test_absent_server_failed_delete(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='absent',
))
from ansible.modules.network.netscaler import netscaler_server
client_mock = Mock()
m = Mock(return_value=client_mock)
server_proxy_attrs = {
'diff_object.return_value': {},
}
server_proxy_mock = Mock()
server_proxy_mock.configure_mock(**server_proxy_attrs)
config_proxy_mock = Mock(return_value=server_proxy_mock)
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_server',
nitro_exception=self.MockException,
get_nitro_client=m,
diff_list=Mock(return_value={}),
get_immutables_intersection=Mock(return_value=[]),
server_exists=Mock(side_effect=[True, True]),
server_identical=Mock(side_effect=[False, False]),
ConfigProxy=config_proxy_mock,
do_state_change=Mock(return_value=Mock(errorcode=0))
):
self.module = netscaler_server
result = self.failed()
self.assertEqual(result['msg'], 'Server seems to be present')
self.assertTrue(result['failed'])
开发者ID:awiddersheim,项目名称:ansible,代码行数:35,代码来源:test_netscaler_server.py
注:本文中的units.modules.utils.set_module_args函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论