Commit Graph

81 Commits (5797e0b199caa44b992929a0f421f6e1a455fffe)

Author SHA1 Message Date
OpenGnSys Support Team 5797e0b199 #915 add wol command to REST API in ogAdmServer
Send Wake-On-Lan to clients (through POST method):

Request:
	curl -X POST http://127.0.0.1:8888/wol
	{ "type" : "unicast", "clients" : [ { "addr" : "192.168.2.1", "mac" : "00AABBCCDD01" } ] }
Reply:
	200 OK
2019-05-27 13:02:52 +02:00
OpenGnSys Support Team 507c75c337 #915 Pass array of addresses to WakeUp()
To reuse this function to the REST API.
2019-05-27 13:02:49 +02:00
OpenGnSys Support Team 7b6fcdbc62 #915 add clients command to REST API in ogAdmServer
Request for existing clients:

	curl -X GET http://127.0.0.1:8888/clients

Request:
	GET /clients
Reply:
	200 OK
	{"clients": [ { "addr" : "192.168.2.1", "state" : "OPG" }, { "addr" : "192.168.2.2", "state" : "OFF" }]}
2019-05-27 13:02:45 +02:00
OpenGnSys Support Team 95e6520c4f #915 add initial REST API for ogAdmServer
Add REST API for ogAdmServer, this API is exposed through port 8888 on
the system that runs the ogAdmServer. The body of the HTTP message is
expressed in JSON format.

This patch implements the command "clients" that maps to the existing
legacy "Sondeo" command, that is used by the web interface to poll
refresh the client state.

This patch also includes an initial test infrastructure using 'curl' to
send commands to the new REST API.

Request:
	POST /clients
	{"clients" : [ "192.168.2.1", "192.168.2.2" ]}
Reply:
	200 OK

This allows to refresh the status of the list of clients.
2019-05-27 13:02:37 +02:00
OpenGnSys Support Team 222637848b #915 add og_msg_alloc() and og_msg_free()
Add function to allocate and release the legacy message format.
2019-05-27 13:02:33 +02:00
OpenGnSys Support Team e979fd2020 #915 add og_send_cmd()
Add new function to check and send commands to the clients. This new
function takes an array of IP addresses (string) and send commands to
the clients.
2019-05-27 13:02:20 +02:00
OpenGnSys Support Team e3e4e6f677 #915 add og_socket_server_init()
Move code to create a socket into a function.
2019-05-27 13:02:06 +02:00
OpenGnSys Support Team 107b17a51b #915 add og_client_state_process_payload()
Move code that handles the message payload into function.
2019-05-27 13:02:00 +02:00
OpenGnSys Support Team d491dfdb2d #915 add og_client_state_recv_hdr()
Move code that handles the receiving header state into function.
2019-05-27 13:01:35 +02:00
OpenGnSys Support Team 0d6dc82669 #898 Remove unused encryption and decryption routines
Remove dead code to encrypt and decrypt the message.
2019-02-06 14:49:49 +01:00
OpenGnSys Support Team b38ed0dfb8 #897 Do not use socket type in ogAdmServer
No need for an extra type, socket descriptors are always integer.
2019-02-06 14:49:04 +01:00
Javier Sánchez Parra 2baf362ac2 #896: Send multicast WoL through a specific interface
* New parameter in ogAdmServer config file for setting an interface.
* ogAdmServer multicast WoL now search the interface of the config file in the
system, if the interface is found in the system the destination IP of the
packet change to a broadcast address of a specific range of addresses.
2019-02-06 14:29:52 +01:00
OpenGnSys Support Team bcc8ccce34 #891 remove function to parse string in hexadecimal to binary
Wake-on-lan does not use it anymore, this function has no clients and we
can just remove it.
2019-01-23 16:40:18 +01:00
OpenGnSys Support Team 63a3d4d8fd #891 fix wake on lan routine
Fix function to send wake-on-lan packet:

