added config file editing capabilities

This commit is contained in:
2018-02-18 14:49:43 +01:00
parent e5b501e6ab
commit e3381fb03e
6 changed files with 19 additions and 4 deletions

4
README
View File

@@ -9,10 +9,10 @@ DONE:
* Power control (ON/OFF) for each socket
* All the outlets are powered ON on boot
* ACF package
* configuration file
* configuration file editing
TODO:
* editing socket parameters
* editing outlet parameters
* everything else (there's a long list)
BUGS:

View File

@@ -16,4 +16,8 @@ mymodule.poweroff = function(self)
return self.handle_form(self, self.model.get_setpower, self.model.setpoweroff, self.clientdata, "commitpower", "Action result")
end
function mymodule.expert(self)
return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Config File", "Configuration Set")
end
return mymodule

View File

@@ -0,0 +1 @@
../expert-html.lsp

View File

@@ -5,6 +5,7 @@ fs = require("acf.fs")
json = require('cjson')
modelfunctions = require("modelfunctions")
local configfile = "/etc/openpdu/openpdu.conf"
local s = modelfunctions.run_executable({"/usr/bin/openpdu", "outlets", "-j"})
local o = json.decode(s)
local outlets = {}
@@ -46,4 +47,12 @@ mymodule.setpoweroff = function(self, r)
return r
end
function mymodule.get_filedetails()
return modelfunctions.getfiledetails(configfile)
end
function mymodule.update_filedetails(self, filedetails)
return modelfunctions.setfiledetails(self, filedetails, {configfile})
end
return mymodule

View File

@@ -1,2 +1,3 @@
#CAT GROUP/DESC TAB ACTION
Applications 20OpenPDU Status status
Applications 20OpenPDU Expert expert

View File

@@ -1,4 +1,4 @@
USER=openpdu:status
EDITOR=openpdu:status
EXPERT=openpdu:status
ADMIN=openpdu:status,openpdu:edit,openpdu:power,openpdu:poweron,openpdu:poweroff
EXPERT=openpdu:status,openpdu:expert
ADMIN=openpdu:status,openpdu:edit,openpdu:expert,openpdu:power,openpdu:poweron,openpdu:poweroff