summaryrefslogtreecommitdiffstats
path: root/src/dbi.c
Commit message (Collapse)AuthorAgeFilesLines
* src: move og_delete_image to dbi.cAlejandro Sirgo Rica2024-10-041-0/+51
| | | | | | | Move og_delete_image into dbi.c as og_dbi_delete_image to use it from client.c no functional changes.
* src: inet_aton() returns 0 on errorOpenGnSys Support Team2024-10-011-6/+6
| | | | not < 0, fix this.
* ogAdmServer: replace old actualizaConfiguracionOpenGnSys Support Team2024-09-231-0/+61
| | | | | | | | | | | | 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.
* src: fallback to use first repository/server foundv1.2.5-19OpenGnSys Support Team2024-09-041-12/+30
| | | | | | use first repository/server in the list in case no specific repository/server is found in the same network, this is a fallback that works if repository/server is reachable through gateway.
* src: infer server IP when it has more than one IP addressOpenGnSys Support Team2024-08-281-2/+85
| | | | | | | | | | | | | | | 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-10/+64
| | | | | | | | | | 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-10/+15
| | | | | | | | | | 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 /center/infoOpenGnSys Support Team2024-06-121-0/+33
| | | | | | | | | | | | 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: room in folder can't be updatedJavier Hernandez2024-02-081-1/+1
| | | | change code to make possible to update rooms that are inside folders
* rest: no assumption on description field in create/imagev1.2.5-7OpenGnSys Support Team2023-12-191-19/+29
| | | | | | | | | 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.
* dbi: og_computer_get_info() uses netmask field in 'room' tablev1.2.5-4OpenGnSys Support Team2023-11-301-2/+2
| | | | | | | | | | | netmask field in 'computers' table is never used, but ogcli still displays it through: # ogcli list client --client-ip 1.2.3.4 and it shows '0' or incorrect netmask (ogCP hardcodes this field). Update SQL query to fetch the room.netmask instead.
* rest: add GET /room/infoOpenGnSys Support Team2023-11-301-0/+37
| | | | | | | 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 }
* dbi: add server_id to og_computer structJose M. Guisado2023-08-231-0/+2
| | | | | | | | | 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 creationJavier Sánchez Parra2022-06-201-43/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Set repository on image creationJavier Sánchez Parra2022-05-261-2/+43
| | | | | Assign to the image the repository indicated in the JSON body instead of a default one.
* #941 Free dbi_inst when og_dbi_open fails to connectJose M. Guisado2021-06-011-0/+1
| | | | | | | | | | When trying to open a connection to a database, an instance of libdbi is created before any connection attempt. If connection is unsuccessful then the og_dbi struct is freed but not the libdbi instance member, thus leaking its memory. Use libdbi dbi_shutdown_r to shutdown libdbi instance member before freeing og_dbi struct inside og_dbi_open.
* ogServer is AGPLv3+OpenGnSys Support Team2021-05-041-2/+3
| | | | Update license header in files.
* #915 Avoid duplicate db entries in /create/imagev1.2.0Jose M. Guisado2021-04-061-0/+18
| | | | | | | | | | /create/image adds an entry to the database for the given partition image created when payload contains a "description" attribute. This insertion into the database is lacking a check for duplicates, which are not supported for the images table. Add a prior duplicate check before inserting. Exit with -1 code if an image with the same name is found.
* #941 Fix get computer center idJavier Sánchez Parra2020-10-271-0/+1
| | | | | | | | | Creating a software profile failed. ogServer obtained the information of a computer without center id because commit cbd9421 removed it unintentionally, making all computer had center id equal to zero. This commit restores the gathering of computer center id from the database.
* #942 Create DB image when calling POST /image/createRoberto Hueso Gómez2020-10-141-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+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-22/+19
| | | | | | 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-8/+45
| | | | | | 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-11/+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/+54
| | | | 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/+45
Use the same folder as in ogClient.