Commit Graph

389 Commits

Author SHA1 Message Date
Ken Moore
94596117ed API CHANGE: Get the sysadm-bridge all finished up. Now to add the necessary bits to the server/client so we can try using it.
NOTE: There is a special API/event for the bridge to announce which server/client connections are available (clients will see only servers, and vice versa)
The syntax for this event is:

{
 "namespace":"events",
 "name":"bridge",
 "id":"",
 "args":{
   "available_connections":["ID1","ID2", etc..]
 }
}

Note that the available_connections are *all* the connections available at that time (it is not a difference from a previous state), so there may be both new ID's in the list and ID's which are no longer listed.

This event will get sent out any time a new connection/disconnection is made from the bridge which impacts the current connection (so a client will only get the event when a server connects/disconnects and vice versa).
2016-05-10 10:49:33 -04:00
Ken Moore
083b8ad694 Oops - forgot to add the new RestStructs.cpp file to GIT. 2016-05-09 14:50:10 -04:00
Ken Moore
1fea33c354 Get the sysadm server message parsing system all setup for bridge relays (no additional encryption/decryption layer yet) 2016-05-09 13:36:40 -04:00
Ken Moore
9287390e54 Fix up the parsing/usage of REST requests in the sysadm server. A Websocket-specific filtering rule was put in place earlier which was filtering out all the REST messages. 2016-05-09 10:15:59 -04:00
Ken Moore
aa9e7583a7 Merge branch 'master' of github.com:pcbsd/sysadm 2016-05-05 09:58:56 -04:00
Ken Moore
f9af7c2efe Add a API call to the server:
rpc/settings: "action" = "list_ssl_checksums"
This will list the MD5 checksums of all the known SSL keys (in no particular order)

REST Request:
-------------------------------
PUT /rpc/settings
{
   "action" : "list_ssl_checksums"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "list_ssl_checksums"
   },
   "namespace" : "rpc",
   "name" : "settings",
   "id" : "fooid"
}

Response:
-------------------------------
{
  "args": {
    "md5_keys": [
      "0`H\u0013\r*\u00023\u000bc"
    ]
  },
  "id": "fooid",
  "name": "response",
  "namespace": "rpc"
}
2016-05-05 09:55:38 -04:00
Ken Moore
8154d8f345 Enable the 30 second window for a client to successfully authorize before the connection is closed. 2016-05-04 14:54:04 -04:00
Ken Moore
45cec48f3c Setup the authorization manager for the sysadm-bridge. The SSL authentication procedures for Bridge<-->System should now be completely functional. 2016-05-04 14:45:59 -04:00
Ken Moore
4ef706afee Get the bridge setup with the rpc/identify API call as well. Also get it all setup for adding additional API calls. 2016-05-03 11:03:53 -04:00
Ken Moore
7f38c91420 Merge branch 'master' of github.com:pcbsd/sysadm 2016-05-03 10:40:16 -04:00
Ken Moore
f7333470a9 API Change:
Add a new API call to the sysadm-server: rpc/identify (no arguments)
This generates a responce identifying the type of sysadm system ("server" in this case). This will be important and I am going to be adding this same API call to all the various sysadm utilities so they can identify which one they are ("server", "bridge", "client").

REST Request:
-------------------------------
PUT /rpc/identify
{}

WebSocket Request:
-------------------------------
{
   "args" : {},
   "namespace" : "rpc",
   "id" : "fooid",
   "name" : "identify"
}

Response:
-------------------------------
{
  "args": {
    "type": "server"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "rpc"
}
2016-05-03 10:26:08 -04:00
Kris Moore
bc2d2e4fa6 Merge branch 'master' of https://github.com/pcbsd/sysadm 2016-05-02 15:04:50 -04:00
Kris Moore
ef792121e5 Use script as rc.d target 2016-05-02 15:04:34 -04:00
Kris Moore
e584066f3c Add rc.d and sysadm-bridge-start 2016-05-02 15:04:07 -04:00
Ken Moore
26f54ff4f0 Simply the server layout of the bridge 2016-05-02 14:57:49 -04:00
Ken Moore
eb0b691c1d Merge branch 'master' of github.com:pcbsd/sysadm 2016-05-02 14:35:24 -04:00
Ken Moore
bd863b70d7 Add the beginning of a new "sysadm-bridge" utility. 2016-05-02 14:34:18 -04:00
Ken Moore
b27166d1d4 Add a couple new settings:
auth/allowUserPassAuth [bool]: Enable username/password combinations for authentication (default value: true)
auth/allowServiceAuth [bool]: Allow local services to connect to the server with reduced priviledges (default value: false)
2016-04-29 14:37:55 -04:00
Ken Moore
6d47bf00bd oops. fix a typo. 2016-04-29 13:41:25 -04:00
Ken Moore
60fc3e1c5a API CHANGE:
Change the sysadm/settings class to rpc/settings

While here also add automatic log pruning capabilities (90 days of logs kept by default).
2016-04-29 13:10:11 -04:00
Ken Moore
78b4dcf62a API CHANGE
Change the namespace of the sysadm/logs class to rpc/logs for consistency between internal/external classes.
2016-04-29 10:58:14 -04:00
Ken Moore
d56e90d557 Add a new API call: rpc/dispatcher -> "action":"kill"
This allows a user with full access to cancel pending/running jobs within the dispatcher system.

Required arguments: "job_id" : <ID string> or [<ID1>, <ID2>, etc..]

REST Request:
-------------------------------
PUT /rpc/dispatcher
{
   "action" : "kill",
   "job_id" : "sysadm_pkg_install-{9c079421-ace9-4b6e-8870-d023b48f4c49}"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "kill",
      "job_id" : "sysadm_pkg_install-{9c079421-ace9-4b6e-8870-d023b48f4c49}"
   },
   "namespace" : "rpc",
   "name" : "dispatcher",
   "id" : "fooid"
}

