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

Adds shared-state rpcd data,error output format and shared-state-async rpcd reimplementation #1103

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

javierbrk
Copy link
Collaborator

Ubus interface for shared state

current implementations of rpcd for shared-state are inconsistent this new implementation adds a consistent format across the three implementations (shared-state, shared-state-async, shared-state-multiwriter )
In every case calls to shared state get or sync will return a json object wit this format

{"data":{},"error":0}

Also this new implementation for shared-state-async uses a shell script to simplify the implementation

Ubus interface for shared state async

ubus -S call shared-state-async get '{"data_type": "bat-hosts"}'

{
  "data": {
    "02:29:0f:a5:1e:d1": "LiMe_a51ed1_eth1_2_29",
    "02:58:47:a5:1e:d1": "LiMe_a51ed1_wlan0_mesh_29",
    "02:95:39:a5:1e:d1": "LiMe_a51ed1_eth0_29",
    "02:ab:46:a5:1e:d1": "LiMe_a51ed1_wlan1_mesh_29",
    "02:bb:ed:a5:1e:d1": "LiMe_a51ed1_eth1_29",
    "02:cc:4e:a5:1e:d1": "LiMe_a51ed1_wlan2_mesh_29",
    "02:db:d6:a5:1e:d1": "LiMe_a51ed1_eth0_1_29",
    "06:ef:f4:3d:4d:75": "LiMe_a51ed1_bat0",
    "a8:40:41:1c:85:16": "LiMe_a51ed1_wlan1_ap",
    "a8:40:41:1c:85:c3": "LiMe_a51ed1_wlan2_ap",
    "a8:40:41:1f:73:a8": "LiMe_a51ed1_wlan0_ap",
    "a8:40:41:1f:73:aa": "LiMe_a51ed1_eth0_1_17",
    "a8:40:41:1f:73:ab": "LiMe_a51ed1_eth1_17",
    "aa:40:41:1c:85:16": "LiMe_a51ed1_wlan1_apname",
    "aa:40:41:1c:85:c3": "LiMe_a51ed1_wlan2_apname",
    "aa:40:41:1f:73:a8": "LiMe_a51ed1_wlan0_apname",
    "ae:40:41:1c:85:16": "LiMe_a51ed1_wlan1_mesh",
    "ae:40:41:1c:85:c3": "LiMe_a51ed1_wlan2_mesh",
    "ae:40:41:1f:73:a8": "LiMe_a51ed1_wlan0_mesh"
  },
  "error": 0
}

ubus -S call shared-state-async get '{"data_type": "bat-hosss"}'

{"data":{},"error":208}

ubus -S call shared-state-async sync '{"data_type": "bat-hosts"}'

{"data":{},"error":146}

ubus -S call shared-state-async sync '{"data_type": "bat-hosss"}'

{"data":{},"error":208}

ubus -S call shared-state-async sync '{"data_type": "bat-hostss", "peers_ip":"10.13.30.20"}'

{"data":{},"error":208}

ubus -S call shared-state-async sync '{"data_type": "bat-hosts", "peers_ip":"10.13.30.20"}'

{"data":{},"error":148}

ubus -S call shared-state-async sync '{"data_type": "bat-hosts", "peers_ip":"127.0.0.1"}'

{"data":{},"error":0}

Ubus interface for shared state and shared state Multiwriter

Get the list of available methods using:

ubus -v list shared-state

Get wifi links information:

ubus -S call shared-state getFromSharedState '{"data_type": "wifi_links_info" }'

Write information that is common to every all the network:

ubus -S call shared-state insertIntoSharedStateMultiWriter '{"data_type": "ref_state_wifi_links", "json": {"primero":{"bleachTTL":27}}}'

Get the information in the same node:

ubus -S call shared-state getFromSharedStateMultiWriter '{"data_type": "ref_state_wifi_links"}'

{"data":{"primero":{"bleachTTL":27}},"error":0}

Get the info in another node, before getting the information the others need to sync on the same topic.
This has to be done before reading and data types usually do it in a cron job.

shared-state-multiwriter sync ref_state_wifi_links

ubus -S call shared-state getFromSharedStateMultiWriter '{"data_type": "ref_state_wifi_links" }'

@javierbrk javierbrk requested a review from G10h4ck April 8, 2024 15:56
@javierbrk javierbrk added this to the mesh-wide milestone Apr 8, 2024
@ilario
Copy link
Member

ilario commented Apr 8, 2024

This looks good :D

Do you think we should include it in the next release candidate once it is merged?

Do you plan to move all this to OpenWrt repositories at some point?

@selankon
Copy link
Collaborator

selankon commented Apr 9, 2024

Do you think we should include it in the next release candidate once it is merged?

imo should be included! This makes the shared state calls more consistent...

But, it will break the compatibility with older versions. Are this packages already included on the actual version?

Do you plan to move all this to OpenWrt repositories at some point?

I think shared state not exists on the OWRT repos no?

@javierbrk javierbrk requested a review from selankon April 9, 2024 12:23
Copy link
Collaborator

@selankon selankon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@ilario
Copy link
Member

ilario commented Apr 10, 2024

Do you think we should include it in the next release candidate once it is merged?

imo should be included! This makes the shared state calls more consistent...

But, it will break the compatibility with older versions. Are this packages already included on the actual version?

Compatibility?
Currently we have the latest stable release 2020.4 based on OpenWrt 19.07 and including LibreMesh code from more than one year ago. Most importantly, it has the legacy non-async shared-state. So the compatibility with this one I feel is not going to be preserved anyway, no?

Do you plan to move all this to OpenWrt repositories at some point?

I think shared state not exists on the OWRT repos no?

Shared state does not exist on OpenWrt repository, correct. But it should be there. It should not be here. In case there is any shared-state developer willing to manage the migration, maybe some people from OpenWrt could help...? @aparcar

@G10h4ck
Copy link
Member

G10h4ck commented Apr 10, 2024

@ilario shared-state developers and it is pretty tied to libre-mesh stuff altought it might be used indipendently, at this stage of development, moving it to openwrt repository could be premature IMHO, but once shared-state-async is more stable and completely substitute shared-state Lua, it might be good to move it in openwrt-packages

Copy link
Member

@G10h4ck G10h4ck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few improvements and it is ready to merge

end
end
#!/bin/sh
# --[[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line should now be blank

# Copyright (C) 2024 Asociacion Civil Altermundi <[email protected]>

# SPDX-License-Identifier: AGPL-3.0-only
# ]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this like show now go away

call)
# source jshn shell library
. /usr/share/libubox/jshn.sh
read nmsg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this variable name means? Either I miss something or a more readable name should be used (always remember what will I understand when I'll reopen this file a couple years after?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it to match the name of the same variable in all the other rpcd scripts "msg"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using shell instead of Lua resulted in a much nicer code as anticipated :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much better, I was worried about json parsing but some else was also worried before me.

packages/shared-state/files/usr/libexec/rpcd/shared-state Outdated Show resolved Hide resolved
@javierbrk
Copy link
Collaborator Author

Shared State rpcd/ubus interface is used only by lime app so they go together.
The last release of limeapp is not using this interface. @selankon can confirm. So this is not required in the candidate release.

@G10h4ck G10h4ck merged commit 75f5d50 into libremesh:master Apr 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants