Commit graph

361 commits

Author SHA1 Message Date
Jan Vaclav 1c41066a40 build: include documentation in meson dist
Previously, the tarball generated by `meson dist` did not contain the
autogenerated documentation due to the way meson works (packaging the
latest revision control commit). This introduces a dist script which
builds & copies the generated documentation into the distribution
tarball.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1811
2024-01-17 12:39:46 +00:00
Thomas Haller 28a1afca63
python: reformat with black-23.7.0-2.fc39.noarch
The base image for the "check-tree" test got bumped to Fedora 39.  This
brings a new python-black version (23.7.0 vs. 22.8.0) and requires
reformatting.

Maybe we should stick to 22.8.0, via `pip install`. But it seems better
to just follow the latest black version (the one from current Fedora).

So do the reformatting instead.

https://black.readthedocs.io/en/stable/change_log.html#id38
2023-12-06 11:56:11 +01:00
Thomas Haller 41e3fed381
tests: improve detection of libtool in "run-nm-test.sh"
The user can set "$NMTST_LIBTOOL" to empty or the path to libtool.

If unset, we want to detect it. However, previously we would always
use "$SCRIPT_PATH/../libtool", even if that file doesn't exit. Improve
that.

For example, when running on Ubuntu with the ".gitlab-ci/debian-install.sh"
script, we don't have libtool. Entering such a container and running the
"run-nm-test.sh" script will fail as "$SCRIPT_PATH/../libtool" doesn't
exist.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1800
2023-11-30 15:36:20 +01:00
Thomas Haller 1054d3bce0
nm-in-container: set TERM=xterm in bashrc
Otherwise, TERM is set to "dump", which breaks a lot of uses of the
pager.
2023-11-20 16:40:10 +01:00
Thomas Haller 84ede1c380
nm-in-container: bind mount additional directories
- If ".git/nm-in-container-host" exists, bind mount all of "/" to
  "/Host".

- also honor all ".git/nm-data-link-*" files for additional
  directories to bind mount.

- as before, honor ".git/NetworkManager-ci" symlink.

Note that directories also get symlinked from "/". Like
"/NetworkManager-ci" which symlinks links to the bind mount location.
2023-11-20 16:00:14 +01:00
Thomas Haller 1c187166c2
nm-in-container: install ausearch/audit package
This is now required by NM-ci. Install it.
2023-11-15 10:41:11 +01:00
Thomas Haller c04c955407
nm-in-container: fix mount command in "_nm-in-container-setup.sh"
On Fedora 39, mount now requires the dummy device argument.
It was wrong to omit it, altough it worked previously.

Fix the mount command line.
2023-11-15 09:28:58 +01:00
Íñigo Huguet f4fbc59a16 man nm-setting-*: proper format for gtkdoc constants
Gtkdoc comments are used, among other things, to generate the various
nm-setting-* manual pages. When a constant is referenced in a gtkdoc
comment (i.e. `%NM_IP_TUNNEL_MODE_IPIP`) it is expanded to show the C name
and the value (i.e. `NM_IP_TUNNEL_MODE_IPIP (1)`). To generate the
nm-setting-* manual pages, we don't use gtkdoc, but we process this data
with the custom script tools/generate-docs-nm-settings-docs-gir.py.
This script was expanding the constants in the same way than gtkdoc.

Showing the constants in that way in nm-setting-* manual pages makes
little sense, because users are not going to use the C identifiers.
Let's show them with a more appropriate format.

Additionally, the different nm-setting-* pages might require different
formats than the other. For example, for nm-setting-nmcli a format like
`"ipip" (1)` is prefered, but for nm-setting-dbus it's better
`1 (ipip)`. Let's generate different nm-settings-docs-gir-*.xml files for
nmcli, dbus, keyfile and ifcfg-rh, using the right format for each one.
2023-09-21 15:57:35 +02:00
Íñigo Huguet c9ced304d2 man nm-setting-*: add "expand enumvals" capability to property-infos
In some cases, properties documentation might require to provide an
explanation of each of the possible values that the property accepts.
If the possible values are the variants of an enum, we can use the
introspection data to get all the possible values for that enum and
their descriptions. With that info, we can automatically generate the
documentation with an always up to date list of accepted values.

Add a new "expand enumvals" feature: it will convert a token with the
format `#EnumName:*` to a list of all the possible values. For the
docbook (description-docbook field in the XML), it is expanded to a
bulleted list of all the values and their respective documentations.

