| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
OpenGnsys partition images store OS information, including
the OS name appended with "64 bits" when the OS is meant for 64 bit
machines.
The detected OS name when probing (refresh) is important, if it differs
from what's stored in the DB OpenGnsys will wipe last image restored
information when running a refresh.
See actualizaConfiguracion from legacy ogserver (ogAdmServer.c) code:
dato = dbi_result_get_uint(result, "idnombreso");
if (idsoi == dato) {
swu = false;
}
...
if (swu) {
result_update = dbi_conn_queryf(dbi->conn,
"UPDATE ordenadores_particiones SET "
" codpar=0x%s,"
" tamano=%s,"
" uso=%s,"
" idsistemafichero=%d,"
" idnombreso=%d,"
" idimagen=0,"
" idperfilsoft=0,"
" fechadespliegue=NULL"
" WHERE idordenador=%d AND numdisk=%s AND numpar=%s",
|
|
|
|
|
| |
Probe response already has client's link speed, but this API is
deprecated.
|
|
|
|
|
|
|
| |
Adds missing slash in the windows reghives path f-string.
When calling os_probe inside refresh (live/ogOperations) the mountpoint
is passed without a trailing slash.
|
|
|
|
|
|
|
| |
Detects OpenGnsys cache partition when building the partition setup of a
live system.
OpenGnsys labels a Linux/ext4 partition as "CACHE".
|
|
|
|
|
|
|
|
|
|
|
|
| |
Removes a workaround enumaration of the partitions of a given libfdisk
context. Use Partition class partno attribute.
This enables detecting non contiguous partitions, like:
/dev/sda
/dev/sda1
/dev/sda2
/dev/sda4
|
|
|
|
|
|
| |
Cannot replace str ('\n') when stdout is a bytes object.
Also fixes some typos (i.e: proc_releaseid stdout was used twice).
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use python binding for libfdisk to retrieve disk label and partition
information [1]. Use utils.py for the rest of the process.
This change aims to drop dependency with external script
'getConfiguration' from the OpenGnsys scripting ecosystem.
Keeps the same json payload structure for the refresh response.
[1] https://git.48k.eu/python-libfdisk/
|
|
|
|
| |
Import ethtool function from utils.py
|
|
|
|
|
|
|
|
|
|
|
|
| |
partcodes.py is used for mapping GPT partition UIIDs to hexcode/decimal
values.
OpenGnsys stores partition types in the database using the decimal
value of this hexcode. The hexcode used for GPT partition UUID is the
same as defined internally in gdisk [1].
[1]
https://sourceforge.net/p/gptfdisk/code/ci/master/tree/parttypes.cc#l75
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* disk.py
Disk discovery
* fs.py
Uses psutil to fetch fs usage information
* menu.py
ogBrowser menu generation
* net.py: gets nic status information
IP address, MAC address and ethernet speed.
* probe.py: probes mountpoints for operating systems
Uses hivexget command to try fetching Windows installation
information.
Looks for /etc/os-release for probing linux systems.
|
|
|
|
| |
This reverts commit 69d214f63b2aa8ef60489d56468393b70795124a.
|
|
|
|
|
|
|
| |
Commit 700aa89ea99 introduced the use of getattr when getting event
socket to avoid errors in case it was not initialized.
Prefer to initialize accordingly inside the ogClient class constructor.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If ogClient does not run on windows or linux mode, it does not create a
datagram event socket.
If ogClient runs in virtual or live mode this will cause an error when
calling get_event_socket because the class instance has no member
"event_sock".
Use getattr when retrieving the event socket from ogClient class, if
there is no event socket, then return None.
Fixes 2465ef25b741 (Add event datagram socket)
|
|
|
|
|
|
|
|
|
|
|
| |
Running ogClient as a service (non interactive user) breaks
poweroff and reboot using ExitWindowsEx function in user32.dll.
Spawn a subshell using os.system and use the 'shutdown' command
instead.
This is a terminating command, we don't need fine grain from
subprocess module.
|
|
|
|
|
|
|
|
|
|
| |
Commit 2dbcd18c06dd breaks interfaceAdm path for live operations.
Keep OG_PATH to the value prior to commit 2dbcd18c06dd.
Check platform before reading config file. If platform is different
from linux then look for cfg/ogclient.json in current folder and
do not use OG_PATH.
|
|
|
|
|
|
|
|
|
|
| |
ogClient can receive events via a datagram socket opened at 55885.
This socket is only opened when in windows or linux mode, for
event reporting from within the system.
Events reported this way are sent back to ogServer via a 103 Early
Hints HTTP message. Information regarding the event is sent in the
response's payload.
|
|
|
|
|
|
|
|
|
| |
Windows does not report a refused connection the same way as Linux.
Unsuccesful connect socket will be kept in the exceptfds, and won't
be in the readable nor writable fds. The socket in this state will
have SO_ERROR set to ECONNREFUSED.
On the other hand, Linux does not use exceptfds for such case.
|
|
|
|
|
|
|
|
|
| |
Add required function call before running any process with
multiprocessing. This is required for windows executables to
work properly when using pyinstaller.
See:
https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Multiprocessing
|
|
|
|
|
|
| |
Uses ExitWindowsEx from user32.dll. Library is loaded using ctypes.
See https://stackoverflow.com/a/50824776
|
|
|
|
|
|
|
| |
If current platform is Linux (either live, virtual or linux) expect
/opt/opengnsys/ogclient/cfg/ to contain ogclient.json.
If current platform is not Linux then we fallback to current directory.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add agent mode for windows platform.
Subprocess module for shell/run is cross-platform an no change was
needed. The subprocess will run with the same privilege as its parent,
ogclient.
TODO: Provide a windows installer. As of now, an administrator
needs to install python and required libraries for this mode to be
usable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We can't use syslog if we want to execute ogClient in the Windows
platform.
Use the native logging library so we can attach different handlers
depending on the mode ogClient is executing.
Logging configuration is done via a python dict. There is a different
dict for linux and windows. These dicts define the configuration of the
root logger, handlers and formatters used.
As of now, it is only expected to use the root logger for everything
logging related. The root logger is obtained via:
LOGGER = logging.getLogger()
More info about handlers, formatters and loggers:
https://docs.python.org/3/howto/logging.html
Logging configuration is done at startup, just after parsing the json
(knowing ogclient mode). If json parsing goes bad, ogclient will only
print a message to stdout.
|
|
|
|
|
|
|
|
|
| |
- Executed script runs with same privilege as ogClient process.
- Uses subprocess.run instead of subprocess.Popen, it's a bit simpler.
We can't specify executable, though. Shouldn't need so in Linux mode.
- Uses shell=True, keep in mind security considerations listed at:
https://docs.python.org/3/library/subprocess.html#security-considerations
(shlex.quote can be used for unix shells)
|
|
|
|
|
|
| |
Adds a systray icon for linux mode. Uses pystray module. Expects a
favicon.ico stored in the same folder as the main ogclient python
script, but if not found a placeholder image is used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ogClient can run in "linux" mode. In addition to live or virtual.
Serves as a substitute to the legacy ogagent, which has not received any
updates since 2020/07/23.
Linux mode initially supports remote reboot and poweroff. Requires
updated ogServer with the Linux ogclient state.
ogClient can be set up to run in linux mode by specifying it in
ogclient.json:
{
"opengnsys": {
"ip": "192.168.56.10",
"port": 8889,
"log": "DEBUG",
"mode": "linux",
...
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Abort command if the connection with the server is lost.
Otherwise, a race condition that leaves ogServer and ogClient
out-of-sync might occur:
1. ogClient is busy running a command (on the worker thread), for example,
image/restore.
2. ogServer is stopped OR ogClient loses connection with ogServer (due to
transient network problem).
3. ogClient reconnects and ogServer sends a refresh command.
4. ogClient worker thread finishes and it sends a reply to image/restore.
5. ogServer gets confused because it expects a reply to the refresh
command, not the old image/restore.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Polling for a qmp port availability is undesirable, as QEMU only handles
one connection to the qmp port at a time, ogClient may interfere with
cloneer-manager.
Check vm thread now connects to a separate qmp tcp socket, listening for
a shutdown guest event.
When ogClient is run just after ogVDI installation (before guest
installation) it will try to connect until it's possible, ie: after an
iso is specified and a qemu vm is started that exposes the appropiate
qmp tcp port.
|
|
|
|
|
|
| |
If server closes the connection, close the socket, reconnect and stop
processing. self.connect() already cleans up the internal state, including the
socket state.
|
|
|
|
| |
add method to clean up interval socket state and use it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
OgClient miscalculates the body size of the request.
ogServer delimits HTTP headers with "\r\n\r\n" to comply with RFC 2616.
But ogClient searches for the first "\r\n" delimiter, hence, ogClient
stops at the first HTTP header field instead of at the end of the header.
Hence, it incorrectly assumes the body starts after the first "\r\n".
This commit updates ogClient to search for the "\r\n\r\n" delimiter.
Example:
POST /shell/run HTTP/1.1\r\n <-- ogClient considers body starts here (WRONG!)
Content-Length: 952\r\n
Content-Type: application/json\r\n
\r\n <-- Here is where the body starts
{"json-body":...}
|
|
|
|
|
|
|
| |
Add ogClient support to receive, parse and send disk type data from the cloning
engine when refreshing disks configuration.
See also commits with #1037 in ogServer and WebConsole repo.
|
|
|
|
| |
Update license header in files.
|
|
|
|
|
|
|
|
| |
Separates probe method into separate ogclient modes (virtual, vdi) so
future supported OS can easily have a tailored probe responses.
Link speed is retrieved using a minimal ethtool command sent using fcntl
module from python.
|
|
|
|
|
| |
Enable TCP keepalive to detect if the ogServer is gone (hard reset). If no reply
after 120 seconds, then release the connection to the server.
|
|
|
|
|
|
|
|
|
| |
When running image_create operation an underlying script "imageCreate"
is called using the subprocess python module. This script may fail, for
example if the repository in which the image is to be stored has no
sufficent capacity.
Check for non-zero when the imageCreate process has finished.
|
|
|
|
|
|
|
|
|
|
|
| |
ogLive related operations are named inside a 'Linux' folder, also its
python class is named OgLinuxOperations. Rename every 'linux' occurrence
with live to further clarify this folder and operations.
- OgLinuxOperations -> OgLiveOperations
- src/linux/ -> src/live/
Fixes: 1377acee ('Rename 'linux' mode to 'live' mode')
|
|
|
|
|
|
|
| |
ogClient /software gets a representation of the target resource’s state.
GET method is more appropriate than POST.
Change /software method from POST to GET.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before this patch the ogRest would hang indifinitely in a BUSY state
when a bad request was received. Fix this by returning ogRest state to
IDLE once the corresponding bad request response has been sent.
This accounts for the following cases:
- Unknown GET action
- Unknown POST action
- Unknown HTTP verb
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ogClient /setup in linux mode do not support to indicate which table
type the user want to use. It always supposes that the partition table
is MBR/MSDOS.
Add ogClient support to work with GPT tables. Add new field table type
to /setup linux mode that expects a string with "MSDOS" or "GPT".
Example old JSON:
{
"disk": "1",
"cache": "0",
"cache_size": "0",
"partition_setup": [...]
}
Example new JSON:
{
"type": "GPT",
"disk": "1",
"cache": "0",
"cache_size": "0",
"partition_setup": [...]
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previous commits updates ogClient and ogServer to support several disks
in Linux (ogLive) mode. This changes disk setup JSON format from an
object to an array. ogClient in virtual mode also need to satisfy this
new format, although it not support several disks.
Adapt ogClient virtual mode to satisfy new disk setup JSON format.
Old format:
"disk_setup": {
"disk": 1,
"partition": 0,
"code": "0",
"filesystem": "",
"os": "",
"size": 32685957,
"used_size": 6
},
New format:
"disk_setup": [
{
"disk": 1,
"partition": 0,
"code": "0",
"filesystem": "",
"os": "",
"size": 32685957,
"used_size": 6
}
],
|
|
|
|
|
|
|
|
| |
ogClient expect to receive information of 1 disk from the Cloning
Engine's script "getConfiguration". ogAdmClient, the deprecated ogLive
client daemon, supported for several disk.
Add ogClient support for several disk.
|
|
|
|
|
|
|
| |
Image datasize is expressed in kibibytes but the existing REST API field
represent data in bytes.
This commit changes ogClient to send datasize in bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Extend ogClient to include more information about the image that has been
created. This patch modifies ogClient to read an info file created by image
creation script, add this info to the JSON response and then remove the file.
Example of new /image/create response:
{
"disk": "1",
"partition": "1",
"code": "131",
"id": "1",
"name": "ubuntu",
"repository": "192.168.56.10",
"software": "Ubuntu 18.04.5 LTS \naccountsservice 0.6.45\n...",
"clonator": "PARTCLONE",
"compressor": "LZOP",
"filesystem": "EXTFS",
"datasize": 2100000
}
New fields are "clonator", "compressor", "filesystem" and "datasize".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Irina reports that "Partition assistant"/"Asistente de particionado" is
not working. This is happening because ogClient is not reading the full
data ogServer sends when the entire HTTP PDU is larger than 1024.
However, ogClient should read the whole message, reading until read data
length is greater or equal to "Content-Length" header value.
ogClient fails to obtain "Content-Length" value because is looking for
"content-length", be aware of the case sensitivity. It also needs to
take into account the header length because read data length also
includes headers.
This patch updates ogClient to:
1) look for "Content-Length instead of "content-length".
2) compare read date length with content length plus headers
length.
|
|
|
|
|
|
|
|
|
| |
Disconnect gracefully from ogServer after booting OS, the script to start the
OS calls kexec, so everything is gone after it. For Windows, this results in a
reboot.
This commit also improves the disconnect function to make sure the
disconnection is synchronous.
|
|
|
|
|
| |
Since version 1.2.0, OpenGnsys supports ogVDI hypervisor OS. This commit
a new status which indicates that clients are running ogVDI
|
|
|
|
|
|
|
|
|
|
| |
This is useful for debuging and getting information on the processes that are
being executed in ogclient.
syslog outputs are something similar to:
Jun 26 10:36:40 ogAdministrator /ogclient: GET refresh HTTP/1.1
Jun 26 10:36:40 ogAdministrator /ogclient: HTTP/1.0 500 Internal Server Err
|
|
|
|
|
|
|
|
|
|
|
|
| |
When restore image command was sent and the restoration failed, you
could see in WebConsole the image as restored and the command completed,
as it if had not failed. This happened because ogClient did not check
the return code of restoration script.
This commit adds return code check on restore image. So, when return
code is a non-zero value ogClient responses with an error 500. When
ogServer receives this error response, it did not set in the database
the image as restored and command as completed without errors.
|
|
|
|
|
| |
This fixes a circular import error produced by the import of ogClient inside of
OgLinuxOperations.
|
|
|
|
| |
'linux' represents ogLive mode that is the reason for the rename.
|