Commit graph

300 commits

Author SHA1 Message Date
Thomas Haller fdec6a97e8
vapi: add test for consistency of "vapi/NM-1.0.metadata" 2023-02-28 13:05:47 +01:00
Thomas Haller a259303e1d
ovs: add support for "other_config" settings
See `man ovs-vswitchd.conf.db` for documentation of "other_config" keys.

https://bugzilla.redhat.com/show_bug.cgi?id=2151455
2023-01-11 21:49:36 +01:00
Lubomir Rintel 03813a530a tools/check-docs: more checks for missing includes
We get this wrong *very* often.
2022-11-13 23:36:37 +01:00
Thomas Haller 139f4b4b2e
build: pass both filenames to "tools/check-compare-generated.sh" script
It just feels nicer to be explicit about the filenames and
not rely on a specific naming.

Also, in meson we can directly pass the target as argument, which
expands to the filename but also adds a dependency.
2022-10-31 09:11:30 +01:00
Thomas Haller ea5cd47bc4
tools: drop unused variables from "tools/generate-docs-nm-property-infos.py"
Found by lgtm.com.
2022-10-25 12:12:44 +02:00
Thomas Haller 70fee1cf46
tools: avoid Python 3 f-string in "generate-docs-nm-property-infos.py"
We also need to build with python2. No f-strings.

Fixes: 8fc7b6df12 ('tools: rework generating documentation from libnm meta data')
2022-10-07 21:08:39 +02:00
Thomas Haller 77e0041b27
tools: sort the settings in "generate-docs-nm-property-infos.py" by name
"nm-setting-ip-config.c" is a base class for IPv4 and IPv6 settings. So
far, any tags there were ignored, which was not obvious. It can be
useful to document common properties there. Well, maybe every property
better has a IPv4/IPv6 specific text, but that should not be a technical
limitation of the tool. So also honor the base file for "ipv4" and
"ipv6" settings.

When doing that, the settings are no longer processed in the order as
they are provided on the command line. Because, one file would be parsed
twice, it wouldn't make much sense. Instead, sort the my setting name.
The advantage is that the generated XML is independent from the order
that make/meson passes to the tool.
2022-10-06 13:40:30 +02:00
Thomas Haller c1bebdfaa6
tools: don't set empty attributes in "generate-docs-nm-property-infos.py"
If the information is missing, the entire attribute should not be there.
Don't set it to the empty word.

Also, don't alias the "variable" attribute to the "name". It's not clear
what the "variable" fields is supposed to mean, but if it's not
explicitly set, don't make up the information. If a user of that
information cares, the can always fallback to the "name".
2022-10-06 13:40:30 +02:00
Thomas Haller e56f7f5c2d
tools: don't write empty XML nodes in "generate-docs-nm-property-infos.py"
This generates '<setting name="XXX">\n</setting>' nodes in case there is
no additional data. Don't do that. Just '<setting name="XXX"/>'
2022-10-06 13:40:29 +02:00
Thomas Haller 8899ecc0d8
tools: preserve newlines and indentation in "generate-docs-nm-property-infos.py"
Our docs can be long. It's important to be able to express paragraphs.
Honor a blank line to include a newline. For XML often whitespace is
ignored, but our tools can choose to honor the newline.

Also, don't strip the whitespace from the beginning and the end.
We keep whitespace for a certain indentation level, but additional
whitespace gets preserved. This is less important, because regular
spaces is indeed irrelevant. But when we write the annotations, we
should be in full control over spaces.
2022-10-06 13:40:29 +02:00
Thomas Haller 8fc7b6df12
tools: rework generating documentation from libnm meta data
With the given input, this produces *exactly* the same XML as before.

- the parsing is now stricter (and thus the code more verbose). No
  funny stuff, get the annotations correct.
- on parsing errors, we log now the affecting lines
- "nm-setting-ip-config.c" is a base class. Previously it was ignored
  and for the moment we still do that. Next, we will allow to also
  describe properties there.
- prepare the code to better preserve whitespace, indentation and line
  wrappings. In particular, to honor a blank line to indicate a line break
  and support paragraphs. This is not yet done to compare the output
  to before, but will be turned on with a small patch next.
- the code will make it simple to promote the XML attributes to
  nodes. Attributes aren't great, let's write XML nodes later.
  We will only need to adjust the "keywords" dictionary for that,
  but this change will require changes to the entire chain of tools.
2022-10-06 13:40:29 +02:00
Thomas Haller af2bc358df
style: fix python black formatting of "generate-docs-nm-settings-docs-merge.py" 2022-09-08 09:00:27 +02:00
Lubomir Rintel 8af1404e54 generate-docs-nm-settings-docs-gir: remove space from the beginning of a para
From nm-settings-dbus(5):

