Skip to content
Permalink
Browse files

Migration to Python3 and oVirt SDK 4, version 2.0.0

  • Loading branch information...
Nicolás Kovac
Nicolás Kovac committed Jul 14, 2019
1 parent 69fc0db commit 54e1ca511e843093d82eee1a449caeaaf79f8d71
Showing with 155 additions and 148 deletions.
  1. +7 −0 CHANGELOG
  2. +38 −63 README.md
  3. +20 −16 credentials.py
  4. +88 −67 ovirtclient.py
  5. +1 −1 requirements.txt
  6. +1 −1 version.py
@@ -1,3 +1,10 @@
2.0.0
-----
**MAJOR**: For migration process for 1.x to 2.0.0 please see README.md.

* Migration to Python 3.x
* Migration to oVirt Python SDK 4.0

1.0.6b
------
* Hotfix of a DBZ when no VMs or VMPools are assigned to a user
101 README.md
@@ -2,20 +2,22 @@

### Description

This project is a simple oVirt-related desktop client. The application will communicate with oVirt via its Python API and provide a list of VMs about which the user has usage privileges, allowing two essential operations:
This project is a simple oVirt-related desktop client. The application will communicate with oVirt via its Python API and provide a list of VMs and VmPools on which the user has usage privileges, allowing two essential operations:

1. _Manage power_: Users will be able to shutdown and start their machines.
2. _Connect to the machine_: The application makes use of _virt-viewer_ to connect to the VM. Both VNC and SPICE protocols are supported.

This application is written in *PyQT5*, and has been verified to be working with oVirt 4.0.0 (should work with any version >= 3.5.0).
This application is written in *PyQT5*, and has been verified to be working with oVirt version >= 4.0.0. It won't work with 3.6.0 versions of oVirt correctly.

This project is also accessible from the URL https://ovirt-desktop-client.click
This project is also accessible from https://ovirt-desktop-client.click

**Disclaimer**: This is an **unofficial** oVirt-related project.

### Installation

Below you'll find the installation steps. Please note that some installing processes are not as smooth as described here and some of you might find a few obstacles in the way. You can also find a [Troubleshooting guide](https://github.com/nkovacne/ovirt-desktop-client/wiki/Install-process). If you find a different problem please share it.
As of version 2.0.0 of oVirt Desktop Client, the installation process is much simpler, because Python3 allows using native PyQt5-sip and PyQt libraries. In previous versions this had to be built manually.

Below you'll find the installation steps. You can also find a [Troubleshooting guide](https://github.com/nkovacne/ovirt-desktop-client/wiki/Install-process). If you find a different problem please feel free to report it.

On Debian/Ubuntu environments, make sure to install these packages:
```
@@ -27,66 +29,29 @@ On RHEL environments, make sure to install these packages:
python python-devel python-virtualenv python-pip gcc gcc-c++ qt5-qtbase qt5-qtbase-devel libcurl-devel libxml2 libxml2-devel libxslt-devel openssl-devel virt-viewer
```

There are 2 sets of instructions you might follow: The short or the long way. You'll need to install 2 components which are SIP and PyQt5 and evidences show that the process to install them is very platform-dependent, so under Ubuntu you'll need to do some steps that might differ quite much from a CentOS platform, for example. The long way aims to be platform independent and should work for most systems. Otherwise, please open an issue.

#### Short way

The short way of installing required components is that you find out which packages correspond to both SIP and PyQt5 and install them. Either via `yum` if you're using RHEL-based systems or `apt-get` under Debian-based, and so on.

Optionally, you can install a `virtualenv` (using the `python-virtualenv` package). This is more a preference matter, some people prefer installing everything under a virtualenv, other prefer the system-wide way.

#### Long (but reliable) way

The latest successfully built combination of SIP and PyQT versions are:

* SIP: 4.19.18
* PyQt: 5.11.3

This doesn't mean other combinations are not possible. These are only the tested ones. However, seems that newer versions of PyQt are failing to `make` (`5.13.0` so far).

1. Create the project directory and create a *virtualenv* inside:
```
mkdir ovirt-desktop-client
cd ovirt-desktop-client
virtualenv --always-copy venv
. venv/bin/activate
```

