| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
| |
Integrates some parts of this operation into native code, eg: the md5
checksum computation.
Wraps non native processes and commands using the subprocess module.
For example, legacy.py stores bash commands pending integration.
Supports python >=3.6, expected until more modern ogLives are put into
production environments.
|
|
|
|
|
|
|
|
| |
If disk has no label, python-libfdisk returns None when accessing
cxt.label
Fixes bug when running refresh on computers whose disk/s have no label.
|
|
|
|
|
|
|
| |
Enables details in libfidsk context constructor call. Ensures size are
displayed as bytes (and not as a human readable string).
Avoids further arithmetical errors (e.g: converting from bytes to KB)
|
|
|
|
|
|
| |
parseGetConf was necessary for parsing output from OpenGnsys
script "getConfiguration", which has been replaced since commit
1ab981a539f3 ("live: replace getConfiguration with refresh")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adds new logging handler redirecting messages to the log file
located in the Samba shared directory (applies to live mode
clients, i.e: ogLive)
Parses log level configuration from ogclient.json. See:
{
"opengnsys": {
...
"log": "INFO",
...
}
...
}
Adds --debug option to set root logger level to DEBUG when starting
ogClient. Overrides log level from config file.
In addition:
- Replaces any occurence of print with a corresponding logging function.
- Unsets log level for handlers, use root logger level instead.
- Default level for root logger is INFO.
- Replaces level from response log messages to debug (ogRest)
|
|
|
|
|
|
|
| |
Old refresh was a wrapper around getConfiguration bash script.
New refresh operation does what getConfiguration used to do
externally. See commit 097769b971f64f93004a87393721a289fe3db13f.
|
|
|
|
|
| |
fdisk reports VFAT, however, OpenGnsys does not have such entry in the
filesystem table. Add an alias to FAT32 as a workaround.
|
|
|
|
|
|
|
|
| |
Returns true if target is already a mountpoint. Does not call mount.
It's possible that another device might be mounted in the target
mountpoint. A future check between the source and target for
equal device major:minor must be added.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Generates a cache.txt file if a cache partition is detected.
OpenGnsys stores information about stored images in its 'cache'
partition via a text file.
The file is stored in a samba shared directory, mounted at
'/opt/opengnsys/log/' in a live client. The file name is '{ip}.cache.txt'.
Previously, the generation of this file was delegated to external bash
scripts.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
|
| |
ogClient allows the user to specify the json config path with optional
parameters -c / --config:
ogclient -c /foo/bar/foobar.json
If specified config file is malformed ogClient will fail to start.
|
|
|
|
|
|
|
|
|
|
|
| |
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 be invoked with additional arguments to send
event datagrams to the default event datagram socket at
127.0.0.1 port 55885.
ogclient session events invokation syntax:
ogclient event login foobar
ogclient event logout foobar
If event commands arguments are detected, ogclient sends the
datagram and closes afterwards.
Datagram syntax for session event is:
session [start | stop] [user]
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
SIGPIPE is only available on Unix. Add try/except so that this
import does not crash ogclient when running in Windows mode.
Only assign SIG_DFL handler to SIGPIPE when mode is not windows.
Prefer signal.signal over signal alone to better distinguish module from
function.
|
|
|
|
|
|
|
|
|
| |
- 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.
|