• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

docs/H01-Apr-2020-2,2011,512

nomad/H01-Apr-2020-2,8882,173

tests/H01-Apr-2020-1,8401,175

.gitignoreH A D01-Apr-202051 87

.travis.ymlH A D01-Apr-20202.1 KiB5453

CONTRIBUTING.mdH A D01-Apr-202014.4 KiB546413

LICENSEH A D01-Apr-20201.1 KiB2217

README.mdH A D01-Apr-20204.2 KiB133105

VagrantfileH A D01-Apr-20201.3 KiB6146

example_batch_parameterized.jsonH A D01-Apr-20202.1 KiB6766

mkdocs.ymlH A D01-Apr-2020937 3332

setup.pyH A D01-Apr-2020956 3027

README.md

1# python-nomad
2
3
4Branch | Status | Coverage |
5---| ---| ---
6master | [![Build Status](https://travis-ci.org/jrxFive/python-nomad.svg?branch=master)](https://travis-ci.org/jrxFive/python-nomad) | [![codecov](https://codecov.io/gh/jrxFive/python-nomad/branch/master/graph/badge.svg)](https://codecov.io/gh/jrxFive/python-nomad)
7
8
9## Installation
10```
11pip install python-nomad
12```
13
14## Documentation
15https://python-nomad.readthedocs.io/en/latest/
16
17## Examples
18```python
19
20
21import nomad
22# For HTTP Nomad instances
23n = nomad.Nomad(host="172.16.100.10", timeout=5)
24
25# For HTTPS Nomad instances with non-self-signed SSL certificates
26n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=True)
27
28# For HTTPS Nomad instances with self-signed SSL certificates and no validate the cert
29n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=False)
30
31# For HTTPS Nomad instances with self-signed SSL certificates that must validate with cert
32n = 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
33
34# For HTTPS Nomad instances with cert file and key
35n = 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
36
37# For HTTPS Nomad instances with namespace and acl token
38n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=False, namespace='Namespace-example',token='3f4a0fcd-7c42-773c-25db-2d31ba0c05fe')
39
40"example" in n.jobs
41
42j = n.jobs["example"]["ID"]
43
44example_allocation = n.job.get_allocations(j)
45
46n.job.deregister_job(j)
47```
48
49## Environment Variables
50
51This library also supports environment variables: `NOMAD_ADDR`, `NOMAD_NAMESPACE`, `NOMAD_TOKEN`, `NOMAD_REGION`, `NOMAD_CLIENT_CERT`, and `NOMAD_CLIENT_KEY`
52for ease of configuration and unifying with nomad cli tools and other libraries.
53
54```bash
55NOMAD_ADDR=http://127.0.0.1:4646
56NOMAD_NAMESPACE=default
57NOMAD_TOKEN=xxxx-xxxx-xxxx-xxxx
58NOMAD_REGION=us-east-1a
59NOMAD_CLIENT_CERT=/path/to/tls/client.crt
60NOMAD_CLIENT_KEY=/path/to/tls/client.key
61```
62
63## Class Dunders
64
65| Class | contains | len | getitem | iter |
66|---|---|---|---|---|
67|agent|N|N|N|N
68|allocation|Y|N|Y|N
69|allocations|N|Y|N|Y
70|client|N|N|N|N
71|evaluation|Y|N|Y|N
72|evaluations|Y|Y|Y|Y
73|job|Y|N|Y|N
74|jobs|Y|Y|Y|Y
75|node|Y|N|Y|N
76|nodes|Y|Y|Y|Y
77|regions|Y|Y|Y|Y
78|status.leader|Y|Y|N|N
79|status.peers|Y|Y|Y|Y
80|system|N|N|N|N
81|validate|N|N|N|N
82|deployments|Y|Y|Y|Y
83|deployment|Y|N|Y|N
84|namespace|Y|N|Y|N
85|namespaces|Y|Y|Y|Y
86|acl|Y|N|Y|N
87|sentinel|Y|N|Y|N
88
89## Development
90* create virtualenv and activate
91* install requirements-dev.txt
92* 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
93
94```
95virutalenv venv
96source venv/bin/activate
97pip install -r requirements-dev.txt
98```
99
100## Testing with vagrant and virtualbox
101```
102vagrant up --provider virtualbox
103py.test --cov=nomad --cov-report=term-missing --runxfail tests/
104```
105
106## Testing with nomad binary
107```
108./nomad agent -dev -node pynomad1 --acl-enabled
109NOMAD_IP=127.0.0.1 NOMAD_VERSION=<SEMNATIC_VERSION> py.test --cov=nomad --cov-report=term-missing --runxfail tests/
110```
111
112- Examples
113    - [x] Acl [:link:](docs/api/acl.md)
114    - [x] Agent [:link:](docs/api/agent.md)
115    - [x] Allocation [:link:](docs/api/allocation.md)
116    - [x] Allocations [:link:](docs/api/allocations.md)
117    - [x] Deployment [:link:](docs/api/deployment.md)
118    - [x] Deployments [:link:](docs/api/deployments.md)
119    - [x] Client [:link:](docs/api/client.md)
120    - [x] Evaluation [:link:](docs/api/evaluation.md)
121    - [x] Evaluations [:link:](docs/api/evaluations.md)
122    - [x] Job [:link:](docs/api/job.md)
123    - [x] Jobs [:link:](docs/api/jobs.md)
124    - [x] Namespace [:link:](docs/api/namespace.md)
125    - [x] Namespaces [:link:](docs/api/namespaces.md)
126    - [x] Node [:link:](docs/api/node.md)
127    - [x] Nodes [:link:](docs/api/nodes.md)
128    - [x] Regions [:link:](docs/api/regions.md)
129    - [x] Sentinel [:link:](docs/api/sentinel.md)
130    - [x] Status [:link:](docs/api/status.md)
131    - [x] System [:link:](docs/api/system.md)
132    - [x] Validate [:link:](docs/api/validate.md)
133