Commit Graph

44 Commits (730d42a872ca48d64d10f3a9c0b668795300dfa0)

Author SHA1 Message Date
OpenGnSys Support Team 730d42a872 src: handle refresh response after image restore
use context to store disk, partition and image id that is requested to client
and handle refresh response from ogclient to update database, otherwise, an
explicit refresh from web frontend is required.
2025-02-13 13:24:42 +01:00
Alejandro Sirgo Rica 6a63218f85 rest: add POST oglive/default
Remove 'is_default' column from 'lives' database table and add
column 'priority' of type INT. This new value can store a priority
value but the actual design only stores 1 or 0.

Update GET oglive/list to use the new 'priority' database value.

Add POST oglive/default.
Set the database column 'priority' to 1 if the new default
exists in the database. Set the others to priority 0.
Modify legacy ogliveinfo.json if the new default coresponds to a
live not found in the database. Edit the field 'default' of the
file's json.
2024-12-10 16:33:49 +01:00
Alejandro Sirgo Rica 4103945785 rest: add POST /oglive/add and POST /oglive/delete
Add API to register and delete oglives from the database.

POST /oglive/add
Register an installed oglive in the database, if the entry already
exists update its creation date.

Example request payload:
{"name": "ogrelive-6.1.0-26"}

POST /oglive/delete
Remove an installed oglive from the database

Example request payload:
{"name": "ogrelive-6.1.0-26"}
2024-11-11 12:29:11 +01:00
OpenGnSys Support Team 479998d76f src: add last client command context and use it for image creation
Add last client command context that is used in the request to client.

This allows to remove the stub image entry in the database in case that the
image creation fails.
2024-10-31 01:18:57 +01:00
OpenGnSys Support Team 16cc22df3e src: place last client command information in struct
just a preparation, no functional changes are intended.
2024-10-31 00:37:03 +01:00
OpenGnSys Support Team 760a82af2c rest: remove unused probe
unused since 87be2ce08
2024-09-30 14:41:49 +02:00
OpenGnSys Support Team ad31c3832d rest: remove scheduler code
Put ogserver into diet, remove this feature, including pending command queue.
2024-09-17 17:46:07 +02:00
Alejandro Sirgo Rica e3a73a504f rest: add GET /efi
Add GET /efi request to obtain information about the client's
boot entries.

Field inside the /refresh payload
'efi': {
  'entries': [
    {
      "order": 0,
      "name": "Boot0000",
      "active": false,
      "description": "grub"
    },
    {
      "order": 1,
      "name": "Boot0001",
      "active": true,
      "description": "UEFI: PXE IP4 Realtek PCIe GBE Family Controller"
    }
  ]
}

If the client is not a EFI system it won't add the 'efi' field.
If an entry is not in the boot order it won't have the 'order' field.

GET /efi resquest payload structure:
{
    'clients': ['10.141.10.21', '10.141.10.22']
}

GET /efi response's structure:
{
  'clients': [
    {
      'ip': '10.141.10.21',
      'entries': [
        {
          "order": 0,
          "name": "Boot0000",
          "active": false,
          "description": "grub"
        },
        {
          "order": 1,
          "name": "Boot0001",
          "active": true,
          "description": "UEFI: PXE IP4 Realtek PCIe GBE Family Controller"
        }
      ]
    },
    {
      'ip': '10.141.10.22',
      'entries': []
    }
  ]
}

The client with ip 10.141.10.22 is a BIOS system.

If an entry does not appear in the boot order it won't have the
'order' field.
2024-09-11 14:09:51 +02:00
Alejandro Sirgo Rica d383ff1c1a rest: add cache/fetch
Add POST cache/fetch request to request download of images in
the client's cache.

Resquest payload structure:
{
    'clients': ['10.141.10.21', '10.141.10.22']
    'image': 'windows.img'
    'type': 'TIPTORRENT'
    'repository': '12.141.10.2'
}