Before (ugly, offensive, possibly in violation of geneva protocol):

  ...
  | set, the authentication retries for 3
  | times before failing the connection.
  |
  |  Currently, this only applies to 802-1x
  | authentication.

After (beautiful, smells good, in harmony with nature):

  ...
  | set, the authentication retries for 3
  | times before failing the connection.
  |
  | Currently, this only applies to 802-1x
  | authentication.
2022-09-07 12:10:21 +02:00
Lubomir Rintel 4d42b81d2a generate-docs-nm-settings-docs-gir: move deprecation info to a separate tag
Previously, the deprecation data was included in <description*>, in form
of an integer. E.g.:

  /**
   * NMSettingLala:hello:
   *
   * Does this and that.
   *
   * Deprecated: 1.12: Be sad instead.
   **/

Results in:

  <property name="hello">
    <description>Does this and that. Deprecated: 1</description>
  </property>

Let's make it do this instead:

  <property name="hello">
    <description>Does this and that.</description>
    <deprecated since="1.12">Be sad instead.</description>
  </property>
2022-09-07 11:01:40 +02:00
Lubomir Rintel d71f0aac39 generate-docs-nm-settings-docs-merge: merge <deprecated*> elements
They will be used to include property deprecation data.
2022-09-07 10:55:31 +02:00
Lubomir Rintel 6ce2aae011 generate-docs-nm-settings-docs-merge: streamline a bit
Replace a pair of overly sophisticated expressions with something that's
easier to follow, avoiding code duplication at the same time.
2022-09-07 10:55:31 +02:00
Thomas Haller 8efc0319ce
build/meson: force overwriting files in "meson-post-install.sh"
Repeated `ninja -C build install` should succeed. But they did not:

  Running custom install script '/data/src/NetworkManager/tools/meson-post-install.sh /usr/share /usr/bin /etc/NetworkManager /usr/lib/NetworkManager /var/lib/NetworkManager /usr/share/man /etc 1 1 1 1'
  --- stdout ---

  --- stderr ---
  ln: failed to create symbolic link '/usr/lib/NetworkManager/dispatcher.d/90-nm-cloud-setup.sh': File exists
2022-08-08 11:54:26 +02:00
Vojtech Bubela 5e4632f021
doc: preserve paraghraphs in nmcli man pages
Improve documentation by preserving paragraphs in the
nm-settings-nmcli man pages.

To do that structure of src/libnm-client-impl/nm-settings-docs-gir.xml
was changed to have "description" as subnode to property node instead
of attribute of property node. Another subnode "description-docbook"
was added - this node is then used when generating man pages.

tools/generate-docs-nm-settings-docs-gir.py and man/nm-settings-dbus.xsl
were also changed to accomodate for changes mentioned above.

Replace xsltproc tool with python script when generating
./src/libnmc-setting/settings-docs.h.

Deleted settings-docs.xsl since it was replaced by python script.

Change src/libnmc-setting/settings-docs.h.in accodring to newly
generated src/libnmc-setting/settings-docs.h

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/661

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1260
2022-07-15 17:25:15 +02:00
Igor Ponomarev daecc226ee
tools: Fix generate-docs-nm-settings-docs-gir.py on Python 2
On python2 the following error is raised:

`LookupError: unknown encoding: unicode`

Seems like `unicode` is a correct encoding in Python 3 but not 2.

Fix:

1. Change encoding to `utf-8`
2. Pass output path string instead of opening file and passing
   opened file object. Python2 and 3 might need different file
   modes, passing just path lets ElementTree select appropriate
   file mode.

Fixes: f00e90923c ('tools: Use ElementTree to write XML in generate-docs-nm-settings-docs-gir.py')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1249
2022-06-03 08:26:12 +02:00
Igor Ponomarev f00e90923c
tools: Use ElementTree to write XML in generate-docs-nm-settings-docs-gir.py
Instead of manually writting XML line by line.
Quoting is automatic.
Makes it much easier to modify. (just add new elements)

Generated XML not indented at the moment.
2022-05-31 13:28:59 +02:00
Igor Ponomarev a2298d31c0
tools: Modernize generate-docs-nm-settings-docs-gir.py to 2022 standards
* Create main() function and put its execution under
  __name__ == '__main__' guard.
* Only one module import per line
* Use required=True to check if necessary arguments have
  been passed.
* Remove usage() as ArgumentParser handles that already
2022-05-31 13:28:51 +02:00
Thomas Haller 7062de9219
build/meson: use "rename" directive for installing nmcli bash completion
Otherwise, `ninja -C build uninstall` tries to delete "nmcli-completion",
when the file got renamed to "nmcli".

