Skip to main content

libraries for account and server management

Project description

ocflib

Build Status Coverage Status PyPI version

ocflib is a Python library for working with Open Computing Facility services (in particular, accounts and server management).

The library targets Python 3.5.3 and 3.7 (the versions available in Debian stretch and buster).

The goal of the library is to make it easier to re-use OCF python code. In the past, code was split between approve, atool, create, chpass, sorry, signat, etc., which made it difficult to do things like share common password requirements.

What belongs here

In general, code which can be re-used should be here, but standalone applications or binaries shouldn't. For example, ocfweb uses ocflib code to change passwords and create accounts, but the Django web app doesn't belong here.

Using on OCF

ocflib is installed by Puppet on the OCF, so you can simply do things like import ocflib.lab.stats from the system python3 installation. We don't install it to python2 site-packages.

We build a Debian package which is installed by Puppet. We also publish new versions to PyPI, which is useful because it allows easy installation into virtualenvs.

Note about lockfiles

This repository includes a poetry.lock file. Lockfiles are usually used to ensure that the exact same versions of dependencies are installed across different machines. However, as this is a library, we don't want to force downstream users to use the exact same versions of dependencies as us, and indeed, the lockfile is ignored when distributing. We still include it in the repository to make it easier to develop, test, and debug ocflib.

Installing locally

For Testing Changes

Development of ocflib uses Poetry. The easiest way to test changes to ocflib is to let Poetry manage the virtual environment for you:

poetry install
poetry shell

Now, if you import something from ocflib, you'll be using the version from your working copy.

Testing and linting

We use pytest to test our code, and pre-commit to lint it. You should run make test before pushing to run both.

The tests directory contains automated tests which you're encouraged to add to (and not break). The tests-manual directory contains scripts intended for testing.

Using pre-commit

We use pre-commit to lint our code before commiting. While some of the rules might seem a little arbitrary, it helps keep the style consistent, and ensure annoying things like trailing whitespace don't creep in.

You can simply run make install-hooks to install the necessary git hooks; once installed, pre-commit will run every time you commit.

Alternatively, if you'd rather not install any hooks, you can simply use make test as usual, which will also run the hooks.

Troubleshooting: Cracklib Error

If you're trying to run make install-hooks on ocfweb (or related repos) and get this error:

./_cracklib.c:40:10: fatal error: 'crack.h' file not found
  #include <crack.h>
           ^~~~~~~~~
  1 error generated.

The issue relates to the cracklib package not finding the necessary header files to install. Make sure cracklib is installed on your machine (https://github.com/cracklib/cracklib, if you're on Mac, brew install cracklib).

Deploying changes

Deploying changes involves:

  • Running tests and linters
  • Pushing a new version to PyPI
  • Building a Debian package
  • Pushing the Debian package to our internal apt

Jenkins will automatically perform all of these steps for you on every push, including automatically generating a new version number. As long as make test passes, your code will be automatically deployed. You can monitor the progress of your deploy here.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocflib-2024.4.20.tar.gz (67.8 kB view details)

Uploaded Source

Built Distribution

ocflib-2024.4.20-py3-none-any.whl (78.9 kB view details)

Uploaded Python 3

File details

Details for the file ocflib-2024.4.20.tar.gz.

File metadata

  • Download URL: ocflib-2024.4.20.tar.gz
  • Upload date:
  • Size: 67.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.16

File hashes

Hashes for ocflib-2024.4.20.tar.gz
Algorithm Hash digest
SHA256 6ca4a7e1bb0b4eddd3d35d6a100f1044692b9d04cdcd9487d35893de180771ed
MD5 3c24a16e939ef0035800660a737fd5e4
BLAKE2b-256 1d57d7e44ff2930ada8ea2dd3374f5c117bcfc1eb0f9eb0760bf6385ac3c5989

See more details on using hashes here.

File details

Details for the file ocflib-2024.4.20-py3-none-any.whl.

File metadata

  • Download URL: ocflib-2024.4.20-py3-none-any.whl
  • Upload date:
  • Size: 78.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.16

File hashes

Hashes for ocflib-2024.4.20-py3-none-any.whl
Algorithm Hash digest
SHA256 7ae384ee2c5efce1f8ac59bfd02ce1b7a9d0c62048270ad905f423f251c56bdd
MD5 b8744a65383bfb961bed791f150a6aea
BLAKE2b-256 7b14d480cc552a79f47db5920ad5cfc296de40c9ff60606b770618a149a41a49

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page