summaryrefslogtreecommitdiffstats
path: root/src/dbi.h
Commit message (Collapse)AuthorAgeFilesLines
* src: move og_delete_image to dbi.cAlejandro Sirgo Rica2024-10-041-0/+1
| | | | | | | Move og_delete_image into dbi.c as og_dbi_delete_image to use it from client.c no functional changes.
* ogAdmServer: replace old actualizaConfiguracionOpenGnSys Support Team2024-09-231-0/+1
| | | | | | | | | | | | Reimplement the legacy funcion actualizaConfiguracion with og_update_client_config in src/client.c if disk does not exist, add it, otherwise update disk contents. if partition size, code, filesystem or os is different, reset image id, otherwise update partition usage only. delete partitions that are gone at the end.
* rest: remove scheduler codeOpenGnSys Support Team2024-09-171-0/+1
| | | | Put ogserver into diet, remove this feature, including pending command queue.
* src: infer server IP when it has more than one IP addressOpenGnSys Support Team2024-08-281-1/+2
| | | | | | | | | | | | | | | infer server IP for a given client. User does not have to attach a client to a given server IP anymore through ordenadores.identorno. this simplifies previous work to allow a server to have more than one IP address a0a347068285 ('#1074 rest: set_mode: add support for different ogserver addresses') 44745a3f2287 ('rest: add POST client/server method') POST /client/server is removed, it is only used by ogcli and explicit association between server and client is not required. server_id json attribute is also removed in GET client/info.
* rest: allow repository to have more than one IP addressOpenGnSys Support Team2024-08-211-7/+1
| | | | | | | | | | Repository can have more than one single IP address. * Add alias field to database to represent the extra IPs that are attached to the repository, update schema and add version 9. * Use og_dbi_get_repository_ip() to infer the repository IP address. * Add helper functions (src/repo.c) to build a list of repositories and update rest API to use it.
* dbi: use repository_id field if front-end offers itOpenGnSys Support Team2024-07-191-1/+1
| | | | | | | | | | If repository_id json field is provided, use it to narrow down the image lookup. After this, search use this same repository ID to fetch the IP address. Old web console may not provide repository_id, infer it from the image name. Always set image id field for creation and update.
* rest: add checksum to GET /imagesOpenGnSys Support Team2024-07-051-0/+3
| | | | | Add a new checksum attribute to GET /images, extend database to add a new checksum field to images table.
* rest: Add /center/infoOpenGnSys Support Team2024-06-121-0/+8
| | | | | | | | | | | | Add URI to allow a GET request to obtain info about a center (name, id and comment of the center as of now). To use this uri, simply send a GET request with a json containing the id of the center whose info needs to be consulted: curl -X GET -H "Authorization: $API_KEY" http://127.0.0.1:8888/center/info -d '{"id":1}' based on work from Javier Hernandez.
* rest: Add uri to update folder nameJavier Hernandez2024-02-051-0/+1
| | | | | | Add support to update computer folder name Add support to update room folder name
* rest: Change room field 'group' to 'folder_id'Javier Hernandez2024-01-111-1/+1
| | | | | | | | Change the name of variable 'group', in og_group struct, to 'folder_id'. Change payload field to 'folder_id' These changes are to make code easier to understand.
* rest: Support adding clients inside folderJavier Hernandez2024-01-111-0/+1
| | | | | | Add support for adding clients that are inside a folder. Add new folder_id field, if zero it means computer is not in a folder.
* rest: Add support for adding foldersJavier Hernandez2024-01-091-0/+7
| | | | Add support for adding computer folders and room folders.
* rest: no assumption on description field in create/imagev1.2.5-7OpenGnSys Support Team2023-12-191-1/+2
| | | | | | | | | do not use description field to decide if this is a new image or an update. add og_dbi_get_image() to check if the image exists. If it is not found, then add new image entry to database. update og_dbi_add_image() to update the image.id field.
* client: parse permissions and lastupdate in /image/create response from clientv1.2.5-5OpenGnSys Support Team2023-12-121-1/+3
| | | | | | Use permissions and last update from client. update src/schema.c to add a new database version.
* rest: add GET /room/infoOpenGnSys Support Team2023-11-301-0/+3
| | | | | | | Add GET /room/info to obtain room information, this includes the name, gateway and netmask. curl -X GET -H "Authorization: $API_KEY" http://127.0.0.1:8888/room/info -d '{ "id" : 1 }
* rest: extend /repository/addv1.2.5Jose M. Guisado2023-10-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POST /repository/add checks validity of the repository ip address specified in the request payload. /repository/add can optionally receive a center id parameter inside its request payload. For backward compatibility, the default center id (1) is used if no center is received inside the request payload. POST /repository/add returns a JSON response payload containing relevant fields from the inserted repository. $ curl -D- \ -X POST \ -H "Authorization: a0e9ab768cbe93dab5b1998e952bcdb7" \ --json '{"name": "helloworld", "ip": "192.168.21.21a", "center": 2}' \ localhost:8888/repository/add HTTP/1.1 400 Bad Request Content-Length: 0 $ curl -D- \ -X POST \ -H "Authorization: a0e9ab768cbe93dab5b1998e952bcdb7" \ --json '{"name": "helloworld", "ip": "192.168.21.21a", "center": 2}' \ localhost:8888/repository/add HTTP/1.1 200 OK Content-Length: 54 {"id": 7, "ip": "192.168.21.21", "name": "helloworld"}
* src: move og_repository to dbi.hJose M. Guisado2023-10-101-0/+6
| | | | | | | | | | Move struct og_repository to dbi.h and use field max length for name and ip. Use og_json_parse_string_copy instead of og_json_parse_string to check maximum length against the request payload. Fixes: 86ccc3c2e8377623 ("#915 Add POST /repository/add")
* dbi: add server_id to og_computer structJose M. Guisado2023-08-231-0/+1
| | | | | | | | | Extend og_dbi_get_computer_info to fetch "identorno" column from "ordenadores". "identorno" holds the row id value from the "entornos" table (valid ogserver addresses). Extend og_computer struct with a new field: "server_id" that will store the value of "identorno" column fetched from the database.
* #915 Use the repository id on image listJavier Sánchez Parra2022-06-201-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | API "GET /images" shows the repository ID the image belongs to, instead of the IP. This is a preparative commit to the support of repositories with several IPs. Request GET /images Response 200 OK: { "images": [ { "name": "windows10", "datasize": 0, "size": 626088433, "modified": "Fri Jun 10 12:20:32 2022", "permissions": "744", "software_id": 1, "type": 1, "id": 6, "repo_id": 1 } ], "disk": { "total": 52573995008, "free": 38964637696 } }
* #915 Use the repository id on image creationJavier Sánchez Parra2022-06-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POST /image/create has two modes, image creation and update. You can find more information about the "creation" mode in commit: d2f20d0be06617f421eecca111449d94672695eb On image creation, use the id to identify repositories instead of the IP. This is a preparative commit to the support of repositories with several IPs. On image update, "repository_id" field is not needed because the image already has the repository assigned. This commit maintains backward compatibility with the Web Console (old web interface), because it only use the "update" mode of /image/create. Request POST /create/image: { "clients": [ "192.168.56.11" ], "disk": "1", "partition": "1", "name": "archlinux", "repository_id": 1, "id": "0", "code": "131", "description": "This is a test", "group_id": 0, "center_id": 1 } Response 200 OK
* #915 Extend GET /images function with the repository IPJavier Sánchez Parra2022-05-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This extension adds the field 'repo_ip', indicating which repository has the image. This new field is 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 "repo_ip": "192.168.56.10" } ] }
* #1054 Fix og_legacy_partition code buffer sizeJose M. Guisado2021-07-261-1/+2
| | | | | | | | | | | The "code" member of the og_legacy_partition is used to hold the string of the partition type *name* for legacy parameter strings. Example: par=2*cpt=LINUX-SWAP*sfi=LINUX-SWAP*tam=10000000*ope=0 Problem: Buffer size is smaller than possible values for this member. Fix: Increase buffer size up to the max length defined in the DB for the corresponding column.
* #915 Add /room/add POST methodJavier Sánchez Parra2021-04-201-0/+13
| | | | | | | | | | | | | | | | | | | | | | | Adds POST method to add rooms (labs), required payload parameters are name, netmask and center; any additional attributes are optional. Required JSON: { "center": 0, "name": "classroom10", "netmask": "255.255.255.0" } Full JSON: { "center": 0, "name": "classroom11", "netmask": "255.255.255.0", "group": 0, "location": "First floor", "gateway": "192.168.56.1", "ntp": "hora.cica.es", "dns": "1.1.1.1", "remote": True } This commit also adds unit tests for /room/add POST method.
* #1042 Update database schema automaticallyJose M. Guisado2021-04-201-0/+2
| | | | | | | | | | | | | | | This patch adds database schema management capabilities to ogServer: - ogServer now tracks the version of its database schema, if no version is detected, creates a 'version' table with a single row starting at 0. - ogServer can upgrade its database schema to a newer version if detected. (ogServer ships required SQL commands to do so) If ogServer is unable to upgrade the schema at startup (if needed be) it *will not* start. Defines schema update v1 which upgrades database engine tables of ogServer database (usually named 'ogAdmBD') from myISAM to innoDB.
* #942 Extend GET /images functionRoberto Hueso Gómez2020-10-141-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* #988 remove legacy configurationOpenGnSys Support Team2020-10-071-5/+3
| | | | | 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.
* #941 Use fixed length strings in og_computer and og_dbi_get_computer_infoRoberto Hueso Gómez2020-10-061-10/+15
| | | | | | 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.
* #941 Extend og_dbi_get_computer_info(...)Roberto Hueso Gómez2020-09-221-3/+17
| | | | | | 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.
* #941 pass og_dbi to og_dbi_get_computer_info()OpenGnSys Support Team2020-09-181-1/+2
| | | | Reuse the existing dbi handler, instead of opening a new one.
* #941 move og_dbi_get_computer_info() to dbiOpenGnSys Support Team2020-09-181-0/+11
| | | | Move this function to the dbi.{h,c} files.
* #988 Add DB port option to ogserver.json config fileRoberto Hueso Gómez2020-07-101-0/+1
| | | | | This patch provides functionality to select a database port. It also adds a default IP for the database.
* #971 rename sources folder to srcOpenGnSys Support Team2020-06-261-0/+51
Use the same folder as in ogClient.