We depend on meson 0.47.2 already.
2022-05-13 16:15:18 +02:00
Thomas Haller aaf2155023
libnm/docs: fix documentation for "proxy.pac-script" 2022-03-21 15:21:37 +01:00
Thomas Haller 180b9e0e41 tests: propagate 77 exit code from "tools/run-nm-test.sh"
This is important. We must not swallow 77, which has the meaning
that the test was skipped.

Fixes: f65747f6e9 ('tests: let "run-nm-test.sh" fail with exit code 1 on failure')
(cherry picked from commit aff40f736c)
2022-02-19 13:43:14 +01:00
Thomas Haller 069089cdf2
tools: fix constructing XML by dropping broken pretty_xml()
I don't understand the code, but it mangles the XML.

There is no difference in the markup we have so far. But if you
have nested XML (like for description-docbook tag) there are cases
where this is wrong.

There is also no need to prettify anything. If you want pretty-formatted
XML, do it yourself, for example with

  $ tidy --indent yes --indent-spaces 4 --indent-attributes yes --wrap-attributes yes --input-xml yes --output-xml yes src/libnm-client-impl/nm-property-infos-nmcli.xml

I think this was initially done, because we had the tool in perl, and
when migrating, we wanted to generate the exactly same output. And it
was the same output, and it was fine for the input we have. But with
different input, it's wrong. Drop it now.

(cherry picked from commit 35599b4349)
2022-02-10 08:41:19 +01:00
Thomas Haller f21cb3065e
tools: re-use regular expression in process_data()
Yes, they get cached by the library already. Still, no need for
doing this repeatedly.

(cherry picked from commit 41a177486b)
2022-02-10 08:41:19 +01:00
Thomas Haller 1701048e02
tests: let "run-nm-test.sh" fail with exit code 1 on failure
`git bisect run` is peculiar about the exit code:

  error: bisect run failed: exit code 134 from '...' is < 0 or >= 128

If we just "exec" the test, it usually will fail on an assert. That results
in SIGABRT or exit code 134. So out of the box that is annoying with
git-bisect.

Work around that and let the test wrapper always coerce any test failure
to exit code 1.

(cherry picked from commit f65747f6e9)
2022-02-10 08:41:15 +01:00
Thomas Haller 1f9de38a7b
tools/tests: set available-connections for vlan device in NM test stub 2022-01-21 12:08:00 +01:00
Thomas Haller eda2c5ac48
tools: support --no-make-first option in "run-nm-test.sh"
Why? Because I often use a command line like

  $ ./tools/run-nm-test.sh -m src/libnm-client-impl/tests/test-nm-client -p /libnm/device-connection-compatibility

or even alias it to a one character command `x`.
Usually I want to do the rebuild, and as `make` is so slow, it
adds noticeable time running the command. Thus, sometimes I want
to modify the command, for which I have to edit the command from the
history, or toggle two separate commands.

Add a `-M` flag that can reverse the effect of an earlier `-m`.

An "enable" flag in general should just also have a "disable" flag.
2022-01-21 12:08:00 +01:00
Thomas Haller 58287cbcc0 core: rework IP configuration in NetworkManager using layer 3 configuration
Completely rework IP configuration in the daemon. Use NML3Cfg as layer 3
manager for the IP configuration of an interface. Use NML3ConfigData as
pieces of configuration that the various components collect and
configure. NMDevice is managing most of the IP configuration at a higher
level, that is, it starts DHCP and other IP methods. Rework the state
handling there.

This is a huge rework of how NetworkManager daemon handles IP
configuration. Some fallout is to be expected.

It appears the patch deletes many lines of code. That is not accurate, because
you also have to count the files `src/core/nm-l3*`, which were unused previously.

Co-authored-by: Beniamino Galvani <bgalvani@redhat.com>
2021-11-18 16:21:29 +01:00
Thomas Haller fc220f94af
build/tests: ignore all valgrind warnings about unhandled syscalls
valgrind might log warnings about syscalls that it doesn't implement.
When we run valgrind tests, we check that the command exits with
success, but we also check that there is no unexpected content in the
valgrind log.

Those warnings are not relevant for us. We don't unit-tests valgrind, we
unit tests NetworkManager. Let's always remove such warnings with `sed`.

We already did that previously, but only for a explicit list of tests.
Now do it for all tests.

This is currently relevant on Fedora 35 and Ubuntu devel, where the
"close_range" syscall is used by libc, but not supported by valgrind.

While at it, rework the confusing logic of "HAS_ERRORS" variable.
2021-10-08 12:45:51 +02:00
Thomas Haller 0363d746ac
tools: use "is" to compare _DEFAULT_ARG in "test-networkmanager-service.py" 2021-07-29 12:37:20 +02:00
Thomas Haller dd595c6c1d
tools: fix bogus code in "tools/generate-docs-nm-property-infos.py"
Coverity warns about this:

  2. NetworkManager-1.32.2/tools/generate-docs-nm-property-infos.py:117: identical_branches:
  The same code is executed regardless of whether "temp.index(subelement) < len(temp) - 1" is
  true, because the then and else branches are identical. Should one of the branches be modified,
  or the entire 'if' statement replaced?

