Commit Graph

171 Commits

Author SHA1 Message Date
Ken Moore
c9f227eebc API CHANGE: last sysadm/firewall action
Final action for the sysadm/firewall class: "action" = "reset-defaults"
This will reset all the firewall settings back to defaults and restart the firewall.
NOTE: This will only work on TrueOS - plain FreeBSD does not have any concept of default firewall settings and this API call will return an error in that case.

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "reset-defaults"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "args" : {
      "action" : "reset-defaults"
   },
   "namespace" : "sysadm",
   "name" : "firewall"
}

Response:
-------------------------------
{
  "args": {
    "result": "success"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-09-13 08:07:31 -04:00
Ken Moore
c089525bf7 API CHANGE: 5 simple "actions" for sysadm/firewall
Add five new "actions" for managing the firewall:
"start" - turn on the firewall
"stop" - turn off the firewall
"restart" - reload the firewall (catches any settings changes - not generally needed)
"enable" - automatically start the firewall on bootup
"disable" - do not start the firewall on bootup

They all use the same input/output syntax, just the "action" input field is different

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "restart"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "args" : {
      "action" : "restart"
   },
   "namespace" : "sysadm",
   "name" : "firewall"
}

Response:
-------------------------------
{
  "args": {
    "result": "success"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-09-13 07:39:27 -04:00
Ken Moore
aca7bbc7b0 API CHANGE: new action for sysadm/firewall
"action":"close"
REQUIRED: "ports":["<number>/<type>", "<number2>"/"<type2>"]

This will close the designated ports in the firewall

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "close",
   "ports" : [
      "12151/tcp"
   ]
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "namespace" : "sysadm",
   "name" : "firewall",
   "args" : {
      "ports" : [
         "12151/tcp"
      ],
      "action" : "close"
   }
}

Response:
-------------------------------
{
  "args": {
    "result": "success"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-09-12 15:52:56 -04:00
Ken Moore
ed3296eaf3 API CHANGE: New action for sysadm/firewall
"action":"open"
REQUIRES: "ports":[<number>/<type>, <number2>/<type2>]

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "open",
   "ports" : [
      "12151/tcp"
   ]
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "name" : "firewall",
   "args" : {
      "ports" : [
         "12151/tcp"
      ],
      "action" : "open"
   },
   "id" : "fooid"
}

Response:
-------------------------------
{
  "args": {
    "result": "success"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-09-12 15:47:54 -04:00
Ken Moore
108a2da675 API CHANGE: New action for sysadm/firewall
"action":"status"
Returns the current status of the firewall

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "status"
}

WebSocket Request:
-------------------------------
{
   "name" : "firewall",
   "args" : {
      "action" : "status"
   },
   "id" : "fooid",
   "namespace" : "sysadm"
}

Response:
-------------------------------
{
  "args": {
    "is_enabled": "true",
    "is_running": "true"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-09-12 15:29:24 -04:00
Ken Moore
6b348c3940 API CHANGE:
Add a new "action" for the new sysadm/firewall class:
"action":"list_open"
Returns an array of all the open port/type combinations for the firewall.

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "list_open"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "list_open"
   },
   "id" : "fooid",
   "name" : "firewall",
   "namespace" : "sysadm"
}

Response:
-------------------------------
{
  "args": {
    "openports": [
      "5353/udp"
    ]
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-09-12 15:21:02 -04:00
Ken Moore
45bb83a05f API CHANGE:
Add a new class to sysadm: sysadm/firewall
This is the new firewall manager (ipfw), for setting options for the system firewall.

Initial API Call: "action":"known_ports"
This will return a list of all known ports and any names/descriptions for them (this is a static list - it does not reflect which ports are in-use or opened on the system. It is just for matching a port to a name/description)

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "known_ports"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "namespace" : "sysadm",
   "args" : {
      "action" : "known_ports"
   },
   "name" : "firewall"
}

Response:
-------------------------------
{
  "args": {
    "1/tcp": {
      "description": "#TCP Port Service Multiplexer",
      "name": "tcpmux",
      "port": "1/tcp"
    },
    "1/udp": {
      "description": "#TCP Port Service Multiplexer",
      "name": "tcpmux",
      "port": "1/udp"
    },
    "100/tcp": {
      "description": "#[unauthorized use]",
      "name": "newacct",
      "port": "100/tcp"
    }
  }
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-09-12 13:18:32 -04:00
Ken Moore
75f21cfe1b API CHANGE
Last round of new "action"s for the sysadm/services class,
"action":"[enable/disable]"
Required input arguments:
"services":["service1","service2","etc"]

Exactly the same syntax as the start/stop/restart API calls, just a different action and the output field is "services_[enabled/disabled]" as well.
2016-08-30 14:22:33 -04:00
Ken Moore
0408f61f4c API CHANGE
Add the "is_running" output field to the sysadm/services "list_services" output.
This also cleans up the is_enabled detection routine so it should be more reliable.
2016-08-30 13:32:53 -04:00
Ken Moore
8a594044bb API CHANGE
Add 3 new API calls (all almost the same - just different "actions" and the return message will be slightly different)

"action":"start" OR "stop" OR "restart"
This will [start/stop/restart] services on the system.
REQUIRED ARGUMENTS:
"services" : <string with a single service, or array of services>

EXAMPLE "start" command (change "services_started" in responce to "services_[started/stopped/restarted]" as needed to match the action:

REST Request (example):
-------------------------------
PUT /sysadm/services
{
   "action" : "start",
   "services" : [
      "cupsd"
   ]
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "start",
      "services" : [
         "cupsd"
      ]
   },
   "name" : "services",
   "id" : "fooid",
   "namespace" : "sysadm"
}

Response:
-------------------------------
{
  "args": {
    "services_started": [
      "cupsd"
    ]
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-08-30 11:27:51 -04:00
Kris Moore
cd959daa3f Ken missed a } 2016-08-29 22:54:04 -04:00
Ken Moore
ce86331f1e Clean up the new sysadm/services class just a bit more. Getting ready to add all the start/stop/restart API calls. 2016-08-29 16:09:30 -04:00
Ken Moore
2f7bfe06aa API CHANGE
Modify the output fields for the sysadm/services, "list_services" action:
Now each service entry will look like this:
"accounting": {
        "description": "",
        "is_enabled": "false",
        "name": "accounting",
        "path": "/etc/rc.d/accounting",
        "tag": "accounting_enable"
      }

I will probably be adding an "is_running" [true/false] field here soon as well - the backend for that still needs to be written first.
2016-08-29 14:09:20 -04:00
Ken Moore
1bf0ec425f API CHANGE
Add a new API class/call to sysadm:
namespace: sysadm
name: services
This class is for managing all the background daemons on the system.

Initial API call:
args : {"action" : "list_services" }
This will return a list of all services available on the system.

*Note: return message shortened for example purposes - there are usually tons of services available

REST Request (example):
-------------------------------
PUT /sysadm/services
{
   "action" : "list_services"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "list_services"
   },
   "id" : "fooid",
   "namespace" : "sysadm",
   "name" : "services"
}

Response:
-------------------------------
{
  "args": {
    "services": {
      "accounting": {
        "name": "accounting",
        "tag": "accounting_enable"
      },
      "addswap": {
        "name": "addswap",
        "tag": "addswap_enable"
      },
      "amd": {
        "name": "amd",
        "tag": "amd_enable"
      },
      "apm": {
        "name": "apm",
        "tag": "apm_enable"
      },
      "apmd": {
        "name": "apmd",
        "tag": "apmd_enable"
      },
      "atm": {
        "name": "atm",
        "tag": "atm_enable"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-08-29 11:41:15 -04:00
Ken Moore
1fd947f5b4 API CHANGE:
Add a new action to the sysadm/users class: "groupmod"
This action allows for modifying a given group on the system

REQUIRED: "name"="<name of group to modify>"
and any one of these options is also required:
"users":["array of users"] (will set the list of users for this group)
"add_users":["array of users"] (will add the listed users to the current users)
"remove_users":["array of users"] (will remove the listed users from the current users)

Example API Request (JSON)
{
"id":"sample",
"namespace":"sysadm",
"name":"users",
"args":{
  "action":"groupmod",
  "name":"operator",
  "users":["user1","user2"]
  }
}
2016-08-17 12:15:48 -04:00
Ken Moore
216ca5a9f2 Oops - fix a true/false reversal in the sysadm/users "userdelete" "clean_home" optional argument. 2016-08-16 09:32:14 -04:00
Ken Moore
dac91284c8 API CHANGE
Add a new option to the sysadm/users class:
"action":"groupdelete"
"name":"groupToDelete"

Returns:
"args"{ "result":"success" } on success action
2016-08-11 10:01:21 -04:00
Ken Moore
373a28c4f5 API CHANGE
Add a new optional input argument to the sysadm/updates, "checkupdates" action:
"force":"[true/false]" (default is false)

This tells the check system to skip all previous checks for updates and re-run the update routines to look for new updates (if force==true), otherwise it might return the previous result of the update check if not enough time has passed since the other check.
2016-08-10 11:51:22 -04:00
Ken Moore
a2bba87315 API CHANGE
Add a new API call to the sysadm/update class:
"action":"changesettings"
This allows for changing the various updatemanager settings (maxbe, package_set, package_url, auto_update)

REST Request (example):
-------------------------------
PUT /sysadm/update
{
   "action" : "changesettings",
   "maxbe" : "6"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "update",
   "namespace" : "sysadm",
   "args" : {
      "maxbe" : "6",
      "action" : "changesettings"
   }
}

Response:
-------------------------------
{
  "args": {
    "changesettings": {
      "result": "success"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-08-09 13:22:46 -04:00
Ken Moore
4457397733 API CHANGE
Add a new API call to the sysadm/update class for reading all the current settings.

REST Request (example):
-------------------------------
PUT /sysadm/update
{
   "action" : "listsettings"
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "listsettings"
   },
   "id" : "fooid",
   "namespace" : "sysadm",
   "name" : "update"
}

Response:
-------------------------------
{
  "args": {
    "listsettings": {
      "maxbe": " 5",
      "package_set": " EDGE"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-08-09 12:45:27 -04:00
Ken Moore
06c71afa4a API CHANGE: Add a new "stopupdate" action for the sysadm/update class. (no additional inputs required).
This will look for any currently-running pc-updatemanager processes and kill/stop them as needed.

Example:
{
 "id":"dummy",
 "namespace":"sysadm",
 "name":"update",
 "args": {
    "action":"stopupdate"
 }
}

Output arguments:
"args":{
  "stopupdate":{
    "result":"success" or "error:<error text>"
  }
}
2016-08-09 11:27:08 -04:00
Ken Moore
4a260b66e2 API CHANGE
Add a "groupadd" action to the sysadm/users class.
This will create a new group on the system
REQUIRED: "name"
OPTIONAL: "gid","users"

REST Request (example):
-------------------------------
PUT /sysadm/users
{
   "action" : "groupadd",
   "name" : "testgroup"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "namespace" : "sysadm",
   "args" : {
      "action" : "groupadd",
      "name" : "testgroup"
   },
   "name" : "users"
}

Response:
-------------------------------
{
  "args": {
    "result": "success"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-07-28 16:11:35 -04:00
Ken Moore
a0d82f2367 API CHANGE
Add an "action"="groupshow" option to the sysadm/users class.
This will list all the known groups on the system and any users associated with them (if all access) or which ones the current user is in (if limited access).

REST Request (example):
-------------------------------
PUT /sysadm/users
{
   "action" : "groupshow"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "users",
   "namespace" : "sysadm",
   "args" : {
      "action" : "groupshow"
   }
}

Response:
-------------------------------
{
  "args": {
    "_dhcp": {
      "gid": "65",
      "name": "_dhcp",
      "users": [
        ""
      ]
    },
    "_ntp": {
      "gid": "123",
      "name": "_ntp",
      "users": [
        ""
      ]
    },
    "_pflogd": {
      "gid": "64",
      "name": "_pflogd",
      "users": [
        ""
      ]
    },
    "_tss": {
      "gid": "601",
      "name": "_tss",
      "users": [
        ""
      ]
    },
    "_ypldap": {
      "gid": "160",
      "name": "_ypldap",
      "users": [
        ""
      ]
    },
    "audit": {
      "gid": "77",
      "name": "audit",
      "users": [
        ""
      ]
    },
    "authpf": {
      "gid": "63",
      "name": "authpf",
      "users": [
        ""
      ]
    },
    "avahi": {
      "gid": "558",
      "name": "avahi",
      "users": [
        ""
      ]
    },
    "bin": {
      "gid": "7",
      "name": "bin",
      "users": [
        ""
      ]
    },
    "bind": {
      "gid": "53",
      "name": "bind",
      "users": [
        ""
      ]
    },
    "colord": {
      "gid": "970",
      "name": "colord",
      "users": [
        ""
      ]
    },
    "cups": {
      "gid": "193",
      "name": "cups",
      "users": [
        ""
      ]
    },
    "daemon": {
      "gid": "1",
      "name": "daemon",
      "users": [
        ""
      ]
    },
    "dialer": {
      "gid": "68",
      "name": "dialer",
      "users": [
        ""
      ]
    },
    "ftp": {
      "gid": "14",
      "name": "ftp",
      "users": [
        ""
      ]
    },
    "games": {
      "gid": "13",
      "name": "games",
      "users": [
        ""
      ]
    },
    "git_daemon": {
      "gid": "964",
      "name": "git_daemon",
      "users": [
        ""
      ]
    },
    "guest": {
      "gid": "31",
      "name": "guest",
      "users": [
        ""
      ]
    },
    "haldaemon": {
      "gid": "560",
      "name": "haldaemon",
      "users": [
        ""
      ]
    },
    "hast": {
      "gid": "845",
      "name": "hast",
      "users": [
        ""
      ]
    },
    "kenmoore": {
      "gid": "1001",
      "name": "kenmoore",
      "users": [
        ""
      ]
    },
    "kmem": {
      "gid": "2",
      "name": "kmem",
      "users": [
        ""
      ]
    },
    "mail": {
      "gid": "6",
      "name": "mail",
      "users": [
        ""
      ]
    },
    "mailnull": {
      "gid": "26",
      "name": "mailnull",
      "users": [
        ""
      ]
    },
    "man": {
      "gid": "9",
      "name": "man",
      "users": [
        ""
      ]
    },
    "messagebus": {
      "gid": "556",
      "name": "messagebus",
      "users": [
        ""
      ]
    },
    "network": {
      "gid": "69",
      "name": "network",
      "users": [
        ""
      ]
    },
    "news": {
      "gid": "8",
      "name": "news",
      "users": [
        ""
      ]
    },
    "nobody": {
      "gid": "65534",
      "name": "nobody",
      "users": [
        ""
      ]
    },
    "nogroup": {
      "gid": "65533",
      "name": "nogroup",
      "users": [
        ""
      ]
    },
    "operator": {
      "gid": "5",
      "name": "operator",
      "users": [
        "root",
        "kenmoore"
      ]
    },
    "polkit": {
      "gid": "562",
      "name": "polkit",
      "users": [
        ""
      ]
    },
    "polkitd": {
      "gid": "565",
      "name": "polkitd",
      "users": [
        ""
      ]
    },
    "proxy": {
      "gid": "62",
      "name": "proxy",
      "users": [
        ""
      ]
    },
    "pulse": {
      "gid": "563",
      "name": "pulse",
      "users": [
        ""
      ]
    },
    "pulse-access": {
      "gid": "564",
      "name": "pulse-access",
      "users": [
        ""
      ]
    },
    "pulse-rt": {
      "gid": "557",
      "name": "pulse-rt",
      "users": [
        ""
      ]
    },
    "quasselcore": {
      "gid": "442",
      "name": "quasselcore",
      "users": [
        ""
      ]
    },
    "smmsp": {
      "gid": "25",
      "name": "smmsp",
      "users": [
        ""
      ]
    },
    "sshd": {
      "gid": "22",
      "name": "sshd",
      "users": [
        ""
      ]
    },
    "staff": {
      "gid": "20",
      "name": "staff",
      "users": [
        ""
      ]
    },
    "stunnel": {
      "gid": "341",
      "name": "stunnel",
      "users": [
        ""
      ]
    },
    "sys": {
      "gid": "3",
      "name": "sys",
      "users": [
        ""
      ]
    },
    "test2": {
      "gid": "1003",
      "name": "test2",
      "users": [
        ""
      ]
    },
    "tty": {
      "gid": "4",
      "name": "tty",
      "users": [
        ""
      ]
    },
    "unbound": {
      "gid": "59",
      "name": "unbound",
      "users": [
        ""
      ]
    },
    "uucp": {
      "gid": "66",
      "name": "uucp",
      "users": [
        ""
      ]
    },
    "video": {
      "gid": "44",
      "name": "video",
      "users": [
        ""
      ]
    },
    "webcamd": {
      "gid": "145",
      "name": "webcamd",
      "users": [
        ""
      ]
    },
    "wheel": {
      "gid": "0",
      "name": "wheel",
      "users": [
        "root",
        "kenmoore"
      ]
    },
    "www": {
      "gid": "80",
      "name": "www",
      "users": [
        ""
      ]
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-07-28 15:06:15 -04:00
Ken Moore
3c24217a88 Ensure we create user's home dir on new user creation. 2016-07-25 15:57:13 -04:00
Ken Moore
5a5e0df1ad API CHANGE
Add a new API call: sysadm/users, action=personacrypt_listdevs
This will run personacrypt and return any removeable devices which may be used as PC devices.

REST Request (example):
-------------------------------
PUT /sysadm/users
{
   "action" : "personacrypt_listdevs"
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "name" : "users",
   "id" : "fooid",
   "args" : {
      "action" : "personacrypt_listdevs"
   }
}

Response:
-------------------------------
{
  "args": {
    "da0": "<SanDisk Cruzer 1.26> 7.5G"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-07-25 15:35:06 -04:00
Ken Moore
585beba03a API CHANGE
Add new "usermod" action to the sysadm/users class. This is nearly identical to the "useradd" action, but performs changes to an existing user only (limited access users may modify their own settings, but not other users settings).

Additional OPTIONAL input: "newname" change the username to this instead.

REST Request (example):
-------------------------------
PUT /sysadm/users
{
   "action" : "usermod",
   "comment" : "somecomment",
   "name" : "test2"
}

WebSocket Request:
-------------------------------
{
   "name" : "users",
   "namespace" : "sysadm",
   "args" : {
      "name" : "test2",
      "comment" : "somecomment",
      "action" : "usermod"
   },
   "id" : "fooid"
}

Response:
-------------------------------
{
  "args": {
    "result": "success"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-07-25 14:45:43 -04:00
Ken Moore
86528334e0 [API CHANGE]
Add a new API call to the sysadm/users framework as well as add a bunch more output to current users requests (error/success reporting instead of just the overall good/bad flag).

New API call: "action":"userdelete"
REQUIRED: "name":<username>
OPTIONAL: "clean_home"="true/false" (default is "true")

REST Request (example):
-------------------------------
PUT /sysadm/users
{
   "name" : "test",
   "action" : "userdelete"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "users",
   "args" : {
      "action" : "userdelete",
      "name" : "test"
   },
   "namespace" : "sysadm"
}

Response:
-------------------------------
{
  "args": {
    "result": "success"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-07-25 10:14:06 -04:00
Ken Moore
6ed9dd4e74 Update a bit of the new "adduser" routine quite a bit, adding support for personacrypt init/import options as well (untested). 2016-07-22 13:20:23 -04:00
Ken Moore
f586a30d77 API CHANGE
Add a new API call for creating a user on the system:
action: "useradd"
Required fields: "password" AND ("name" OR "uid")
Optional fields: "comment", "home_dir", "expire", "change", "shell", "group", "other_groups", "class"

REST Request (example):
-------------------------------
PUT /sysadm/users
{
   "password" : "test",
   "name" : "test2",
   "action" : "useradd"
}

WebSocket Request:
-------------------------------
{
   "name" : "users",
   "namespace" : "sysadm",
   "id" : "fooid",
   "args" : {
      "password" : "test",
      "name" : "test2",
      "action" : "useradd"
   }
}

Response:
-------------------------------
{
  "args": {},
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-07-21 16:21:28 -04:00
Ken Moore
35f8f466f9 API CHANGE
Add a new "sysadm/users" API class to sysadm for managing users/groups on the system. The "usershow" action is the only one enabled at the present time.

REST Request (example):
-------------------------------
PUT /sysadm/users
{
   "action" : "usershow"
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "name" : "users",
   "id" : "fooid",
   "args" : {
      "action" : "usershow"
   }
}

Response:
-------------------------------
{
  "args": {
    "_dhcp": {
      "change": "0",
      "class": "",
      "comment": "dhcp programs",
      "expire": "0",
      "gid": "65",
      "home_dir": "/var/empty",
      "name": "_dhcp",
      "shell": "/usr/sbin/nologin",
      "uid": "65"
    },
    "_ntp": {
      "change": "0",
      "class": "",
      "comment": "NTP Daemon",
      "expire": "0",
      "gid": "123",
      "home_dir": "/var/empty",
      "name": "_ntp",
      "shell": "/usr/sbin/nologin",
      "uid": "123"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-07-21 14:57:03 -04:00
Ken Moore
376a903991 Fix up the bridge/server connection management stuff. Now the server will automatically check/re-connect as needed. 2016-05-23 10:05:09 -04:00
Ken Moore
d479e424f5 Turn off a bunch of debugging in the sysadm-server. 2016-05-20 14:56:02 -04:00
Ken Moore
23c254e11e Get a lot more of the bridge/server connections functional. Just have to work through a mismatch between server/client MD5 sums of valid keys. 2016-05-20 14:11:06 -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
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
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
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
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
033bea2e7b Add a new API call: sysadm/pkg, "action"="pkg_remove".
This will remove the given packages from the system.
Required arguments:
"pkg_origins" = (single origin string or array of origin strings).
Optional arguments:
"recursive" = "true" or "false" (default: "true"). If true, other packages which depend on this package will also be removed (no broken dependencies).
NOTE: The actual information will be returned as a Dispatcher event - this API call just queues up the pkg operation (limitation of pkg - only one process call at a time)

REST Request:
-------------------------------
PUT /sysadm/pkg
{
   "recursive" : "false",
   "action" : "pkg_remove",
   "pkg_origins" : "games/angband"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "pkg",
   "namespace" : "sysadm",
   "args" : {
      "action" : "pkg_remove",
      "recursive" : "false",
      "pkg_origins" : "games/angband"
   }
}

Response:
-------------------------------
{
  "args": {
    "pkg_remove": {
      "proc_cmd": "pkg delete -y games/angband",
      "proc_id": "sysadm_pkg_remove-{2aa844aa-f6a8-4e8f-ae71-b56af735ccb8}",
      "status": "pending"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-03-28 11:59:42 -04:00
Ken Moore
ab0ce827cf Add a new API call: sysadm/pkg, "action"="pkg_install".
This will install the given packages on the system.
Required arguments:
"pkg_origins" = (single origin string or array of origin strings).
Optional arguments:
"repo": Name of the remote repository to use (if not supplied, pkg will automatically determine repository).
NOTE: The actual information will be returned as a Dispatcher event - this API call just queues up the pkg operation (limitation of pkg - only one process call at a time)

REST Request:
-------------------------------
PUT /sysadm/pkg
{
   "pkg_origins" : "games/angband",
   "action" : "pkg_install",
   "repo" : "pcbsd-major"
}

WebSocket Request:
-------------------------------
{
   "name" : "pkg",
   "namespace" : "sysadm",
   "id" : "fooid",
   "args" : {
      "action" : "pkg_install",
      "pkg_origins" : "games/angband",
      "repo" : "pcbsd-major"
   }
}

Response:
-------------------------------
{
  "args": {
    "pkg_install": {
      "proc_cmd": "pkg install -y --repository \"pcbsd-major\" games/angband",
      "proc_id": "sysadm_pkg_install-{ae444472-47df-4a65-91eb-013cc82ce4ad}",
      "status": "pending"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-03-28 11:50:31 -04:00