summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* #1065 Support pyinstaller for WindowsJose M. Guisado2021-11-221-1/+2
| | | | | | | | | 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
* #1065 windows: add poweroff and rebootJose M. Guisado2021-11-191-0/+9
| | | | | | Uses ExitWindowsEx from user32.dll. Library is loaded using ctypes. See https://stackoverflow.com/a/50824776
* #1065 revisit config_path initializationJose M. Guisado2021-11-181-1/+4
| | | | | | | 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.
* #1065 Add windows modeJose M. Guisado2021-11-184-2/+118
| | | | | | | | | | | | 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.
* #1065 Use logging module instead of syslogJose M. Guisado2021-11-182-14/+85
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* #1065 linux: add shell run operationJose M. Guisado2021-11-151-2/+19
| | | | | | | | | - 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)
* #1065 linux: add systray iconJose M. Guisado2021-11-151-0/+52
| | | | | | 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.
* #1065 src: add linux modeJose M. Guisado2021-11-154-1/+51
| | | | | | | | | | | | | | | | | | | | | 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", ... }
* #1056 stop thread if connection with server is lostOpenGnSys Support Team2021-11-111-0/+1
| | | | | | | | | | | | | | | | 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.
* #1059 virtual: replace qmp polling for event listeningJose M. Guisado2021-09-013-8/+322
| | | | | | | | | | | | | | 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.
* #1056 stop request processing on connection closureOpenGnSys Support Team2021-07-151-1/+1
| | | | | | If server closes the connection, close the socket, reconnect and stop processing. self.connect() already cleans up the internal state, including the socket state.
* #1056 add cleanup method and use itOpenGnSys Support Team2021-07-151-10/+8
| | | | add method to clean up interval socket state and use it
* #1000 Fix HTTP request header length parsingJavier Sánchez Parra2021-07-131-3/+4
| | | | | | | | | | | | | | | | | | | 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":...}
* #1037 Add disk typeJavier Sánchez Parra2021-05-261-0/+1
| | | | | | | 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.
* ogClient is AGPLv3+OpenGnSys Support Team2021-05-147-29/+17
| | | | Update license header in files.
* #995 Add link speed in probe responsesJose M. Guisado2021-05-043-5/+41
| | | | | | | | 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.
* #980 Broken TCP connection times out after 120 seconds through keepaliveOpenGnSys Support Team2021-04-231-0/+5
| | | | | 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.
* #1000 live: check imageCreate for non-zero return codev1.2.0Jose M. Guisado2020-12-151-0/+3
| | | | | | | | | 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.
* Rename 'linux' folder and operations to 'live'Jose M. Guisado2020-12-033-3/+3
| | | | | | | | | | | 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')
* #1010 Change POST /software to GETJavier Sánchez Parra2020-12-021-2/+2
| | | | | | | 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.
* #1000 ogRest: set idle state after processing bad requestJose M. Guisado2020-12-011-0/+3
| | | | | | | | | | | | 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
* #1008 Add support to work with GPT tableJavier Sánchez Parra2020-11-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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": [...] }
* #1008 Adapt virtual disk setup JSON formatJavier Sánchez Parra2020-11-191-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 } ],
* #1008 Add support for several disksJavier Sánchez Parra2020-11-181-2/+2
| | | | | | | | 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.
* #1004 Send datasize in bytesJavier Sánchez Parra2020-09-291-1/+4
| | | | | | | 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.
* #1004 Add new fields to /image/create responseJavier Sánchez Parra2020-09-102-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | 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".
* #1000 Fix ogClient HTTP length handlingJavier Sánchez Parra2020-08-251-4/+9
| | | | | | | | | | | | | | | | | | | | 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.
* #999 Fix ogClient session commandJavier Sánchez Parra2020-08-212-1/+2
| | | | | | | | | 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.
* Add Virtual statusJavier Sánchez Parra2020-06-261-1/+4
| | | | | Since version 1.2.0, OpenGnsys supports ogVDI hypervisor OS. This commit a new status which indicates that clients are running ogVDI
* Add syslog logs for HTTP requests and responsesRoberto Hueso Gómez2020-06-261-0/+21
| | | | | | | | | | 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
* Check return code on restore image commandJavier Sánchez Parra2020-06-231-0/+2
| | | | | | | | | | | | 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.
* Import OgLinuxOperations only when necessaryRoberto Hueso Gómez2020-06-081-2/+1
| | | | | This fixes a circular import error produced by the import of ogClient inside of OgLinuxOperations.
* Rename 'linux' mode to 'live' modeRoberto Hueso Gómez2020-06-052-2/+2
| | | | 'linux' represents ogLive mode that is the reason for the rename.
* Delete ogConfig.pyRoberto Hueso Gómez2020-06-053-50/+18
| | | | | This file is only used for its OG_PATH variable, this variable is now in ogClient.
* Refresh partitions.json after image restoreRoberto Hueso Gómez2020-05-291-0/+1
| | | | | This is necessary for cloneer-manager to start the guest OS after the next reboot.
* Move check_vm_state_loop() into OgVirtualOperationsRoberto Hueso Gómez2020-05-262-14/+15
| | | | | | Improves code encapsulation by moving check_vm_state_loop method into OgVirtualOperations class. This also fixes import error when running ogclient in 'linux' mode.
* Fix OgLinuxOperations class paramsJavier Sánchez Parra2020-05-201-15/+15
| | | | | | | | | Commit 621fb7a7 added class initialization with two parameters. These two parameters were wrongly initialized, "self." was missing. The call of these params in other functions of the class was also wrong. This commit fix the initialization of the parameters of OgLinuxOperations and fix the calls to these params.
* Only import virtual functions when needed.Javier Sánchez Parra2020-05-201-1/+2
| | | | | | | | | ogClient may runs on an OS that do not have all the dependencies needed to use virtual functions. This commit change the behaviour to only import virtual functions when the ogClient has to work with Virtual Machines. This way ogClient works on environments which do not need virtual functions.
* Handle other exceptions on virtual /refreshRoberto Hueso Gómez2020-05-191-0/+3
| | | | | | | Ths patch handles different cases when a /refresh request can be made. More specifically this handles the situation in which the VM is stopped when /refresh is called but it starts during the processing of /refresh, in this case we just send the last recorded setup.
* Refactor OgQMP and adapt operationsRoberto Hueso Gómez2020-05-191-55/+54
| | | | | | | | | | | This patch: - Fixes logic errors in the communication with QMP (the order of handshake messages was not right). - Rewrite parts of OgQMP class. - Enforces better coding practices by using Python's "context managers" to avoid forgeting an open socket in case exceptions occur. - Adapt virtual operations to the use of "context managers" using the "with" statement.
* Update filesystems on /refreshRoberto Hueso Gómez2020-05-181-0/+9
| | | | This updates partitions.json filesystems.
* Use virtio-vga to run VMsRoberto Hueso Gómez2020-05-181-2/+2
| | | | | | This is the device that has the best empirical performance right now and it seems like it is where most of the qemu development is directed towards for the future.
* Adapt ogLinuxOperation to work with json config fileJavier Sánchez Parra2020-05-182-7/+5
| | | | | | | ogClient changed its config file format to json. This patch adapts ogLinuxOperation to use new config file. Co-authored-by: Roberto Hueso <rhueso@soleta.eu>
* Wait before polling QMP for host poweroffRoberto Hueso Gómez2020-05-141-2/+2
| | | | | This patch waits before polling qemu with QMP so that it has time to be ready for requests. It also increases wait time in case the host machine is slow.
* Fix typo on linux shellrun operationRoberto Hueso Gómez2020-05-141-1/+1
|
* Rename operation 'execCMD' to 'shellrun'Roberto Hueso Gómez2020-05-133-5/+4
| | | | This patch also ignores calls to shellrun when virtual mode is activated.
* remove platform checkOpenGnSys Support Team2020-05-131-3/+0
|
* Change permissions on virtual images for /refreshRoberto Hueso Gómez2020-05-131-1/+1
| | | | | Write permission is not needed to get information about each virtual drive so this patch changes permissions to 'only read'. This can prevent race conditions.
* Add VNC support for virtual mode VMsRoberto Hueso Gómez2020-05-131-7/+33
| | | | | This patch makes possible to interact with guest OS from a remote machine using VNC.
* Switch config file to jsonRoberto Hueso Gómez2020-05-132-14/+20
| | | | | This patch makes configuration parsing easier as well as making the full configuration available in many subclasses.