The clients listed in the 'clients' field will receive a
cache/fetch POST request with the payload received by the server
without the 'clients' field.
The clients respond with the contents of their cache so the server
can update the database.
2024-08-09 10:47:18 +02:00
OpenGnSys Support Team e9a8f467f1 rest: add GET,POST /image/restrict
Allow to restrict image to scope:

 POST /image/restrict
 { "image" : 49, "scopes" : [ 1,3 ] }

 response: 200 OK

This restricts image with ID 49 to scopes 1 and 3.

You can also fetch the current list of restrictions:

 GET /image/restrict
 { "image" : 49 }

 response: 200 OK

 { "image" : 49, "scopes" : [ 1,3 ] }

Existing limitations in this interface:

 - Only restriction of image to center is possible at this moment.
 - This is only used by ogCP to validate if this is possible, no existing code
   in the ogserver uses this to restrict POST image/restore.

This is a usability feature.
2024-07-17 17:15:27 +02:00
Alejandro Sirgo Rica c0ca4b8cbc rest: add shell/list
Add GET shell/list request to obtain the list of scripts available
in /opt/opengnsys/client/shell

Resquest payload structure: no paylaod

Response's structure:
{
    'scripts': ['script', 'script2']
}
2024-06-25 13:50:10 +02:00
OpenGnSys Support Team 6a65b72114 rest: add timestamp to shell/output
Provide a timestamp that tells when the command output from client was received.
2024-06-21 15:12:39 +02:00
OpenGnSys Support Team 6cbe69e89e rest: add cmd to shell/output
Add "cmd" field to json that provides the original command string, so it is
provided with the output and the return code.
2024-06-21 15:05:26 +02:00
OpenGnSys Support Team 12d5caf6a6 rest: add retcode to shell/output
Add retcode field to specify return code of shell invocation.
2024-06-21 14:12:02 +02:00
OpenGnSys Support Team 86beb111d4 rest: Add /client/move
Add URI to allow a POST request to move clients to a new room/folder.

Request POST /client/move:

    {
      "clients": [
        "192.168.56.11"
      ],
      "room": 10,
      "folder_id": 0,
    }

If folder_id is zero then that means computer is not stored in a folder.
2024-06-17 13:35:19 +02:00
OpenGnSys Support Team 9891276246 rest: Add /center/info
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.
2024-06-12 11:38:08 +02:00
Alejandro Sirgo Rica 111f077d17 rest: add cache/delete
Add POST cache/delete request to request deletion of images in
the client's cache.

Resquest payload structure:
{
    'clients': ['10.141.10.21', '10.141.10.22']
    'images': ['windows.img', 'linux.img']
}

The clients listed in the 'clients' field will receive a
cache/delete POST request with the 'clients' field removed and
only containing 'images' from the payload received by the server.
Each client will try to delete as many images as available in
their cache from the list of files in 'images'.
The clients will give response with the contents of the cache so
the server can update the database.
2024-05-30 11:16:25 +02:00
Alejandro Sirgo Rica 6666aba8b7 rest: add cache/list
Add GET cache/list request to obtain information about the client's
cache.

Resquest payload structure:
{
    'clients': ['10.141.10.21', '10.141.10.22']
}

Response's structure:
{
    'clients': [
        {
            'ip': '10.141.10.21',
            'cache_size': 2894572304857,
            'images': [
                {name:'img1', size: 87283902343, checksum: '5d4dcc677bc19f40a647d0002f4ade90'},
                {name:'img2', size: 894572304857, checksum: '3eb22f888f88a55ad954f55644e1192e'}
            ]
        },
        {
            'ip': '10.141.10.22',
            'cache_size': 49872839023434,
            'images': [
                {name:'img2', size: 894572304857, checksum: '3eb22f888f88a55ad954f55644e1192e'}
            ]
        }
    ]
}

Both 'cache_size' and the values in 'image_sizes' are provided
as bytes.

If a client has no cache partition the payload will include it as:
...
	{
            'ip': '10.141.10.22',
            'cache_size': 0,
            'images': []
        }
...
2024-05-30 11:16:20 +02:00
Javier Hernandez 16ca353576 rest: Add uri to update folder name
Add support to update computer folder name

