Commit Graph

9 Commits (bc787a9a68de88cd534f8cb8541ecec0861a2053)

Author SHA1 Message Date
OpenGnSys Support Team ee09056908 client: parse permissions and lastupdate in /image/create response from client
Use permissions and last update from client.

update src/schema.c to add a new database version.
2023-12-12 17:02:44 +01:00
Jose M. Guisado 35a3b0a1a3 schema: fix bug when og_dbi_open cannot open a connection
When og_dbi_open cannot open a connection during schema update, then
ogServer crashes.

og_dbi_open returns NULL when it cannot open a DB connection.

Do not use dbi variable if og_dbi_open is unable to open a DB
connection.

Add syslog message when database schema couldn't be updated.
2023-09-28 10:07:07 +02:00
Javier Sánchez Parra a0a3470682 #1074 rest: set_mode: add support for different ogserver addresses
Add foreign key "identornos" from table "entornos" to table
"ordenadores".

A row in table "entornos" represent a valid ogServer address.
Multiple ogServer valid addresses can exist when running several
instances or a single ogServer instance is exposed to different networks.

Can't delete rows in "entornos" table nor update their id (primary
key) if the row has any associated clients ({ON UPDATE/ON DELETE} RESTRICT).

Allows assigning different but valid ogServer IPs to clients.
Enabling support for multiple instances of ogServer (e.g: load balancing) or
exposing a single ogServer instance to different networks (e.g: VLAN).

Look up for the valid ogServer IP of a given client when changing a
client's mode (og_set_client_mode).

Determines valid ogServer IP using a JOIN statement.

	JOIN entornos USING(identorno)

Reuses the fetched ip using a statement variable.

	@serverip:=entornos.ipserveradm

For example, for a two VLAN setup:

	vlan1 ogserver: 192.168.56.10
	vlan2 ogserver: 192.168.57.10

The "entornos" table should look like:

	identorno       ipserveradm             ...
	---------       -----------             ...
	1               192.168.56.10           ...
	2               192.168.57.10           ...

And computers in the "ordenadores" table might look like:

	idordenador     identorno       ...
	----------      ---------       ...
	1               1               ...
	2               1               ...
	3               2               ...
	4               2               ...
	...             ...             ...

Additionally, splits the SQL query for better readability.

Co-authored-by: Jose Guisado <jguisado@soleta.eu>
2022-06-01 08:51:19 +02:00
OpenGnSys Support Team ee2f909dbe #1042 fix multiple definition of ogconfig
/usr/bin/ld: src/schema.o:/home/soleta/opengnsys/ogServer/src/schema.c:50: multiple definition of `ogconfig'; src/main.o:/home/soleta/opengnsys/ogServer/src/main.c:31: first defined here
 collect2: error: ld returned 1 exit status
 make: *** [Makefile:411: ogserver] Error 1
2021-05-27 12:22:49 +02:00
Javier Sánchez Parra a00eccc767 #1037 Simplify database update v3 code
Simplify database update v3, no need for iteration.

Fixes: 12d8fff (#1037 Add disk type)
2021-05-27 11:02:42 +02:00
Javier Sánchez Parra 12d8fff3ef #1037 Add disk type
Add ogServer support for parsing and storing in the DB disk type data
from ogClient refresh response.

See also commits with #1037 in ogClient and WebConsole repo.
2021-05-26 17:19:30 +02:00
OpenGnSys Support Team a7cce8d442 ogServer is AGPLv3+
Update license header in files.
2021-05-04 17:59:11 +02:00
Jose M. Guisado 8775c06d36 #1042 Add schema version 2
Add foreign keys (version 1 introduced innoDB as default db engine)
allowing cascade deletions for some tables:

	- perfilessoft_softwares

	If a software profile or a software component is deleted, the
	corresponding row in this table will be deleted too.

	- ordenadores_particiones

	If a computer or a partition is deleted from the DB, delete the
	corresponding row inside this table.

	- aulas

	If the center the room is in is removed, delete the room too.

	- ordenadores

	If the room in which a computer is in is removed, the computer
	will be deleted accordingly.

We should take into account that this schema superseeds some code
regarding deletions inside WebConsole that probably are not needed any
more, at least for the tables mentioned.
(See admin/WebConsole/gestores/relaciones/*.php in OpenGnsys repo)
2021-04-28 12:10:27 +02:00
Jose M. Guisado 7d74d42c79 #1042 Update database schema automatically
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.
2021-04-20 11:27:21 +02:00