Commit Graph

15 Commits (30d6af09d5db938612b6ea803c5f88ea531cf7b7)

Author SHA1 Message Date
Javier Sánchez Parra 30d6af09d5 #915 Use the repository id on image list
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
  }
}
2022-06-20 10:41:50 +02:00
Javier Sánchez Parra 52a38d3e57 #915 Use the repository id on image creation
POST /image/create has two modes, image creation and update. You can
find more information about the "creation" mode in commit:
d2f20d0be0

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
2022-06-20 10:41:32 +02:00
Javier Sánchez Parra b86b6e1443 #915 Extend GET /images function with the repository IP
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"
    }
  ]
}
2022-05-26 15:15:52 +02:00
Jose M. Guisado 047677bb4b #1054 Fix og_legacy_partition code buffer size
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.
2021-07-26 16:58:40 +02:00
Javier Sánchez Parra 29e7641e91 #915 Add /room/add POST method
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.
2021-04-20 12:05:42 +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
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
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
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
Roberto Hueso Gómez cbd9421bae #941 Extend og_dbi_get_computer_info(...)
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.
2020-09-22 15:20:57 +02:00
OpenGnSys Support Team d7e2022bdd #941 pass og_dbi to og_dbi_get_computer_info()
Reuse the existing dbi handler, instead of opening a new one.
2020-09-18 15:38:16 +02:00
OpenGnSys Support Team 3cb98c7187 #941 move og_dbi_get_computer_info() to dbi
Move this function to the dbi.{h,c} files.
2020-09-18 15:34:30 +02:00
Roberto Hueso Gómez 0631b0e8e6 #988 Add DB port option to ogserver.json config file
This patch provides functionality to select a database port. It also adds a
default IP for the database.
2020-07-10 16:21:58 +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