- setsockopt() expects an integer as parameter.
- zero the struct socketaddr_in local structure.
- use sscanf() to parse the mac address string.
2019-01-23 16:39:21 +01:00
OpenGnSys Support Team 9fc0037bd7 #580 ignore SIGPIPE signal
This signal is received when socket hit connection reset by peer
state, which may happen in transient network failures.
2019-01-17 13:19:02 +01:00
OpenGnSys Support Team 162d7808b0 #580 incorrect return value in handler
All handlers must return a boolean.
2019-01-17 13:18:57 +01:00
OpenGnSys Support Team effbcea987 #883 standalone log file is now deprecated
display message in old log file that ogAdmServer uses syslog.
2019-01-17 13:18:55 +01:00
OpenGnSys Support Team a1d02f4f2a #883 remove unnecessary logging
Remove redundant logging, use syslog() whenever possible.
2019-01-17 13:18:53 +01:00
OpenGnSys Support Team b56cbeb737 #883 replace standalone log file by syslog 2019-01-17 13:18:51 +01:00
OpenGnSys Support Team 2ed3a0cd1a #883 use LOG_DEBUG instead of LOG_INFO
Log file may grow in size too quickly in standard syslog configurations.
2019-01-17 13:18:49 +01:00
OpenGnSys Support Team 57c8c50524 #883 do not use argv[0] in syslog log message
Before:

Dec  3 11:18:12 ogLab /opt/opengnsys/sbin/ogAdmServer[1025]: server closing connection to 192.168.56.10:50476

After this patch:

Dec  3 11:18:12 ogLab ogAdmServer[1025]: server closing connection to 192.168.56.10:50476
2019-01-17 13:18:47 +01:00
OpenGnSys Support Team f09aca620c #580 fix management of keepalive connections to clients
OgAdmServer leaves a connection in keepalive more (similar to HTTP
keepalive feature), the existing handling is not correct. The tbsocket
table is never cleaned up and properly.

Use the new og_client object that represents connections from the
clients in tbsocket[] instead.

The keepalive field now stores the index in the tbsocket table, so there
is no need to consult mysql to fetch the slot that this client is using.

This patch also extends syslog() support to include port number when
reporting connections from clients.
2019-01-17 13:18:40 +01:00
OpenGnSys Support Team ef6e3d263c #883 add initial syslog support 2019-01-17 13:18:34 +01:00
OpenGnSys Support Team 212280e1bc #580 rework server socket handling
Modern server side using libev library, includes timeouts for clients.

After this patch, your system requires the libev-dev and libev4 packages
to compile ogAdmServer.
2019-01-17 13:18:32 +01:00
OpenGnSys Support Team 08783c9330 #580 more robust check for remote function
Use strncmp() that is bound to the function name length.
2019-01-17 13:18:30 +01:00
OpenGnSys Support Team 97641858c7 #883 add og_info() and use it
Use __FUNCTION__ to print function name, this is a preparation work
to introduce syslog support.
2019-01-17 13:18:28 +01:00
OpenGnSys Support Team 9dea2d6592 #580 use true/false definition from standard stdbool.h 2019-01-17 13:18:26 +01:00
OpenGnSys Support Team a1fbe2dc0e #580 disregard INVALID_SOCKET 2019-01-17 13:18:23 +01:00
OpenGnSys Support Team 28b435c5fd #580 disregard SOCKET_ERROR 2019-01-17 13:18:19 +01:00
OpenGnSys Support Team 1d64416ce0 #580 remove dead code uncovered by statification
These functions are not used, remove them.

sources/ogAdmServer.cpp:2208:13: warning: ‘bool actualizaCreacionSoftIncremental(Database, Table, char*, char*)’ defined but not used [-Wunused-function]
 static bool actualizaCreacionSoftIncremental(Database db, Table tbl, char* idi,char* idf)
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sources/ogAdmServer.cpp:1626:13: warning: ‘bool RESPUESTA_Comando(int, TRAMA*)’ defined but not used [-Wunused-function]
 static bool RESPUESTA_Comando(int socket_c, TRAMA* ptrTrama)
             ^~~~~~~~~~~~~~~~~
sources/ogAdmServer.cpp:1600:13: warning: ‘bool Comando(int, TRAMA*)’ defined but not used [-Wunused-function]
 static bool Comando(int socket_c, TRAMA* ptrTrama)
             ^~~~~~~