This feature is limited to the "property-infos" comments (those like
---nmcli---, ---dbus---, etc). This comments are used only to generate
the nm-settings-* manual pages. For the documentation under the doc/
folder this is not needed: it's not supported by gtkdoc and, anyway,
it's better to use just `#EnumName` that will generate an HTML link.

Additionally, expansion of `%ENUM_VALUE` is now supported in the
property-infos comments. Instead of expanding them in the same style
than gtkdoc "ENUM_VALUE (num)", it is expanded in a format more suitable
for the nm-setting-* manual pages:
- for nmcli: value_nick (num)
- others: num (value_nick)

Also, fix typo in meson build file propery -> property.
2023-09-21 15:57:35 +02:00
Íñigo Huguet 5c6ae44e00 man nm-settings-nmcli: add "Special values" field
If there are properties that accept special values apart from the
normally accepted values, or any of those values has an special meaning,
it can be shown as "Special value", indicating the nicknames and numbers
that can be used to select it.
2023-09-21 15:57:35 +02:00
Íñigo Huguet 925d4df801 man nm-settings-nmcli: add "Valid values" field
Show a new field called "Valid values" in those properties that only
accept a limited set of values, like enums, ints with a valid range of
values, etc.

As there is some complex logic behind getting this information, this
logic has been put in nm-meta-setting-desc and nm-enum-utils so they can
be re-used, avoiding duplicity and errors. Some refactor has been done
in nm-meta-setting-desc in this direction, too.
2023-09-21 15:57:35 +02:00
Íñigo Huguet 52c347677f tools: nm-in-vm: fix error if pool folder doesn't exist yet
If libvirt's default pool folder doesn't exist yet (i.e. the user has
never installed a VM there), create it to avoid error and script exit.
2023-09-21 15:53:03 +02:00
Íñigo Huguet 0ec71289ed tools: nm-in-vm: fix motd
Message of the day was shown twice because the same bashrc.my file than
for containers was used. That file contained some code to show motd in
the container, where it is not shown by default. But in the VM, the motd
is shown by default, so it was shown twice.

Move the code to show motd to a file used only by nm-in-container and
not by nm-in-vm.

Also, modify the explanation about using prepare-for-system.sh because
it's only valid for Fedora but nm-in-vm can be used with other SOs too.
2023-09-21 15:53:03 +02:00
Íñigo Huguet c8a329bc12 tools: nm-in-vm: don't allow invalid hostnames, fix regex
The $VM name is used also as hostname in the guest so ssh connection can
be made to root@$VM. However, valid hostnames can only contain letters,
numbers and '-'. If other characters are used, they are removed from the
hostname so you cannot connect to root@$VM. Fix it by not allowing
invalid hostnames in $VM at VM creation.

Also, fix some incorrect bash regexes.
2023-09-21 15:53:03 +02:00
Íñigo Huguet 25e6218e94 tools: nm-in-vm: fix CentOS Stream guest
Install missing repositories required to install all the packages.

Unluckily, it doesn't support 9P filesystem shares, and virtiofs is not
supported for non-root hosts. Emit a warning about that.
2023-09-21 15:53:03 +02:00
Íñigo Huguet f9cfe80b56 tools: nm-in-vm: change default image size
Images of qcow2 format dynamically grow up to the maximum size that they
have been configured at creation time. Because of this, higher size can
be selected without wasting unnecesary space in the host. Rise image
size to 20G.

Also, allow to set an empty value to IMAGE_SIZE, and don't resize in
that case. This is useful because virt-resize fails with some guest
partition layouts (like with ubuntu-20.04).
2023-09-21 15:53:03 +02:00
Íñigo Huguet 28cb8024e3 tools: nm-in-vm add convenience options --vm and os_version
Using more than one VM can be a quite common use case. Insteado of
having to do VM=vm_name ./nm-in-vm, allow the more common way of passing
options ./nm-in-vm --vm vm_name.

Also, in build command, accept one positional argument to set OS_VERSION.
2023-09-21 15:53:03 +02:00
Íñigo Huguet 49175cb2cb tools: nm-in-vm: Debian/Ubuntu with extra pkgs and fixed installation 2023-09-21 15:53:03 +02:00
Íñigo Huguet 2b44baf137 tools: nm-in-vm: fix connectivity with host
The connectivity with the host depends on getting a DHCP lease from the
host. With the latest commit's customizations, the virtual NIC is not
managed by NM so it is not configured.

