Commit Graph

590 Commits (3c395ecea2bb538cf5182a64df503329a0a1cbcc)
 

Author SHA1 Message Date
Roberto Hueso Gómez a8eccba706 Add GET /hardware REST request
This patch implements HTTP GET /hardware request which returns a list of
the hardware associated with a particular computer.

Request: GET /hardware
{
  "scope": {
    "id": 6,
    "type": "computer"
  }
}

Response: 200 OK
{
  "hardware": [
    {
      "type": "Microprocesadores",
      "description": "CPU arch:x86 target:x86_64 cores:4"
    },
    {
      "type": "Memorias",
      "description": "QEMU 4096MiB"
    },
    {
      "type": "Tarjetas gráficas",
      "description": "Red Hat, Inc Virtio GPU"
    },
    {
      "type": "Tarjetas de Red",
      "description": "Intel Corporation 82540EM Gigabit Ethernet Controller
                      QEMU Virtual Machine"
    },
    {
      "type": "Controladores IDE",
      "description": "Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
                      Qemu virtual machine"
    }
  ]
}
2020-07-08 17:08:46 +02:00
Roberto Hueso Gómez 33b0c6f694 Add POST /modes REST request
This patch implements HTTP POST /modes request which can change the mode of any
particular scope.

Request: POST /modes
{
  "scope": {"id": 1,
            "type": "computer"},
  "mode": "pxe"
}
Response: 200 OK
2020-07-06 17:27:33 +02:00
OpenGnSys Support Team 96b02b5424 #971 split wake on lan code
Add wol.c and wol.h that implements WakeOnLan.
2020-07-06 11:14:43 +02:00
Javier Sánchez Parra 06af0c26f4 #990 Use client broadcast address on WoL
Some universities have computers in a different subnet where the
ogServer is, but ogServer WoL functionality only supported to send
packet to its own subnets. This commit solves this.

Now ogServer sends two WoL packets per client, one with the broadcast
address of the interface indicated in the config file, the other with
the broadcast address calculated with the address and netmask of the
client.

To ensure that the second WoL works correctly you must configure
correctly the IP and netmask of the clients. Also, you have to configure
the network of your organization to route WoL packet to the correct
subnet.
2020-07-03 14:11:35 +02:00
OpenGnSys Support Team d6789f1384 #971 linkage error after split
/usr/bin/ld: src/cfg.o:/home/opengnsys/ogServer/src/ogAdmServer.h:25: multiple definition of `servidoradm'; src/ogAdmServer.o:/home/javi/trabajo/soleta/opengnsys/ogServer/src/ogAdmServer.h:25: first defined here
/usr/bin/ld: src/cfg.o:/home/opengnsys/ogServer/src/ogAdmServer.h:26: multiple definition of `puerto'; src/ogAdmServer.o:/home/javi/trabajo/soleta/opengnsys/ogServer/src/ogAdmServer.h:26: first defined here
/usr/bin/ld: src/cfg.o:/home/opengnsys/ogServer/src/ogAdmServer.h:35: multiple definition of `tbsockets'; src/ogAdmServer.o:/home/javi/trabajo/soleta/opengnsys/ogServer/src/ogAdmServer.h:35: first defined here
/usr/bin/ld: src/cfg.o:/home/opengnsys/ogServer/src/ogAdmLib.h:81: multiple definition of `ndebug'; src/ogAdmServer.o:/home/javi/trabajo/soleta/opengnsys/ogServer/src/ogAdmLib.h:81: first defined here
/usr/bin/ld: src/cfg.o:/home/opengnsys/ogServer/src/ogAdmLib.h:80: multiple definition of `szPathFileLog'; src/ogAdmServer.o:/home/javi/trabajo/soleta/opengnsys/ogServer/src/ogAdmLib.h:80: first defined here
/usr/bin/ld: src/cfg.o:/home/opengnsys/ogServer/src/ogAdmLib.h:80: multiple definition of `szPathFileCfg'; src/ogAdmServer.o:/home/javi/trabajo/soleta/opengnsys/ogServer/src/ogAdmLib.h:80: first defined here
2020-07-02 12:34:38 +02:00
Roberto Hueso Gómez f520a57f58 #980 Refactor GET /scopes backend
This improves style and fixes some memleaks.

Co-authored-by: OpenGnSys Support Team <soporte-og@soleta.eu>
2020-07-02 12:14:19 +02:00
OpenGnSys Support Team e54c5ca411 #980 Fix memleak in og_cmd_get_modes()
Missing closedir() call.
2020-06-30 19:40:12 +02:00
Roberto Hueso Gómez 76c0a05f28 #980 Fix memleak in og_cmd_scope_get
If either root or children_root fail to be created but the other one does not,
then reserved memory for the successful one would not be freed.
2020-06-30 16:50:11 +02:00
Roberto Hueso Gómez 608709f620 #980 Add GET /modes REST request
This patch implements HTTP GET /modes request which returns all modes available
for clients:

