Commit Graph

143 Commits (efedaa27f1402331911b50f33ca3315a8b888884)
 

Author SHA1 Message Date
Alvaro Neira Ayuso 6f7ba325b8 Modify way to close PID process
With our client disconnection, we hid that the ogClient process will be
closed too. This new way only close the subprocess keeping the ogClient
still working.
2020-02-24 09:35:24 +01:00
Alvaro Neira Ayuso 583057bd69 Use state machine to avoid race condition problems
This patch allows us to control the thread using a state machine. This state
machine controls if the client is busy or not. This new way to control the
threads give us more control for avoiding race condition problems.
2020-02-23 20:04:47 +01:00
OpenGnSys Support Team e5f1db1e47 remove unused getters 2020-02-21 12:58:11 +01:00
OpenGnSys Support Team 3917c3675f pep-0008 cleanup
From pep-0008: Method Names and Instance Variables

Use the function naming rules: lowercase with words separated by underscores as
necessary to improve readability.
2020-02-21 12:57:54 +01:00
Roberto Hueso Gómez 54c0ebf098 Use 'bash' as the default shell for operations scripts 2020-02-09 00:04:43 +01:00
Roberto Hueso Gómez 1fd9f2e07c Use 'with' keyword for file reading
This is applied to /software and /hardware file reads.
We should use 'with' instead of opening and closing a file since this prevents
that files stay open after an exception is raised.
2020-02-05 16:49:42 +01:00
Roberto Hueso Gómez 1c236b4548 Use python f-strings for commands composition 2020-02-05 16:49:37 +01:00
Roberto Hueso Gómez eaba1acbc3 Fix /session execution
The script now reads arguments correctly.
2020-02-05 13:42:20 +01:00
Roberto Hueso Gómez fe4236dcd8 Fix /image/restore execution and response 2020-02-05 13:42:10 +01:00
Roberto Hueso Gómez 680214317e Fix /image/create execution and response 2020-02-05 13:41:54 +01:00
Alvaro Neira Ayuso 834f5cd5c2 Convert main file from dos format to unix format
Change from dos format to unix the whole main file.
2020-02-04 14:23:05 +01:00
Alvaro Neira Ayuso 38056d78a7 (BUG) Rename OG_SCRIPT_PATH to OG_PATH 2020-02-04 14:19:38 +01:00
Roberto Hueso Gómez 2934773d88 Fix /setup execution and response 2020-02-03 10:15:54 +01:00
Roberto Hueso Gómez e96e187825 Fix parseGetConf(...) configuration parsing
This patch also reformats the response to the /refresh command.
2020-02-03 10:15:49 +01:00
OpenGnSys Support Team f86999da0c add space after Content-Length and Content-Type
ogAdmServer needs this space to work fine.
2020-01-28 09:14:13 +01:00
Roberto Hueso Gómez 7196e7198e Add /refresh test
This test covers a correct request.
2020-01-21 17:33:09 +01:00
Roberto Hueso Gómez dabc7ebf83 Change POST /refresh to GET /refresh
This patch changes the HTTP method for /refresh and cleans up the implementation
of the /refresh Linux operator.
2020-01-21 17:33:05 +01:00
Roberto Hueso Gómez ca0a62f9c6 Fix /software command Linux operation
This patch runs the script InventarioSoftware with the right arguments.
This also increases the recv buffer size for the test server.
2020-01-21 17:32:57 +01:00
Roberto Hueso Gómez d401c9ff46 Add /software test
This test covers a correct request.
2020-01-21 17:32:52 +01:00
Roberto Hueso Gómez 9890d60300 Fix /shell/run commands splitting
This patch splits shell commands either with ';' or '\n'.
2020-01-21 17:32:48 +01:00
Roberto Hueso Gómez 96c2ddea2d Fix /hardware command Linux operation
This patch runs the script InventarioHardware with the right arguments.
2020-01-21 17:32:42 +01:00
Roberto Hueso Gómez 434bb272b5 Add /hardware tests
This tests covers a correct request.
2020-01-21 17:32:39 +01:00
Roberto Hueso Gómez 8a9a32fa6b Add test for /run/schedule
This test covers a correct request.
2020-01-19 20:18:14 +01:00
Roberto Hueso Gómez a5ce597196 Add test for non-existent function 2020-01-19 20:18:14 +01:00
Roberto Hueso Gómez 65a5c95cc2 Add test for sequential /shell/run requests
This also fixes test bugs in the cases:
- Malformed json
- No json
2020-01-19 20:18:14 +01:00
Roberto Hueso Gómez 2c5e477dfb Add /probe tests for multiple probes and extra parameter in json 2020-01-19 20:18:14 +01:00
Roberto Hueso Gómez 025e4da5a9 Remove unnecessary variables from test server 2020-01-19 20:18:14 +01:00
Alvaro Neira Ayuso 2e806531a0 (Clean-Up) Rename all the functions in ogRest to new ones more clears 2020-01-19 20:18:14 +01:00
Alvaro Neira Ayuso e39fe2fc52 (Clean-Up) Rename HTTPParser file to restRequest 2020-01-19 20:18:14 +01:00
Alvaro Neira Ayuso 86eb703964 (Clean-Up) Modify restResponse to get the response using constructor and get function 2020-01-19 20:18:07 +01:00
Alvaro Neira Ayuso 8fc251eff3 (Clean-Up) Rename HTTPParser to restRequest 2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso 44a4662fef (Clean-Up) Rename cmd variable to body 2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso 8e54420dfd (Clean-Up) Rename cmd function/variables to use "run" syntax 2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso 51ad896dee (Clean-Up) Rename jsoncmd variable to json_param 2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso 5603a280ef Improve /image/create command response
With this new patch, the image/create command will create a response message
with more information for the server. The new format is:

