
This reverts commit 850269646f5b4b30f3bf43f65cc0d244c09e0ed5. Reason for revert: a patch is being applied on top of the original change (https://review.opendev.org/c/starlingx/stx-puppet/+/938636) which ensures that the interfaces in the auto file are ordered as follows: lo -> eths -> bondings -> slaves -> vlans -> labels. This guarantees that the interfaces are properly initialized at boot, effectively fixing the issue that caused the change to be reverted in the first place. This commit replaces the apply_network_config.sh script by the Python- coded equivalent apply_network_config.py, and includes automated tests for it. The original scripts apply_network_config.sh, network_ifupdown.sh and network_sysconfig.sh are being marked as obsolete and shall be removed in the future. Flake8 test has been changed to include all files in the puppet-manifests folder, adjustments had to be made to puppet-update-grub-env.py, k8s_wait_for_endpoints_health.py and change_k8s_control_plane_params.py for conformance. Tests: 1. Installation [PASS] AIO-SX IPv4 full install on virtualBox [PASS] AIO-DX IPv6 full install on virtualBox [PASS] AIO-DX IPv4 full install on a physical lab [PASS] AIO-DX IPv6 full install on a physical lab 2. Network configuration change For this test, a regular AIO-SX setup on VirtualBox is used with default settings: Address pools - oam-ipv4: 10.20.6.0/24 - management-ipv4: 192.168.204.0/24 - cluster-host-ipv4: 192.168.206.0/24 Interfaces - lo (lo, platform): management, cluster-host - enp0s3 (oam0, platform): oam - enp0s9 (data0, data) - enp0s10 (data1, data) Procedure: - Lock host - Execute sequence of commands - Unlock host - Wait for the host to unlock-reboot - Check that kernel networking config reflects sysinv config - Check that files in /etc/network/ were correctly generated - Check that logs in /var/log/user.log are coherent - Reboot host - Check that interfaces are correctly initialized on boot [PASS] Test 2.1: Add IPv6 stack, add addresses and routes to data1 system addrpool-add oam-ipv6 fd00:: 64 --ranges fd00::1-fd00::ffff \ --order random --floating-address fd00::3 --gateway-address fd00::1 system addrpool-add management-ipv6 fd01:: 64 \ --ranges fd01::1-fd01::ffff --order random \ --floating-address fd01::1 --controller0-address \ fd01::2 --controller1-address fd01::3 system addrpool-add cluster-host-ipv6 fd02:: 64 \ --ranges fd02::1-fd02::ffff --order random --floating-address \ fd02::1 --controller0-address fd02::2 --controller1-address fd02::3 system network-addrpool-assign oam oam-ipv6 system network-addrpool-assign mgmt management-ipv6 system network-addrpool-assign cluster-host cluster-host-ipv6 system host-if-modify controller-0 data1 --ipv4-mode static \ --ipv6-mode static system host-addr-add controller-0 data1 177.201.1.2 24 system host-addr-add controller-0 data1 bd01:201::1:2 64 system host-route-add controller-0 data1 208.166.11.0 24 177.201.1.111 system host-route-add controller-0 data1 af04:11:: 64 bd01:201::111 [PASS] Test 2.2: Move mgmt and cluster-host networks from lo to eth mgmt_intnet=$(system interface-network-list controller-0 | \ grep "mgmt" | awk '{print $4}') clhost_intnet=$(system interface-network-list controller-0 | \ grep "cluster-host" | awk '{print $4}') system interface-network-remove $mgmt_intnet system interface-network-remove $clhost_intnet system host-if-modify controller-0 enp0s8 -n mgmt0 -c platform system interface-network-assign controller-0 mgmt0 mgmt system interface-network-assign controller-0 mgmt0 cluster-host system host-route-add controller-0 mgmt0 208.166.1.0 24 192.168.204.111 system host-route-add controller-0 mgmt0 af04:1:: 64 fd01::111 system host-route-add controller-0 mgmt0 208.166.2.0 24 192.168.206.111 system host-route-add controller-0 mgmt0 af04:2:: 64 fd02::111 [PASS] Test 2.3: Move mgmt and cluster-host networks to VLANs mgmt_intnet=$(system interface-network-list controller-0 | \ grep "mgmt" | awk '{print $4}'); clhost_intnet=$(system interface-network-list controller-0 | \ grep "cluster-host" | awk '{print $4}'); system interface-network-remove $mgmt_intnet system interface-network-remove $clhost_intnet while read i; do uuid=$(echo "$i" | awk '{print $2}'); system \ host-route-delete "$uuid"; done <<< $(system host-route-list \ controller-0 | grep "mgmt0"); system host-if-modify controller-0 mgmt0 -n pxeboot0 system host-if-add controller-0 mgmt0 vlan pxeboot0 -V 10 -c platform system host-if-add controller-0 cluster0 vlan pxeboot0 -V 11 -c platform system host-if-add controller-0 datavlan1 vlan data1 -V 201 -c data \ --ipv4-mode static --ipv6-mode static system interface-network-assign controller-0 pxeboot0 pxeboot system interface-network-assign controller-0 mgmt0 mgmt system interface-network-assign controller-0 cluster0 cluster-host system host-addr-add controller-0 datavlan1 177.202.1.2 24 system host-addr-add controller-0 datavlan1 bd01:202::1:2 64 system host-route-add controller-0 mgmt0 208.166.1.0 24 192.168.204.111 system host-route-add controller-0 mgmt0 af04:1:: 64 fd01::111 system host-route-add controller-0 cluster0 \ 208.166.2.0 24 192.168.206.111 system host-route-add controller-0 cluster0 af04:2:: 64 fd02::111 system host-route-add controller-0 datavlan1 \ 208.166.21.0 24 177.202.1.111 system host-route-add controller-0 datavlan1 af04:21:: 64 bd01:202::111 [PASS] Test 2.4: Move pxeboot, mgmt and cluster-host to a bonding pxeboot_intnet=$(system interface-network-list controller-0 | \ grep "pxeboot" | awk '{print $4}') mgmt_intnet=$(system interface-network-list controller-0 | \ grep "mgmt" | awk '{print $4}') clhost_intnet=$(system interface-network-list controller-0 | \ grep "cluster-host" | awk '{print $4}') system interface-network-remove $pxeboot_intnet system interface-network-remove $mgmt_intnet system interface-network-remove $clhost_intnet system host-if-delete controller-0 mgmt0 system host-if-delete controller-0 cluster0 system host-if-modify controller-0 pxeboot0 -c none system host-if-modify controller-0 data0 -c none system host-if-add controller-0 bond0 ae enp0s8 enp0s9 -c platform system interface-network-assign controller-0 bond0 mgmt system interface-network-assign controller-0 bond0 cluster-host system host-route-add controller-0 bond0 208.166.1.0 24 192.168.204.111 system host-route-add controller-0 bond0 af04:1:: 64 fd01::111 system host-route-add controller-0 bond0 208.166.2.0 24 192.168.206.111 system host-route-add controller-0 bond0 af04:2:: 64 fd02::111 [PASS] Test 2.5: Move mgmt and cluster-host to vlans on top of a bonding mgmt_intnet=$(system interface-network-list controller-0 | \ grep "mgmt" | awk '{print $4}') clhost_intnet=$(system interface-network-list controller-0 | \ grep "cluster-host" | awk '{print $4}') system interface-network-remove $mgmt_intnet system interface-network-remove $clhost_intnet system host-if-add controller-0 mgmt0 vlan bond0 -V 10 -c platform system host-if-add controller-0 cluster0 vlan bond0 -V 11 -c platform system interface-network-assign controller-0 mgmt0 mgmt system interface-network-assign controller-0 cluster0 cluster-host while read i; do uuid=$(echo "$i" | awk '{print $2}'); system \ host-route-delete "$uuid"; done <<< $(system host-route-list \ controller-0 | grep "bond0"); system host-route-add controller-0 mgmt0 208.166.1.0 24 192.168.204.111 system host-route-add controller-0 mgmt0 af04:1:: 64 fd01::111 system host-route-add controller-0 cluster0 \ 208.166.2.0 24 192.168.206.111 system host-route-add controller-0 cluster0 af04:2:: 64 fd02::111 3. Distributed cloud [PASS] Subcloud enrollment, OAM over ethernet, same subnet [PASS] Subcloud enrollment, OAM over VLAN, different VLAN ID, different subnet Story: 2011338 Task: 51635 Change-Id: I0a9e095dcff5c59a0e543b481c8d0856e8485340 Signed-off-by: Lucas Ratusznei Fonseca <lucas.ratuszneifonseca@windriver.com>
176 lines
7.0 KiB
INI
176 lines
7.0 KiB
INI
[tox]
|
|
envlist = linters,pep8,pylint
|
|
minversion = 2.3
|
|
skipsdist = True
|
|
sitepackages=False
|
|
|
|
[testenv]
|
|
install_command = pip install -U {opts} {packages}
|
|
setenv =
|
|
VIRTUAL_ENV={envdir}
|
|
OS_STDOUT_CAPTURE=1
|
|
OS_STDERR_CAPTURE=1
|
|
OS_DEBUG=1
|
|
OS_LOG_CAPTURE=1
|
|
deps =
|
|
-r{toxinidir}/requirements.txt
|
|
-r{toxinidir}/test-requirements.txt
|
|
allowlist_externals =
|
|
bash
|
|
|
|
[testenv:shellcheck]
|
|
basepython = python3
|
|
# The following are currently suppressed:
|
|
# SC1083: This '{' or '}' is literal. Check expression (missing ;/\n?) or quote it.
|
|
# SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
|
|
# SC2004: $/${} is unnecessary on arithmetic variables.
|
|
# SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
|
|
# SC2006: Use $(...) notation instead of legacy backticked `...`.
|
|
# SC2012: Use find instead of ls to better handle non-alphanumeric filenames.
|
|
# SC2034: variable appears unused. Verify use (or export if used externally).
|
|
# SC2044: For loops over find output are fragile. Use find -exec or a while read loop.
|
|
# SC2046: Quote this to prevent word splitting
|
|
# SC2068: Double quote array expansions to avoid re-splitting elements.
|
|
# SC2076: Remove quotes from right-hand side of =~ to match as a regex rather than literally.
|
|
# SC2086: Double quote to prevent globbing and word splitting
|
|
# SC2091: Remove surrounding $() to avoid executing output (or use eval if intentional).
|
|
# SC2115: Use "${var:?}" to ensure this never expands to /* .
|
|
# SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
|
|
# SC2154: i is referenced but not assigned.
|
|
# SC2155: Declare and assign separately to avoid masking return values.
|
|
# SC2162: read without -r will mangle backslashes
|
|
# SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
|
|
# SC2181: Check exit code directly with e.g. if mycmd; not indirectly with $?
|
|
# SC2199: Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).
|
|
# SC2206: Quote to prevent word splitting/globbing, or use mapfile or read -a.
|
|
# SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting)
|
|
# SC2219: Instead of 'let expr', prefer (( expr ))
|
|
# SC2254: Quote expansions in case patterns to match literally rather than as a glob.
|
|
# SC2317: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
|
|
|
|
# shellcheck is called twice, to handle shell scripts that do not end in .sh
|
|
commands =
|
|
bash -c "find {toxinidir} \
|
|
-not \( -type d -name .?\* -prune \) \
|
|
-type f \
|
|
-not -name \*~ \
|
|
-not -name \*.md \
|
|
-name \*.sh \
|
|
-print0 | xargs -r -n 1 -0 shellcheck \
|
|
-eSC1083 -eSC2002 -eSC2004 -eSC2005 -eSC2006 -eSC2012 -eSC2034 \
|
|
-eSC2044 -eSC2046 -eSC2068 -eSC2076 -eSC2086 -eSC2091 -eSC2115 \
|
|
-eSC2148 -eSC2154 -eSC2155 -eSC2162 -eSC2166 -eSC2181 -eSC2199 \
|
|
-eSC2206 -eSC2207 -eSC2219 -eSC2254 -eSC2317"
|
|
bash -c "find {toxinidir} \
|
|
-not \( -type d -name .?\* -prune \) \
|
|
-type f \
|
|
-not -name \*~ \
|
|
-not -name \*.md \
|
|
\( -exec bash -c 'file \{\} | grep -q shell' \; \
|
|
-a ! -name '*.sh' \) \
|
|
-print0 | xargs -r -n 1 -0 shellcheck \
|
|
-eSC1083 -eSC2002 -eSC2004 -eSC2005 -eSC2006 -eSC2012 -eSC2034 \
|
|
-eSC2044 -eSC2046 -eSC2068 -eSC2076 -eSC2086 -eSC2091 -eSC2115 \
|
|
-eSC2148 -eSC2154 -eSC2155 -eSC2162 -eSC2166 -eSC2181 -eSC2199 \
|
|
-eSC2206 -eSC2207 -eSC2219 -eSC2254"
|
|
|
|
[testenv:bashate]
|
|
# Treat all E* codes as Errors rather than warnings using: -e 'E*'
|
|
# The following codes are being suppressed:
|
|
# E006 Line too long
|
|
# E011 Then keyword is not on same line as if or elif keyword
|
|
# bashate is called twice, to handle shell scripts that do not end in .sh
|
|
# the suppression lists are different (eventually nothing will be suppressed)
|
|
commands =
|
|
bash -c "find {toxinidir} \
|
|
-not \( -type d -name .?\* -prune \) \
|
|
-type f \
|
|
-not -name \*~ \
|
|
-not -name \*.md \
|
|
-name \*.sh \
|
|
-print0 | xargs -r -n 1 -0 bashate -v \
|
|
-i E006 \
|
|
-e 'E*'"
|
|
bash -c "find {toxinidir} \
|
|
-not \( -type d -name .?\* -prune \) \
|
|
-type f \
|
|
-not -name \*~ \
|
|
-not -name \*.md \
|
|
-not -name \*.ldif \
|
|
\( -exec bash -c 'file \{\} | grep -q shell' \; \
|
|
-a ! -name '*.sh' \) \
|
|
-print0 | xargs -r -n 1 -0 bashate -v \
|
|
-i E006,E011 \
|
|
-e 'E*'"
|
|
|
|
|
|
[testenv:bindep]
|
|
# Do not install any requirements. We want this to be fast and work even if
|
|
# system dependencies are missing, since it's used to tell you what system
|
|
# dependencies are missing! This also means that bindep must be installed
|
|
# separately, outside of the requirements files.
|
|
deps = bindep
|
|
commands = bindep test
|
|
|
|
[testenv:linters]
|
|
basepython = python3
|
|
# Note: centos developer env requires ruby-devel
|
|
# Ubuntu developer env requires ruby-dev
|
|
allowlist_externals =
|
|
gem
|
|
bash
|
|
setenv =
|
|
GEM_HOME = {envdir}
|
|
GEM_PATH = {envdir}
|
|
skip_tests = \
|
|
--no-autoloader_layout-check \
|
|
--no-documentation-check
|
|
commands =
|
|
gem install --no-document json:2.5.1 puppet-lint:2.3.6
|
|
bash -c "find {toxinidir}/puppet-manifests {toxinidir}/modules \
|
|
-name \*.pp -print0 \
|
|
| xargs -0 puppet-lint --fail-on-warnings {[testenv:linters]skip_tests}"
|
|
{[testenv:bashate]commands}
|
|
{[testenv:shellcheck]commands}
|
|
|
|
[testenv:pep8]
|
|
basepython = python3
|
|
usedevelop = False
|
|
description =
|
|
Run style checks.
|
|
|
|
|
|
commands =
|
|
flake8 puppet-manifests
|
|
|
|
[testenv:pylint]
|
|
basepython = python3
|
|
sitepackages = False
|
|
|
|
deps = {[testenv]deps}
|
|
requests
|
|
pylint<2.5.0
|
|
commands =
|
|
pylint {posargs} --rcfile=./pylint.rc puppet-manifests
|
|
|
|
[flake8]
|
|
# E123, E125 skipped as they are invalid PEP-8.
|
|
# E126 continuation line over-indented for hanging indent
|
|
# E127 continuation line over-indented for visual indent
|
|
# H104: File contains nothing but comments
|
|
# H306: imports not in alphabetical order
|
|
# H404: multi line docstring should start without a leading new line
|
|
# H405: multi line docstring summary not separated with an empty line
|
|
# W504: line break after binary operator
|
|
show-source = True
|
|
ignore = E123,E125,E126,E127,H104,H306,H404,H405,W504
|
|
# Max line length set to 100 to coincide with opendev's code view width
|
|
max-line-length = 100
|
|
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*
|
|
|
|
[testenv:bandit]
|
|
basepython = python3
|
|
description = Bandit code scan for *.py files under config folder
|
|
deps = -r{toxinidir}/test-requirements.txt
|
|
commands = bandit -r {toxinidir}/ -x '**/.tox/**,**/.eggs/**' -lll
|