|
|
|
@ -32,9 +32,6 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|
|
|
def setUp(self):
|
|
|
|
def setUp(self):
|
|
|
|
super(TestIosxrNetconfModule, self).setUp()
|
|
|
|
super(TestIosxrNetconfModule, self).setUp()
|
|
|
|
|
|
|
|
|
|
|
|
self.mock_exec_command = patch('ansible.modules.network.iosxr.iosxr_netconf.exec_command')
|
|
|
|
|
|
|
|
self.exec_command = self.mock_exec_command.start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.mock_get_config = patch('ansible.modules.network.iosxr.iosxr_netconf.get_config')
|
|
|
|
self.mock_get_config = patch('ansible.modules.network.iosxr.iosxr_netconf.get_config')
|
|
|
|
self.get_config = self.mock_get_config.start()
|
|
|
|
self.get_config = self.mock_get_config.start()
|
|
|
|
|
|
|
|
|
|
|
|
@ -43,7 +40,6 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
def tearDown(self):
|
|
|
|
super(TestIosxrNetconfModule, self).tearDown()
|
|
|
|
super(TestIosxrNetconfModule, self).tearDown()
|
|
|
|
self.mock_exec_command.stop()
|
|
|
|
|
|
|
|
self.mock_get_config.stop()
|
|
|
|
self.mock_get_config.stop()
|
|
|
|
self.mock_load_config.stop()
|
|
|
|
self.mock_load_config.stop()
|
|
|
|
|
|
|
|
|
|
|
|
@ -54,14 +50,14 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|
|
|
!
|
|
|
|
!
|
|
|
|
ssh server netconf vrf default
|
|
|
|
ssh server netconf vrf default
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
self.exec_command.return_value = 0, '', None
|
|
|
|
self.load_config.return_value = 'dummy diff'
|
|
|
|
set_module_args(dict(netconf_port=830, netconf_vrf='default', state='absent'))
|
|
|
|
set_module_args(dict(netconf_port=830, netconf_vrf='default', state='absent'))
|
|
|
|
result = self.execute_module(changed=True)
|
|
|
|
result = self.execute_module(changed=True)
|
|
|
|
self.assertEqual(result['commands'], ['no netconf-yang agent ssh', 'no ssh server netconf port 830', 'no ssh server netconf vrf default'])
|
|
|
|
self.assertEqual(result['commands'], ['no netconf-yang agent ssh', 'no ssh server netconf port 830', 'no ssh server netconf vrf default'])
|
|
|
|
|
|
|
|
|
|
|
|
def test_iosxr_enable_netconf_service(self):
|
|
|
|
def test_iosxr_enable_netconf_service(self):
|
|
|
|
self.get_config.return_value = ''
|
|
|
|
self.get_config.return_value = ''
|
|
|
|
self.exec_command.return_value = 0, '', None
|
|
|
|
self.load_config.return_value = 'dummy diff'
|
|
|
|
set_module_args(dict(netconf_port=830, netconf_vrf='default', state='present'))
|
|
|
|
set_module_args(dict(netconf_port=830, netconf_vrf='default', state='present'))
|
|
|
|
result = self.execute_module(changed=True)
|
|
|
|
result = self.execute_module(changed=True)
|
|
|
|
self.assertEqual(result['commands'], ['netconf-yang agent ssh', 'ssh server netconf port 830', 'ssh server netconf vrf default'])
|
|
|
|
self.assertEqual(result['commands'], ['netconf-yang agent ssh', 'ssh server netconf port 830', 'ssh server netconf vrf default'])
|
|
|
|
@ -73,7 +69,7 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|
|
|
!
|
|
|
|
!
|
|
|
|
ssh server netconf vrf default
|
|
|
|
ssh server netconf vrf default
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
self.exec_command.return_value = 0, '', None
|
|
|
|
self.load_config.return_value = 'dummy diff'
|
|
|
|
set_module_args(dict(netconf_port=9000, state='present'))
|
|
|
|
set_module_args(dict(netconf_port=9000, state='present'))
|
|
|
|
result = self.execute_module(changed=True)
|
|
|
|
result = self.execute_module(changed=True)
|
|
|
|
self.assertEqual(result['commands'], ['ssh server netconf port 9000'])
|
|
|
|
self.assertEqual(result['commands'], ['ssh server netconf port 9000'])
|
|
|
|
@ -85,7 +81,7 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|
|
|
!
|
|
|
|
!
|
|
|
|
ssh server netconf vrf default
|
|
|
|
ssh server netconf vrf default
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
self.exec_command.return_value = 0, '', None
|
|
|
|
self.load_config.return_value = 'dummy diff'
|
|
|
|
set_module_args(dict(netconf_vrf='new_default', state='present'))
|
|
|
|
set_module_args(dict(netconf_vrf='new_default', state='present'))
|
|
|
|
result = self.execute_module(changed=True)
|
|
|
|
result = self.execute_module(changed=True)
|
|
|
|
self.assertEqual(result['commands'], ['ssh server netconf vrf new_default'])
|
|
|
|
self.assertEqual(result['commands'], ['ssh server netconf vrf new_default'])
|
|
|
|
|