From 29af4e91f6017b278da9370c2a3dca3ab36bafbc Mon Sep 17 00:00:00 2001 From: Roger Pueyo Centelles Date: Tue, 7 Feb 2017 18:11:20 +0100 Subject: [PATCH 1/2] add qmp plugin --- libremap-agent/Makefile | 3 +- .../files/etc/uci-defaults/80_libremap-agent | 3 ++ .../luasrc/libremap/plugins/qmp.lua | 29 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 libremap-agent/luasrc/libremap/plugins/qmp.lua diff --git a/libremap-agent/Makefile b/libremap-agent/Makefile index a2009be..aadf27b 100644 --- a/libremap-agent/Makefile +++ b/libremap-agent/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libremap-agent -PKG_RELEASE:=0.1.8 +PKG_RELEASE:=0.1.8.1 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) include $(INCLUDE_DIR)/package.mk @@ -75,6 +75,7 @@ $(eval $(call BuildPlugin,system,system,)) $(eval $(call BuildPlugin,wireless,wireless,)) $(eval $(call BuildPlugin,babel,babel,)) $(eval $(call BuildPlugin,bmx6,bmx6,)) +$(eval $(call BuildPlugin,qmp,qmp,)) define Package/libremap-agent SECTION:=utilities diff --git a/libremap-agent/files/etc/uci-defaults/80_libremap-agent b/libremap-agent/files/etc/uci-defaults/80_libremap-agent index 635a56c..21f0b40 100755 --- a/libremap-agent/files/etc/uci-defaults/80_libremap-agent +++ b/libremap-agent/files/etc/uci-defaults/80_libremap-agent @@ -71,6 +71,9 @@ config plugin 'babel' config plugin 'bmx6' option enabled '0' + +config plugin 'qmp' + option enabled '0' EOF } diff --git a/libremap-agent/luasrc/libremap/plugins/qmp.lua b/libremap-agent/luasrc/libremap/plugins/qmp.lua new file mode 100644 index 0000000..1910b98 --- /dev/null +++ b/libremap-agent/luasrc/libremap/plugins/qmp.lua @@ -0,0 +1,29 @@ +--[[ + +Copyright 2017 Roger Pueyo Centelles + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +]]-- + +local uci = (require 'uci').cursor() + +function insert(doc, options) + -- get values from qMp config + local community_name = tostring(uci:get('qmp', 'node', 'community_name')) + local mesh_name = tostring(uci:get('qmp', 'node', 'mesh_name')) + local device_id = tostring(uci:get('qmp', 'node', 'device_id')) + + -- store in doc + doc.community_name = community_name + doc.mesh_name = mesh_name + doc.device_id = device_id +end + +return { + insert = insert +} From 148664269b9964f0124c27e667ffcdefa0f13a9f Mon Sep 17 00:00:00 2001 From: Roger Pueyo Centelles Date: Mon, 6 Mar 2017 15:18:33 +0100 Subject: [PATCH 2/2] Fix issue #23: drop deprecated sysyinfo call --- .../luasrc/libremap/plugins/system.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libremap-agent/luasrc/libremap/plugins/system.lua b/libremap-agent/luasrc/libremap/plugins/system.lua index 6539542..fce78d0 100644 --- a/libremap-agent/luasrc/libremap/plugins/system.lua +++ b/libremap-agent/luasrc/libremap/plugins/system.lua @@ -11,16 +11,19 @@ http://www.apache.org/licenses/LICENSE-2.0 ]]-- -sys = require 'luci.sys' +sys = require 'luci.sys' +util = require 'luci.util' return { insert = function(doc, options) - local name, model, memtotal = sys.sysinfo() - local system = { - name = name:match('[^\n]+'), - model = model:match('[^\n]+'), - memtotal = memtotal - } + local sysinfo = util.ubus("system", "info") or { } + local sysboard = util.ubus("system", "board") or { } + + local system = { } + system["name"] = sysinfo["hostname"] + system["model"] = sysboard["system"] + system["memtotal"] = sysinfo["memory"]["total"] + doc.attributes = doc.attributes or {} doc.attributes.system = system end