Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rest.network.configuration): Fix net interfaces property management again #5535

Merged
merged 6 commits into from
Nov 11, 2024

Conversation

pierantoniomerlino
Copy link
Contributor

Since the #5531 has been temporary dropped, we decided to adopt a easier approach to fix the issue about network rest configuration.

The fix is limited to the org.eclipse.kura.internal.rest.network.configuration.NetworkConfigurationRestService class.
Now, when an update request is received, the code parses the property names and extracts the network interface names.
They are compared with the ones in the net.interfaces property from the current configuration and, it they are not listed there, they are added.

In this way the framework is aware if the new network interface and it can handle it correctly.

Any side note on the changes made: The net.interface.<interface-name>.type property is now mandatory, otherwise the value on the snapshot will be UNKNOWN and this will cause troubles to the webUI.

@mattdibi
Copy link
Contributor

mattdibi commented Nov 11, 2024

Test performed on DG1014 in combination with #5533 (actually https://github.com/eurotech/kura_eth/pull/2349 in this case) on a freshly installed system.

At startup we have the following:

Nov 11 09:32:24 dynagate-10-14 ESF[866]: Update NetworkConfigurationService...
Nov 11 09:32:24 dynagate-10-14 ESF[866]: Applying configuration using NetworkManager Dbus connector
Nov 11 09:32:24 dynagate-10-14 ESF[866]: Device "lo" of type "NM_DEVICE_TYPE_LOOPBACK" with status "UNMANAGED"/"UNMANAGED" currently not supported
Nov 11 09:32:24 dynagate-10-14 ESF[866]: Settings iface "eth0":NM_DEVICE_TYPE_ETHERNET
Nov 11 09:32:25 dynagate-10-14 ESF[866]: Settings iface "eth1":NM_DEVICE_TYPE_ETHERNET
Nov 11 09:32:30 dynagate-10-14 ESF[866]: Device "p2p0" of type "NM_DEVICE_TYPE_WIFI" not configured. Disabling...
Nov 11 09:32:30 dynagate-10-14 ESF[866]: Device "wlan0" of type "NM_DEVICE_TYPE_WIFI" not configured. Disabling...
Nov 11 09:32:30 dynagate-10-14 ESF[866]: Device "3-1.3" of type "NM_DEVICE_TYPE_MODEM" not configured. Disabling...

Which is expected since 3-1.3 doesn't have a configuration in the snapshot0.

Then, when running the following RestAPI request:

curl -k -u admin:[REDACTED] -X PUT \
    --location https://172.16.0.1/services/networkConfiguration/v1/configurableComponents/configurations/_update \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
      \"configs\": [
      {
            \"pid\": \"org.eclipse.kura.net.admin.NetworkConfigurationService\",
            \"properties\": {
                \"net.interface.3-1.3.config.ip6.status\": {
                    \"value\": \"netIPv6StatusDisabled\",
                    \"type\": \"STRING\"
                },
                \"net.interface.3-1.3.config.ip4.status\": {
                    \"value\": \"netIPv4StatusEnabledWAN\",
                    \"type\": \"STRING\"
                },
                \"net.interface.3-1.3.config.dhcpClient4.enabled\": {
                    \"value\": true,
                    \"type\": \"BOOLEAN\"
                },
                \"net.interface.3-1.3.config.resetTimeout\": {
                    \"value\": 5,
                    \"type\": \"INTEGER\"
                }
            }
        }
      ]
    }"

the configuration is correctly applied:

Applying configuration using NetworkManager Dbus connector
Device "lo" of type "NM_DEVICE_TYPE_LOOPBACK" with status "UNMANAGED"/"UNMANAGED" currently not supported
Settings iface "eth0":NM_DEVICE_TYPE_ETHERNET
Ignoring parameter accept-all-mac-addresses [-1]: NetworkManager 1.32 or above is required
Settings iface "eth1":NM_DEVICE_TYPE_ETHERNET
Ignoring parameter accept-all-mac-addresses [-1]: NetworkManager 1.32 or above is required
Device "p2p0" of type "NM_DEVICE_TYPE_WIFI" not configured. Disabling...
Device "wlan0" of type "NM_DEVICE_TYPE_WIFI" not configured. Disabling...
Settings iface "3-1.3":NM_DEVICE_TYPE_MODEM

image


Performing the same test on our current Kura version will result in:

Applying configuration using NetworkManager Dbus connector
Device "lo" of type "NM_DEVICE_TYPE_LOOPBACK" with status "UNMANAGED"/"UNMANAGED" currently not supported
Settings iface "eth0":NM_DEVICE_TYPE_ETHERNET
Ignoring parameter accept-all-mac-addresses [-1]: NetworkManager 1.32 or above is required
Settings iface "eth1":NM_DEVICE_TYPE_ETHERNET
Ignoring parameter accept-all-mac-addresses [-1]: NetworkManager 1.32 or above is required
Device "p2p0" of type "NM_DEVICE_TYPE_WIFI" not configured. Disabling...
Settings iface "wlan0":NM_DEVICE_TYPE_WIFI
Device "3-1.3" of type "NM_DEVICE_TYPE_MODEM" not configured. Disabling...