Request: GET /modes HTTP/1.0
Response: 200 OK
{
  "modes": [
    "pxe",
    "10",
    "13",
    "00unknown",
    "11",
    "19pxeADMIN",
    "12"
  ]
}
2020-06-30 16:49:11 +02:00
OpenGnSys Support Team 37e91b2ebb #971 rename sources folder to src
Use the same folder as in ogClient.
2020-06-26 20:13:42 +02:00
OpenGnSys Support Team 8215e0c6c1 #988 fix json file open error check
if open() fails it returns a negative value.
2020-06-26 20:08:36 +02:00
OpenGnSys Support Team 96090fdec1 #988 use ogserver.json fallback to legacy configuration file
Check for ogserver.json file first, then fall back to legacy.
2020-06-26 20:08:28 +02:00
Roberto Hueso Gómez 866b6c5e37 #988 add json configuration file
New configuration file at /opt/opengnsys/cfg/ogserver.json
2020-06-26 14:55:23 +02:00
Javier Sánchez Parra c0f5d2c206 #980 Add Virtual status
Since version 1.2.0, OpenGnsys supports ogVDI hypervisor OS. This commit
a new status which indicates that clients are running ogVDI.
2020-06-26 14:36:22 +02:00
OpenGnSys Support Team f6f1f18bd8 #971 syslog on error from the initialization path 2020-06-24 14:51:36 +02:00
OpenGnSys Support Team 1a406b2d19 #971 rename ogAdmServer to ogserver in syslog 2020-06-24 14:51:31 +02:00
OpenGnSys Support Team 48de51537e #971 split socket core logic and main files
Extract socket core and main from ogAdmServer file.
2020-06-24 14:43:10 +02:00
OpenGnSys Support Team c46fa3c9e5 #980 coding style cleanup
* Curly braces after function definition
* use _dbi_ infix for function name
2020-06-24 13:34:04 +02:00
Roberto Hueso Gómez 3d253e65bc #980 Add GET /scopes REST request
This patch implements HTTP GET /scopes request which returns the scopes
hierarchy:

Request: HTTP GET /scopes
Response: 200 OK
{
  "scope": [
    {
      "name": "Center 1",
      "type": "center",
      "id": 1,
      "scope": [
        {
          "name": "Room 1",
          "type": "room",
          "id": 1,
          "scope": [
            {
              "name": "Computer 1",
              "type": "computer",
              "id": 1,
              "scope": []
            },
            {
              "name": "Computer 3",
              "type": "computer",
              "id": 2,
              "scope": []
            }
          ]
        }
      ]
    }
  ]
}
2020-06-24 13:31:24 +02:00
Roberto Hueso Gómez 9c8e5c7102 #941 Move OG_COMPUTER_NAME_MAXLEN to dbi.h
This parameter is actually a database related parameter so now it is renamed to
OG_DB_COMPUTER_NAME_MAXLEN.
2020-06-24 11:27:27 +02:00
Javier Sánchez Parra 4397ea8a40 #986 Rename configuration and systemd to ogserver
Step forward to rename all ogAdmServer references to ogServer
2020-06-19 12:59:05 +02:00
OpenGnSys Support Team 333abbe160 #986 rename to ogserver 2020-06-19 11:19:55 +02:00
OpenGnSys Support Team 83937b85f2 #971 move configuration file to cfg folder 2020-06-18 18:52:51 +02:00
OpenGnSys Support Team 04ca20e9f1 #971 split into smaller file
Split ogAdmServer into several files:

* sources/rest.c that implements the server REST API.
* sources/client.c that implements the client REST API.
* sources/json.c that provides a few JSON helpers.
2020-06-18 18:46:48 +02:00
OpenGnSys Support Team 0b9465f783 #985 add COPYING file 2020-06-18 16:48:20 +02:00
OpenGnSys Support Team 122d7a0a32 #985 add .gitignore file 2020-06-17 18:20:32 +02:00
Javier Sánchez Parra 75a8d470bb #981 Add ogAdmServer own systemd unit file
This commit is a step in the direction to remove the old unit file. It
also allow us to move ogAdmServer to its own repo.
2020-06-16 11:48:54 +02:00
OpenGnSys Support Team cf7bbdac90 #971 move ogAdmLib to ogAdmServer
Move remaining ogAdmLib code to ogAdmServer
2020-06-09 13:32:28 +02:00
OpenGnSys Support Team f4e7832656 #971 add str_toupper()
Add new utils.c file and replace old StrToUpper().
2020-06-08 18:31:48 +02:00
OpenGnSys Support Team d8f2e6ba20 #971 do not use og_log()
ogAdmServer uses syslog for logging.
2020-06-08 18:13:05 +02:00
OpenGnSys Support Team 9c8a1390ff #971 replace og_info() by syslog() 2020-06-08 18:10:14 +02:00
OpenGnSys Support Team eba3c79321 #971 replace reservaMemoria() by calloc() 2020-06-08 18:06:25 +02:00
OpenGnSys Support Team 01586d69fb #971 replace liberaMemoria() by free() 2020-06-08 18:03:46 +02:00
Javier Sánchez Parra 3acd4b476f #942 add WoL on commands, procedures and tasks
These cases are different from a basic WoL command because they all use
the queue. The queue standard behaviour waits for the client to be ON
to send orders, but in WoL commands the client is going to be OFF. The
behaviour of WoL must be different.

