Esempio n. 1
0
def test_config_changed(mock_module):
    """
    cl_interface - test config change
    """
    # no change
    mock_module.custom_desired_config = {
        'name': 'swp1',
        'addr_method': None,
        'config': {
            'address': '10.1.1.1/24',
            'mtu': '9000'
        }
    }
    mock_module.custom_current_config = {
        'name': 'swp1',
        'addr_method': None,
        'config': {
            'address': '10.1.1.1/24',
            'mtu': '9000'
        }
    }
    assert_equals(cl_int.config_changed(mock_module), False)
    # change
    mock_module.custom_desired_config = {
        'name': 'swp1',
        'addr_method': None,
        'config': {
            'address': '10.1.1.2/24',
            'mtu': '9000'
        }
    }
    mock_module.custom_current_config = {
        'name': 'swp1',
        'addr_method': None,
        'config': {
            'address': '10.1.1.1/24',
            'mtu': '9000'
        }
    }
    assert_equals(cl_int.config_changed(mock_module), True)
    # config hash has no changed, but  addr_method has changed
    mock_module.custom_desired_config = {
        'name': 'swp1',
        'addr_method': 'dhcp',
        'config': {
            'mtu': '9000'
        }
    }
    mock_module.custom_current_config = {
        'name': 'swp1',
        'addr_method': None,
        'config': {
            'mtu': '9000'
        }
    }
    assert_equals(cl_int.config_changed(mock_module), True)
Esempio n. 2
0
def test_config_changed_lo_config_same(mock_module, mock_exec):
    """ Test config change loopback config the same"""
    instance = mock_module.return_value
    instance.params.get.return_value = 'lo'
    mock_exec.return_value = ''.join(open('tests/lo.txt').readlines())
    iface = loop_iface()
    assert_equals(config_changed(instance, iface), False)
    _msg = 'no change in interface lo configuration'
    instance.exit_json.assert_called_with(msg=_msg, changed=False)
def test_config_changed_lo_config_same(mock_module, mock_exec):
    """ Test config change loopback config the same"""
    instance = mock_module.return_value
    instance.params.get.return_value = 'lo'
    mock_exec.return_value = ''.join(open('tests/lo.txt').readlines())
    iface = loop_iface()
    assert_equals(config_changed(instance, iface), False)
    _msg = 'no change in interface lo configuration'
    instance.exit_json.assert_called_with(
        msg=_msg, changed=False)
def test_config_changed_different_state_absent(mock_module,
                                               mock_exec):
    """
    cl-interface - test config_changed with state == noconfig
    """
    instance = mock_module.return_value
    instance.params.get_return_value = 'lo'
    iface = {'name': 'lo', 'ifacetype': 'loopback',
             'config': {
                 'alias': 'noconfig'
             }}
    mock_exec.return_value = ''.join(open('tests/lo.txt').readlines())
    assert_equals(config_changed(instance, iface), True)
Esempio n. 5
0
def test_config_changed_different_state_absent(mock_module, mock_exec):
    """
    cl-interface - test config_changed with state == noconfig
    """
    instance = mock_module.return_value
    instance.params.get_return_value = 'lo'
    iface = {
        'name': 'lo',
        'ifacetype': 'loopback',
        'config': {
            'alias': 'noconfig'
        }
    }
    mock_exec.return_value = ''.join(open('tests/lo.txt').readlines())
    assert_equals(config_changed(instance, iface), True)
Esempio n. 6
0
def test_config_changed_lo_config_different(mock_module, mock_exec):
    """
    Test config changed loopback config is different
    """
    instance = mock_module.return_value
    instance.params.get.return_value = 'lo'
    iface = {
        'ifacetype': 'loopback',
        'config': {
            'address': "10.3.3.4/32",
            'speed': '1000'
        },
        'name': 'lo'
    }
    mock_exec.return_value = ''.join(open('tests/lo.txt').readlines())
    assert_equals(config_changed(instance, iface), True)
def test_config_changed_lo_config_different(mock_module,
                                            mock_exec):
    """
    Test config changed loopback config is different
    """
    instance = mock_module.return_value
    instance.params.get.return_value = 'lo'
    iface = {
        'ifacetype': 'loopback',
        'config': {
            'address': "10.3.3.4/32",
            'speed': '1000'
        },
        'name': 'lo'
    }
    mock_exec.return_value = ''.join(open('tests/lo.txt').readlines())
    assert_equals(config_changed(instance, iface), True)