summaryrefslogtreecommitdiffstats
path: root/src/rest.c
Commit message (Collapse)AuthorAgeFilesLines
* #915 Test GET /scopesDiego Crespo Quinta2020-12-011-0/+5
| | | | And fix ogserver, report error if GET /scopes have a JSON body.
* #1008 Add support to work with GPT tablesJavier Sánchez Parra2020-11-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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": [...] }
* #942 Add GET /session REST API functionRoberto Hueso Gómez2020-10-201-2/+99
| | | | | | | | | | | | | | | | | | | | | | | 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 } ] }
* #942 Use client's IP as filter in GET /hardwareRoberto Hueso Gómez2020-10-201-17/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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" } ] }
* #942 Add GET /software REST API functionRoberto Hueso Gómez2020-10-161-2/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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" ] }
* #942 Extend GET /images functionRoberto Hueso Gómez2020-10-141-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 } ] }
* #942 Create DB image when calling POST /image/createRoberto Hueso Gómez2020-10-141-6/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add REST POST /client/delete methodRoberto Hueso Gómez2020-10-081-0/+61
| | | | | | | | | | | | | | | 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>
* #988 remove legacy configurationOpenGnSys Support Team2020-10-071-16/+16
| | | | | 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.
* #988 rename og_server_cfg to cfgOpenGnSys Support Team2020-10-071-2/+2
| | | | to avoid clash with existing variable cfg in client.c
* #941 Use fixed length strings in og_computer and og_dbi_get_computer_infoRoberto Hueso Gómez2020-10-061-25/+28
| | | | | | 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.
* #1004 Add GET /imagesJavier Sánchez Parra2020-09-291-0/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 } }
* #942 Add POST /client/add HTTP REST methodRoberto Hueso Gómez2020-09-241-0/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* #1004 Add GET /client/info HTTP REST methodRoberto Hueso Gómez2020-09-221-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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": "" }
* Fix size of og_cmd_get_client_setup() return arrayRoberto Hueso Gómez2020-09-151-1/+2
| | | | The return array needs to store 1 extra element for the disk setup.
* #1004 Add GET /client/setup HTTP REST methodRoberto Hueso Gómez2020-09-141-0/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 } ] }
* #980 do not report busy client if probing is pendingOpenGnSys Support Team2020-08-211-1/+6
| | | | og_client_status() should not report busy when probing is going on.
* #980 Add 'ip' field in GET /scopes requestRoberto Hueso Gómez2020-08-141-4/+4
| | | | | The 'ip' field is added to the json for scopes that have an IP (i.e. computers).
* #980 Select POST /mode clients by ip instead of scope nameRoberto Hueso Gómez2020-08-141-14/+18
| | | | | | 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.
* #998 disable incremental image APIOpenGnSys Support Team2020-08-141-473/+0
| | | | This API is not supported by ogClient yet and it uses the obsolete socket hydra API.
* #980 fix compile warning in og_set_client_modeOpenGnSys Support Team2020-08-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | 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); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* #980 error reporting in setclientmodeOpenGnSys Support Team2020-08-061-1/+3
| | | | Add syslog and use exit()
* #986 Fixs error in 'Advanced Netboot' caused by loss information from ↵Irina Gómez2020-08-051-7/+12
| | | | ogserver process owner (author Roberto Hueso Gómez).
* #980 Change GET and POST /modes URI to /modeRoberto Hueso Gómez2020-08-031-2/+2
| | | | | This patch changes the URI since it is semantically more correct to use the singular.
* #980 Fix POST /modes to use 'setclientmode' scriptRoberto Hueso Gómez2020-07-291-35/+140
| | | | | | | | | | | 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.
* Add GET /hardware REST requestRoberto Hueso Gómez2020-07-081-2/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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" } ] }
* Add POST /modes REST requestRoberto Hueso Gómez2020-07-061-2/+96
| | | | | | | | | | | | | 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
* #990 Use client broadcast address on WoLJavier Sánchez Parra2020-07-031-1/+13
| | | | | | | | | | | | | | | | 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.
* #980 Refactor GET /scopes backendRoberto Hueso Gómez2020-07-021-64/+68
| | | | | | This improves style and fixes some memleaks. Co-authored-by: OpenGnSys Support Team <soporte-og@soleta.eu>
* #980 Fix memleak in og_cmd_get_modes()OpenGnSys Support Team2020-06-301-0/+1
| | | | Missing closedir() call.
* #980 Fix memleak in og_cmd_scope_getRoberto Hueso Gómez2020-06-301-1/+6
| | | | | 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.
* #980 Add GET /modes REST requestRoberto Hueso Gómez2020-06-301-0/+54
| | | | | | | | | | | | | | | | | | | 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" ] }
* #971 rename sources folder to srcOpenGnSys Support Team2020-06-261-0/+3296
Use the same folder as in ogClient.