Commit Graph

183 Commits (6bc71b201dafd552a46b8e9ab5ee8f1ee5577c17)

Author SHA1 Message Date
Diego Crespo Quinta aeb53bd351 #915 Test GET /scopes
And fix ogserver, report error if GET /scopes have a JSON body.
2020-12-01 19:29:37 +01:00
Javier Sánchez Parra 0dd3edd27c #1008 Add support to work with GPT tables
ogServer /setup do not support to indicate which table type the user
want to use. It always supposes that the partition table is MBR/MSDOS.

Add ogServer support to work with GPT tables. Add new field table type
to /setup that expects a string with "MSDOS" or "GPT".

Example old JSON:
{
  "clients": [...],
  "disk": "1",
  "cache": "0",
  "cache_size": "0",
  "partition_setup": [...]
}

Example new JSON:
{
  "clients": [...],
  "type": "GPT",
  "disk": "1",
  "cache": "0",
  "cache_size": "0",
  "partition_setup": [...]
}
2020-11-27 12:52:21 +01:00
Roberto Hueso Gómez 7f5ab4ac35 #942 Add GET /session REST API function
This function returns the installed and available OSs in a client to be
booted from.

Request:
GET /session
{
  "client": ["192.168.56.11"]
}

Response
200 OK
{
  "sessions": [
    {
      "disk": 1,
      "name": "Ubuntu 18.04.4 LTS",
      "partition": 1
    }
  ]
}
2020-10-20 15:34:15 +02:00
Roberto Hueso Gómez 2958d23db2 #942 Use client's IP as filter in GET /hardware
This patch uses client's IP instead of scope ID as a filter for the
request.

Request:
GET /hardware
{
  "client": ["192.168.56.11"]
}

Response:
200 OK
{
  "hardware": [
    {
      "description": "BIOS",
      "type": "Tipo de proceso de arranque"
    },
    {
      "description": "QEMU Standard PC (i440FX + PIIX, 1996)  v.pc-i440fx-5.1",
      "type": "Marca y modelo del equipo"
    },
    {
      "description": "Intel Corp. Intel Core Processor (Haswell, no TSX, IBRS) 2GHz v.pc-i440fx-5.1",
      "type": "Microprocesadores"
    },
    {
      "description": "QEMU  2049MiB  (DIMM 0)",
      "type": "Memorias"
    },
    {
      "description": "Red Hat, Inc. Virtio network device  v.00",
      "type": "Tarjetas de Red"
    }
  ]
}
2020-10-20 13:44:44 +02:00
Roberto Hueso Gómez 25c1c16e99 #942 Add GET /software REST API function
This function retrieves a list of the software installed in a specific
disk and partition of a client. This list can be updated by using POST
/software beforehand.

Request:
GET /software
{
  "client": ["192.168.56.11"],
  "disk": 1,
  "partition": 1
}

Response:
200 OK
{
  "software": [
    "grub-pc-bin 2",
    "grub-pc 2.02",
    "grub2-common 2.02",
    "groff-base 1.22.3",
    "gpg 2.2.4",
    "gnupg-utils 2.2.4",
    "gnupg-l10n 2.2.4",
    "gnupg 2.2.4",
    "gnome-video-effects 0.4.3",
    "gnome-user-guide 3.28.2+git20180715",
    "gnome-user-docs 3.28.2+git20180715",
    "gnome-todo-common 3.28.1",
    "gnome-mines 3.28.0",
    "gnome-menus 3.13.3",
    "gnome-mahjongg 3.22.0",
    "gnome-keyring-pkcs11 3.28.0.2",
    "gnome-keyring 3.28.0.2",
    "gnome-initial-setup 3.28.0",
    "accountsservice 0.6.45"
  ]
}
2020-10-16 14:40:33 +02:00
Roberto Hueso Gómez d8b78bb922 #942 Extend GET /images function
This extension removes replaces the field 'filename' for 'name' and adds
new fields (software_id, type and id). These new fields are useful when
restoring an image.

Request:
GET /images

