Commit Graph

25 Commits (38076677c7113bae4b50f7989ec45ebf521eae23)

Author SHA1 Message Date
OpenGnSys Support Team b0d18cd887 #915 remove old REST API from run-test.sh 2020-10-23 13:27:36 +02:00
OpenGnSys Support Team 83b242ce58 #942 Add support for scheduled tasks and commands
This field needs to be at least 31 bits long to store all days in a month.
Other fields are also set to 32 bits because unsigned int length can change
depending on the system.

We also need to support the three ways that the ogAdmAgent and the WebConsole
have to create an schedule. At first, we only supported the easiest
method:
	* Hour, day, month and year -> 10:00, 28, february, 2020

This commit adds these two ways to create an schedule:
	* Hour, week day, month and year -> 10:00, Monday, february,
	  2020
	* Hour, week, month and year -> 10:00, first week, february,
	  2020
2020-06-02 12:32:36 +02:00
OpenGnSys Support Team 96b9bb865c #942 Add /run/task to API REST
This patch adds a new command to the REST API to run tasks.

A task (tarea) is composed of procedures (procedimientos), each procedure is
composed of commands (acciones) that are represented through legacy sockHidra
parameters in the database.

This results in iterating over the task (tareas_acciones) table in the
database to fetch the list of procedures (procedimientos).

Then, this iterates over the list commands that compose a procedures
represented through procedimientos_acciones table.

Finally, this builds and sends the sockHidra legacy message for the client.

This patch includes an implementation of the Linux linked list.
2020-06-02 12:32:36 +02:00
Roberto Hueso Gómez 6c91d147c1 #915 Rename POST /image/setup for /setup in REST API
This patch renames the setup command to avoid semantic confusion.
2019-11-13 14:15:43 +01:00
Roberto Hueso Gómez 2f7e9da5ab #915 Add POST "run/schedule" command to REST API in ogAdmServer
This patch implements the command "run/schedule" that kicks in pending commands
execution.

Request:

    POST /run/schedule
    {
        "clients": ["192.168.56.11"]
    }

Reply:
    200 OK

This patch also adds a simple test to cover correction of the command.
2019-10-25 14:12:09 +02:00
Javier Sánchez Parra 90672e4a25 #915 Add test for POST /image/restore/incremental command
This test covers correction of the command.
2019-10-11 11:57:08 +02:00
Roberto Hueso Gómez 45f414e32c #915 Add test for POST "image/create/incremental" command
This test covers correction of the command.
2019-10-11 11:57:08 +02:00
Javier Sánchez Parra 17eeac1284 #915 Add test for POST /image/restore/basic command
This test covers correction of the command.
2019-10-09 15:27:59 +02:00
Javier Sánchez Parra 74061887ee #915 Add test for POST /image/create/basic command
This test covers correction of the command.
2019-10-08 14:01:14 +02:00
Roberto Hueso Gómez ad4d4bdbbe Add test for POST /image/create command
This test covers correction of the command.
2019-10-07 11:15:28 +02:00
Roberto Hueso Gómez 1dde02e1ab #915: Add POST /image/restore command to REST API in ogAdmServer
This patch implements the command "image/create" that creates an image
in a client.

	Request:
		POST /image/restore
		{ "clients" : [ "192.168.56.11" ], "disk" : "1", "partition" : "1", "name" : "test", "repository" : "192.168.56.10", "type" : "UNICAST", "filesystem": "1", "image_id": "1"}
	Reply:
		200 OK
2019-10-01 12:56:10 +02:00
Roberto Hueso Gómez 1a8ada191f #915: Add POST /image/create command to REST API in ogAdmServer
This patch implements the command "image/create" that creates an image
in a client.

    Request:
            POST /image/create
	    { "clients" : [ "192.168.2.1" ], "disk" : "1", "partition" : "1", "code" : "1", "id" : "1", "name" : "test", "repository" : "192.168.2.2" }
    Reply:
            200 OK
2019-10-01 12:56:10 +02:00
OpenGnSys Support Team b4a9fddf30 #915 add POST software command to REST API in ogAdmServer
This patch implements the command "software" that fetches the software
configuration from the clients.

Request:
        POST /software
        {"clients" : [ "192.168.2.1", "192.168.2.2" ]}
Reply:
        200 OK

This allows to refresh the software inventory from clients.
2019-07-03 02:56:07 +02:00
OpenGnSys Support Team 6b30dbc65c #915 add POST hardware command to REST API in ogAdmServer
This patch implements the command "hardware" that fetches the hardware
configuration from the clients.

Request:
	POST /hardware
        {"clients" : [ "192.168.2.1", "192.168.2.2" ]}
Reply:
        200 OK

