Commit Graph

561 Commits (e62a55ae37bfdb2aba86696dde5bc27555dd5cf8)
 

Author SHA1 Message Date
Roberto Hueso Gómez cbd9421bae #941 Extend og_dbi_get_computer_info(...)
For the strings in og_computer we do not need to know the max size in
advance but instead we need to free up memmory using
og_dbi_free_computer_info(...) function.
2020-09-22 15:20:57 +02:00
OpenGnSys Support Team d7e2022bdd #941 pass og_dbi to og_dbi_get_computer_info()
Reuse the existing dbi handler, instead of opening a new one.
2020-09-18 15:38:16 +02:00
OpenGnSys Support Team 3cb98c7187 #941 move og_dbi_get_computer_info() to dbi
Move this function to the dbi.{h,c} files.
2020-09-18 15:34:30 +02:00
OpenGnSys Support Team 540cfb597f #988 fix compilation warning in json configuration file to legacy
src/cfg.c: In function ‘from_json_to_legacy’:
src/cfg.c:161:2: warning: format not a string literal and no format arguments [-Wformat-security]
2020-09-15 20:16:12 +02:00
Roberto Hueso Gómez ff71a2ad6e Fix size of og_cmd_get_client_setup() return array
The return array needs to store 1 extra element for the disk setup.
2020-09-15 15:00:17 +02:00
Roberto Hueso Gómez b59ff7c604 #1004 Add GET /client/setup HTTP REST method
This method provides the partitions setup for a specific client. The
request must contain exactly 1 client's IP.

Request:
GET /client/setup
{'client': ['192.168.56.12']}

Response:
200 OK
{
  "partitions": [
    {
      "disk": 1,
      "partition": 0,
      "code": 0,
      "size": 20971520,
      "used_size": 0,
      "filesystem": 0,
      "os": 0,
      "image": 0,
      "software": 0
    }
  ]
}
2020-09-14 12:13:06 +02:00
OpenGnSys Support Team 280e23f8ee #971 replace reservaMemoria() by calloc()
reservaMemoria() is only used once, remove it.
2020-09-10 16:24:18 +02:00
OpenGnSys Support Team 7dbe1a73a0 #971 remove unused functions in ogAdmLib
Remove unused legacy code.
2020-09-10 16:20:02 +02:00
Javier Sánchez Parra 0efc182c9b #1004 Handle new fields in /image/create response
ogClient now includes more information regarding the new image. This patch
modifies ogServer to support new elements sent in ogClient /image/create
response and store them in the database.

Example of new /image/create response:

{
  "disk": "1",
  "partition": "1",
  "code": "131",
  "id": "1",
  "name": "ubuntu",
  "repository": "192.168.56.10",
  "software": "Ubuntu 18.04.5 LTS \naccountsservice 0.6.45\n...",
  "clonator": "PARTCLONE",
  "compressor": "LZOP",
  "filesystem": "EXTFS",
  "datasize": 2100000
}

New fields are "clonator", "compressor", "filesystem" and "datasize".
2020-09-10 14:48:26 +02:00
OpenGnSys Support Team a1aaad46fb #980 do not report busy client if probing is pending
og_client_status() should not report busy when probing is going on.
2020-08-21 18:10:39 +02:00
Roberto Hueso Gómez 91c3a285ba #980 Add 'ip' field in GET /scopes request
The 'ip' field is added to the json for scopes that have an IP (i.e.
computers).
2020-08-14 12:55:18 +02:00
Roberto Hueso Gómez 4ae9903dc3 #980 Select POST /mode clients by ip instead of scope name
This patch selects clients whose modes need to be changed in the current
request. This patch makes POST /mode consistent with the rest of the
REST API where clients are selected and filtered by ip.
2020-08-14 12:50:24 +02:00
OpenGnSys Support Team ca545d39bd #998 disable incremental image API
This API is not supported by ogClient yet and it uses the obsolete socket hydra API.
2020-08-14 12:48:21 +02:00
OpenGnSys Support Team 060e31cb53 #990 add wol_socket_open()
Add wol_socket_open() to initialize the WoL socket
2020-08-06 13:39:46 +02:00
OpenGnSys Support Team 1855b68af3 #980 fix compile warning in og_set_client_mode
CC       src/rest.o
src/rest.c: In function ‘og_cmd_post_modes.isra.27’:
src/rest.c:966:4: warning: ‘%s’ directive output may be truncated writing up to 4096 bytes into a region of size between 3018 and 4041 -Wformat-truncation=]
    "MODE_FILE='%s'\nMAC='%s'\nDATA='%s'\n"
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/rest.c:1085:7:
       template_name, scope_name);
       ~~~~~~~~~~~~~
src/rest.c:967:33: note: format string is defined here
    "MODE='PERM'\nTEMPLATE_NAME='%s'",
                                 ^~
src/rest.c:965:2: note: ‘snprintf’ output 57 or more bytes (assuming 5176) into a destination of size 4096
  snprintf(cmd_params, sizeof(cmd_params),
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "MODE_FILE='%s'\nMAC='%s'\nDATA='%s'\n"
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "MODE='PERM'\nTEMPLATE_NAME='%s'",
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    mode, mac, params, template_name);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-08-06 10:45:03 +02:00
OpenGnSys Support Team 5286c93d69 #980 error reporting in setclientmode
Add syslog and use exit()
2020-08-06 10:36:44 +02:00
Irina Gomez 139633a334 #986 Fixs error in 'Advanced Netboot' caused by loss information from ogserver process owner (author Roberto Hueso Gómez). 2020-08-05 14:21:16 +02:00
Roberto Hueso Gómez b8a509b1dd #980 Change GET and POST /modes URI to /mode
This patch changes the URI since it is semantically more correct to use
the singular.
2020-08-03 13:14:44 +02:00
Roberto Hueso Gómez 532b0819c4 #980 Fix POST /modes to use 'setclientmode' script
Now POST /modes does not only write to the database, it also uses the
external bash script 'setclientmode' to generate configured PXE
templates for each machine.

NOTE: This fix requires that room and computer names are unique in the
OpenGnsys DB. This behaviour is inherited from the previous
'setclientmode' script but, eventually, it should be replaced for an
actual scope selector.
2020-07-29 20:17:34 +02:00
Roberto Hueso Gómez a8e5b844c5 #988 Check DB port size is in [0, UINT16_MAX]
Max port number is UINT16_MAX, so this checks whether this config
parameter is in the correct range.
2020-07-15 12:47:45 +02:00
Roberto Hueso Gómez 0631b0e8e6 #988 Add DB port option to ogserver.json config file
This patch provides functionality to select a database port. It also adds a
default IP for the database.
2020-07-10 16:21:58 +02:00
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