Response:
200 OK
{
  "disk": {
    "free": 37091418112,
    "total": 52573995008
  },
  "images": [
    {
      "datasize": 5939200000,
      "id": 25,
      "modified": "Wed Oct 14 11:49:00 2020",
      "name": "archlinux",
      "permissions": "744",
      "size": 1844222333,
      "software_id": 19,
      "type": 1
    }
  ]
}
2020-10-14 17:31:43 +02:00
Roberto Hueso Gómez d2f20d0be0 #942 Create DB image when calling POST /image/create
In case the DB entry for an image does not exist when POST /image/create
is called, this patch takes care of calling it.

This adds few optional json parameters to the POST /image/create API. If
optional parameters are included then this patch creates the DB entry,
otherwise it just creates the actual image and updates the existing
entry.

Request:
POST /image/create
{
  "clients":["192.168.56.11"],
  "disk":"1",
  "partition":"1",
  "name":"archlinux",
  "repository":"192.168.56.10",
  "id":"24",
  "code":"131",
  "description":"This is a test",
  "group_id":0,
  "center_id":1
}
Response:
200 OK
2020-10-14 12:05:25 +02:00
Roberto Hueso Gómez 24c8b940e6 Add REST POST /client/delete method
This method deletes a client from the DB.

Request:
POST /client/delete
{
  "clients": ["192.168.56.30"]
}

Response:
200 OK

Co-authored-by: Javier Sánchez Parra <jsanchez@soleta.eu>
2020-10-08 12:56:32 +02:00
OpenGnSys Support Team fe1ce97c50 #988 remove legacy configuration
Use og_server_cfg everywhere. Convert port to string to make it easy for the
dbi API since it expects a string. Remove legacy example configuration file.
2020-10-07 11:17:00 +02:00
OpenGnSys Support Team 3cea4bb763 #988 rename og_server_cfg to cfg
to avoid clash with existing variable cfg in client.c
2020-10-07 11:11:04 +02:00
Roberto Hueso Gómez f537dafa77 #941 Use fixed length strings in og_computer and og_dbi_get_computer_info
This patch is a refactor for og_computer and og_dbi_get_computer_info.
It now uses fixed lenght strings to make it more reliable and avoid
errors if the DB is not returning a null ended string.
2020-10-06 16:04:17 +02:00
Javier Sánchez Parra 403e7c323b #1004 Add GET /images
This commit adds GET /images to the ogServer REST API.

This call returns information of all the images in ogServer.

Example response:

{
  "images": [
    {
      "filename": "ubuntu.img",
      "datasize": 2150400000,
      "size": 613476223,
      "modified": "Wed Sep 23 10:37:36 2020",
      "permissions": "744"
    },
    {
      "filename": "test.img",
      "datasize": 2150400000,
      "size": 613236475,
      "modified": "Tue Sep 29 08:57:47 2020",
      "permissions": "744"
    }
  ],
  "disk": {
    "total": 52573995008,
    "free": 39624544256
  }
}
2020-09-29 12:43:07 +02:00
Roberto Hueso Gómez 65a14e56d3 #942 Add POST /client/add HTTP REST method
This method adds a new client. This new client's IP cannot be duplicated
in the DB.

Request:
POST /client/add
{
  "boot": "19pxeADMIN",
  "center": 0,
  "hardware_id": 0,
  "id": 2,
  "ip": "192.168.56.12",
  "livedir": "ogLive",
  "mac": "0800270E6512",
  "maintenance": true,
  "name": "pc12",
  "netdriver": "generic",
  "netiface": "eth1",
  "netmask": "255.255.255.0",
  "remote": false,
  "repo_id": 1,
  "room": 1,
  "serial_number": ""
}

Response:
200 OK
2020-09-24 17:03:56 +02:00
Roberto Hueso Gómez af47a082ad #1004 Add GET /client/info HTTP REST method
This method provides information about a specific client. The request
must contain exactly 1 client's IP.

Request:
GET /client/info
{"client": ["192.168.56.12"]}

Response:
200 OK
{
  "boot": "19pxeADMIN",
  "center": 0,
  "hardware_id": 0,
  "id": 2,
  "ip": "192.168.56.12",
  "livedir": "ogLive",
  "mac": "0800280E6871",
  "maintenance": true,
  "name": "pc12",
  "netdriver": "generic",
  "netiface": "eth1",
  "netmask": "255.255.255.0",
  "remote": false,
  "repo_id": 1,
  "room": 1,
  "serial_number": ""
}
2020-09-22 15:24:38 +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 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 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 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
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
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