This allows to refresh the hardware inventory from clients.
2019-07-03 02:56:07 +02:00
OpenGnSys Support Team fd305405b7 #915 add support for HTTP Authorization
Add APITOKEN= field to ogAdmServer.cfg to specify the REST API key.
2019-06-24 13:42:25 +02:00
OpenGnSys Support Team 17f55b41c3 #915 add POST refresh command to REST API in ogAdmServer
Forces client to fetch and run any pending command from the server,
reload its local configuration file and re-start its selection menu.

curl -X POST http://127.0.0.1:8888/refresh -d @refresh.json

    Request
            POST /refresh
            {"clients": [ "192.168.2.1" ] }
    Reply:
            200 OK
2019-05-30 15:32:24 +02:00
OpenGnSys Support Team 1e6c889256 #915 add POST stop command to REST API in ogAdmServer
Stop the menu selection on client (through POST method):

curl -X POST http://127.0.0.1:8888/stop -d @stop.json

Request
	POST /stop
	{"clients": [ "192.168.2.1" ] }
Reply:
	200 OK
2019-05-30 15:32:22 +02:00
OpenGnSys Support Team 5f0191d73f #915 add POST reboot command to REST API in ogAdmServer
Reboot a client (through POST method):

        curl -X POST http://127.0.0.1:8888/reboot -d @reboot.json

Request
        POST /reboot
        {"clients": [ "192.168.2.1" ] }
Reply:
        200 OK
2019-05-30 15:32:18 +02:00
OpenGnSys Support Team 23fed47639 #915 add POST poweroff command to REST API in ogAdmServer
Power off a client (through POST method):

        curl -X POST http://127.0.0.1:8888/poweroff -d @poweroff.json

Request
        POST /poweroff
        {"clients": [ "192.168.2.1" ] }
Reply:
        200 OK
2019-05-30 15:32:01 +02:00
OpenGnSys Support Team 7ab5f0cbfb #915 add POST session command to REST API in ogAdmServer
Start a session on client (through POST method):

        curl -X POST http://127.0.0.1:8888/session -d @session.json

Request
        POST /session
        {"clients": [ "192.168.2.1" ] }
Reply:
        200 OK
2019-05-27 13:03:05 +02:00
OpenGnSys Support Team c6020f2ad1 #915 add POST shell/output command to REST API in ogAdmServer
Fetching result from run command on client (through GET method):

        curl -X POST http://127.0.0.1:8888/shell/output -d @post_shell_output.json

Request
        POST /shell/output
        {"clients": [ "192.168.2.1" ] }
Reply:
        200 OK
	{"clients": [ { "addr" : "192.168.2.1", "output" : "..." } ] }
2019-05-27 13:03:00 +02:00
OpenGnSys Support Team 7e4e5b5e08 #915 add run command to REST API in ogAdmServer
Run command on client (through POST method):

	curl -X POST http://127.0.0.1:8888/shell/run -d @post_run.json

Request
	POST /shell/run
	{"clients": [ "192.168.2.1", "192.168.2.2" ], "run" : "ls" }
Reply:
	200 OK
2019-05-27 13:02:57 +02:00
OpenGnSys Support Team 5797e0b199 #915 add wol command to REST API in ogAdmServer
Send Wake-On-Lan to clients (through POST method):

Request:
	curl -X POST http://127.0.0.1:8888/wol
	{ "type" : "unicast", "clients" : [ { "addr" : "192.168.2.1", "mac" : "00AABBCCDD01" } ] }
Reply:
	200 OK
2019-05-27 13:02:52 +02:00
OpenGnSys Support Team 7b6fcdbc62 #915 add clients command to REST API in ogAdmServer
Request for existing clients:

	curl -X GET http://127.0.0.1:8888/clients

Request:
	GET /clients
Reply:
	200 OK
	{"clients": [ { "addr" : "192.168.2.1", "state" : "OPG" }, { "addr" : "192.168.2.2", "state" : "OFF" }]}
2019-05-27 13:02:45 +02:00
OpenGnSys Support Team 95e6520c4f #915 add initial REST API for ogAdmServer
Add REST API for ogAdmServer, this API is exposed through port 8888 on
the system that runs the ogAdmServer. The body of the HTTP message is
expressed in JSON format.

This patch implements the command "clients" that maps to the existing
legacy "Sondeo" command, that is used by the web interface to poll
refresh the client state.

This patch also includes an initial test infrastructure using 'curl' to
send commands to the new REST API.

Request:
	POST /clients
	{"clients" : [ "192.168.2.1", "192.168.2.2" ]}
Reply:
	200 OK

This allows to refresh the status of the list of clients.
2019-05-27 13:02:37 +02:00