Fixes: c3504f7e62 ('Rewrite `./tools/generate-docs-nm-property-infos.py` with XML library')
2021-07-06 09:08:36 +02:00
Wen Liang 0b87d8d6c5 Support new attribute tag description-docbook
`description-docbook` is the alternative tag to `description`, the
difference is that `description-docbook` expects docbook XML but not
plaintext.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-06-23 08:59:45 -04:00
Frederic Martinsons 8dc64c7bdd
tools: correct NetworkManager top object set_state function
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-06-23 13:56:15 +02:00
Frederic Martinsons e27141fb90
tools: suppress duplicate state change in deactivation step of active connection
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-06-23 13:56:15 +02:00
Thomas Haller 85c6ab97ef
tools: add debug printf statements to "tools/generate-docs-nm-settings-docs-merge.py"
It's hard to understand what "tools/generate-docs-nm-settings-docs-merge.py"
does. Add dbg() statements that are all NOP by default. But the user can
easily patch the code to print what is happening. This is only for
debugging the script.
2021-06-09 12:46:32 +02:00
Thomas Haller 26f0fb0604
python: remove unused imports
They are flagged by lgtm.com. Avoid the warning by dropping unused
includes.
2021-05-27 08:52:30 +02:00
Thomas Haller c3d3429916
tools: drop spurious whitespace in "src/libnm-client-impl/nm-property-infos-*.xml"
<nm-setting-docs>
  -  <setting name="6lowpan">
  +<setting name="6lowpan">
   </setting>
2021-05-26 15:33:29 +02:00
Wen Liang c3504f7e62
Rewrite ./tools/generate-docs-nm-property-infos.py with XML library
Instead of writing XML text word by word, it is less error prone to
write with XML library.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-20 10:41:20 +02:00
Wen Liang dd38eb1f76
Adjust property tag format in nm-property-infos-*.xml
In order to make the generated XML file format consistent before and
after using XML library, adjust `property` tag format.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-20 10:41:19 +02:00
Thomas Haller c34e36bb8d
Revert "Rewrite ./tools/generate-docs-nm-property-infos.py with XML library"
This breaks build on RHEL7, probably due to an older python version.
Revert for now.

This reverts commit a83fb33840.
2021-05-18 16:00:25 +02:00
Wen Liang a83fb33840
Rewrite ./tools/generate-docs-nm-property-infos.py with XML library
Instead of writing XML text word by word, it is less error prone to
write with XML library.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang 403d776730
Remove unnecessary escaping for single quote
When writing XML text with XML library, single quote will not be
escaped. So remove the escaping for single quote in current tool.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang f6e52708a2
Add paired property tag to nm-property-infos-*.xml
In order to make the generated XML file format consistent before and
after using XML library, replace self-closing `property` tag with
paired `property` tag.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang 90422ddd1a
Remove line breaks in attribute value of nm-property-infos-*.xml
Since line breaks are not needed for XML's attribute tag, remove the
unnecessary line breaks.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Thomas Haller b6a195cf81
tools: remove deprecated PropertiesChanged signal in "test-networkmanager-service.py" 2021-05-14 10:57:35 +02:00
Wen Liang 86dcb31ab3
build: replace ./tools/generate-docs-nm-property-infos.pl with python script
In order to have more structured settings in man page and make it more
manageable to generate the docbook, it is recommended to use python
script to replace `./tools/generate-docs-nm-property-infos.pl` (this
tool is used to parse the comment section starting with `---nmcli---`,
`---dbus---`, `---keyfile---`, `---ifcfg-rh---`).

Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/824
2021-05-05 15:28:17 +02:00
orbea 68913466af
tools: use libtool --mode=execute
Better fix for https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732

The original issue was that when compiling NetworkManager with slibtool
the create-exports-NetworkManager.sh script gave the NetworkManager-all-sym
slibtool wrapper script to nm(1) instead of the actual binary. This is
because slibtool and GNU libtool do not place the compiled programs in
the same location. The original fix was to test both locations, but this
is bit of a hack especially since the build system should not be using the
.libs directory directly. However with $(LIBTOOL) --mode=execute this is
not a problem since both implementations can figure out where the correct
binary is.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/805
2021-04-04 09:27:35 +02:00
Thomas Haller d8dd6e94e6
tui: move from "clients/tui/" to "src/nmtui/" 2021-03-15 17:10:54 +01:00