Keep it unmanaged so debuging NetworkManager doesn't affect to this
virtual NIC. Use dhclient to get a DHCP lease from the host. Assign a
fixed interface name (host_net) to match it from NM and dhclient config
files.
2023-09-21 15:53:03 +02:00
Íñigo Huguet db78d7b1b0 tools: nm-in-vm: add NM custom files, packages and configs
Same packages and customizations than in nm-in-container. Packages for
Debian/Ubuntu pending of being added because they have different names.
2023-09-21 15:53:03 +02:00
Íñigo Huguet d00a5d2a8b tools: nm-in-container: don't generate files from the script
The script was generating the data-* files that later copies to the
container.

In order to the files being reusable for nm-in-vm, put them as separate
files inside the data directory.

However, some of the files need the full path to NetworkManager project,
which varies for each user. Instead, make a sed replacement on them and
generate the actual files that will be copied. Replacement:
{{BASEDIR_NM}} -> $BASEDIR_NM

Also, rename the files to more descriptive names, using some prefixes
that give a hint of where those files will be put, and the .in extension
to indicate that they will be processed.
2023-09-21 15:53:03 +02:00
Íñigo Huguet 3100e4b6e2 tools: nm-in-container: move data to a common path for nm-in-vm
nm-in-vm can use the same generated files than nm-in-container, so let's
move them to a place common for both: tools/nm-guest-data.

With this change, it is not worth it to have the nm-in-container
directory, so move the script to tools and delete the subdirectory.
2023-09-21 15:53:03 +02:00
Íñigo Huguet 97595fb00b tools: add nm-in-vm script
Script to download, configure and install a virtual machine to build and
test NetworkManager. This is useful because there are some things that
doesn't work properly on containers so a VM is needed to test.

It works almost the same way than nm-in-container.

Configurations specific to NetworkManager such as installing the required
packages are not implemented yet.
2023-09-21 15:53:03 +02:00
Íñigo Huguet fb851f3294 nmcli: warn if daemon version mismatch
When updating NetworkManager to a new version, normally the service is
not restarted by the installer to avoid interrupting networking.
However, next nmcli invocation will use the updated version, but against
the older version of the daemon that is still running. Although this is
suposed to work, it is advisable that nmcli and daemon's versions are
the same. Emit a warning recommending restarting the daemon.

Add nmcli test to check the new feature. To avoid breaking the existing
tests, test-networkmanager-service now reports the same version than the
running nmcli except if it's instructed to report a different one.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1703
2023-08-03 10:09:06 +02:00
Fernando Fernandez Mancera 2115032869 nmcli: show bandwidth on wifi device output
Example output:

```
NAME:                                   AP[3]
SSID:                                   testX
SSID-HEX:                               4D4F5649535441525F504C55535F32453037
BSSID:                                  80:78:71:90:2E:15
MODE:                                   Infra
CHAN:                                   104
FREQ:                                   5520 MHz
RATE:                                   540 Mbit/s
BANDWIDTH:                              40 MHz
SIGNAL:                                 32
BARS:                                   ▂▄__
SECURITY:                               WPA2
WPA-FLAGS:                              (none)
RSN-FLAGS:                              pair_ccmp group_ccmp psk
DEVICE:                                 wlp0s20f3
ACTIVE:                                 yes
IN-USE:                                 *
DBUS-PATH:                              /org/freedesktop/NetworkManager/AccessPoint/3
```
2023-08-02 00:54:32 +02:00
Thomas Haller 6985c011c7
nm-in-container: add NetworkManager.service override 2023-06-30 15:44:05 +02:00
Thomas Haller c59e7dfdee
nm-in-container: install pytest by default
It is useful for running unit tests on NetworkManager-ci.
2023-06-28 12:20:11 +02:00
Thomas Haller ddcb396495
tests: avoid Python3 f-string in "test-cloud-meta-mock.py"
It breaks tests on Debian:9, which use Python2 still.

Fixes: e1f3acf3a6 ('test-cloud-meta-mock: allow configuring the provider that are mimicked')
2023-06-28 12:14:21 +02:00
Wen Liang f04a9eb098 cloud-setup: add pre-up event to prevent reaching network-online.target
network-online.target should not be reached before nm-cloud-setup
completes configuring the network, which may make user service get
started before the network is fully configured.

