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

gluon-status-page, gluon-mesh-batman-adv: make statuspage mesh-protoc… #1366

Closed
wants to merge 3 commits into from
Closed

gluon-status-page, gluon-mesh-batman-adv: make statuspage mesh-protoc… #1366

wants to merge 3 commits into from

Conversation

christf
Copy link
Member

@christf christf commented Apr 14, 2018

…ol-agnostic

this PR will make the staus page backend independent from batctl.

this replaces the backend-part from #1053

Copy link
Member

@neocturne neocturne left a comment

Choose a reason for hiding this comment

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

In addition to the noted changes, please also add an entry

packages 'status-page & (mesh-batman-adv-14 | mesh-batman-adv-15)' \
        'gluon-status-page-mesh-batman-adv'

to package/features, so that enabling the status-page and mesh-batman-adv-... features automatically selects the gluon-status-page-mesh-batman-adv package.

@@ -33,3 +33,4 @@ LDLIBS += $(LIBBATADV_LDLIBS)

respondd.so: respondd.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -D_GNU_SOURCE -o $@ $^ $(LDLIBS) -lgluonutil -liwinfo -luci

Copy link
Member

Choose a reason for hiding this comment

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

It seems this line was added accidentally?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah.. done.

define Package/gluon-status-page-mesh-batman-adv
TITLE:=Batman-data provider for gluon-status-page
SECTION:=gluon
CATEGORY:=Gluon
Copy link
Member

Choose a reason for hiding this comment

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

The above two lines can be dropped since 994c949

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -6,6 +6,6 @@ badrequest() {
exit 1
}

( batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest
( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I think the complexity of this command is high enough that we should encapsulate the whole thing up to the || in a small script provided by gluon-core. Something like gluon-is-meshif. I guess the grep could also be replaced by an extension of the jsonfilter expression.

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed - how about we create gluon-get-mesh-ifs that contains everything up to the Igrep. This would be usable in a more universal way than when incorporating the grep for a specific interface....

Copy link
Member

Choose a reason for hiding this comment

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

Fine with me.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


neighbours-batadv: neighbours-batadv.c
$(CC) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDFLAGS_JSONC) -o $@ $^ $(LDLIBS)

Copy link
Member

Choose a reason for hiding this comment

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

Ugh, I hate the amount of boilerplate code in this file... I'll clean this up very soon, in all Makefiles that use libbatadv.

@@ -27,6 +27,8 @@ static struct json_object *get_stations(const struct iwinfo_ops *iw, const char
json_object_object_add(station, "signal", json_object_new_int(entry->signal));
json_object_object_add(station, "noise", json_object_new_int(entry->noise));
json_object_object_add(station, "inactive", json_object_new_int(entry->inactive));
json_object_object_add(station, "rx_rate", json_object_new_int(entry->rx_rate.rate));
json_object_object_add(station, "tx_rate", json_object_new_int(entry->tx_rate.rate));
Copy link
Member

Choose a reason for hiding this comment

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

This change looks unrelated, and we should not add these values unless the frontend also uses them.

Copy link
Member Author

Choose a reason for hiding this comment

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

in general I agree but since we are splitting backend and frontend here, I left it in the commit. I will remove it now, but I really do like those stats.

SECTION:=gluon
CATEGORY:=Gluon
PROVIDES:=gluon-status-page-data-provider
DEPENDS:=+gluon-status-page +gluon-mesh-batman-adv +libnl-tiny +libbatadv +libjson-c
Copy link
Member

Choose a reason for hiding this comment

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

gluon-mesh-batman-adv is a virtual package. Remove the + sign prefixing the dependency - never use selecting dependencies with virtual packages!

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

TITLE:=Batman-data provider for gluon-status-page
SECTION:=gluon
CATEGORY:=Gluon
PROVIDES:=gluon-status-page-data-provider
Copy link
Member

Choose a reason for hiding this comment

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

I think this PROVIDES is somewhat useless; as long as gluon-status-page-mesh-batman-adv depends on gluon-status-page, the result will be a circular dependency, which should always be avoided.

As the status page does not have a public API anymore, the status-page frontend for a specific mesh protocol will always be provided by the same package the backend comes in. As such, there is no common functionality in different backend packages that would justify a PROVIDES.

Copy link
Member

@neocturne neocturne left a comment

Choose a reason for hiding this comment

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

Thinking about this again, I'm seeing the problem that now the frontent depends on parts of the backend that are moved to a separate package; I would like to avoid such dependencies.

In consequence, we actually need to move the frontend to a separate package first, before the backend may follow.

@@ -0,0 +1,2 @@
#!/bin/sh
ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe name it "gluon-mesh-interfaces"? In any case, it should start with "gluon-".

Copy link
Member Author

Choose a reason for hiding this comment

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

sure. I like verbs, so I would go with gluon-get-mesh-interfaces ok?

Copy link
Member

Choose a reason for hiding this comment

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

Ok

@@ -10,7 +10,7 @@ start_service () {
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn ${respawn_threshold:-3660} ${respawn_timeout:-5} ${respawn_retry:-0}
interfaces=$(for dev in $( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device");do echo " -m $dev"; done;
interfaces=$(for dev in $(/usr/bin/get-mesh-ifs);do echo " -m $dev"; done;
Copy link
Member

Choose a reason for hiding this comment

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

Remove the full path here, just use the name of the script.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed the path here but kept it in the scripts that are called by the statuspage.

Copy link
Member

Choose a reason for hiding this comment

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

Why, do those script not have a proper PATH set?

@neocturne
Copy link
Member

I've prepared the frontend part in 35ade80.

@christf
Copy link
Member Author

christf commented Apr 15, 2018

rename and rebase is done.

@@ -6,6 +6,6 @@ badrequest() {
exit 1
}

( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest
( /usr/bin/gluon-get-mesh-interfaces | grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest
Copy link
Member

Choose a reason for hiding this comment

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

The other absolute paths in these files don't make much sense either, let's not introduce another one.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry about changing my mind again, but I think I would prefer the verb "list" to "get" in the script name.

Copy link
Member Author

Choose a reason for hiding this comment

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

np. Adjusting now....

Copy link
Member Author

Choose a reason for hiding this comment

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

done. - for the paths I had to touch the files again anyways. I like list better than get too.

@neocturne
Copy link
Member

The package/features update is still missing.

@neocturne
Copy link
Member

And /lib/gluon/status-page/mesh.lua should be moved into the new package as well.

…list-mesh-ifs that lists all currently active mesh interfaces
@neocturne
Copy link
Member

Thanks, merged.

@neocturne neocturne closed this Apr 15, 2018
@rotanid rotanid added 0. type: enhancement The changeset is an enhancement 3. topic: package Topic: Gluon Packages labels Apr 16, 2018
@rotanid rotanid added this to the 2018.1 milestone Apr 16, 2018
@oszilloskop oszilloskop deleted the christf_statuspage-mesh-agnostic branch October 22, 2019 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. type: enhancement The changeset is an enhancement 3. topic: package Topic: Gluon Packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants