Commit graph

614 commits

Author SHA1 Message Date
Till Maas
cf04059fc8 test: Use new py26 environment
Signed-off-by: Till Maas <opensource@till.name>
2022-02-18 09:57:46 +01:00
Till Maas
d400cadfe4 pytest: Remove PyYAML dependency
This does not seem to be needed anymore.

Signed-off-by: Till Maas <opensource@till.name>
2022-02-18 09:57:46 +01:00
Wen Liang
f2760ab059 CHANGELOG: update changelog for 1.7.0 release
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-15 14:58:58 +01:00
Wen Liang
59be618857 Support more bond options
In order to enable user to flexibly control the network transmission
over the bonded interface, support all the bond options which are
currently supported by NetworkManager.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-11 23:40:34 +01:00
Wen Liang
fde69e0758 Disable all initscripts provider tests on Fedora
The initscripts provider tests are unstable on Fedora and users are not
using the initscripts on Fedora, therefore, disable all initscripts
provider tests on Fedora.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-11 21:59:35 +01:00
Till Maas
a4267e4e91 GitHub CI: Exclude unsupported tests
To ensure that new tests are going to be tested by the CI, only exclude
tests that are not supported instead of only included the supported
ones.

Signed-off-by: Till Maas <opensource@till.name>
2022-02-09 23:40:43 +08:00
Rich Megginson
206c354b7e [citest skip] bump tox-lsr version to 2.9.1
Signed-off-by: Rich Megginson <rmeggins@redhat.com>

The new tox-lsr also requires the use of `{toxinidir}` for the
local config file paths.
2022-02-07 18:58:27 -07:00
Gris Ge
0e3d480de7 CI: Enable CentOS 9 stream integration test
Signed-off-by: Gris Ge <fge@redhat.com>
2022-02-05 19:25:09 +01:00
Fernando Fernandez Mancera
2ebc8b5022 tests: do not run test_switch_provider on CentOS/RHEL 9
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-02-05 07:15:54 +01:00
Till Maas
ac33851552 Contributing: Update IRC information
Signed-off-by: Till Maas <opensource@till.name>
2022-02-04 18:33:39 +01:00
Till Maas
adf4192e38 Contributing: Fix spelling
Signed-off-by: Till Maas <opensource@till.name>
2022-02-04 18:33:39 +01:00
Till Maas
9d8a280b8a README: Clarify the name setting
Signed-off-by: Till Maas <opensource@till.name>
2022-02-04 18:14:52 +01:00
Wen Liang
2307969aef Remove CentOS8 GitHub actions CI Tests
As CentOS8 is already EOL, remove CentOS8 CI integration tests.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-04 09:23:58 +01:00
Wen Liang
62b0be6091 CHANGELOG: update changelog for 1.6.0 release
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-04 09:07:56 +01:00
Rich Megginson
f8a5e8576a fix python black errors
fix python black errors

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2022-02-03 16:01:09 +01:00
Fernando Fernandez Mancera
2b881a6c3f tests: use down_profile+delete_interface instead of down_profile
The files must be named so that it explain what happens. In addition,
`down_profile+delete_interface` must use `changed_when` to match the
content of `delete_interface`.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-01-28 17:47:13 +01:00
Gris Ge
c98c17a236 Fix problem when switch provider from initscript to nm
Problem:

After `tests_bridge_initscripts.yml` passed, the `tests_bridge_nm.yml`
will fail with NetworkManager 1.18.

Root cause:

 1. The `absent` and `down` action of initscript provider will not
    remove the bridge interface which fail the assertion in
    `tests_bridge_nm.yml`.
 2. In initscript mode, network role will create ifcfg file with
    `NM_CONTROLLED=no` instructing NetworkManager to mark the bridge as
    unmanaged. The follow up `down` and `absent` action of initscript
    provider will not change the NetworkManager's understanding on
    unmanaged state of this interface.

Fixes:
 1. We cannot change existing behaviour of initscript on not deleting
    interface in `down` and `absent` action. So we change the test
    function `tests/playbooks/down_profile.yml` to delete the interface
    manually via `ip link del <ifname>` command.

 2. Use `NM.Client.reload_connections_async()` to reload the
    configuration for nm provider on NetworkManager 1.18.

Previous test infrastructure is running each test file in a brand new VM
or container which cause this problem not been found before.

Dedicate test case `tests/tests_switch_provider.yml` included.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-01-28 17:47:13 +01:00
Gris Ge
f508c27674 CI: Enable CentOS 7 integration test
Removed `tests_wireless_nm.yml` as github CI has no mac80211_hwsim
kernel module.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-01-28 17:47:13 +01:00
Wen Liang
5eb03fa992 Support routing tables in static routes
The users want to use the policy routing (e.g. source routing), so
that they can forward the packet based on the other criteria except for
the destination address in the packet. In such scenario, the routing
tables have to be supported beforehand in static routes, so that the
users can define policy routing rules later to instruct the system
which table to use to determine the correct route.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-01-27 18:18:47 +01:00
Rich Megginson
20667b0860 bump tox-lsr version to 2.8.3
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2022-01-10 12:35:01 -05:00
Wen Liang
af123707c2 Set DNS search setting only for enabled IP families
NetworkManager requires to configure DNS options (such as the search
setting) for each IP family even though it does not matter in the
system's DNS configuration. Also, NetworkManager only allows to
configure the DNS options for each IP family, when they are enabled. In
the network_connections dictionary, the DNS options are configured
without considering the IP family. Therefore, configure ipv4.dns-search
or ipv6.dns-search only if the IP family is enabled.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-12-21 09:18:38 +01:00
Wen Liang
4790e20ca4 CHANGELOG: update changelog for 1.5.0 release
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-12-15 11:27:18 -05:00
Wen Liang
5db8d0c5d1 Reject DNS_search setting if no IP family is enabled
NetworkManager only allows to configure the DNS options for each IP
family, when they are enabled. Therefore, reject DNS settings in
ArgValidator if no IP family is enabled.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-12-14 13:29:08 +01:00
Wen Liang
05b38b4217 Reject IPv6 DNS setting if IPv6 family is not enabled
NetworkManager only allows to configure the IPv6 nameservers if the
IPv6 family is enabled. Therefore, reject the IPv6 nameservers setting
in ArgValidator if the IPv6 family is not enabled.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-11-29 10:33:58 -05:00
Sergei Petrosian
5c7fa548ea update tox-lsr version to 2.8.0
New version adds check for proper commenting of the ansible_managed var
2021-11-23 09:36:17 +01:00
Rich Megginson
be8e38a5c6 use tox-lsr 2.7.1 with Ansible 2.12 GA
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-11-08 20:01:01 +01:00
Rich Megginson
cdea768ffa drop python 3.7 from CI
None of the platforms we support use python 3.7, so drop it from
CI testing.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-11-08 20:01:01 +01:00
Rich Megginson
16ac152542 support ansible-core 2.12; ansible-plugin-scan; fix pylint errors; py39
Use the new tox-lsr that uses ansible-core 2.12.
Use ansible-plugin-scan in CI.
Fix pylint errors found by new ansible-test pylinter.
CI test with py39

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-11-08 20:01:01 +01:00
Wen Liang
774242fb63 test IPv6 DNS when static IPv6 is configured
When static IPv6 is configured, configuring IPv6 DNS will not raise any
validation error. Add unit test to verify that.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-29 12:42:23 -04:00
Wen Liang
b0c8195843 unit tests: Fix python 2.6 compatibility
Introduce Python26CompatTestCase to fix Python 2.6 support for unit
tests:

- Use TestCase.assertRaises on Python 2.6 because it does not support
  TestCase.assertRaisesRegexp

- Use TestCase.assertRaisesRegex on Python 3.2 and newer because it
  deprecates TestCase.assertRaisesRegexp

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-28 14:20:38 +02:00
Wen Liang
f813fb33b7 fix ensure_provider_tests.py; fix generated tests; add check to CI
Fix ensure_provider_tests.py so that the tests are correctly generated.
Because the generated tests have not been checked in a while, there was
some drift between the actual tests and what should have been generated,
so the new generated tests have also been included.
When `ensure_provider_tests.py` detects differences, it will now show
the diffs using a unified diff format.
Added a new tox testenv `ensure_provider_tests` - use
`tox -e ensure_provider_tests` to run - to pass arguments, use
`tox -e ensure_provider_tests -- generate`
Added `ensure_provider_tests` as one of the tox testenvs to run for
github tox CI.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-10-19 20:21:03 +02:00
Wen Liang
1112bc2664 refactor IPv6 DNS test when IPv6 is disabled
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-13 10:19:18 +02:00
Rich Megginson
db10fc2035 add support for ansible-core 2.11 ansible-lint, ansible-test
Add support for using latest ansible-lint and ansible-test with
ansible-core 2.11.  There are a few new warnings that need to
be addressed or suppressed.

One of the changes is to add `# noqa ignore-errors` to the places in
the role where `ignore_errors: true` is used.  In general, it is not
a good idea to use `ignore_errors: true` - instead, it is better to
capture the result of the command using a `register`, then use
`failed_when`.  Or, if that is not possible, use a `block`/`rescue`
for more complex error handling.  However, in the case where the network
role is using `ignore_errors: true` in test code, it is acceptable.
see https://ansible-lint.readthedocs.io/en/latest/default_rules.html#ignore-errors

Another change is to have all tasks have a valid `name:`.  This
is explained at https://ansible-lint.readthedocs.io/en/latest/default_rules.html#unnamed-task

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-10-11 12:03:00 -06:00
Sergei Petrosian
c0f6038082 On RHEL 7, enable epel using yum-config-manager
Fixing the CI on RHEL 7, it was broken by PR #422

Signed-off-by: Sergei Petrosian <spetrosi@redhat.com>
2021-10-06 20:02:12 +02:00
Wen Liang
9fd19afa25 Allow configuring network connection via matching path
Users can easily configure or update network connection via matching
physical device path of the interface, which add certain flexibilty of
user experience.

Update connection profile via matching `path` setting:

```yaml
  - name: eth0
    type: ethernet
    autoconnect: yes
    # For PCI devices, the path has the form "pci-$domain:$bus:$device.$function"
    # It will only update the interface with the path "pci-0000:00:03.0"
    match:
      path:
        - pci-0000:00:03.0
```

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-06 18:22:42 +08:00
Wen Liang
b569704c72 arg_validator: accept None as valid input for ArgValidatorDict
Users might want to use jinja2 templates to set properties. As such,
it's convenient to accept None as an alias for an empty dictionary.

For exmaple, setting like `"match": None` will be allowed by the role:
e.g.
        network_connections:
          - name: enp0s8
            type: ethernet
            persistent_state: present
            state: up
            match:
            ip:
              route_metric4: 10

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-06 18:22:42 +08:00
Wen Liang
af07c2a58d arg_validator: accept None as valid input for ArgValidatorList
Users might want to use jinja2 templates to set properties. As such,
it's convenient to accept None as an alias for an empty list.

For exmaple, setting like `"match": {"path": None}` will be allowed by
the role:

        network_connections:
          - name: enp0s8
            type: ethernet
            persistent_state: present
            state: up
            match:
              path:
            ip:
              route_metric4: 10

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-06 18:22:42 +08:00
Wen Liang
71b4ff9357 Replace setting_type.new() with setting_type()
When `setting_type` is `NM.SettingMatch`, `setting_type.new()` will not
work because `nm_setting_match_new()` symbol is only exposed and usable
since libnm version 1.32 (using `setting_type.new()` is equivalent to
call libnm function `nm_setting_*_new()`).