Setting nm-cloud-setup.service as "Before=network-online.target" would
maybe have already achieved that. However, also use a pre-up dispatcher
script, so that the device activation in NetworkManager is also waiting
for nm-cloud-setup to complete.

https://bugzilla.redhat.com/show_bug.cgi?id=2151040
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1653
2023-06-09 09:18:20 -04:00
Frederic Martinsons ae408fe4ab tools/tests: correct variant parsing
Seen in NM 1.42.6 where there is now a ipv4.dns-data key which
have as signature:
dbus.Array([dbus.String('a.b.c.d')], signature=dbus.Signature('s'), variant_level=1)

This lead to the following exception:
Cannot convert array element to type 's': Must be string, not Variant

Moreover, the exception TypeError has no message field so it raised
another expcetion which gave me trouble to find what's going on.

Hence the addition of a log file from the previous commit

Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
2023-06-07 05:48:09 +00:00
Frederic Martinsons 2f7a571759 tools/tests: add ability to log to a file
That has been proven useful for debugging the tool during tests

Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
2023-06-07 05:48:09 +00:00
Thomas Haller e432b26112
nm-in-container: improve documentation 2023-06-06 15:01:56 +02:00
Thomas Haller d67d63bf14
nm-in-container: improve README.md 2023-05-30 10:20:29 +02:00
Thomas Haller e1f3acf3a6
test-cloud-meta-mock: allow configuring the provider that are mimicked
"test-cloud-meta-mock.py" needs to be mocked, so it only replies
to stuff that we tell it to. Except for the API token, that is
pushed by the client.

We need to be able to tell the mock whether it supports that API
or not. By default it does, but by setting "/.nmtest/providers"
we can limit that.

The DEFAULT_RESOURCE are now grouped by provider. If a path is not
explicitly mocked, we may fallback to the DEFAULT_RESOURCE, but only if
the respective "/.nmtest/providers" is enabled and if /.nmtest/allow-default"
indicates so (which they do by default).
2023-05-22 17:26:10 +02:00
Thomas Haller 4691f45bde
test-cloud-meta-mock: add and use helper to send response code 2023-05-22 17:24:55 +02:00
Thomas Haller 77fd4d5f0e
test-cloud-meta-mock: update default MAC address for test-cloud-meta-mock.py
Choose a MAC address that is easily recognizable. And where you can
see which is mac1 and mac2.
2023-05-22 17:24:55 +02:00
Thomas Haller 6dad817c05
tools: fix python2 compatibility in "generate-docs-nm-settings-docs-merge.py"
Fixes: 42aa225185 ('docs: better handle description tags in generate-docs-nm-settings-docs-merge.py')
2023-05-19 15:53:20 +02:00
Thomas Haller b7d0218ee1
docs: rework selecting properties with "generate-docs-nm-settings-docs-merge.py"
"generate-docs-nm-settings-docs-merge.py" merges properties from
multiple XMLs. It supported an argument "--only-from-first", to
only select properties that were in the first of the provided XMLs.

The idea is that the first XML would be "src/nmcli/gen-metadata-nm-settings-nmcli.xml"
which is generated from nmcli meta-data and exactly describes the
supported properties. For example, "connection.read-only", "user.data"
or "wireless.tx-power" exist as properties somewhere, but not supported
by nmcli.

Change that, to not tie the selected property to the first XML.
"gen-metadata-nm-settings-nmcli.xml" is the XML that contains which
properties to select from, but "src/libnm-client-impl/nm-property-infos-nmcli.xml"
contains hand crafted descriptions. The latter descriptions are
preferred. As the order of the XML is already relevant for which
description is preferred, the selection is orthogonal to that.

With this, prefer descriptions from "src/libnm-client-impl/nm-property-infos-nmcli.xml"
but still select properties from "src/nmcli/gen-metadata-nm-settings-nmcli.xml".