Add support to update room folder name
2024-02-05 11:34:44 +01:00
Javier Hernandez 5b75df049e rest: Add uri to update room
Add uri to allow the change of a room's properties, such as 'name',
'gateway' or 'netmask'

Reject update if new name is already being used by any room of the
center where the room is located
2024-02-01 11:25:34 +01:00
Javier Hernandez 5e2b562330 rest: Add uri to update center
Add uri to allow the change of a center's properties such as 'name' or
'comment'

Refuse to update center's name if that name is already in use by another
center. This is because a center should not share name with another one.
2024-02-01 11:23:54 +01:00
OpenGnSys Support Team 41ce640033 rest: update og_uri_handle with new folder commands
Add folder/add and folder/delete, otherwise logging shows "unknown"
2024-01-11 12:14:43 +01:00
OpenGnSys Support Team 3b3fc32999 rest: missing POST /image/update in syslog
Update it so it shows in syslog, instead of unknown:

Dec 19 18:31:18 ogserver ogserver[1133]: 127.0.0.1:36538 POST /unknown clients=150.128.34.25
2023-12-21 11:58:48 +01:00
OpenGnSys Support Team f64b1c2767 rest: add POST image/update
add explicit API to update an image
2023-12-19 12:42:32 +01:00
OpenGnSys Support Team edac32bb98 rest: add GET /room/info
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 }
2023-11-30 20:20:07 +01:00
Javier Hernandez 5ff92a826e rest: add POST repository/update
Add POST repository/update request to update repository. Repository is
identified by its id, that is provided in the payload.

This can be tested with curl like:
curl -X POST -H "Authorization: $API_KEY"
http://127.0.0.1:8888/repository/update -d '{ "repo_id" : 16, "center" :
3, "name": "newName", "ip":"127.0.0.1" }'
2023-11-24 11:02:52 +01:00
OpenGnSys Support Team 56e4a01af0 rest: revisit logging
Skip logging for the following REST API invocations:

- GET /scopes
- GET /clients
- POST /clients (for legacy web console only)

The web front-end generated very frequent requests for this.

Update logging format to:

 127.0.0.1:54637 POST /wol clients=192.168.2.130

to include client IP address.
2023-11-23 22:08:49 +01:00
Jose M. Guisado b2c8c9d9ab rest: support DELETE HTTP request method
Reuse endpoints in order to add deletion operation such as "/server".
This way there is no need to declare a different if/else block in order
to parse a new URI for the new "*/delete" endpoint.

Current deletion operations are implemented using a different endpoint
name such as "/client/delete", "/center/delete" with POST request method.

Endpoints using "/delete" suffix may not be removed for backwards
compatibility. Adding HTTP method DELETE support for endpoints such as
"/center" or "/client" can use the already existing *_post_delete*
functions.
2023-08-23 11:39:19 +02:00
Jose M. Guisado d2c19ef13d core: add X-Sequence header support
Add non-standard HTTP header "X-Sequence" to the header section of
requests (og_send_request) sent to a connected client.

Define a starting sequence number when creating a new instance of struct
og_client inside og_server_accept_cb. This sequence number is
incremented by one for each outgoing request from ogServer.

This sequence number is checked when receiving a response from a
connected client, if they do not match the connection is dropped.

Use sequence 0 for out-of-band commands (reboot, poweroff, stop). Any
client response with header "X-Sequence: 0" bypasses sequence check.
2023-06-13 14:04:54 +02:00
Javier Sánchez Parra df5161ebc3 #915 Add last_cmd to GET /clients API
"last_cmd" json object contains information of the last command executed
by the correspondent client. For now, it only includes "result" string
property, which stores "success" if the last command finished correctly
or "failure" on the contrary.

To populate "result" property, this commit also adds "last_cmd_result"
enum attribute to og_client struct. Client response processing fills
this attribute according to its success.

Clients in WOL_SENT state always have last_cmd->result = "unknown".

Request: GET /clients