2019-01-17 13:18:17 +01:00
OpenGnSys Support Team 59fb4d5ce2 #580 constify parameter and statify function
Remove unnecessary function declaration in header files
2019-01-17 13:18:14 +01:00
OpenGnSys Support Team 691af634e6 #580 remove AULAUP in configuration file
Overrides catalog, and aulaup variable is never set / used.
2019-01-17 13:18:11 +01:00
OpenGnSys Support Team aff4cfdd5f #580 simplify check for empty string 2019-01-17 13:18:09 +01:00
OpenGnSys Support Team 2427e9d8fe #580 move global variable definitions to file
Save us from unnecessary initialization given this is in the .bss area.
2019-01-17 13:18:06 +01:00
OpenGnSys Support Team 2ef2ceabfa #580 add og_log() and use it 2019-01-17 13:18:04 +01:00
OpenGnSys Support Team f74067ffdc #580 use bool from stdbool.h instead of BOOLEAN
C99 includes boolean definition in stdbool.h, use them.
2019-01-17 13:18:02 +01:00
OpenGnSys Support Team 07d2b73a13 #580 disregard SOCKET type, use int instead
Socket file descriptors are always an integer, no need for typedef.
2019-01-17 13:18:00 +01:00
OpenGnSys Support Team 20fa7b937e #580 simplify load configuration file
Use fgets() and strtok() to parse the configuration to simplify the
existing handler.
2019-01-17 13:17:58 +01:00
OpenGnSys Support Team 4665749212 #580 no need to iterate 1024 times to find a matching handler
There are only 41 handlers, no need to keep inspecting up to 1024.
Most entries in this array are null.
2019-01-17 13:17:55 +01:00
OpenGnSys Support Team 8e0216a2ca #580: No need for runtime initialization of handlers.
Removes 70 LoCs.
2019-01-17 13:17:41 +01:00
Ramón M. Gómez 9e3c02a58a #834: Eliminar algunos espacios sobreantes y saltos de línea tipo CRLF. 2018-05-17 13:54:59 +02:00
Irina Gomez 5c9cb183c5 #580 Se resuelve errata en ogAdmServer por la que al restaurar una imagen sin perfil de software asociado se cae el servicio.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5712 a21b9725-9963-47de-94b9-378ad31fedc9
2018-04-09 12:04:26 +00:00
ramon 6ee505f3dc #730 #738: Si se reinicia el servicio ogAdmServer, se reutiliza el pureto en Linux 3.9+; se actualiza la configuración del cliente tras el comando Restaurar Imagen (falta aplicar cambios en imagen básica).
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5398 a21b9725-9963-47de-94b9-378ad31fedc9
2017-07-03 18:34:47 +00:00
Irina Gomez 466106d638 #559 ogAdmServer: Se libera memoria de variables y de resultados de la base de datos. Database.cpp y Database.h: Se crea función liberaResult.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5132 a21b9725-9963-47de-94b9-378ad31fedc9
2016-12-20 09:26:11 +00:00
Irina Gomez ed05cd56fa #730 Se optimiza el código en EjecutarScripts.js de los asistentes y el servicio ogAdmServer.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5043 a21b9725-9963-47de-94b9-378ad31fedc9
2016-10-24 12:18:04 +00:00
Irina Gomez faee12ece6 #737 Comando crear imagen de la consola: actualiza en la base de datos las propiedades de la particion: imagen, revisión y fecha de despliegue.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5024 a21b9725-9963-47de-94b9-378ad31fedc9
2016-09-30 07:47:16 +00:00
ramon b5022791ab #713 #743: Corregir erratas de revisiones r4906 y r4927.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4929 a21b9725-9963-47de-94b9-378ad31fedc9
2016-05-13 16:34:33 +00:00
ramon 24df599aa9 #713: Detectar nº de serie del cliente en el proceso de inicio y, si se envía al servidor, incluir el dato en la BD, si está vacío.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4927 a21b9725-9963-47de-94b9-378ad31fedc9
2016-05-12 16:56:04 +00:00
Irina Gomez c20cf9c67f #738 Corrige la perdida del nombre de la imagen restaurada: el comando restaurar guarda en la BD el id del sistema operativo de la partición, al reiniciar no encuentra cambios y permanece el nombre
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4903 a21b9725-9963-47de-94b9-378ad31fedc9
2016-04-26 12:52:09 +00:00
Irina Gomez 8712fd91b0 #738 #713 Inventario de software: se muestra sistema operativo y se guarda en el perfil de software
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4901 a21b9725-9963-47de-94b9-378ad31fedc9
2016-04-26 07:41:46 +00:00