-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* boilerplate setup * initial jobs class and tests. Vagrant file added for local testing/integration tests * add job endpoint with tests ( need to cover some more ), several helper functions added in base, restructured calls for currently setup endpoints * added `.travis.yml` updated common.py for local use and travis testing by looking for env variables or defaulting to vagrant static values * typo/can't spell * proper matrix for global variables and nomad version variables * attempt to fix interpolation issue with env vars * fix attempt #2 for env interpolation * bump * absolute path of nomad binary * replicate Vagrantfile setup without nohup, if fail try nohup.. * debug nomad see if process is actually coming up * try nohup * try all interfaces * try absolute * name nomad node, updated tests for node name * IP back to loop * debug all interface and no redirect to dev null * nohup dev/null 1&2 * brought down quay image tested locally/manually steps should work... * sleep to wait for nomad to come up * fix relative imports for py3+ * switch to codecov + README.md * added coverage badge * added delete to requester, additional tests for job * added Node,Regions,Status,System + tests * removed BaseException and changed allocations test * updated tests for py2 unicode and py3 str, updated setup.py (#1) * updated tests for py2 unicode and py3 str, updated setup.py * `sys.verion[0]` to int * Feature/allocations (#2) * updated tests for py2 unicode and py3 str, updated setup.py * `sys.verion[0]` to int * allocations/allocation endpoints * Evaluations (#3) * added evaluations and related tests * add .gitignore * Completed evaluation (#6) * added evaluations and related tests * add .gitignore * fixed reference from job to node * add evaluation and related tests * make naming conventions consistent with other tests * request exception already rasied for key error * added client + tests (#7) * added client + tests * added sleeps for state to change for integration tests * bump * brute force wait with limit * bump with assert 0 after max checks * implement function TODO * Feature/agent (#8) * merge test * add agent with get and join functionality * fixed endpoint logic * add function for members endpoint * add server and force leave functions and updated post logic for params and non json responses * add function to update servers * updated join and server post calls to take multiple parameters * add test cases for agent * update force leave function name * remove unused code * removed BaseException (#9) * remove test file (#10) * added custom exceptions logic and try/except (#11) * added custom exceptions logic and try/except * remove debug * Feature/docs (#13) * added mkdocs setup * autopep8 * docstrings and autopep8
- Loading branch information
Showing
60 changed files
with
2,707 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.pyc | ||
.cache | ||
.coverage | ||
.idea | ||
.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
language: "python" | ||
python: | ||
- "2.7" | ||
- "3.3" | ||
- "3.4" | ||
- "3.5" | ||
|
||
env: | ||
global: | ||
- NOMAD_IP="127.0.0.1" | ||
- NOMAD_PORT="4646" | ||
matrix: | ||
- NOMAD_VERSION="0.3.2" | ||
|
||
before_install: | ||
- "curl -L -o /tmp/nomad_${NOMAD_VERSION}_linux_amd64.zip https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip" | ||
- "yes | unzip -d /tmp /tmp/nomad_${NOMAD_VERSION}_linux_amd64.zip" | ||
- "/tmp/nomad agent -dev -bind ${NOMAD_IP} -node pynomad1 > /dev/null 2>&1 &" | ||
- "sleep 15" #wait for nomad to come up | ||
|
||
install: | ||
- pip install -r requirements-dev.txt | ||
- pip install codecov | ||
|
||
script: | ||
- py.test --cov=nomad --cov-report=term-missing --runxfail tests/ | ||
|
||
after_success: | ||
- codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Jonathan Cross | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#python-nomad | ||
|
||
|
||
Branch | Status | Coverage | | ||
---| ---| --- | ||
develop | [![Build Status](https://travis-ci.org/jrxFive/python-nomad.svg?branch=develop)](https://travis-ci.org/jrxFive/python-nomad) | [![codecov](https://codecov.io/gh/jrxFive/python-nomad/branch/develop/graph/badge.svg)](https://codecov.io/gh/jrxFive/python-nomad) | ||
|
||
|
||
## Installation | ||
``` | ||
pip install python-nomad | ||
``` | ||
|
||
## Examples | ||
```python | ||
|
||
n = nomad.Nomad("172.16.100.10",timeout=5) | ||
|
||
"example" in n.jobs | ||
|
||
j = n.jobs["example"]["ID"] | ||
|
||
example_allocation = n.allocation.get_allocations(j) | ||
|
||
n.job.deregister_job(j) | ||
``` | ||
|
||
## TODO | ||
* functional tests | ||
* Inherit Base class, remove duplication and override parent dunders | ||
* readthedocs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
IP = "192.168.33.10" | ||
NOMAD_VERSION = "0.3.2" | ||
NOMAD_PORT_GUEST = 4646 | ||
NOMAD_PORT_HOST = 4646 | ||
|
||
Vagrant.configure(2) do |config| | ||
|
||
config.vm.box = "centos/7" | ||
|
||
config.vm.network "forwarded_port", guest: NOMAD_PORT_GUEST, host: NOMAD_PORT_HOST | ||
|
||
config.vm.network "private_network", ip: "#{IP}" | ||
|
||
config.vm.provider "virtualbox" do |vb| | ||
vb.name = "python-nomad" | ||
vb.gui = false | ||
vb.memory = "1024" | ||
end | ||
|
||
config.vm.provision "shell", inline: <<-SHELL | ||
if [ ! -e /etc/yum.repos.d/docker.repo ] | ||
then | ||
tee /etc/yum.repos.d/docker.repo <<-EOF | ||
[dockerrepo] | ||
name=Docker Repository | ||
baseurl=https://yum.dockerproject.org/repo/main/centos/7/ | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://yum.dockerproject.org/gpg | ||
EOF | ||
fi | ||
yum -y install docker-engine unzip wget net-tools | ||
usermod -aG docker vagrant | ||
systemctl enable docker; systemctl start docker | ||
wget -q -P /tmp/ https://releases.hashicorp.com/nomad/#{NOMAD_VERSION}/nomad_#{NOMAD_VERSION}_linux_amd64.zip | ||
yes | unzip -d /tmp /tmp/nomad_#{NOMAD_VERSION}_linux_amd64.zip | ||
if [ ! -f /usr/bin/nomad ] | ||
then | ||
cp /tmp/nomad /usr/bin/. | ||
fi | ||
if [ $(pgrep nomad) ] | ||
then | ||
echo "Nomad running" | ||
else | ||
echo "Starting Nomad" | ||
nohup nomad agent -dev -bind #{IP} -node pynomad1 > /dev/null 2>&1 & | ||
fi | ||
SHELL | ||
|
||
end |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"Job": { | ||
"Region": "global", | ||
"ID": "example", | ||
"Name": "example", | ||
"Type": "service", | ||
"Priority": 50, | ||
"AllAtOnce": false, | ||
"Datacenters": [ | ||
"dc1" | ||
], | ||
"Constraints": [ | ||
{ | ||
"LTarget": "${attr.kernel.name}", | ||
"RTarget": "linux", | ||
"Operand": "=" | ||
} | ||
], | ||
"TaskGroups": [ | ||
{ | ||
"Name": "cache", | ||
"Count": 1, | ||
"Constraints": null, | ||
"Tasks": [ | ||
{ | ||
"Name": "redis", | ||
"Driver": "docker", | ||
"User": "", | ||
"Config": { | ||
"image": "redis:latest", | ||
"port_map": [ | ||
{ | ||
"db": 6379 | ||
} | ||
] | ||
}, | ||
"Constraints": null, | ||
"Env": null, | ||
"Services": [ | ||
{ | ||
"Id": "", | ||
"Name": "cache-redis", | ||
"Tags": [ | ||
"global", | ||
"cache" | ||
], | ||
"PortLabel": "db", | ||
"Checks": [ | ||
{ | ||
"Id": "", | ||
"Name": "alive", | ||
"Type": "tcp", | ||
"Command": "", | ||
"Args": null, | ||
"Path": "", | ||
"Protocol": "", | ||
"Interval": 10000000000, | ||
"Timeout": 2000000000 | ||
} | ||
] | ||
} | ||
], | ||
"Resources": { | ||
"CPU": 500, | ||
"MemoryMB": 256, | ||
"DiskMB": 300, | ||
"IOPS": 0, | ||
"Networks": [ | ||
{ | ||
"Public": false, | ||
"CIDR": "", | ||
"ReservedPorts": null, | ||
"DynamicPorts": [ | ||
{ | ||
"Label": "db", | ||
"Value": 0 | ||
} | ||
], | ||
"IP": "", | ||
"MBits": 10 | ||
} | ||
] | ||
}, | ||
"Meta": null, | ||
"KillTimeout": 5000000000, | ||
"LogConfig": { | ||
"MaxFiles": 10, | ||
"MaxFileSizeMB": 10 | ||
}, | ||
"Artifacts": null | ||
} | ||
], | ||
"RestartPolicy": { | ||
"Interval": 300000000000, | ||
"Attempts": 10, | ||
"Delay": 25000000000, | ||
"Mode": "delay" | ||
}, | ||
"Meta": null | ||
} | ||
], | ||
"Update": { | ||
"Stagger": 10000000000, | ||
"MaxParallel": 1 | ||
}, | ||
"Periodic": null, | ||
"Meta": null, | ||
"Status": "", | ||
"StatusDescription": "", | ||
"CreateIndex": 0, | ||
"ModifyIndex": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# There can only be a single job definition per file. | ||
# Create a job with ID and Name 'example' | ||
job "example" { | ||
# Run the job in the global region, which is the default. | ||
# region = "global" | ||
|
||
# Specify the datacenters within the region this job can run in. | ||
datacenters = ["dc1"] | ||
|
||
# Service type jobs optimize for long-lived services. This is | ||
# the default but we can change to batch for short-lived tasks. | ||
# type = "service" | ||
|
||
# Priority controls our access to resources and scheduling priority. | ||
# This can be 1 to 100, inclusively, and defaults to 50. | ||
# priority = 50 | ||
|
||
# Restrict our job to only linux. We can specify multiple | ||
# constraints as needed. | ||
constraint { | ||
attribute = "${attr.kernel.name}" | ||
value = "linux" | ||
} | ||
|
||
# Configure the job to do rolling updates | ||
update { | ||
# Stagger updates every 10 seconds | ||
stagger = "10s" | ||
|
||
# Update a single task at a time | ||
max_parallel = 1 | ||
} | ||
|
||
# Create a 'cache' group. Each task in the group will be | ||
# scheduled onto the same machine. | ||
group "cache" { | ||
# Control the number of instances of this groups. | ||
# Defaults to 1 | ||
# count = 1 | ||
|
||
# Configure the restart policy for the task group. If not provided, a | ||
# default is used based on the job type. | ||
restart { | ||
# The number of attempts to run the job within the specified interval. | ||
attempts = 10 | ||
interval = "5m" | ||
|
||
# A delay between a task failing and a restart occurring. | ||
delay = "25s" | ||
|
||
# Mode controls what happens when a task has restarted "attempts" | ||
# times within the interval. "delay" mode delays the next restart | ||
# till the next interval. "fail" mode does not restart the task if | ||
# "attempts" has been hit within the interval. | ||
mode = "delay" | ||
} | ||
|
||
# Define a task to run | ||
task "redis" { | ||
# Use Docker to run the task. | ||
driver = "docker" | ||
|
||
# Configure Docker driver with the image | ||
config { | ||
image = "redis:latest" | ||
port_map { | ||
db = 6379 | ||
} | ||
} | ||
|
||
service { | ||
name = "${TASKGROUP}-redis" | ||
tags = ["global", "cache"] | ||
port = "db" | ||
check { | ||
name = "alive" | ||
type = "tcp" | ||
interval = "10s" | ||
timeout = "2s" | ||
} | ||
} | ||
|
||
# We must specify the resources required for | ||
# this task to ensure it runs on a machine with | ||
# enough capacity. | ||
resources { | ||
cpu = 500 # 500 Mhz | ||
memory = 256 # 256MB | ||
network { | ||
mbits = 10 | ||
port "db" { | ||
} | ||
} | ||
} | ||
|
||
# The artifact block can be specified one or more times to download | ||
# artifacts prior to the task being started. This is convenient for | ||
# shipping configs or data needed by the task. | ||
# artifact { | ||
# source = "http://foo.com/artifact.tar.gz" | ||
# options { | ||
# checksum = "md5:c4aa853ad2215426eb7d70a21922e794" | ||
# } | ||
# } | ||
|
||
# Specify configuration related to log rotation | ||
# logs { | ||
# max_files = 10 | ||
# max_file_size = 15 | ||
# } | ||
|
||
# Controls the timeout between signalling a task it will be killed | ||
# and killing the task. If not set a default is used. | ||
# kill_timeout = "20s" | ||
} | ||
} | ||
} |
Oops, something went wrong.