image

@pierantoniomerlino pierantoniomerlino force-pushed the fix_net_interfaces_property_management_again branch from ed3972b to 72a61f5 Compare November 11, 2024 10:03
pierantoniomerlino and others added 6 commits November 11, 2024 12:04
Signed-off-by: pierantoniomerlino <[email protected]>
Signed-off-by: pierantoniomerlino <[email protected]>
…main/java/org/eclipse/kura/internal/rest/network/configuration/NetworkConfigurationRestService.java

Co-authored-by: Mattia Dal Ben <[email protected]>
…main/java/org/eclipse/kura/internal/rest/network/configuration/NetworkConfigurationRestService.java

Co-authored-by: Mattia Dal Ben <[email protected]>
@pierantoniomerlino pierantoniomerlino force-pushed the fix_net_interfaces_property_management_again branch from f517515 to 9fcb5df Compare November 11, 2024 11:05
@mattdibi mattdibi merged commit da1feb6 into develop Nov 11, 2024
4 checks passed
@mattdibi mattdibi deleted the fix_net_interfaces_property_management_again branch November 11, 2024 15:43
eclipse-kura-bot pushed a commit that referenced this pull request Nov 11, 2024
…nt again (#5535)

* Added net.interfaces property management in NetworkConfiguration Rest

Signed-off-by: pierantoniomerlino <[email protected]>

* Changed parsing logic

Signed-off-by: pierantoniomerlino <[email protected]>

* Improved string parsing

Signed-off-by: pierantoniomerlino <[email protected]>

* Added tests for net.interfaces property

Signed-off-by: pierantoniomerlino <[email protected]>

* Update kura/org.eclipse.kura.rest.network.configuration.provider/src/main/java/org/eclipse/kura/internal/rest/network/configuration/NetworkConfigurationRestService.java

Co-authored-by: Mattia Dal Ben <[email protected]>

* Update kura/org.eclipse.kura.rest.network.configuration.provider/src/main/java/org/eclipse/kura/internal/rest/network/configuration/NetworkConfigurationRestService.java

Co-authored-by: Mattia Dal Ben <[email protected]>

---------

Signed-off-by: pierantoniomerlino <[email protected]>
Co-authored-by: Mattia Dal Ben <[email protected]>
(cherry picked from commit da1feb6)
MMaiero pushed a commit that referenced this pull request Nov 12, 2024
…nt again [backport release-5.6.0] (#5538)

fix(rest.network.configuration): Fix net interfaces property management again (#5535)

* Added net.interfaces property management in NetworkConfiguration Rest

Signed-off-by: pierantoniomerlino <[email protected]>

* Changed parsing logic

Signed-off-by: pierantoniomerlino <[email protected]>

* Improved string parsing

Signed-off-by: pierantoniomerlino <[email protected]>

* Added tests for net.interfaces property

Signed-off-by: pierantoniomerlino <[email protected]>

* Update kura/org.eclipse.kura.rest.network.configuration.provider/src/main/java/org/eclipse/kura/internal/rest/network/configuration/NetworkConfigurationRestService.java

Co-authored-by: Mattia Dal Ben <[email protected]>

* Update kura/org.eclipse.kura.rest.network.configuration.provider/src/main/java/org/eclipse/kura/internal/rest/network/configuration/NetworkConfigurationRestService.java

Co-authored-by: Mattia Dal Ben <[email protected]>

---------

Signed-off-by: pierantoniomerlino <[email protected]>
Co-authored-by: Mattia Dal Ben <[email protected]>
(cherry picked from commit da1feb6)

Co-authored-by: Pierantonio Merlino <[email protected]>
MMaiero pushed a commit that referenced this pull request Dec 20, 2024
…nt again (#5535)

* Added net.interfaces property management in NetworkConfiguration Rest

Signed-off-by: pierantoniomerlino <[email protected]>

* Changed parsing logic

Signed-off-by: pierantoniomerlino <[email protected]>

* Improved string parsing

Signed-off-by: pierantoniomerlino <[email protected]>

* Added tests for net.interfaces property

Signed-off-by: pierantoniomerlino <[email protected]>

* Update kura/org.eclipse.kura.rest.network.configuration.provider/src/main/java/org/eclipse/kura/internal/rest/network/configuration/NetworkConfigurationRestService.java

Co-authored-by: Mattia Dal Ben <[email protected]>

* Update kura/org.eclipse.kura.rest.network.configuration.provider/src/main/java/org/eclipse/kura/internal/rest/network/configuration/NetworkConfigurationRestService.java

Co-authored-by: Mattia Dal Ben <[email protected]>

---------

Signed-off-by: pierantoniomerlino <[email protected]>
Co-authored-by: Mattia Dal Ben <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants