Skip to main content

Client library for Hashicorp Nomad

Project description

python-nomad

Python Nomad Test and Publish codecov PyPI version PyPI pyversions Downloads Downloads PyPI license

Installation

pip install python-nomad

Documentation

https://python-nomad.readthedocs.io/en/latest/

Examples

import nomad
# For HTTP Nomad instances
n = nomad.Nomad(host="172.16.100.10", timeout=5)

# For HTTPS Nomad instances with non-self-signed SSL certificates
n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=True)

# For HTTPS Nomad instances with self-signed SSL certificates and no validate the cert
n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=False)

# For HTTPS Nomad instances with self-signed SSL certificates that must validate with cert
n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=True, cert="/path/to/certfile") # See http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification

# For HTTPS Nomad instances with cert file and key
n = nomad.Nomad(host="https://172.16.100.10", secure=True, timeout=5, verify=True, cert=("/path/to/certfile", "/path/to/key")) # See http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification

# For HTTPS Nomad instances with namespace and acl token
n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=False, namespace='Namespace-example',token='3f4a0fcd-7c42-773c-25db-2d31ba0c05fe')

"example" in n.jobs

j = n.jobs["example"]["ID"]

example_allocation = n.job.get_allocations(j)

n.job.deregister_job(j)

Environment Variables

This library also supports environment variables: NOMAD_ADDR, NOMAD_NAMESPACE, NOMAD_TOKEN, NOMAD_REGION, NOMAD_CLIENT_CERT, and NOMAD_CLIENT_KEY for ease of configuration and unifying with nomad cli tools and other libraries.

NOMAD_ADDR=http://127.0.0.1:4646
NOMAD_NAMESPACE=default
NOMAD_TOKEN=xxxx-xxxx-xxxx-xxxx
NOMAD_REGION=us-east-1a
NOMAD_CLIENT_CERT=/path/to/tls/client.crt
NOMAD_CLIENT_KEY=/path/to/tls/client.key

Class Dunders

Class contains len getitem iter
agent N N N N
allocation Y N Y N
allocations N Y N Y
client N N N N
evaluation Y N Y N
evaluations Y Y Y Y
event N N N N
job Y N Y N
jobs Y Y Y Y
node Y N Y N
nodes Y Y Y Y
regions Y Y Y Y
status.leader Y Y N N
status.peers Y Y Y Y
system N N N N
validate N N N N
deployments Y Y Y Y
deployment Y N Y N
namespace Y N Y N
namespaces Y Y Y Y
acl Y N Y N
sentinel Y N Y N

Development

  • create virtualenv and activate
  • install requirements-dev.txt
  • can either use the Vagrantfile for local integration testing or create environment variables NOMAD_IP and NOMAD_PORT that are assigned to a nomad binary that is running
virtualenv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt

Testing with vagrant and virtualbox

vagrant up --provider virtualbox
py.test --cov=nomad --cov-report=term-missing --runxfail tests/

Testing with nomad binary

./nomad agent -dev -node pynomad1 --acl-enabled
NOMAD_IP=127.0.0.1 NOMAD_VERSION=<SEMNATIC_VERSION> py.test --cov=nomad --cov-report=term-missing --runxfail tests/

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

python-nomad-1.5.0.tar.gz (20.2 kB view details)

Uploaded Source

Built Distributions

python_nomad-1.5.0-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

python_nomad-1.5.0-py2-none-any.whl (34.8 kB view details)

Uploaded Python 2

File details

Details for the file python-nomad-1.5.0.tar.gz.

File metadata

  • Download URL: python-nomad-1.5.0.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for python-nomad-1.5.0.tar.gz
Algorithm Hash digest
SHA256 5699e026f9bd78aeb494f78521b8e74f0cd65a827db5104360fe528210cc6c08
MD5 e872e98791a07754af9623241a3c4383
BLAKE2b-256 0b12307d20605a147beca2a141a24bc455a2ab12bdf274ab4d3c6fd61ba7a260

See more details on using hashes here.

File details

Details for the file python_nomad-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_nomad-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fd2faa792269b25a2d355c89d7a24094e99065357ffed752633c52d181e2bab
MD5 fd44fc5dd34d5bafc872952615c2a8ce
BLAKE2b-256 0bfd427e236e4cd4486de462ff00642abebc66847cbde1b0f00493e583d6da4d

See more details on using hashes here.

File details

Details for the file python_nomad-1.5.0-py2-none-any.whl.

File metadata

File hashes

Hashes for python_nomad-1.5.0-py2-none-any.whl
Algorithm Hash digest
SHA256 7833e4d21d9326df98b7b9cca687e042fe7dff40c562bd71fc828be9167f909e
MD5 70abb58ab6c892ab8c623a6c1c9b4c45
BLAKE2b-256 8340afa6fffd0fde4209880c00aed0ad33b2aa21862fe18518eff960a7b4be9a

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