Skip to main content

Module that determines a host's cloud provider

Project description

cloud-detect

PyPI - Python Version PyPI PyPI - License CI

About

cloud-detect is a Python module that determines a host's cloud provider. Highly inspired by the Go based Satellite, cloud-detect uses the same techniques (file systems and provider metadata) to properly identify cloud providers.

Features

  • Supports identification of Alibaba, AWS, Azure, Digital Ocean, GCP, Oracle Cloud and Vultr hosts.
  • Fast and supports asyncio
  • Logging integration.
  • Small and extensible.

Usage

>>> from cloud_detect import provider
>>> provider()
'aws'

>>> provider() # when tested in local/non-supported cloud env
'unknown'

Right now the only possible responses are: 'alibaba', 'aws', 'azure', 'do', 'gcp', 'oci', 'vultr' or 'unknown'

You can get the list of supported providers using

>>> from cloud_detect import SUPPORTED_PROVIDERS

Installation

Via pip:

pip install cloud-detect

Examples

Termination-handler uses cloud-detect to keep the handling of termination notices on spot/preemptible instances cloud-agnostic, making easier to operate the same tooling in various distinct environments.

How to contribute

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
  2. Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).
  3. Set up a local dev environment: python -m venv .venv && source .venv/bin/activate && pip install -U pip && pip install -e '.[dev]', then run tests with pytest and lint with ruff check ..
  4. Write a test which shows that the bug was fixed or that the feature works as expected.
  5. Send a pull request and bug me until it gets merged and published.

Some things that would be great to have:

  • Add more cloud providers
  • Add codecov

Publishing a release

Requires maintainer access to the project on PyPI (authenticate with an API token: username __token__, password pypi-...).

  1. Bump version in pyproject.toml.
  2. Build and upload:
rm -rf dist
pip install -U build twine
python -m build
twine upload dist/*

Project details


Download files

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

Source Distribution

cloud_detect-0.0.14.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloud_detect-0.0.14-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file cloud_detect-0.0.14.tar.gz.

File metadata

  • Download URL: cloud_detect-0.0.14.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for cloud_detect-0.0.14.tar.gz
Algorithm Hash digest
SHA256 19abeaddc665eed5b5bcac8bdd9420efe04342bb7b838c7c4d57c52f85c1c570
MD5 e1f9683a0081b4991d9b65bbc66d4492
BLAKE2b-256 2e1c08ef4bd1e1c8ff6b7e03b11ab5a305f5d995ba59e25c03e96aea35f8f410

See more details on using hashes here.

File details

Details for the file cloud_detect-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: cloud_detect-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for cloud_detect-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 a2b68f77616a3641fae50f96eef7987cf0dacf53b939e8f1e178d646f18bb7a3
MD5 9f4d1febef45344050fb811ee99be6fb
BLAKE2b-256 115dff9729223b5fd0752b4a5c063917ec2c45ef611da0998f6a4c91f68f9d2d

See more details on using hashes here.

Supported by

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