Commit Graph

273 Commits

Author SHA1 Message Date
dlavigne
40f629230a Doc deactivatepool action. 2016-02-04 12:43:29 -05:00
dlavigne
b848d76be0 Doc activatepool action. 2016-02-04 11:47:21 -05:00
Kris Moore
21d016e3b8 Merge branch 'master' of https://github.com/pcbsd/sysadm 2016-02-04 11:37:25 -05:00
Kris Moore
a17cc0b7e4 Update the api-test script, now we only "simulate" the REST request
and show the same reponse from websockets. This prevents issues
from running API requests two times in a row

Also, add support for ENV variables to be used, instead of interactive
elements
2016-02-04 11:36:30 -05:00
dlavigne
e899e2c678 Doc stopjail action. 2016-02-04 11:30:06 -05:00
dlavigne
521e7f9ec8 Doc startjail action. 2016-02-04 11:21:18 -05:00
dlavigne
ee8fa9d436 Doc setsysctl action. 2016-02-04 11:07:54 -05:00
dlavigne
661c0e8cbe Doc sysctllist action. 2016-02-04 10:58:58 -05:00
dlavigne
916cbaff6e Doc killproc action. 2016-02-04 10:51:54 -05:00
dlavigne
c100aa2b93 Unclobber systemmanager rename in docs. 2016-02-04 10:37:29 -05:00
dlavigne
a9887c9156 Add ip4 to examples. 2016-02-04 10:28:47 -05:00
dlavigne
69d8a97944 Doc procinfo action. 2016-02-04 10:25:01 -05:00
dlavigne
1750146d3d Correct description of standalone update. 2016-02-04 10:01:40 -05:00
Brandon Schneider
98409969c5 Add a new iocage API call to deactivate pools.
REST Request:
-------------------------------
PUT /sysadm/iocage
{
   "action" : "deactivatepool",
   "pool" : "tank"
}