Function `setting_type()` will always construct an instance of that
`setting_type` and will not need a workaround when `setting_type` is
`NM.SettingMatch`. So drop `setting_type.new()` in favor of
`setting_type()`.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-06 18:22:42 +08:00
Brian Smith
46ff0ece04 Update README.md to note that network teaming is deprecated in RHEL 9.
Signed-off-by: Brian Smith <briasmit@redhat.com>
2021-10-04 22:58:50 -04:00
Wen Liang
fbd335af27 validate that ipv6_disabled is conflicting with other settings
When IPv6 is disabled, it is conflicting with enabling `auto6`
or configuring static IPv6 or configuring `gateway6` or
configuring `route_metric6`. Add unit tests to check if
this is properly handled in Argvalidator.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-09-27 14:12:56 -04:00
Rich Megginson
867482d35b replace ini_file with yum/dnf
For ansible-core 2.11 compatability, replace the use of `ini_file`
with the yum/dnf config-manager command

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-09-16 08:39:37 -06:00
Rich Megginson
81248c01c4 use apt-get install -y
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-09-15 16:17:55 -06:00
Rich Megginson
9ce48eb05a replace json_query with selectattr
In order to work with ansible-core, json_query is replaced
with selectattr.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-09-14 07:49:16 -06:00
Rich Megginson
fca9ca5f36 use tox-lsr 2.5.1
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-09-13 09:58:18 -06:00
Thomas Haller
7a1683848c arg_validator: make ArgValidator.DEFAULT the default for dictionary's default value
The most used default value for ArgValidatorDict is
ArgValidator.DEFAULT, which means to generate the default value
based on the nested validators.

ArgValidator.DEFAULT is also a better default for the default_value.
Otherwise, it's a bit odd to have (and honor) ArgValidator.DEFAULT, if
that is not in fact the default default_value.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-08-26 16:30:09 +08:00
Thomas Haller
63ddf64a41 arg_validator: use DEFAULT argument to generate default value for dictionaries
The previous solution was ugly, as it hacked the private
self._default_value of the parent.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-08-26 16:30:09 +08:00
Thomas Haller
e01e550c59 arg_validator: support generating default value for ArgValidatorDict
Some dictionaries may wish to have a default value that is a dictionary
with the default of all keys.

Add a method to generate this.

This returns a callable instead of a plain dictionary. In practice, the
generated default value should always be the same. However, we also
expect that ArgValidator validation gives a result that is owned by the
caller. In case of mutable values (like a dictionary), we want a deep
clone.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-08-26 16:30:09 +08:00
Thomas Haller
e0a1b6af68 arg_validator: make ArgValidatorDeprecated a subclass of ArgValidator
ArgValidatorDeprecated is used as a nested validator, it also should
subtype ArgValidator base class. Technially, in python you can do duck
typing and get away with a different class that merely behaves
sufficiently similar. But why?

That way, we also can set default_value=ArgValidator.MISSING.
As a result, we no longer need to special case ArgValidatorDeprecated
at various places, because the default value will indicate that
it should not be present.

Co-authored-by: Till Maas <opensource@till.name>

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-08-26 16:30:09 +08:00
Thomas Haller
a262c77c26 arg_validator: expect ArgValidatorDeprecated.deprecated_by setting to be valid
"validator.deprecated_by" is user configuration of the validator. It depends on the
setup of the current ArgValidatorDict instance. It would be a bug if the user
references a non-existing validator.

Thus, use dictionary lookup instead of get() and fail early.

The previous code of course also didn't work, because the
returned None value would have led to an exception shortly after.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-08-26 16:30:09 +08:00
Thomas Haller
72319a1294 arg_validator: call get_default_value() for getting the default value
self._default_value might be a callable, to get the actual default
value, self.get_default_value() must be called.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-08-26 16:30:09 +08:00