This commit implements WoL for queued commands, procedures and tasks.
The queue now sends Wol commands without waiting to the client to be ON.
2020-06-02 12:32:36 +02:00
Javier Sánchez Parra 16e45fa83e #980 add procedure auto execution
Users can configure clients to execute a procedure at start.

This commit adapt this functionality to new functions and behaviour
of the ogAdmServer.
2020-06-02 12:32:36 +02:00
Javier Sánchez Parra a63ec0ba7f #942 Fix immediate procedures
New versions of ogAdmServer handle pending commands in a different way.
Instant procedures uses the old way, now unsupported, so we need to
adapt instant procedures.

This commit adapts instant procedures to work with the new pending
commands implementation.
2020-06-02 12:32:36 +02:00
OpenGnSys Support Team 6c7d827904 #942 ignore stale schedules on start 2020-06-02 12:32:36 +02:00
OpenGnSys Support Team 894d8332f4 #942 add command type to POST /schedule/create
Pass idcomando as task_id.
2020-06-02 12:32:36 +02:00
OpenGnSys Support Team 63c4ea5e12 #942 add enum og_schedule_type 2020-06-02 12:32:36 +02:00
OpenGnSys Support Team 8fa9ec647a #942 add type to POST /schedule/create
Moreover, add og_task_schedule_create() function.
2020-06-02 12:32:36 +02:00
OpenGnSys Support Team b31e7ddccf #890 handle 202 Accepted 2020-06-02 12:32:36 +02:00
OpenGnSys Support Team 38057365cb #941 missing og_dbi_close 2020-06-02 12:32:36 +02:00
Javier Sánchez Parra f7292aefab #980 Add action completion 2020-06-02 12:32:36 +02:00
Javier Sánchez Parra 85b345db77 #942 Add tasks to queue 2020-06-02 12:32:36 +02:00
Javier Sánchez Parra 9a85c7a317 #942 Fix task break down
OpenGnsys tasks can contain other tasks. To know if a element of the
task is another task, we need to check if it has the parameter tareaid
(Task ID). The code had a bug and the check was done on an non-existent
parameter

This commit fix this bug changing the non-existent parameter for
tareaid.

Signed-off-by: OpenGnSys Support Team <soporte-og@soleta.eu>
2020-06-02 12:32:36 +02:00
Javier Sánchez Parra e4907cc26a #942 Improve scope break down process
OpenGnsys has a hierarchical scope system to organize clients:

				 +------+
				 |Center|
				 +------+
				 |      |
				 |      |
				 v      v
	    +--------------------+      +----------+
	+-->+Groups of classrooms+----->+Classrooms|
	|   +-+------------------+      +----------+
	|     |                         |          |
	+-----+                         |          |
					v          v
		      +-----------------+          +-------+
		  +-->+Groups of clients+--------->+Clients|
		  |   +-+---------------+          +-------+
		  |     |
		  +-----+

OpenGnsys can send commands and tasks to several clients simultaneously
selecting a scope. For example: send poweroff to center Faculty of
Pharmacy. We had a waterfall process to loop through all members of the
scope and obtain the clients.

This commit simplifies the process with queries that save us to loop
through the members.

Co-authored-by: Irina Gómez <irinagomez@us.es>
2020-06-02 12:32:36 +02:00
Javier Sánchez Parra 87be2ce08d #980 Change initial probe to refresh
We have observed that an initial refresh is needed when the ogClient (in
ogLive mode) connects with the ogAdmServer, to generate the HTML menu.

This commit changes the probe command that was done at the beginning of
the connection to a refresh command. This way the client first generates
his HTML menu and the show to the user the browser with all the correct
information.
2020-06-02 12:32:36 +02:00
Javier Sánchez Parra 130b6ffae8 #942 Add weeks and week days to the schedule API
* add og_schedule_create_weekdays()
* add og_schedule_create_weeks()
* add og_schedule_create_days()
2020-06-02 12:32:36 +02:00
Roberto Hueso Gómez 54c7ca3bb3 #980 Complete API REST for ogClient 2020-06-02 12:32:36 +02:00
OpenGnSys Support Team e81d2309d0 #971 remove obsolete code 2020-06-02 12:32:36 +02:00