Code Monkey home page Code Monkey logo

python-nomad's Introduction

python-nomad

Branch Status Coverage
master Build Status codecov

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 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

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
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
virutalenv 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/

python-nomad's People

Contributors

automaticgiant avatar bantonj avatar gokhansengun avatar jcua avatar jeteon avatar jonathanrcross avatar jrxfive avatar mjay-taskize avatar pserranoa avatar rvilim avatar sergiohgz avatar tzahimizrahi avatar xbreak avatar yuntai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.