Response:
-------------------------------
{
  "args": {
    "killed": {
      "jobs": ["sysadm_pkg_install-{9c079421-ace9-4b6e-8870-d023b48f4c49}"]
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "rpc"
}
2016-04-29 10:25:36 -04:00
Ken Moore
caad04ece9 Add a new API call:
rpc/dispatcher -> "action":"list"
This will list all the currently running/pending processes within the dispatcher queues.
Possible Queues: "no_queue", "pkg_queue", "iocage_queue"

REST Request:
-------------------------------
PUT /rpc/dispatcher
{
   "action" : "list"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "list"
   },
   "namespace" : "rpc",
   "name" : "dispatcher",
   "id" : "fooid"
}

Response:
-------------------------------
{
  "args": {
    "jobs": {
      "pkg_queue": {
        "sysadm_pkg_install-{9c079421-ace9-4b6e-8870-d023b48f4c49}": {
          "commands": [
            "pkg install -y --repository \"pcbsd-major\" misc/pcbsd-meta-mate"
          ],
          "queue_position": "0",
          "state": "running"
        }
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "rpc"
}
2016-04-29 10:00:43 -04:00
Ken Moore
4cee9244e4 Add a new API call/class:
namespace: "sysadm"
name: "logs"
This is a class used for interacting with the log files created by the sysadm server.

"action":"read_logs"
Optional Arguments:
"logs" : array/string of log type(s) (valid types: "hostinfo", "dispatcher", "events-dispatcher","events-lifepreserver","events-state"
"time_format" : one of the following formats (required for custom start/end times below). Valid Formats: "time_t_seconds", "epoch_mseconds, "relative_[day/month/second]", or a QDateTime String code (see http://doc.qt.io/qt-5/qdatetime.html#fromString for details).
"start_time" : "<number/string corresponding to format above>"
"end_time" : "<number/string corresponding to format above>"

If the time_format is missing, or the start/end times are not defined, the end time will be the current date/time, and the start time will be 12 hours previous.
If the "logs" argument is missing/empty, then all logs matching the search parameters will be returned.

Example Input:
{
 "action" : "read_logs",
 "time_format" : "relative_second",
 "start_time" : "-3600"
}
This returns all log entries within the last hour.

Return Format:
"args" : {
  "<log_file_type>" : {
    "<date_time_stamp>" : <message>,
    "<date_timo_stamp2>" : <message>
  }
}
2016-04-27 16:41:17 -04:00
Ken Moore
0acebe7435 Fix up a couple LP API calls. Now they function properly again. 2016-04-26 13:59:53 -04:00
Ken Moore
1b29b2966f Merge branch 'master' of github.com:pcbsd/sysadm 2016-04-26 09:43:24 -04:00
Ken Moore
b07f11bfe3 API Change: Add a simple "pkg_autoremove" action for the sysadm/pkg subsystem (no additional inputs). This will queue up the pkg autoremove action which prunes all orphaned packages on the systems. 2016-04-26 09:41:58 -04:00
Kris Moore
dd33e9648c Merge branch 'master' of https://github.com/pcbsd/sysadm 2016-04-21 14:55:20 -04:00
Kris Moore
b2a4386c36 Add a new 'fs' class to sysadm API, along with the initial "dirlist"
command which will return a listing of the requested directory

REST Request:
-------------------------------
PUT /sysadm/fs
{
   "dir" : "/root",
   "action" : "dirlist"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "dir" : "/root",
      "action" : "dirlist"
   },
   "id" : "fooid",
   "name" : "fs",
   "namespace" : "sysadm"
}

Response:
-------------------------------
{
  "args": {
    "dirlist": {
      "VirtualBox VMs": {
        "dir": true
      },
      "freenas-auto.iso": {
        "group": "wheel",
        "owner": "root",
        "size": 408049664
      },
      "ixbuild": {
        "dir": true
      },
      "pc-sysinstall.cfg": {
        "group": "wheel",
        "owner": "root",
        "size": 1741
      },
      "pc-sysinstall.log": {
        "group": "wheel",
        "owner": "root",
        "size": 125408
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-04-21 14:54:12 -04:00
Ken Moore
e4db11a0f7 Fix a missing "ok=true" in the ZFS list_pools API call. 2016-04-21 13:09:48 -04:00
Kris Moore
f5d402108b Fix starting sysadm-server 2016-04-21 11:34:06 -04:00
Kris Moore
cff5baae47 Add new API call to return list of ZFS datasets on a particular pool
REST Request:
-------------------------------
PUT /sysadm/zfs
{
   "action" : "datasets",
   "zpool" : "tank"
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "id" : "fooid",
   "args" : {
      "action" : "datasets",
      "zpool" : "tank"
   },
   "name" : "zfs"
}

Response:
-------------------------------
{
  "args": {
    "datasets": {
      "tank": {
        "avail": "320G",
        "mountpoint": "none",
        "refer": "96K",
        "used": "125G"
      },
      "tank/ROOT": {
        "avail": "320G",
        "mountpoint": "none",
        "refer": "96K",
        "used": "63.7G"
      },
      "tank/ROOT/11.0-CURRENTAPRIL2016-up-20160418_124146": {
        "avail": "320G",
        "mountpoint": "/",
        "refer": "34.7G",
        "used": "63.7G"
      },
      "tank/ROOT/11.0-CURRENTFEB2016-up-20160303_094216": {
        "avail": "320G",
        "mountpoint": "/",
        "refer": "29.7G",
        "used": "272K"
      },
      "tank/ROOT/11.0-CURRENTMAR2016-up-20160304_102405": {
        "avail": "320G",
        "mountpoint": "/",
        "refer": "30.5G",
        "used": "248K"
      },
      "tank/ROOT/11.0-CURRENTMAR2016-up-20160315_092952": {
        "avail": "320G",
        "mountpoint": "/",
        "refer": "31.2G",
        "used": "256K"
      },
      "tank/ROOT/11.0-CURRENTMAR2016-up-20160318_090405": {
        "avail": "320G",
        "mountpoint": "/",
        "refer": "34.7G",
        "used": "280K"
      },
      "tank/ROOT/initial": {
        "avail": "320G",
        "mountpoint": "/mnt",
        "refer": "5.60G",
        "used": "232K"
      },
      "tank/iocage": {
        "avail": "320G",
        "mountpoint": "/iocage",
        "refer": "152K",
        "used": "1.13G"
      },
      "tank/iocage/.defaults": {
        "avail": "320G",
        "mountpoint": "/iocage/.defaults",
        "refer": "96K",
        "used": "992K"
      },
      "tank/iocage/download": {
        "avail": "320G",
        "mountpoint": "/iocage/download",
        "refer": "96K",
        "used": "203M"
      },
      "tank/iocage/download/10.2-RELEASE": {
        "avail": "320G",
        "mountpoint": "/iocage/download/10.2-RELEASE",
        "refer": "202M",
        "used": "202M"
      },
      "tank/iocage/jails": {
        "avail": "320G",
        "mountpoint": "/iocage/jails",
        "refer": "104K",
        "used": "1000K"
      },
      "tank/iocage/releases": {
        "avail": "320G",
        "mountpoint": "/iocage/releases",
        "refer": "96K",
        "used": "953M"
      },
      "tank/iocage/releases/10.2-RELEASE": {
        "avail": "320G",
        "mountpoint": "/iocage/releases/10.2-RELEASE",
        "refer": "96K",
        "used": "952M"
      },
      "tank/iocage/releases/10.2-RELEASE/root": {
        "avail": "320G",
        "mountpoint": "/iocage/releases/10.2-RELEASE/root",
        "refer": "825M",
        "used": "951M"
      },
      "tank/iocage/templates": {
        "avail": "320G",
        "mountpoint": "/iocage/templates",
        "refer": "96K",
        "used": "992K"
      },
      "tank/iohyve": {
        "avail": "320G",
        "mountpoint": "/iohyve",
        "refer": "96K",
        "used": "22.8G"
      },
      "tank/iohyve/Firmware": {
        "avail": "320G",
        "mountpoint": "/iohyve/Firmware",
        "refer": "96K",
        "used": "992K"
      },
      "tank/iohyve/ISO": {
        "avail": "320G",
        "mountpoint": "/iohyve/ISO",
        "refer": "96K",
        "used": "453M"
      },
      "tank/iohyve/ISO/FreeBSD-10.1-RELEASE-amd64-bootonly.iso": {
        "avail": "320G",
        "mountpoint": "/iohyve/ISO/FreeBSD-10.1-RELEASE-amd64-bootonly.iso",
        "refer": "219M",
        "used": "220M"
      },
      "tank/iohyve/ISO/FreeBSD-10.2-RELEASE-amd64-bootonly.iso": {
        "avail": "320G",
        "mountpoint": "/iohyve/ISO/FreeBSD-10.2-RELEASE-amd64-bootonly.iso",
        "refer": "231M",
        "used": "232M"
      },
      "tank/iohyve/bsdguest": {
        "avail": "320G",
        "mountpoint": "/iohyve/bsdguest",
        "refer": "96K",
        "used": "22.4G"
      },
      "tank/iohyve/bsdguest/disk0": {
        "avail": "341G",
        "mountpoint": "-",
        "refer": "1.75G",
        "used": "22.4G"
      },
      "tank/tmp": {
        "avail": "320G",
        "mountpoint": "/tmp",
        "refer": "2.95M",
        "used": "18.3M"
      },
      "tank/usr": {
        "avail": "320G",
        "mountpoint": "none",
        "refer": "96K",
        "used": "37.5G"
      },
      "tank/usr/home": {
        "avail": "320G",
        "mountpoint": "/usr/home",
        "refer": "96K",
        "used": "27.8G"
      },
      "tank/usr/home/kris": {
        "avail": "320G",
        "mountpoint": "/usr/home/kris",
        "refer": "21.9G",
        "used": "27.8G"
      },
      "tank/usr/jails": {
        "avail": "320G",
        "mountpoint": "/usr/jails",
        "refer": "96K",
        "used": "992K"
      },
      "tank/usr/obj": {
        "avail": "320G",
        "mountpoint": "/usr/obj",
        "refer": "4.68G",
        "used": "4.75G"
      },
      "tank/usr/ports": {
        "avail": "320G",
        "mountpoint": "/usr/ports",
        "refer": "2.20G",
        "used": "2.96G"
      },
      "tank/usr/src": {
        "avail": "320G",
        "mountpoint": "/usr/src",
        "refer": "1.82G",
        "used": "2.01G"
      },
      "tank/var": {
        "avail": "320G",
        "mountpoint": "none",
        "refer": "96K",
        "used": "13.5M"
      },
      "tank/var/audit": {
        "avail": "320G",
        "mountpoint": "/var/audit",
        "refer": "96K",
        "used": "992K"
      },
      "tank/var/log": {
        "avail": "320G",
        "mountpoint": "/var/log",
        "refer": "1.43M",
        "used": "5.21M"
      },
      "tank/var/mail": {
        "avail": "320G",
        "mountpoint": "/var/mail",
        "refer": "120K",
        "used": "1.21M"
      },
      "tank/var/tmp": {
        "avail": "320G",
        "mountpoint": "/var/tmp",
        "refer": "3.20M",
        "used": "5.99M"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-04-21 11:28:37 -04:00
Kris Moore
4f8b78c361 Add new API call to create a new snapshot via Life-Preserver
REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "snap" : "mytestsnap",
   "dataset" : "tank",
   "comment" : "Testing",
   "action" : "createsnap"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "comment" : "Testing",
      "dataset" : "tank",
      "action" : "createsnap",
      "snap" : "mytestsnap"
   },
   "name" : "lifepreserver",
   "namespace" : "sysadm",
   "id" : "fooid"
}

Response:
-------------------------------
{
  "args": {
    "createsnap": {
      "comment": "Testing",
      "dataset": "tank",
      "snap": "mytestsnap"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-04-21 10:36:44 -04:00
Kris Moore
5f53dd4a4e Finish adding relaunchd services for sysadm server 2016-04-19 10:00:56 -04:00
Kris Moore
9153467480 Disable launchd support for now 2016-04-14 15:57:29 -04:00
Kris Moore
47428cef37 Detect if we get a 'cannot destroy' error from iohyve rmiso 2016-04-14 10:36:29 -04:00
Kris Moore
57cc4212bb Comments on sysadm server wrapper 2016-04-13 14:30:05 -04:00
Kris Moore
fc55d22a9f Merge branch 'master' of https://github.com/pcbsd/sysadm 2016-04-12 16:56:29 -04:00
Kris Moore
1f62042828 Add new relaunchd configuration files, but keep rc.d so both
can be used
2016-04-12 16:55:03 -04:00
Ken Moore
b257874672 Disable the rpc/syscache backend from the sysadm server. The new sysadm/pkg backend completely replaces it. 2016-04-12 07:38:52 -04:00
Ken Moore
f4c0bc632f (API CHANGE) Enhance the sysadm-pkg search functionality a bit:
1) Add a new optional argument to the pkg_search action: "search_excludes" (string or array of strings). This will exclude matches which contain a restricted string.
2) Add a new output field to the search results:
"pkg_search":{"results_order":[list of origins by priority], <other results/data> }
3) Adjust how the search is performed when the search term has multiple words. First look for any result which contains all the words, then if nothing is found look for any result which contains any of the words.
2016-04-11 10:34:28 -04:00
Ken Moore
6cdf2c32ba Fix a bug with the new SQL database connections - the sub-queries needed the individual DB to use as well. 2016-04-05 14:37:03 -04:00
Ken Moore
b7273f7e19 Make sure that when starting updates via sysadm - it will remove the temporary/last update log file so the next check is forced to re-run. 2016-04-05 10:22:37 -04:00
Ken Moore
36b30e6c9c Finish cleaning up the new "pending" state for dispatcher processes. 2016-04-05 10:19:05 -04:00
Ken Moore
8ad8babafa Adjust the pkg search routine to also detect exact name matches. 2016-04-05 09:43:17 -04:00
Ken Moore
9409ef7908 Setup the dispatcher system to have "pending" processes send out regular pings about still being pending. 2016-04-05 09:38:39 -04:00
Ken Moore
72e337f10b Fix up the SQL connection queue issues. Now it works a little faster and multiple threads accessing the same database will not cause crashes. 2016-04-05 09:10:04 -04:00
Ken Moore
221b666262 Turn off some debugging, and switch the pkg database connection system over to a clone system so one request cannot interfere with another. 2016-04-01 15:06:10 -04:00
Ken Moore
e5d8c33b81 Remove some comments from the pkg interface, and make sure the dispatcher sends out a full update when starting for the first time (in case the proc is a special subsystem process). 2016-03-31 10:09:37 -04:00
Ken Moore
341a546c4b Fix a bug in the new annotations streamline - now it gets added to the proper sub-object. 2016-03-31 08:19:28 -04:00