def test_module_args(mock_module,
                     mock_curr_config,
                     mock_desired_config,
                     mock_compare,
                     mock_replace,
                     mock_exists):
    """ cl_bond - test module args """
    mock_exists.return_value = True
    cl_int.main()
    mock_module.assert_called_with(
        required_together=[['virtual_ip', 'virtual_mac']],
        mutually_exclusive=[['lacp_bypass_priority', 'lacp_bypass_all_active']],
        argument_spec={
            'addr_method': {
                'type': 'str',
                'choices': ['', 'dhcp']},
            'name': {'required': True, 'type': 'str'},
            'slaves': {'required': True, 'type': 'list'},
            'mtu': {'type': 'str'},
            'alias_name': {'type': 'str'},
            'ipv4': {'type': 'list'},
            'ipv6': {'type': 'list'},
            'virtual_mac': {'type': 'str'},
            'virtual_ip': {'type': 'str'},
            'vids': {'type': 'list'},
            'pvid': {'type': 'str'},
            'use_carrier': {'type': 'int', 'choices': [0, 1]},
            'mstpctl_portnetwork': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'mstpctl_bpduguard': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'mstpctl_portadminedge': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'clag_id': {'type': 'str'},
            'lacp_rate': {'type': 'int', 'default': 1},
            'lacp_bypass_allow': {'type': 'int', 'choices': [0, 1]},
            'lacp_bypass_all_active': {'type': 'int', 'choices': [0, 1]},
            'lacp_bypass_period': {'type': 'int'},
            'lacp_bypass_priority': {'type': 'list'},
            'miimon': {'type': 'int', 'default': 100},
            'min_links': {'type': 'int', 'default': 1},
            'mode': {'type': 'str', 'default': '802.3ad'},
            'xmit_hash_policy': {'type': 'str', 'default': 'layer3+4'},
            'location': {'type': 'str', 'default': '/etc/network/interfaces.d'}}
    )
示例#2
0
def test_module_args(mock_module,
                     mock_curr_config,
                     mock_desired_config,
                     mock_compare,
                     mock_replace,
                     mock_exists):
    """ cl_bond - test module args """
    mock_exists.return_value = True
    cl_int.main()
    mock_module.assert_called_with(
        required_together=[['virtual_ip', 'virtual_mac']],
        mutually_exclusive=[['lacp_bypass_priority', 'lacp_bypass_all_active']],
        argument_spec={
            'addr_method': {
                'type': 'str',
                'choices': ['', 'dhcp']},
            'name': {'required': True, 'type': 'str'},
            'slaves': {'required': True, 'type': 'list'},
            'mtu': {'type': 'str'},
            'alias_name': {'type': 'str'},
            'ipv4': {'type': 'list'},
            'ipv6': {'type': 'list'},
            'virtual_mac': {'type': 'str'},
            'virtual_ip': {'type': 'str'},
            'vids': {'type': 'list'},
            'pvid': {'type': 'str'},
            'mstpctl_portnetwork': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'mstpctl_bpduguard': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'mstpctl_portadminedge': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'clag_id': {'type': 'str'},
            'lacp_rate': {'type': 'int', 'default': 1},
            'lacp_bypass_allow': {'type': 'int', 'choices': [0, 1]},
            'lacp_bypass_all_active': {'type': 'int', 'choices': [0, 1]},
            'lacp_bypass_period': {'type': 'int'},
            'lacp_bypass_priority': {'type': 'list'},
            'miimon': {'type': 'int', 'default': 100},
            'min_links': {'type': 'int', 'default': 1},
            'mode': {'type': 'str', 'default': '802.3ad'},
            'xmit_hash_policy': {'type': 'str', 'default': 'layer3+4'},
            'location': {'type': 'str', 'default': '/etc/network/interfaces.d'}}
    )
def test_main_integration_test(mock_module,
                               mock_curr_config,
                               mock_desired_config,
                               mock_compare,
                               mock_replace, mock_exists):
    """ cl_bond - basic integration test of main """
    mock_exists.return_value = True
    instance = mock_module.return_value
    # if config_changed == false. no change
    instance.params = {'name': 'swp1'}
    mock_compare.return_value = False
    cl_int.main()
    instance.exit_json.assert_called_with(
        msg='interface swp1 config not changed',
        changed=False)
    # if config_changed == true, change
    mock_compare.return_value = True
    cl_int.main()
    instance.exit_json.assert_called_with(
        msg='interface swp1 config updated',
        changed=True)
    # if location does not exist
    instance.params['location'] = '/etc/network/ansible'
    mock_exists.return_value = False
    cl_int.main()
    instance.fail_json.assert_called_with(
        msg='/etc/network/ansible does not exist.')
示例#4
0
def test_main_integration_test(mock_module,
                               mock_curr_config,
                               mock_desired_config,
                               mock_compare,
                               mock_replace, mock_exists):
    """ cl_bond - basic integration test of main """
    mock_exists.return_value = True
    instance = mock_module.return_value
    # if config_changed == false. no change
    instance.params = {'name': 'swp1'}
    mock_compare.return_value = False
    cl_int.main()
    instance.exit_json.assert_called_with(
        msg='interface swp1 config not changed',
        changed=False)
    # if config_changed == true, change
    mock_compare.return_value = True
    cl_int.main()
    instance.exit_json.assert_called_with(
        msg='interface swp1 config updated',
        changed=True)
    # if location does not exist
    instance.params['location'] = '/etc/network/ansible'
    mock_exists.return_value = False
    cl_int.main()
    instance.fail_json.assert_called_with(
        msg='/etc/network/ansible does not exist.')