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=2151040https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1653
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>
"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).
"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.
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.
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>.
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.
"preexec_fn" is not great, because it is not generally safe in multi
threaded code (and we don't know whether the test didn't start other
threads already, like a GDBus worker thread). Well, it probably is safe,
if you only call async signal safe code, but it's not clear what os.dup2()
does under the hood.
Just avoid that. We can pass on the FD directly.
The activation_state_change_delay_ms was not too useful, since it could
be changed only after the AC started activating. Not a big deal, since
it was actually unused.
Apart from that, the SetActiveConnectionStateChangedDelay() didn't make
a whole lot of sense either: it accepted a Device path, but actually
was looking up an AC.
Let's move the property to the Device, so that 1.) it can be adjusted
before the AC is constructed (the AC will inherit it from the Device)
and 2.) SetActiveConnectionStateChangedDelay() does no longer hurt my
feelings.
I don't know what's going on:
======================================================================
ERROR: test_ec2 (__main__.TestNmCloudSetup.test_ec2)
----------------------------------------------------------------------
Traceback (most recent call last):
File "NetworkManager/src/tests/client/test-client.py", line 2169, in f
func(self)
File "NetworkManager/src/tests/client/test-client.py", line 2194, in test_ec2
conn = self.srv.op_AddAndActivateConnection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "NetworkManager/src/tests/client/test-client.py", line 748, in __call__
return method(*args)
^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/proxies.py", line 72, in __call__
return self._proxy_method(*args, **keywords)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/proxies.py", line 141, in __call__
return self._connection.call_blocking(self._named_service,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/connection.py", line 634, in call_blocking
reply_message = self.send_message_with_reply_and_block(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dbus.exceptions.DBusException: org.freedesktop.DBus.Python.Exception: Traceback (most recent call last):
File "/usr/lib64/python3.11/site-packages/dbus/service.py", line 712, in _message_cb
retval = candidate_method(self, *args, **keywords)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "NetworkManager/tools/test-networkmanager-service.py", line 1693, in AddAndActivateConnection
conpath, acpath, result = self.AddAndActivateConnection2(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "NetworkManager/tools/test-networkmanager-service.py", line 1707, in AddAndActivateConnection2
conpath = gl.settings.AddConnection(con_hash)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "NetworkManager/tools/test-networkmanager-service.py", line 2198, in AddConnection
return self.add_connection(con_hash)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "NetworkManager/tools/test-networkmanager-service.py", line 2208, in add_connection
con_inst = Connection(self.c_counter, con_hash, do_verify_strict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "NetworkManager/tools/test-networkmanager-service.py", line 2045, in __init__
NmUtil.con_hash_verify(con_hash, do_verify_strict=do_verify_strict)
File "NetworkManager/tools/test-networkmanager-service.py", line 594, in con_hash_verify
BusErr.raise_nmerror(e)
File "NetworkManager/tools/test-networkmanager-service.py", line 497, in raise_nmerror
raise e
File "NetworkManager/tools/test-networkmanager-service.py", line 590, in con_hash_verify
con_nm = NmUtil.con_hash_to_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "NetworkManager/tools/test-networkmanager-service.py", line 537, in con_hash_to_connection
assert GLib.Variant.equal(x_con, Util.variant_from_dbus(con_hash))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "NetworkManager/tools/test-networkmanager-service.py", line 378, in variant_from_dbus
raise Exception("Unsupported type for value '%s'" % (repr(val)))
Exception:
Unsupported type for value 'dbus.Dictionary({
dbus.String('connection'): dbus.Dictionary({
dbus.String('type'): dbus.String('802-3-ethernet'),
dbus.String('id'): dbus.String('con-eth0'),
'uuid': '5fcfd6d7-1e63-3332-8826-a7eda103792d'
}, signature=dbus.Signature('ss')),
dbus.String('ipv4'): dbus.Dictionary({
dbus.String('method'): dbus.String('auto')
}, signature=dbus.Signature('ss'))
}, signature=dbus.Signature('sa{ss}'))'
The `\0` being used to refer to the whole match is a GNU
extension. On other implementations of sed, this will simply
replace the each matched line with ` 0;`, resulting in symbols
being missing in the NetworkManager executable, which breaks the
wifi plugin and others.
Use `&` instead, which behaves as expected in all implementations.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1562
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.
"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.
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".
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.
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.
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.
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>