mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
Update the various lpreserver API backends, to use new CLI
syntax, and uppdate README with further information about testing
This commit is contained in:
24
README.md
24
README.md
@@ -2,7 +2,8 @@
|
||||
|
||||
Official repo for PC-BSD's sysadm middleware WebSocket & REST server
|
||||
|
||||
This middleware acts as the core for controlling a PC-BSD or FreeBSD system either locally or remotely via WebSockets or REST.
|
||||
This middleware acts as the core for controlling a PC-BSD or FreeBSD
|
||||
system either locally or remotely via WebSockets or REST.
|
||||
|
||||
### Required Qt Modules
|
||||
|
||||
@@ -39,7 +40,9 @@ https://api.pcbsd.org
|
||||
|
||||
### Contributing new API calls
|
||||
|
||||
Adding new API calls to the middleware is very straight-forward, simply add a new function which accepts JSON in, and returns JSON, then connect it to the backend.
|
||||
Adding new API calls to the middleware is very straight-forward, simply
|
||||
add a new function which accepts JSON in, and returns JSON, then connect
|
||||
it to the backend.
|
||||
|
||||
Example:
|
||||
https://github.com/pcbsd/sysadm/commit/4d3b590f460d301b9376a063f9407dabfd7c9c66
|
||||
@@ -51,3 +54,20 @@ Adding a new API class requires tweaking a few more files than a new API call on
|
||||
Example:
|
||||
https://github.com/pcbsd/sysadm/commit/1ba65b33880e2298ade3e5cc4f2718aa6112e44f
|
||||
|
||||
### Testing new API calls / classes
|
||||
|
||||
Before committing or sending a pull request, you'll need to run our
|
||||
"api-test.sh" script and confirm it works properly. To do so, first add
|
||||
your new call and restart the websocket server. Next do the following:
|
||||
|
||||
```
|
||||
% cd sysadm/tests
|
||||
% ./api-test.sh
|
||||
```
|
||||
|
||||
The api-test script will prompt you to enter username, password, and some
|
||||
information about which class / API call to run. When that is done, and you
|
||||
have verified the functionality of your new call you should add the output
|
||||
of the test script (either from copy-n-paste, or from the file /tmp/api-response)
|
||||
to your commit. (This will allow us to document the new call / class)
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ QJsonObject LifePreserver::initReplication(QJsonObject jsin) {
|
||||
QJsonObject LifePreserver::listCron() {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList output = General::RunCommand("lpreserver listcron").split("\n");
|
||||
QStringList output = General::RunCommand("lpreserver cronsnap list").split("\n");
|
||||
QList<QStringList> snaps;
|
||||
|
||||
// Parse the output
|
||||
@@ -254,7 +254,7 @@ QJsonObject LifePreserver::listSnap(QJsonObject jsin) {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
QStringList output = General::RunCommand("lpreserver listsnap " + pool ).split("\n");
|
||||
QStringList output = General::RunCommand("lpreserver snapshot list " + pool ).split("\n");
|
||||
QList<QStringList> snaps;
|
||||
QStringList snapitems;
|
||||
QRegExp sep("\\s+");
|
||||
@@ -350,7 +350,7 @@ QJsonObject LifePreserver::removeSnapshot(QJsonObject jsin) {
|
||||
}
|
||||
|
||||
QStringList output;
|
||||
output = General::RunCommand("lpreserver rmsnap " + dataset + " " + snap).split("\n");
|
||||
output = General::RunCommand("lpreserver snapshot remove " + dataset + " " + snap).split("\n");
|
||||
|
||||
// Check for any errors
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
@@ -426,7 +426,7 @@ QJsonObject LifePreserver::revertSnapshot(QJsonObject jsin) {
|
||||
}
|
||||
|
||||
QStringList output;
|
||||
output = General::RunCommand("lpreserver revertsnap " + dataset + " " + snap).split("\n");
|
||||
output = General::RunCommand("lpreserver snapshot revert " + dataset + " " + snap).split("\n");
|
||||
|
||||
// Check for any errors
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
@@ -589,9 +589,9 @@ QJsonObject LifePreserver::scheduleSnapshot(QJsonObject jsin) {
|
||||
|
||||
QStringList output;
|
||||
if ( frequency == "none" )
|
||||
output = General::RunCommand("lpreserver cronsnap " + pool + " stop " ).split("\n");
|
||||
output = General::RunCommand("lpreserver cronsnap stop " + pool ).split("\n");
|
||||
else
|
||||
output = General::RunCommand("lpreserver cronsnap " + pool + " start " + frequency + " " + keep ).split("\n");
|
||||
output = General::RunCommand("lpreserver cronsnap start " + pool + " " + frequency + " " + keep ).split("\n");
|
||||
|
||||
// Check for any errors
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
|
||||
@@ -132,6 +132,7 @@ fi
|
||||
# Now check the response via WebSockets
|
||||
export NODE_TLS_REJECT_UNAUTHORIZED=0
|
||||
|
||||
rm $ofile >/dev/null 2>/dev/null
|
||||
ofile="/tmp/api-response"
|
||||
echo "" > $ofile
|
||||
|
||||
@@ -149,4 +150,3 @@ echo "" | tee -a $ofile
|
||||
echo "Response:" | tee -a $ofile
|
||||
echo "-------------------------------" | tee -a $ofile
|
||||
echo "{ \"namespace\":\"${APITESTNAMESPACE}\", \"name\":\"${APITESTCLASS}\", \"id\":\"fooid\", \"args\":${APITESTPAYLOAD} }" | node sendwebsocket.js "$APITESTUSER" "$APITESTPASS" | tee -a $ofile
|
||||
rm $ofile
|
||||
|
||||
Reference in New Issue
Block a user