Ken Moore de9b9af3c0 API CHANGE: New class - sysadm/powerd
This is a class for managing the "powerd" service on the system.

Available "action"s:
"list_options": List all the available options and possible settings for each.
"read_options": Show all the current settings.
"set_options":  Modify any settings.
"list_status":  List the current state of the service (running, enabled)
"set_active":   Enable this device for starting on bootup.
"set_inactive": Disable this device from starting on bootup.
"start":        Start this service now.
"stop":         Stop this service now.

Example API Calls:
==================

REST Request (example):
-------------------------------
PUT /sysadm/powerd
{
   "action" : "list_options"
}

WebSocket Request:
-------------------------------
{
   "name" : "powerd",
   "namespace" : "sysadm",
   "args" : {
      "action" : "list_options"
   },
   "id" : "fooid"
}

Response:
-------------------------------
{
  "args": {
    "list_options": {
      "ac_power_mode": [
        "maximum",
        "hiadaptive",
        "adaptive",
        "minumum"
      ],
      "adaptive_lower_threshold_percent": "int min=1 max=100",
      "adaptive_raise_threshold_percent": "int min=1 max=100",
      "battery_power_mode": [
        "maximum",
        "hiadaptive",
        "adaptive",
        "minumum"
      ],
      "max_cpu_freq": "int frequency(hz)>0",
      "min_cpu_freq": "int frequency(hz)>0",
      "polling_interval_ms": "int milliseconds>0",
      "unknown_power_mode": [
        "maximum",
        "hiadaptive",
        "adaptive",
        "minumum"
      ]
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
===============================

REST Request (example):
-------------------------------
PUT /sysadm/powerd
{
   "action" : "read_options"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "powerd",
   "args" : {
      "action" : "read_options"
   },
   "namespace" : "sysadm"
}

Response:
-------------------------------
{
  "args": {
    "read_options": {
      "ac_power_mode": "maximum",
      "adaptive_lower_threshold_percent": "50",
      "adaptive_raise_threshold_percent": "75",
      "battery_power_mode": "adaptive",
      "max_cpu_freq": "-1",
      "min_cpu_freq": "-1",
      "polling_interval_ms": "250",
      "unknown_power_mode": "adaptive"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
===========================

REST Request (example):
-------------------------------
PUT /sysadm/powerd
{
   "action" : "list_status"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "powerd",
   "namespace" : "sysadm",
   "args" : {
      "action" : "list_status"
   }
}

Response:
-------------------------------
{
  "args": {
    "list_status": {
      "enabled": "true",
      "running": "true"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
===================

REST Request (example):
-------------------------------
PUT /sysadm/powerd
{
   "action" : "stop"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "stop"
   },
   "id" : "fooid",
   "namespace" : "sysadm",
   "name" : "powerd"
}

Response:
-------------------------------
{
  "args": {
    "stop": {
      "stopped": "true"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
==================

REST Request (example):
-------------------------------
PUT /sysadm/powerd
{
   "battery_power_mode" : "minimum",
   "action" : "set_options"
}

WebSocket Request:
-------------------------------
{
   "name" : "powerd",
   "args" : {
      "action" : "set_options",
      "battery_power_mode" : "minimum"
   },
   "id" : "fooid",
   "namespace" : "sysadm"
}

Response:
-------------------------------
{
  "args": {
    "set_options": {
      "ac_power_mode": "maximum",
      "adaptive_lower_threshold_percent": "50",
      "adaptive_raise_threshold_percent": "75",
      "battery_power_mode": "minimum",
      "max_cpu_freq": "-1",
      "min_cpu_freq": "-1",
      "polling_interval_ms": "250",
      "unknown_power_mode": "adaptive"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2017-02-07 12:34:33 -05:00
2017-02-07 12:34:33 -05:00
2015-12-08 14:37:18 -05:00
2016-08-18 14:07:31 -04:00

Table of Contents generated with DocToc

SysAdm

Official repo for TrueOS' sysadm middleware WebSocket & REST server

This middleware acts as the core for controlling a TrueOS or FreeBSD
system either locally or remotely via WebSockets or REST. It is also the
server component to TrueOS' SysAdm GUI client.

Required Qt Modules

Qt5 Core (pkg install qt5-core)
Qt5 Concurrent (pkg install qt5-concurrent)
Qt5 Websockets (pkg install qt5-websockets)

Building SysAdm

% git clone https://github.com/trueos/sysadm.git
% cd sysadm/src
% /usr/local/lib/qt5/bin/qmake -recursive
% make && sudo make install

Starting SysAdm

SysAdm can be started one of two ways:

  1. The traditional rc(8) mechanism
  2. The new jobd(8) mechanism

To run under rc(8):

(For WebSockets - Required for SysAdm Client)
% sudo sysrc -f /etc/rc.conf sysadm_enable="YES"
% sudo service sysadm start

(Optional for REST)
% sudo sysrc -f /etc/rc.conf sysadm_rest_enable="YES"
% sudo service sysadm-rest start

To run under jobd(8):

(For WebSockets - Required for SysAdm Client)
% sudo jobctl org.pcbsd.sysadm enable

(Optional for REST)
% sudo jobctl org.pcbsd.sysadm-rest enable

API Documentation

https://api.pcbsd.org

Contributing new API calls

SysAdm is written using the Qt toolkit, which has excellent reference documentation.

All Qt Core classes (I.E. non-gui) can be used in SysAdm server.

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: 4d3b590f46

Adding new Classes for API calls

Adding a new API class requires tweaking a few more files than a new API call only.

Example: 1ba65b3388

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)

Description
No description provided
Readme BSD-2-Clause 5.2 MiB
Languages
C++ 85.6%
Shell 12.7%
C 0.8%
QMake 0.6%
JavaScript 0.2%