Note that the argument is only used to generate "man/nm-settings-docs-nmcli.xml",
and with the current input, there is no actual change in behavior.
2023-05-19 12:52:01 +02:00
Thomas Haller 42aa225185
docs: better handle description tags in generate-docs-nm-settings-docs-merge.py
When we generate the manual page for nm-settings-nmcli, we run:

   "/usr/bin/python" \
        ./tools/generate-docs-nm-settings-docs-merge.py \
        --only-from-first \
        man/nm-settings-docs-nmcli.xml \
        src/nmcli/gen-metadata-nm-settings-nmcli.xml \
        src/libnm-client-impl/nm-property-infos-nmcli.xml \
        src/libnm-client-impl/nm-settings-docs-gir.xml

If "gen-metadata-nm-settings-nmcli.xml" contains either a <description>
or a <description-docbook>, then we must not continue searching the
other XML documents. The user provided an explicit override, and
fallback (search further) is wrong. Previously, we might take
<description> from the first file, and <description-docbook> from the
second file. As "man/nm-settings-nmcli.xsl" prefers
<description-docbook>, it takes the wrong text. Instead, as we search
the files during merge, we must prefer the first one.

Note that the change doesn't really matter anymore, because each XML
now must also contain both <description> and <description-docbook>.
There is an assertion for that.

Also, stop generating <deprecated-docbook>. First, it lacked the
important "since=" attribute and was necessary. Also, it's redundant and
does not contain anything interesting. So far, we don't need special
formatting for the deprecated message, and we likely never will.

Also, stop accepting or generating the "description=" attribute. This
should always be an XML element now.
2023-05-19 12:52:00 +02:00
Thomas Haller 89abede3df
docs: rework generating property infos to use <description> element
The "generate-docs-nm-property-infos.py" script parses the tags like
"---nmcli---" and generates an XML.

Rework it:

- don't put long text descriptions in a "description=" XML attribute.
  Instead, use an XML element. That is in line with what
  "generate-docs-nm-settings-docs-gir.py" does, which generates
  a similar file.

- if there is no <description-docbook> element, generate one based
  on <description>. That is important, because we want to create
  paragraphs.
  It's also important because "generate-docs-nm-settings-docs-gir.py"
  tends to generate <description-docbook> from the libnm/gir data.
  However, if you specify a "---nmcli---" override, then that should
  automatically apply to <description> and <description-docbook>.
2023-05-19 12:52:00 +02:00
Thomas Haller 676a99c96a
docs: drop redundant list([...]) in "generate-docs-nm-settings-docs-merge.py" 2023-05-19 12:51:59 +02:00
Thomas Haller 8c17077289
docs: simplify generating paragraphs in "generate-docs-nm-settings-docs-gir.py" 2023-05-19 12:51:59 +02:00
Thomas Haller e37a15acad
all: avoid "==" bashism in scripts 2023-05-18 09:16:41 +02:00
Thomas Haller 33f7ee0bb7
nm-in-container: run with "--no-hosts" to have a plain /etc/hosts in the container
The bind mount interferes with running certain CI tests that want to
change /etc/hosts.
2023-05-15 11:02:10 +02:00
Lubomir Rintel c72e085f5c
test/cloud-meta-mock: mock GCP metadata API
Not used for testing, but still might be useful for development.
2023-05-12 12:42:55 +02:00
Lubomir Rintel 5b5ef08aee
test/cloud-meta-mock: mock azure metadata API
Not used for testing, but still might be useful for development.
2023-05-12 12:42:55 +02:00
Lubomir Rintel 620a737cb7
test/cloud-meta-mock: mock aliyun metadata API
Not used for testing, but still might be useful for development.
2023-05-12 12:42:55 +02:00
Lubomir Rintel 41f0f6fec8
test/cloud-meta-mock: allow putting the resources
This reworks the cloud metadata mock server in a significant way.

Most importantly this makes it possible for the client to add and
modify the resources for later retrieval using the PUT method.
This allows the test to create the fixture for itself.

The default set of resources is still provided, so that the too remains
useful as a development aid. If that is not desirable, the --empty
parameter might be passed to cause the server to start with no
resources.
2023-05-12 12:42:55 +02:00
Lubomir Rintel 2e8ff9f8a0
Revert "client/tests: don't do dup2() dance to pass file descriptor to "tools/test-cloud-meta-mock.py""
This changed the fd passing protocol making it not compatible with
systemd-socket-activate(1).

This reverts commit 342ee618c7.
2023-05-12 12:42:54 +02:00
Thomas Haller 840abc6c45
nm-in-container: set NMCI_DEBUG=1 in bashrc 2023-04-26 11:05:18 +02:00