python-nomad


Namepython-nomad JSON
Version 1.5.0 PyPI version JSON
download
home_pagehttp://github.com/jrxfive/python-nomad
SummaryClient library for Hashicorp Nomad
upload_time2022-12-06 12:23:23
maintainer
docs_urlNone
authorjrxfive
requires_python
licenseMIT
keywords nomad hashicorp client
VCS
bugtrack_url
requirements requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-nomad


[![Python Nomad Test and Publish](https://github.com/jrxFive/python-nomad/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/jrxFive/python-nomad/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/jrxFive/python-nomad/branch/master/graph/badge.svg)](https://codecov.io/gh/jrxFive/python-nomad)
[![PyPI version](https://badge.fury.io/py/python-nomad.svg)](https://badge.fury.io/py/python-nomad)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/python-nomad.svg)](https://pypi.python.org/pypi/python-nomad/)
[![Downloads](https://pepy.tech/badge/python-nomad/month)](https://pepy.tech/project/python-nomad)
[![Downloads](https://static.pepy.tech/personalized-badge/python-nomad?period=total&units=international_system&left_color=black&right_color=blue&left_text=Downloads)](https://pepy.tech/project/python-nomad)
[![PyPI license](https://img.shields.io/pypi/l/python-nomad.svg)](https://pypi.python.org/pypi/python-nomad/)


## Installation
```
pip install python-nomad
```

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

## Examples
```python


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.

```bash
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/
```

- Examples
    - [x] Acl [:link:](docs/api/acl.md)
    - [x] Agent [:link:](docs/api/agent.md)
    - [x] Allocation [:link:](docs/api/allocation.md)
    - [x] Allocations [:link:](docs/api/allocations.md)
    - [x] Deployment [:link:](docs/api/deployment.md)
    - [x] Deployments [:link:](docs/api/deployments.md)
    - [x] Client [:link:](docs/api/client.md)
    - [x] Evaluation [:link:](docs/api/evaluation.md)
    - [x] Evaluations [:link:](docs/api/evaluations.md)
    - [x] Event [:link:](docs/api/event.md)
    - [x] Job [:link:](docs/api/job.md)
    - [x] Jobs [:link:](docs/api/jobs.md)
    - [x] Namespace [:link:](docs/api/namespace.md)
    - [x] Namespaces [:link:](docs/api/namespaces.md)
    - [x] Node [:link:](docs/api/node.md)
    - [x] Nodes [:link:](docs/api/nodes.md)
    - [x] Regions [:link:](docs/api/regions.md)
    - [x] Sentinel [:link:](docs/api/sentinel.md)
    - [x] Search [:link:](docs/api/search.md)
    - [x] Status [:link:](docs/api/status.md)
    - [x] System [:link:](docs/api/system.md)
    - [x] Validate [:link:](docs/api/validate.md)
    - [x] Variable [:link:](docs/api/variable.md)
    - [x] Variables [:link:](docs/api/variables.md)

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/jrxfive/python-nomad",
    "name": "python-nomad",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "nomad hashicorp client",
    "author": "jrxfive",
    "author_email": "jrxfive@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0b/12/307d20605a147beca2a141a24bc455a2ab12bdf274ab4d3c6fd61ba7a260/python-nomad-1.5.0.tar.gz",
    "platform": null,
    "description": "# python-nomad\n\n\n[![Python Nomad Test and Publish](https://github.com/jrxFive/python-nomad/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/jrxFive/python-nomad/actions/workflows/main.yml)\n[![codecov](https://codecov.io/gh/jrxFive/python-nomad/branch/master/graph/badge.svg)](https://codecov.io/gh/jrxFive/python-nomad)\n[![PyPI version](https://badge.fury.io/py/python-nomad.svg)](https://badge.fury.io/py/python-nomad)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/python-nomad.svg)](https://pypi.python.org/pypi/python-nomad/)\n[![Downloads](https://pepy.tech/badge/python-nomad/month)](https://pepy.tech/project/python-nomad)\n[![Downloads](https://static.pepy.tech/personalized-badge/python-nomad?period=total&units=international_system&left_color=black&right_color=blue&left_text=Downloads)](https://pepy.tech/project/python-nomad)\n[![PyPI license](https://img.shields.io/pypi/l/python-nomad.svg)](https://pypi.python.org/pypi/python-nomad/)\n\n\n## Installation\n```\npip install python-nomad\n```\n\n## Documentation\nhttps://python-nomad.readthedocs.io/en/latest/\n\n## Examples\n```python\n\n\nimport nomad\n# For HTTP Nomad instances\nn = nomad.Nomad(host=\"172.16.100.10\", timeout=5)\n\n# For HTTPS Nomad instances with non-self-signed SSL certificates\nn = nomad.Nomad(host=\"172.16.100.10\", secure=True, timeout=5, verify=True)\n\n# For HTTPS Nomad instances with self-signed SSL certificates and no validate the cert\nn = nomad.Nomad(host=\"172.16.100.10\", secure=True, timeout=5, verify=False)\n\n# For HTTPS Nomad instances with self-signed SSL certificates that must validate with cert\nn = 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\n\n# For HTTPS Nomad instances with cert file and key\nn = 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\n\n# For HTTPS Nomad instances with namespace and acl token\nn = nomad.Nomad(host=\"172.16.100.10\", secure=True, timeout=5, verify=False, namespace='Namespace-example',token='3f4a0fcd-7c42-773c-25db-2d31ba0c05fe')\n\n\"example\" in n.jobs\n\nj = n.jobs[\"example\"][\"ID\"]\n\nexample_allocation = n.job.get_allocations(j)\n\nn.job.deregister_job(j)\n```\n\n## Environment Variables\n\nThis library also supports environment variables: `NOMAD_ADDR`, `NOMAD_NAMESPACE`, `NOMAD_TOKEN`, `NOMAD_REGION`, `NOMAD_CLIENT_CERT`, and `NOMAD_CLIENT_KEY`\nfor ease of configuration and unifying with nomad cli tools and other libraries.\n\n```bash\nNOMAD_ADDR=http://127.0.0.1:4646\nNOMAD_NAMESPACE=default\nNOMAD_TOKEN=xxxx-xxxx-xxxx-xxxx\nNOMAD_REGION=us-east-1a\nNOMAD_CLIENT_CERT=/path/to/tls/client.crt\nNOMAD_CLIENT_KEY=/path/to/tls/client.key\n```\n\n## Class Dunders\n\n| Class | contains | len | getitem | iter |\n|---|---|---|---|---|\n|agent|N|N|N|N\n|allocation|Y|N|Y|N\n|allocations|N|Y|N|Y\n|client|N|N|N|N\n|evaluation|Y|N|Y|N\n|evaluations|Y|Y|Y|Y\n|event|N|N|N|N\n|job|Y|N|Y|N\n|jobs|Y|Y|Y|Y\n|node|Y|N|Y|N\n|nodes|Y|Y|Y|Y\n|regions|Y|Y|Y|Y\n|status.leader|Y|Y|N|N\n|status.peers|Y|Y|Y|Y\n|system|N|N|N|N\n|validate|N|N|N|N\n|deployments|Y|Y|Y|Y\n|deployment|Y|N|Y|N\n|namespace|Y|N|Y|N\n|namespaces|Y|Y|Y|Y\n|acl|Y|N|Y|N\n|sentinel|Y|N|Y|N\n\n## Development\n* create virtualenv and activate\n* install requirements-dev.txt\n* 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\n\n```\nvirtualenv .venv\nsource .venv/bin/activate\npip install -r requirements-dev.txt\n```\n\n## Testing with vagrant and virtualbox\n```\nvagrant up --provider virtualbox\npy.test --cov=nomad --cov-report=term-missing --runxfail tests/\n```\n\n## Testing with nomad binary\n```\n./nomad agent -dev -node pynomad1 --acl-enabled\nNOMAD_IP=127.0.0.1 NOMAD_VERSION=<SEMNATIC_VERSION> py.test --cov=nomad --cov-report=term-missing --runxfail tests/\n```\n\n- Examples\n    - [x] Acl [:link:](docs/api/acl.md)\n    - [x] Agent [:link:](docs/api/agent.md)\n    - [x] Allocation [:link:](docs/api/allocation.md)\n    - [x] Allocations [:link:](docs/api/allocations.md)\n    - [x] Deployment [:link:](docs/api/deployment.md)\n    - [x] Deployments [:link:](docs/api/deployments.md)\n    - [x] Client [:link:](docs/api/client.md)\n    - [x] Evaluation [:link:](docs/api/evaluation.md)\n    - [x] Evaluations [:link:](docs/api/evaluations.md)\n    - [x] Event [:link:](docs/api/event.md)\n    - [x] Job [:link:](docs/api/job.md)\n    - [x] Jobs [:link:](docs/api/jobs.md)\n    - [x] Namespace [:link:](docs/api/namespace.md)\n    - [x] Namespaces [:link:](docs/api/namespaces.md)\n    - [x] Node [:link:](docs/api/node.md)\n    - [x] Nodes [:link:](docs/api/nodes.md)\n    - [x] Regions [:link:](docs/api/regions.md)\n    - [x] Sentinel [:link:](docs/api/sentinel.md)\n    - [x] Search [:link:](docs/api/search.md)\n    - [x] Status [:link:](docs/api/status.md)\n    - [x] System [:link:](docs/api/system.md)\n    - [x] Validate [:link:](docs/api/validate.md)\n    - [x] Variable [:link:](docs/api/variable.md)\n    - [x] Variables [:link:](docs/api/variables.md)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Client library for Hashicorp Nomad",
    "version": "1.5.0",
    "split_keywords": [
        "nomad",
        "hashicorp",
        "client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "70abb58ab6c892ab8c623a6c1c9b4c45",
                "sha256": "7833e4d21d9326df98b7b9cca687e042fe7dff40c562bd71fc828be9167f909e"
            },
            "downloads": -1,
            "filename": "python_nomad-1.5.0-py2-none-any.whl",
            "has_sig": false,
            "md5_digest": "70abb58ab6c892ab8c623a6c1c9b4c45",
            "packagetype": "bdist_wheel",
            "python_version": "py2",
            "requires_python": null,
            "size": 34776,
            "upload_time": "2022-12-06T12:23:23",
            "upload_time_iso_8601": "2022-12-06T12:23:23.817558Z",
            "url": "https://files.pythonhosted.org/packages/83/40/afa6fffd0fde4209880c00aed0ad33b2aa21862fe18518eff960a7b4be9a/python_nomad-1.5.0-py2-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "fd44fc5dd34d5bafc872952615c2a8ce",
                "sha256": "7fd2faa792269b25a2d355c89d7a24094e99065357ffed752633c52d181e2bab"
            },
            "downloads": -1,
            "filename": "python_nomad-1.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fd44fc5dd34d5bafc872952615c2a8ce",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 34772,
            "upload_time": "2022-12-06T12:23:21",
            "upload_time_iso_8601": "2022-12-06T12:23:21.652033Z",
            "url": "https://files.pythonhosted.org/packages/0b/fd/427e236e4cd4486de462ff00642abebc66847cbde1b0f00493e583d6da4d/python_nomad-1.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "e872e98791a07754af9623241a3c4383",
                "sha256": "5699e026f9bd78aeb494f78521b8e74f0cd65a827db5104360fe528210cc6c08"
            },
            "downloads": -1,
            "filename": "python-nomad-1.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e872e98791a07754af9623241a3c4383",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20217,
            "upload_time": "2022-12-06T12:23:23",
            "upload_time_iso_8601": "2022-12-06T12:23:23.131080Z",
            "url": "https://files.pythonhosted.org/packages/0b/12/307d20605a147beca2a141a24bc455a2ab12bdf274ab4d3c6fd61ba7a260/python-nomad-1.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-06 12:23:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "jrxfive",
    "github_project": "python-nomad",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.27.1"
                ]
            ]
        }
    ],
    "lcname": "python-nomad"
}
        
Elapsed time: 0.28863s