2. You have to download the SIP and PyQT5 projects and install them manually. Starting with SIP, [download](https://www.riverbankcomputing.com/software/sip/download) the *tar.gz* file to your ~/ovirt_client directory, uncompress it and compile it.
```
tar zxvf sip-X.X.X.tar.gz
cd sip-X.X.X
python configure.py
make
make install
cd ..
```
Now just clone, install a virtualenv with Python3 as the Python executable and install the requirements for the project.

3. Let's do the same with [PyQT5](https://www.riverbankcomputing.com/software/pyqt/download5). **Note**: Versions from `5.11.x` and above won't work. Use the latest version of the `5.10.x` minor.
```
pip install enum34
tar zxvf PyQt-gpl-X.X.tar.gz
cd PyQt-gpl-X.X
python configure.py (you'll need to accept the license to install PyQt5)
make
make install
cd ..
```
```
git clone https://github.com/nkovacne/ovirt-desktop-client.git
virtualenv -p python3 --always-copy venv
. venv/bin/activate
cd ovirt-desktop-client
pip install -r requirements.txt
```

4. Clone the oVirt-desktop-client project:
```
git clone https://github.com/nkovacne/ovirt-desktop-client.git
```
### Upgrading from version 1.x to 2.x

5. Install the Python requirements with `pip`:
```
pip install -r ovirt-desktop-client/requirements.txt
```
In previous versions, SIP and PyQt packages needed to be built manually. Furthermore, it was based on Python 2, whereas version >= 2.0.0 is Python 3 based. To upgrade, the fastest way is to `pull` the 2.0.0 version, destroy the virtualenv and recreate it. Just follow these commands to upgrade.

6. You're done. Even if you have not configured settings yet, you can try to start the application just to see if it works.
```
python ovirt-desktop-client/ovirtclient.py
```
```
deactivate (in case you're working in the virtualenv)
rm -rf venv
virtualenv -p python3 --always-copy venv
. venv/bin/activate
cd ovirt-desktop-client
git pull
pip install -r requirements.txt
```

### Configuration

@@ -96,7 +61,7 @@ To run the application, a file named `settings.conf` must exist in the same dire

The beggining of this section is marked with the `[ovirt]` line and references some settings that are directly related to the oVirt infrastructure that you mean to connect to. It only has 2 parameters, and both are **mandatory**:

* **url**: You oVirt infrastructure API URL. If you're using oVirt version 3.6.x, URL should be somewhat like: `https://myovirt.mydomain.com/api`. If you're using oVirt version 4.0.x or greater, URL should be somewhat like: `https://myovirt.mydomain.com/ovirt-engine/api`.
* **url**: You oVirt infrastructure API URL. If you're using oVirt version 4.0.x or greater, URL should be somewhat like: `https://myovirt.mydomain.com/ovirt-engine/api`.
* **domain**: The domain under which your users will authenticate. When you create an AAA authenticator (LDAP, Kerberos, ...), a domain name is created to match it. This value goes here, so users will authenticate as `username@domain` (Ex: LDAP, MyCompany, ...). It's the 'Profile' field value when you're logging into the oVirt web-based API.

#### app section
@@ -105,13 +70,23 @@ The beggining of this section is marked with the `[app]` line and references som

* **lang**: Chooses the application language. Available languages are stored under the `lang` folder. If you don't see your language, you can translate it and send a push request so I can merge it into the project. Default: en.
* **connection_timeout**: Establishes the number of seconds to wait after sending a request to your oVirt infrastructure after which the request will be considered timed out. Default: 15
* **preferred_protocol**: Some VMs have more than one graphics protocols enabled (i.e, VNC and SPICE) at a time. These VMs allow choosing which one you prefer to use when opening a console window. In case that the VM only has one protocol enabled, this will be used disregarding this parameter. Possible values: spice, vnc. Default: spice
* **preferred_protocol**: Some VMs have more than one graphics protocol enabled (i.e, VNC and SPICE) at a time. These VMs allow choosing which one you prefer to use when opening a console window. In case that the VM only has one protocol enabled, this will be used disregarding this parameter. Possible values: spice, vnc. Default: spice
* **fullscreen**: Enables opening the console window as fullscreen or the default size. Possible values: 1 (full screen), 0 (default size). Default: 0
* **allow_remember**: Defines whether show or not the "Remember credentials" checkbox. Some environments might prefer not enabling it (for example, thin-client fashioned terminals). Possible values: 1 (enable the remembering credentials checkbox), 0 (disable the remembering credentials checkbox). Default: 1
* **autologout**: Time in minutes of idleness after which the session is forcibly closed. If set to 0, the autologout feature is disabled. Only works if there are not any credentials stored (also with allow_remember = 0), which is incompatible with this feature. Default: 0
* **notify_autologout**: The time before *autologout* in minutes before a warning window will be shown to the user alerting them about an imminent forced logout event. Accepting the warning means resetting the idle time. This setting needs to have a lower value than *autologout*. If this setting is set and 'autologout' is not, or if the value of *notify_autologout* is lower than the value in *autologout*, this setting will be set to the default value. A value of 0 means that no warning windows will be shown to the user. _Example_: If *autologout* is 15 and *notify_autologout* is 5, means that 5 minutes before reaching the 15 minutes limit of idleness a warning window will be shown. If the user accepts the warning within the next 5 minutes limit, the idleness count will be reset. Otherwise the enforced logout will be performed. Default: 0
* **remote_viewer_path**: The path to the remote-viewer binary. By default, it's set to a path that is compatible with most systems. However, you can set a customized path here. If set to an invalid path, the app will still try to find the correct binary. Will exit if no suitable binary was found. Default: /usr/bin/remote-viewer

### How to run

Just run the `virtualenv` and the `ovirtclient.py` executable.

```
. venv/bin/activate
cd ovirt-desktop-client
python ovirtclient.py
```

### Current version

Current stable version is 1.0.6b. You can find a CHANGELOG file inside your directory to see news.
Current stable version is 2.0.0. You can find a CHANGELOG file inside your directory to see news.
@@ -24,9 +24,7 @@
from PyQt5.QtWidgets import QProgressBar, QPushButton, QDesktopWidget, QDialog, QLabel, QLineEdit, QGridLayout, QCheckBox, QMessageBox
from PyQt5.QtGui import QImage, QPixmap, QIcon
from PyQt5.QtCore import QBasicTimer, Qt
# FIXME
#from ovirtsdk.api import API
#from ovirtsdk.infrastructure.errors import ConnectionError, RequestError
from ovirtsdk4 import Connection, Error

class CheckCreds(QDialog):
"""
@@ -81,20 +79,27 @@ def timerEvent(self, e):
self.status.setText(_('authenticating'))

if not conf.USERNAME:
# FIXME: API class no longer exists
try:
kvm = API(url=conf.CONFIG['ovirturl'], username=self.uname + '@' + conf.CONFIG['ovirtdomain'], password=self.pw, insecure=True, timeout=int(conf.CONFIG['conntimeout']), filter=True)
conf.OVIRTCONN = kvm
conn = Connection(
url=conf.CONFIG['ovirturl'],
username=self.uname + '@' + conf.CONFIG['ovirtdomain'],
password=self.pw,
ca_file=conf.CONFIG['cafile'],
insecure=True,
timeout=int(conf.CONFIG['conntimeout']),
headers={'filter':True}
)

conn.test(raise_exception=True)

conf.SOCKOBJ = conn
conf.OVIRTCONN = conn.system_service()
conf.USERNAME = self.uname
conf.PASSWORD = self.pw
self.status.setText(_('authenticated_and_storing'))
self.step = 49
except ConnectionError as e:
err.critical(self, _('apptitle') + ': ' + _('error'), _('ovirt_connection_error') + ': ' + sub('<[^<]+?>', '', str(e)))
self.status.setText(_('error_while_authenticating'))
self.step = 100
except RequestError as e:
err.critical(self, _('apptitle') + ': ' + _('error'), _('ovirt_request_error') + ': ' + sub('<[^<]+?>', '', str(e)))
except Error as e:
err.critical(self, _('apptitle') + ': ' + _('error'), _('ovirt_connection_error') + ': ' + str(e))
self.status.setText(_('error_while_authenticating'))
self.step = 100

@@ -107,10 +112,9 @@ def timerEvent(self, e):
# Credentials were ok, we check whether we should store them for further uses
if self.remember:
self.status.setText(_('storing_credentials'))
# FIXME
#with os.fdopen(os.open(conf.USERCREDSFILE, os.O_WRONLY | os.O_CREAT, 0600), 'w') as handle:
# handle.write('[credentials]\nusername=%s\npassword=%s' % (self.uname, encode(self.pw, 'rot_13')))
# handle.close()
with os.fdopen(os.open(conf.USERCREDSFILE, os.O_WRONLY | os.O_CREAT, 0o600), 'w') as handle:
handle.write('[credentials]\nusername=%s\npassword=%s' % (self.uname, encode(self.pw, 'rot_13')))
handle.close()
self.step = 99
else:
self.status.setText(_('successfully_authenticated'))

0 comments on commit 54e1ca5

Please sign in to comment.
You can’t perform that action at this time.