REST Response:
-------------------------------
{
    "args": {
        "deactivatepool": {
            "success": "pool tank deactivated."
        }
    }
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "iocage",
   "args" : {
      "pool" : "tank",
      "action" : "deactivatepool"
   },
   "namespace" : "sysadm"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "deactivatepool": {
      "success": "pool tank deactivated."
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}

Also added some error control to the activate API call.
2016-02-03 19:37:23 -06:00
Brandon Schneider
1048b3a6da Add a new iocage API call to activate zpools.
It has 2 different outputs depending on if `pool` was actually specified.

If you specify a pool this is what you get:
REST Request:
-------------------------------
PUT /sysadm/iocage
{
   "action" : "activatepool",
   "pool" : "tank"
}

REST Response:
-------------------------------
{
    "args": {
        "activatepool": {
            "success": "pool tank activated."
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "activatepool",
      "pool" : "tank"
   },
   "name" : "iocage",
   "id" : "fooid",
   "namespace" : "sysadm"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "activatepool": {
      "success": "pool tank activated."
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}

If you do not specify a pool, this is your output:
REST Request:
-------------------------------
PUT /sysadm/iocage
{
   "action" : "activatepool"
}

REST Response:
-------------------------------
{
    "args": {
        "activatepool": {
            "currently active": {
                "pool": " tank"
            }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "activatepool"
   },
   "namespace" : "sysadm",
   "name" : "iocage",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "activatepool": {
      "currently active": {
        "pool": " tank"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-03 19:14:18 -06:00
Brandon Schneider
437b3d76f3 Added stopping an iocage jail API call
REST Request:
-------------------------------
PUT /sysadm/iocage
{
   "action" : "stopjail",
   "jail" : "test"
}

REST Response:
-------------------------------
{
    "args": {
        "stopjail": {
            "test": {
                "* Stopping 0bf985de-ca0f-11e5-8d45-d05099728dbf (test)": "",
                "+ Removing jail process OK": "",
                "+ Running post-stop OK": "",
                "+ Running pre-stop OK": "",
                "+ Stopping services OK": ""
            }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "jail" : "test",
      "action" : "stopjail"
   },
   "namespace" : "sysadm",
   "id" : "fooid",
   "name" : "iocage"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "stopjail": {
      "test": {
        "INFO": " 0bf985de-ca0f-11e5-8d45-d05099728dbf (test) is already down"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-03 17:18:28 -06:00
Brandon Schneider
a5f05b7162 Added starting iocage jail API call
Websocket is duplicated after REST call, so it actually shows the jail as up since the REST request has already run

REST Request:
-------------------------------
PUT /sysadm/iocage
{
   "action" : "startjail",
   "jail" : "test"
}

REST Response:
-------------------------------
{
    "args": {
        "startjail": {
            "test": {
                "* Starting 0bf985de-ca0f-11e5-8d45-d05099728dbf (test)": "",
                "+ Started (shared IP mode) OK": "",
                "+ Starting services OK": ""
            }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "id" : "fooid",
   "args" : {
      "action" : "startjail",
      "jail" : "test"
   },
   "name" : "iocage"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "startjail": {
      "test": {
        "INFO": " 0bf985de-ca0f-11e5-8d45-d05099728dbf (test) is already up"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-03 17:14:09 -06:00
Brandon Schneider
668aae79df Removed duplicate qDebug include 2016-02-03 16:11:05 -06:00
Kris Moore
f4a61e7d0a Add new API call to set a sysctl
REST Request:
-------------------------------
PUT /sysadm/systemmanager
{
   "value" : "0",
   "sysctl" : "security.jail.mount_devfs_allowed",
   "action" : "setsysctl"
}

REST Response:
-------------------------------
{
    "args": {
        "setsysctl": {
            "response": "security.jail.mount_devfs_allowed: 1 -> 0",
            "sysctl": "security.jail.mount_devfs_allowed",
            "value": "0"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "value" : "0",
      "action" : "setsysctl",
      "sysctl" : "security.jail.mount_devfs_allowed"
   },
   "name" : "systemmanager",
   "namespace" : "sysadm",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "setsysctl": {
      "response": "security.jail.mount_devfs_allowed: 1 -> 0",
      "sysctl": "security.jail.mount_devfs_allowed",
      "value": "0"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-03 13:21:00 -05:00
Kris Moore
fccac94ab6 Add new API call "sysctllist"
Returns the list of all setable sysctl values

REST Request:
-------------------------------
PUT /sysadm/systemmanager
{
   "action" : "sysctllist"
}

REST Response:
-------------------------------
{
    "args": {
        "sysctllist": {
            "compat.ia32.maxdsiz": "536870912",
            "compat.ia32.maxssiz": "67108864",
            "compat.ia32.maxvmem": "0",
            "compat.linux.osname": "Linux",
            "compat.linux.osrelease": "2.6.18",
            "compat.linux.oss_version": "198144",
            "compat.linux32.maxdsiz": "536870912",
            "compat.linux32.maxssiz": "67108864",
            "compat.linux32.maxvmem": "0",
            ....
        }
    }
}

WebSocket Request:
-------------------------------
{
   "name" : "systemmanager",
   "namespace" : "sysadm",
   "id" : "fooid",
   "args" : {
      "action" : "sysctllist"
   }
}

WebSocket Response:
-------------------------------
{
  "args": {
    "sysctllist": {
      "compat.ia32.maxdsiz": "536870912",
      "compat.ia32.maxssiz": "67108864",
      "compat.ia32.maxvmem": "0",
      "compat.linux.osname": "Linux",
      "compat.linux.osrelease": "2.6.18",
      "compat.linux.oss_version": "198144",
      "compat.linux32.maxdsiz": "536870912",
      "compat.linux32.maxssiz": "67108864",
      "compat.linux32.maxvmem": "0",
      ....
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-03 13:09:31 -05:00
Kris Moore
36d2f77d5c Add API call to kill processes on the system
pid = <pid>
signal = {INT|QUIT|ABRT|KILL|ALRM|TERM}

REST Request:
-------------------------------
PUT /sysadm/systemmanager
{
   "signal" : "KILL",
   "pid" : "13939",
   "action" : "killproc"
}

REST Response:
-------------------------------
{
    "args": {
        "killproc": {
            "action": "killproc",
            "pid": "13939",
            "signal": "KILL"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "args" : {
      "pid" : "13939",
      "action" : "killproc",
      "signal" : "KILL"
   },
   "id" : "fooid",
   "name" : "systemmanager"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "killproc": {
      "action": "killproc",
      "pid": "13939",
      "signal": "KILL"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-03 12:45:02 -05:00
Kris Moore
6fd9a689b4 Rename "systeminfo" class -> "systemmanager"
Updated the docs as part of this commit
2016-02-03 12:27:06 -05:00
Ken Moore
37224472cc Make the websocket/rest server distinctions a bit more clear. Now the logs are in websocket/restserver subdirectories, the LP file watchers will resume from the last log point (server-type aware), and a couple other changes for saving server-dependent variables. 2016-02-03 10:12:01 -05:00
Brandon Schneider
b2cde628fb Whoops! Fixed that unintended whitespace. 2016-02-03 01:10:41 -06:00
Brandon Schneider
5a048cbdba Add ip4 to iocage's listjails sysadm API call
REST Request:
-------------------------------
PUT /sysadm/iocage
{
   "action" : "listjails"
}

REST Response:
-------------------------------
{
    "args": {
        "listjails": {
            "0bf985de-ca0f-11e5-8d45-d05099728dbf": {
                "boot": "off",
                "ip4": "-",
                "jid": "-",
                "state": "down",
                "tag": "test",
                "type": "basejail"
            }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "name" : "iocage",
   "id" : "fooid",
   "args" : {
      "action" : "listjails"
   },
   "namespace" : "sysadm"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "listjails": {
      "0bf985de-ca0f-11e5-8d45-d05099728dbf": {
        "boot": "off",
        "ip4": "-",
        "jid": "-",
        "state": "down",
        "tag": "test",
        "type": "basejail"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-03 01:08:31 -06:00
Ken Moore
a9ba0a317c Make sure the event file watcher checks for new watched files on a more regular basis. This will check every time a client asks for the latest logs, and will automatically load/parse any new file which appears. 2016-02-02 14:26:10 -05:00
Ken Moore
7ed1c6ad74 Merge branch 'master' of github.com:pcbsd/sysadm 2016-02-02 14:08:47 -05:00
Ken Moore
407b9a8d5d A bit more cleanup in the server.
Remove the dispatcher-client files (the dispatcher is now an internal system, not an external script).
Clean up some comments and log stuff.
2016-02-02 14:07:25 -05:00
Kris Moore
c4a8e5a701 Add logging of LP events 2016-02-02 14:04:07 -05:00
Ken Moore
8166ef8a79 Cleanup a lot of the logging in the sysadm server. Now the hostinfo log file will clearly list connection time/IP, auth attempts/IP, Dispatches/IP, disconnections/IP. The dispatcher and events systems also properly log activity within their individual log files. 2016-02-02 13:46:23 -05:00
Ken Moore
3c991ebf4c Merge branch 'master' of github.com:pcbsd/sysadm 2016-02-02 13:01:18 -05:00
Ken Moore
470000b08b Get all the threading working properly so teh dispatcher functions correctly now. 2016-02-02 13:00:49 -05:00
Kris Moore
c9e4b2479a Add a new API call to "systeminfo" class, which returns
information about all processes on the system.

The below example was greatly truncated ;)

REST Request:
-------------------------------
PUT /sysadm/systeminfo
{
   "action" : "procinfo"
}

REST Response:
-------------------------------
{
    "args": {
        "procinfo": {
                  "228": {
        "command": "adjkerntz",
        "cpu": "3",
        "nice": "0",
        "pri": "52",
        "res": "1968K",
        "size": "8276K",
        "state": "pause",
        "thr": "1",
        "time": "0:00",
        "username": "root",
        "wcpu": "0.00%"
          }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "namespace" : "sysadm",
   "name" : "systeminfo",
   "args" : {
      "action" : "procinfo"
   }
}

WebSocket Response:
-------------------------------
{
  "args": {
    "procinfo": {
      "228": {
        "command": "adjkerntz",
        "cpu": "3",
        "nice": "0",
        "pri": "52",
        "res": "1968K",
        "size": "8276K",
        "state": "pause",
        "thr": "1",
        "time": "0:00",
        "username": "root",
        "wcpu": "0.00%"
      }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-02 11:06:45 -05:00
dlavigne
922ceaea43 Doc startupdate action. 2016-02-02 09:23:09 -05:00
Ken Moore
be12e18983 Fix up the log function so that now it will actually create/save the log. 2016-02-01 16:51:31 -05:00
Ken Moore
b36958b33a Enable a bit more logging from host/client connections. Still seems to be a problem with the log getting saved to disk though. 2016-02-01 16:37:39 -05:00
Ken Moore
6fd315f8cc Merge branch 'master' of github.com:pcbsd/sysadm 2016-02-01 15:40:59 -05:00
Ken Moore
c8f97a69fe Clean up a fair bit of the server backends. Getting rid of compilation warnings, signal/slot connection issues, etc.. 2016-02-01 15:39:29 -05:00
Kris Moore
bd53bbc29b Add new API class for 'iohyve' along with the initial 'listvms'
API call

REST Request:
-------------------------------
PUT /sysadm/iohyve
{
   "action" : "listvms"
}

REST Response:
-------------------------------
{
    "args": {
        "listvms": {
            "testguest": {
                "description": "February 1, 2016 at 03:11:57 PM EST",
                "rcboot": "NO",
                "running": "NO",
                "vmm": "YES"
            }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "args" : {
      "action" : "listvms"
   },
   "name" : "iohyve",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "listvms": {
      "testguest": {
        "description": "February 1, 2016 at 03:11:57 PM EST",
        "rcboot": "NO",
        "running": "NO",
        "vmm": "YES"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-01 15:23:21 -05:00
Kris Moore
e65a967729 Don't show errors if the service isn't running anymore 2016-02-01 14:46:17 -05:00
Kris Moore
90ee8021d6 Merge branch 'master' of https://github.com/pcbsd/sysadm 2016-02-01 14:37:12 -05:00
Kris Moore
2b0fbcc2a2 Get rid of all the extra compile warnings 2016-02-01 14:36:58 -05:00
Ken Moore
7463d84229 Merge branch 'master' of github.com:pcbsd/sysadm 2016-02-01 14:22:27 -05:00
Ken Moore
87c545230c New API: Change the sysadm dispatcher access to use the built-in dispatcher system now instead of the old shell script. This new API will have the server queue up generic processes/commands as the user needs (main output will return through the event system). The example blow included a single command queue (procID1), as well an an example of chaining a couple commands together as a single process call (procID2).
REST Request:
-------------------------------
PUT /rpc/dispatcher
{
   "action" : "run",
   "procID2" : [
      "echo chainCmd1",
      "echo chainCmd2"
   ],
   "procID1" : "echo sample1"
}

REST Response:
-------------------------------
{
    "args": {
        "started": [
            "procID1",
            "procID2"
        ]
    }
}

WebSocket Request:
-------------------------------
{
   "name" : "dispatcher",
   "namespace" : "rpc",
   "id" : "fooid",
   "args" : {
      "procID1" : "echo sample1",
      "procID2" : [
         "echo chainCmd1",
         "echo chainCmd2"
      ],
      "action" : "run"
   }
}

WebSocket Response:
-------------------------------
{
  "args": {
    "started": [
      "procID1",
      "procID2"
    ]
  },
  "id": "fooid",
  "name": "response",
  "namespace": "rpc"
}
2016-02-01 14:19:25 -05:00
Kris Moore
e9fd60096b Have the api-test.sh script cleanup after itself 2016-02-01 14:18:40 -05:00
Kris Moore
a5c594f3da Cleanup pkg-plist 2016-02-01 14:05:40 -05:00
Kris Moore
dabbc5398c Update API call for lpreserver runreplication to now queue
the action and return right away
2016-02-01 14:04:21 -05:00
Ken Moore
ad2f352a5d Merge branch 'master' of github.com:pcbsd/sysadm 2016-02-01 14:03:07 -05:00
Ken Moore
cabcd0a2b2 Fix up the sysadm.pro file - forgot to clean up the old library subdir in it. 2016-02-01 14:02:37 -05:00
Kris Moore
62465ad03e Add the 'startupdate' API call which allows you to queue a
system update

Valid args:

target : "chbranch/pkgupdate/fbsdupdate/fbsdupdatepkgs/standalone"
branch: "newbranch" - (Only used with chbranch target)
tag: "pkgng-1.6.9" - (Only used with standalone target)

REST Request:
-------------------------------
PUT /sysadm/update
{
   "action" : "startupdate",
   "target" : "pkgupdate"
}

REST Response:
-------------------------------
{
    "args": {
      "startupdate": {
        "queueid": "611c89ae-c43c-11e5-9602-54ee75595566",
        "command": "pc-updatemanager pkgupdate",
        "comment": "Task Queued"
        }
    }
}

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

WebSocket Response:
-------------------------------
{
  "args": {
    "startupdate": {
      "queueid": "611c89ae-c43c-11e5-9602-54ee75595566",
      "command": "pc-updatemanager pkgupdate",
      "comment": "Task Queued"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-02-01 13:21:17 -05:00