Skip to content

Commit

Permalink
luci-app-lldpd: Fix mysterious Command failed: Unknown error
Browse files Browse the repository at this point in the history
Executing the following command:

ubus call luci.lldpd getStatus

always returned 'Command failed: Unknown error', but the underlying

lldpcli -f json0 show *

worked fine. Fixed with a chained ?.read?

Tested on 23.05.3

Signed-off-by: Paul Donald <[email protected]>
  • Loading branch information
systemcrash committed Oct 10, 2024
1 parent 02f2d47 commit c40253a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions applications/luci-app-lldpd/root/usr/share/rpcd/ucode/luci.lldpd
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import { popen } from 'fs';

function lldpcli_json(section) {
return json(popen(`lldpcli -f json0 show ${section}`, 'r'));
return json(popen(`lldpcli -f json0 show ${section}`, 'r')?.read?.('all'));
}

return {
'luci.lldpd': {
getStatus: {
call: function() {
return {
statistics: lldpcli_json("statistics"),
neighbors: lldpcli_json("neighbors details"),
interfaces: lldpcli_json("interfaces"),
chassis: lldpcli_json("chassis")
};
}
const methods = {
getStatus: {
call: function() {
return {
statistics: lldpcli_json("statistics"),
neighbors: lldpcli_json("neighbors details"),
interfaces: lldpcli_json("interfaces"),
chassis: lldpcli_json("chassis")
};
}
}
};

return { 'luci.lldpd': methods };

0 comments on commit c40253a

Please sign in to comment.