Response: 200 OK
{
  "clients": [
    {
      "addr": "10.141.10.102",
      "state": "WOL_SENT",
      "last_cmd": {
        "result": "unknown"
      }
    },
    {
      "addr": "10.141.10.101",
      "state": "OPG",
      "speed": 1000,
      "last_cmd": {
        "result": "success"
      }
    },
    {
      "addr": "10.141.10.100",
      "state": "OPG",
      "speed": 1000,
      "last_cmd": {
        "result": "failure"
      }
    }
  ]
}
2022-05-18 16:50:14 +02:00
OpenGnSys Support Team 20301007a1 #915 release existing client on reconnections
Trasient network problems might result in duplicated clients, drop
client object if it already exists before creating a new one.
2022-01-21 15:18:47 +01:00
OpenGnSys Support Team b8b3839bba #915 remove temporary file to store shell output
Remove legacy behaviour, store it in the client object instead of a temporary
file.
2022-01-18 10:48:59 +01:00
Jose M. Guisado 772811e76f #1065 Add support for client events
ogServer supports events from clients in an agent mode
(linux/windows).

Client sends event information (eg. user login/logout)
via a 103 Early Hints http response message.
2021-12-01 15:14:24 +01:00
Jose M. Guisado b6b1040997 #1065 client: add support for ogclient win state
ogClient can be run in windows mode, enabling connection with ogServer
when running on a Windows machine.

Don't expect the same payload in windows mode as a in live or virtual.
Client in windows mode does not send partition setup information, only
the status/state. (same case for linux mode)
2021-11-17 10:36:50 +01:00
Jose M. Guisado 5a3fd51261 #1065 client: add support for ogclient linux state
ogClient can be run in linux mode, intended for exposing some
ogServer commands when running in a linux distribution.

When connecting with a client in linux mode, do not expect a full
partition setup response. Just expect a 'status', and then accept
the connection without updating any partition information in
the database.
2021-11-17 09:07:57 +01:00
Jose M. Guisado 2d68f8a0ec #1061 add timeout to pending scheduled commands
Pending schedule commands can deny ogLive boot of clients due
to filling of pending cmd queue with commands such as "Iniciar Sesión".

For example: Using RemotePC to serve clients that do not boot into
ogLive will fill up the pending command queue with "Iniciar Sesión".

Introduce a safety timeout for pending (scheduled) commands to
avoid this situation.
2021-09-06 12:32:38 +02:00
OpenGnSys Support Team 88c8b52e88 move json function declarations to json.h
These function declarations belong to json.h:

int og_json_parse_partition_setup(json_t *element, struct og_msg_params *params);
int og_json_parse_create_image(json_t *element, struct og_msg_params *params);
int og_json_parse_restore_image(json_t *element, struct og_msg_params *params);
2021-06-10 17:00:43 +02:00
Jose M. Guisado 141b0797e1 #915 Add schedule/command
Enables ogserver to schedule commands (also referred as actions in
legacy web console jargon).

This feature enables ogserver to write in the "acciones" table in order
to have full capabilities for command scheduling purposes, thus not
depending in the legacy web console to insert into "acciones" table.
2021-06-09 13:41:28 +02:00
Jose M. Guisado 40d4279b31 #995 Add link speed parsing to client probe response
If a probe response contains speedinformation, parse and store
it inside the client struct. Speed is interpreted as an unsigned
integer representing Mbit/s.
2021-05-04 18:13:35 +02:00
OpenGnSys Support Team 79e7e2b8c8 #915 only API REST is supported
Socket hidra API has been removed, all connections use a REST API.
2021-05-04 16:14:38 +02:00
OpenGnSys Support Team 8a0a32cea1 #580 remove old keepalive code
Needed by the old socket Hydra that does not exist anymore
2021-05-04 16:11:34 +02:00
OpenGnSys Support Team 0a09c5b09c #1022 increase maximum API REST request size
Software inventory generates a request larger that 64 Kbytes.
Rise the maximum API REST request size to 128 Kbytes.
2021-02-04 13:29:24 +01:00
Javier Sánchez Parra 403e7c323b #1004 Add GET /images
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
  }
}
2020-09-29 12:43:07 +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