This is the Python library behind the client management-tool opsi.
This library is released under the AGPLv3 and the copyright belongs to uib GmbH if this is not noted otherwise in the file itself.
You can use Sphinx to build the documentation. If you are looking for information on how to setup or configure an opsi system please get the getting started from opsi.org.
Building the documentation
First we create the API documentation from the Python files:
sphinx-apidoc --separate --output-dir=doc/src OPSI/
After that we can build the documentation:
sphinx-build -b html -d doc/_build/doctrees doc/src/ doc/python-opsi/
After that you will find the documentation in the folder
Opsi relies on a mix of Python-libraries and system tools that need to be installed.
The dependencies for your distribution can either be found in
Please use your distributions recommended tool for the installation of
Installing on Ubuntu
Installing the depedencies via apt-get:
apt-get install lsb-release python-twisted-web python-twisted-conch python-magic python-crypto python-ldap python-newt python-pam python-openssl python-mysqldb python-sqlalchemy iproute duplicity python-m2crypto lshw python-dev python-ldaptor
For installing further depedencies on your system we also recommend to install the header files for Python, librsync and to test the SQLite-backend we also need apsw.
This can be done with:
apt-get install build-essential python-dev librsync-dev python-apsw
Install via pip
It is possible to use
pip to install most of the requirements - some
requirements are for other programs that can not be installed via pip.
pip install -r requirements.txt
Packages can be build for distributions that use either Debian or RPM
Please install the necessary build requirements from either
rpm/python-opsi.spec before you build a package.
On Debian-based systems
For building on a Debian-based system you can use the following command:
dpkg-buildpackage -us -uc
On RPM-based systems
For building on a RPM-based system you can use the following command:
rpmbuild -ba rpm/python-opsi.spec
Tests can be found in the
tests folder. We use pytest for our tests.
Requirements for the tests can be found in
They can be installed with the following command:
pip install -r requirements-qa.txt
Configuring database for test
Testing the MySQL backend requires a license file for most of the tests.
To run tests with MySQL as a backend you need to install and configure your MySQL server first. You then need to create a user and database for the tests. Please follow the corresponding guides of your distribution and/or MySQL to do so.
Warning: The tests will drop every table on the configured database so make sure you are not running things against your production database!
It is possible to let opsi create a database for you by running
opsi-setup --configure-mysql and then re-use the configuration from
To configure the tests copy the example configuration to
cp tests/Backends/config.py.example tests/Backends/config.py
In this file fill the dict
MySQLconfiguration with the settings for your test database.
If your are reusing the values from
/etc/opsi/backends/mysql.conf you can copy the content of
config to it.
Tests can then be run with:
Contributions are welcome.
If you find any security problem please inform us (email@example.com) before disclosing the security vulnerability in public.
Please provide tests or a guide on how to test with your contributions. After applying your code changes all tests must pass.
Indentation should be done with hard tabs.
Code should be written in
For backend methods that can be executed via a call to the webservice
please use stick to the use of camelCase but seperate the object type
and the method name with an underscore like this:
For more general information about webservice methods please refer to the manual.
Besides this please follow PEP 008.
Semi-Automated Quality Checks
There is a script that runs
flake8 and all the tests.
If you want to use it please install the requirements for it first:
pip install -r requirements-qa.txt
After that you can execute the script:
The script will not display any problems reported by
pep8 but instead creates the files
You then can check the corresponding output.
It will also run all tests and create a coverage from those tests as
Documentation should be provided for any non-intuitive or complex part.
Please provide the documentation either directly as Python docstrings or
provide it in the form of documents inside the
The documentation should be integrated into the documentation that is
built with Sphinx.