{"disk" : "1", "partition" : "1", "code" : "1", "id" : "1", "name" : "test",
"repository" : "192.168.2.4", "software" : "xyz"}

"xyz" will be the output saved during the execution of InventarioSoftware in
a specific path.
2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso b5e182f7dd Add Refresh command
This patch allows us to execute refresh command using ogClient. This command
gets all the configuration in our machine and send this information to the
server. The format of the message that ogClient will send to the server will be:

{"disk": "1", "partition_setup": [{"partition": "1", "code": "LINUX",
"filesystem": "NTFS", "size": "498688", "format": "0"}, {"partition": "2",
"code": "LINUX", "filesystem": "NTFS", "size": "498688", "format": "0"},
{"partition": "3", "code": "LINUX", "filesystem": "NTFS", "size": "498688",
"format": "0"}]}
2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso b2fd0b5fff Add image/create command for creating a new image
This patch allows us to use a new support for creating images using ogClient.
ogClient receives from the server a message which json body must be:

{"disk" : "1", "partition" : "1", "code" : "1", "id" : "1", "name" : "test",
"repository" : "192.168.2.4" }

ogClient returns to the server the software inventory executed before
create the image. The message for the server is:

{ "disk" : "0", "partition" : "1", "software" : "xyz" }

    "xyz" will be the output saved during the execution of InventarioSoftware in
    a specific path.
2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso fdd4ba59c7 (BUG) Include client parameter in restore command 2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso 05b1088827 Include License header 2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso d5dca0f756 Add stop command
This patch includes a new support for stopping all the process running on
the ogClient.
2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso 230bdca0ea Execute cmd command using thread
This patch prepares the code for future stop command.
2020-01-19 19:50:44 +01:00
Roberto Hueso Gómez b9c33f2c83 Fix echo check for process_shellrun in ogRest 2020-01-19 19:50:44 +01:00
Roberto Hueso Gómez df98db2c3c Add /shell/run tests
These tests cover:
- Correct request with echo
- Correct request without echo
- No json request
- Malformed json request
2020-01-19 19:50:44 +01:00
Roberto Hueso Gómez 9c34a8e69f Change /probe from GET to POST in ogClient 2020-01-19 19:50:44 +01:00
Roberto Hueso Gómez 3a44e48e4b Adapt client responses to the server's
Header parameters need to be sorted for the test server.
2020-01-19 19:50:44 +01:00
Roberto Hueso Gómez 3c450b0d81 Fix ogClient socket.error typo 2020-01-19 19:50:44 +01:00
Roberto Hueso Gómez 23cc1e6b86 Add /probe tests
These tests cover:
- Correct request
- No json request
- Malformed json request
2020-01-19 19:50:44 +01:00
Roberto Hueso Gómez bb65bd7bf0 Add unit testing basic structure 2020-01-19 19:50:44 +01:00
Roberto Hueso gomez 0c5cbee301 Change ogClient.py encoding from dos to unix 2020-01-19 19:50:44 +01:00
Alvaro Neira Ayuso a9d81adb1f Include echo option for returning shell output
This patch adds a new echo option in /shell/run command. In case that the option
is set up to true, the server will receive in the response a json with the shell
output. Otherwise, the server will receive a response message without json
body.

A side effect of this change is that the command /shell/output/ disapears.
2020-01-19 19:50:44 +01:00