Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Ethel

Ethel is a tool that allows you to manipulate with accounts in Stage, QA or any other environment, buy Subscriptions, activate them and do other chores.

Instalation

pip install ethel

Usage

Prerequisites

Before you can use Ethel, you have to set up your environment accordingly:

# Required:
EBS_CERT_PUBLIC=<PATH_TO_EBS_SSL_CLIENT_CERTIFICATE>
EBS_CERT_KEY=<PATH_TO_EBS_SSL_CLIENT_CERTIFICATE_KEY>

# Optional:
CANDLEPIN_USERNAME=<CANDLEPIN_SUPERUSER_USERNAME>  # Defaults to "candlepin_admin"
CANDLEPIN_PASSWORD=<CANDLEPIN_SUPERUSER_PASSWORD>  # Defaults to "candlepin_admin"

Basic usage

The most basic usecase is to simply create an account and subscribe it to a product.

>>> from ethel import Ethel

>>> ethel = Ethel.stage()

>>> account = ethel.create_account('some_fancy_username', 'not_so_secret_password')

>>> account.subscribe('product_sku')

Ethel provides access to Stage and QA environments via Ethel.stage() and Ethel.qa() class methods.

Advanced usage

Ethel, by default, processes everything for you when the account is being created. Also, if account with the same username already exists, Ethel verifies your credentials and returns you the already existant account entry.

When account is being created, Ethel ensures that it's Candlepins owners are created (forces Candlepin refresh) and accepts all required Terms and Conditions. To disable this behavior, you can pass create_owners=False and/or accept_terms=False when creating account and do it yourself later:

>>> account = ethel.create_account(
... "some_fancy_username",
... "not_so_secret_password",
... first_name="Gretchen",
... last_name="SomeOldSurname",
... email="grandmas.dont.have@emails.com",
... create_owners=False,
... accept_terms=False,
... )

>>> account.start_refresh()

>>> account.get_refresh_status()
'RUNNING'

>>> account.get_refresh_status()
'FINISHED'

>>> account.accept_all_terms(optional=True)  # Accepts also the optional Terms and Conditions

You can also specify more details about your desired subscription when asking Ethel to subscribe it you your account:

>>> account.subscribe(
... 'product_sku',
... quantity=42,
... start_date='yesterday',  # accepts 'yesterday', 'today', 'tomorrow', ISO date 'YYYY-MM-DD' or datetime.date
... duration=365 # accepts integer that means 'days' or datetime.timedelta
... )

Errors and Exceptions

If an exception is returned to Ethel from either Candlepin or the EBS rest API services, they are unified and interfaced as an EthelError. Depending on the exact API that raised the exception, the level of detail varies. Following properties are stored:

  • message - Should contain the reason why the exception occurred.
  • message_type - Class of the exception reason description (different to exception_type).
  • exception_type - Type of exception (class name).
  • status_code - HTTP status code (EBS likes to return HTTP_500 for any reason).
  • source - API that caused the exception.
  • uuid - Exception's tracking code for Candlepin API.
  • raw_error - HTTPError object providing access to PreparedRequest and Response directly.

Ethel does not handle requests.ConnectionError and requests.Timeout. For convenience a shorthand EthelConnectionError is provided. Ethel doesn't retry any request, it's up to user to handle this behavior.

>>> account = ethel.create_account('USERNAME', 'WRONG_PASSWORD')
EthelError: From: Candlepin(api_base_url=<CANDLEPIN_URL_FOR_THIS_ENV>). Reason: Invalid user credentials. Status code: 401. Call(method=GET, url=<CANDLEPIN_URL_FOR_THIS_ENV>)/users/<USERNAME>/owners).

>>> try:
...     account = ethel.create_account('<USERNAME>', '<WRONG_PASSWORD>')
... except EthelError as e:
...     logging.error("Status Code %d, Message: %s, Tracking code %s" % (e.status_code, e.message, e.uuid))

ERROR:root:Status Code 401, Message: Invalid user credentials, Tracking code e7275480-2c59-42fa-a6db-b8df6a9dc323

Additional properties

Ethel stores few important properties for each of your accounts that might be usefull to you:

  • Organization ID
  • Candlepin Owner ID
  • List of all Subscription orders done in this session
  • List of all Activation orders done in this session
>>> account.org_id
123456789

>>> account.owner_id
987654321

>>> account.orders
[...]

>>> account.activations
[...]

View Account

And since Ethel allows you to have a Black Friday for subscriptions everyday, you may want to look up all the things you've bought:

>>> account.list_pools()  # You can pass future=True argument to list also pools valid in future
[
    {
        'pool_id': '<USE_THIS_TO_SUBSCRIBE>',
        'sku_id': '<PRODUCT_SKU_ID>',
        'product_name': 'Fancy Product Name',
        'start_date': '2020-02-07T05:00:00+0000',
        'end_date': '2021-02-07T04:59:59+0000',
        'muiltiplier': None,
        'quantity': 'unlimited',
        'instance_multiplier': None
    },
    {
        'pool_id': '<ALSO_USE_THIS_TO_SUBSCRIBE>',
        'sku_id': '<ANOTHER_PRODUCT_SKU_ID>',
        'product_name': 'Fancy Product Name',
        'start_date': '2020-02-06T05:00:00+0000',
        'end_date': '2021-02-06T04:59:59+0000',
        'muiltiplier': None,
        'quantity': 1,
        'instance_multiplier': 16
    },
    ...
]

Developer setup

After cloning this repo, setup the local environment via Poetry:

poetry install

Prepared tasks

  • poetry run task lint - runs Mypy and Pylint
  • poetry run task test - runs Pytest test suite

Release files for ethel 3.0.0rc2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ethel 3.0.0rc2
File Size Uploaded
ethel-3.0.0rc2.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ethel 3.0.0rc2
File Interpreter ABI Platform
ethel-3.0.0rc2-py3-none-any.whl Python 3 none any Details

Total release size: 36.5 kB

Release files / ethel-3.0.0rc2.tar.gz

Download URL ethel-3.0.0rc2.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9cd7640b866b75bfd3b2fe452d62edbcb9320f2c8e4bf8383e45df443bda25cb
BLAKE2b-256 checksum
How to use checksums
fbd81aed072572b43b086de85c06b43a5f2808f00617cf22d8510d6c5338ca85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.5 Linux/5.8.1-zen1-1-zen

Release files / ethel-3.0.0rc2-py3-none-any.whl

Download URL ethel-3.0.0rc2-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3d2c45b9eee7e97331fec16fe706c81fe38a2a33c9d5596f4dee60ff6c843e8
BLAKE2b-256 checksum
How to use checksums
e6dbc764fc96a9e36fc2183eb2510eb81a395a6c93731071b340365e5e1914f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.5 Linux/5.8.1-zen1-1-zen

Release history Release notifications | RSS feed

This release

3.0.0rc2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page