├── .dockerignore
├── .github
└── dependabot.yml
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING
├── CONTRIBUTORS.md
├── Dockerfile
├── ISSUE_TEMPLATE.md
├── LICENSE
├── PULL_REQUEST_TEMPLATE.md
├── README.md
├── config
├── __init__.py
├── conf.json
├── config.py
└── exmaple_conf.json.example
├── functions
├── __init__.py
├── db
│ ├── __init__.py
│ └── mongo.py
└── hashing
│ └── hashing.py
├── manager.py
├── requirements.txt
├── shippable.yml
└── test
├── __init__.py
├── test_nebula_python_manager.py
├── test_nebula_python_manager_functions_db_mongo.py
├── test_nebula_python_manager_functions_hashing.py
└── travis_ci_scripts
├── deploy.sh
├── docker-compose.yml
└── travis_ci_build_script.sh
/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.git
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: docker
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | time: "10:00"
8 | open-pull-requests-limit: 10
9 | - package-ecosystem: pip
10 | directory: "/"
11 | schedule:
12 | interval: daily
13 | time: "10:00"
14 | open-pull-requests-limit: 10
15 | labels:
16 | - enhancement
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 |
49 | # Translations
50 | *.mo
51 | *.pot
52 |
53 | # Django stuff:
54 | *.log
55 | local_settings.py
56 |
57 | # Flask stuff:
58 | instance/
59 | .webassets-cache
60 |
61 | # Scrapy stuff:
62 | .scrapy
63 |
64 | # Sphinx documentation
65 | docs/_build/
66 |
67 | # PyBuilder
68 | target/
69 |
70 | # Jupyter Notebook
71 | .ipynb_checkpoints
72 |
73 | # pyenv
74 | .python-version
75 |
76 | # celery beat schedule file
77 | celerybeat-schedule
78 |
79 | # SageMath parsed files
80 | *.sage.py
81 |
82 | # dotenv
83 | .env
84 |
85 | # virtualenv
86 | .venv
87 | venv/
88 | ENV/
89 |
90 | # Spyder project settings
91 | .spyderproject
92 | .spyproject
93 |
94 | # Rope project settings
95 | .ropeproject
96 |
97 | # mkdocs documentation
98 | /site
99 |
100 | # mypy
101 | .mypy_cache/
102 | .idea/
103 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: python
2 | dist: xenial
3 | python:
4 | - '3.7'
5 | env:
6 | global:
7 | - MONGO_URL=mongodb://nebula:nebula@127.0.0.1:27017/nebula?authSource=admin
8 | - DOCKER_HUB_ORG=nebulaorchestrator
9 | - DOCKER_HUB_REPO=manager
10 | - GITHUB_PROJECT=manager
11 | - secure: I9/SoRRodn/UwDS3J09o+kSlZyGAUF+3Ek8GhDO1+UxXTeE1/E0dUgJi3rJD98V+1+L4PYnBq6WxpHENFDkZMvuS09pKKeZOaG+eaiF+Il2iRcRHLk2QlBCcAHbjCuJlH4+zDPk+lE+gjdWpc3yH6qg7XyxELzNvvLjnxUCD+jMUkaEdTGXH94GTAfHps1RDn+YeNiZrut6V82PoLTIT6NBzaqN1ZF4Ux+PJY+Cq/Yl0MzChQM8ID9a9nDGJ0sLJe6qjYJQn/kxqDNXMsGxSLfPTaAW+jRWU06pQiCJjGgI2vbYTNBX+KqGZ59fzCGpzHAB1iM+uLaWwnahJKxXyDtwlBQGlMAkfOcY7RmmzSQ5eoFFGtVjSW+aBqtsWuQsM6R5tHPHMCKE0Id2j+bpWgM+QXdLnIcTnvsQCKlsPDKs2ndDF2lgp4stwQP227BlOvd4W/+rrFXnNvkvoZ4vNGXuONR7NuDM0+5XBgUTSDEbLAxOex4HEsdQe9vjQLX46Le7bZSw7F8WT63UlCm9VciniQ37UW+SglobVvT//sa3erx+K810I/MXNbC89qY1Aw+EjrNggHKE3p6DdJqw3o9IWg6bFasIz2or1QnfH81NCDFmbRzh/GlYIk2uHwmR2TJ5WW88XngwQCP3so2IJ67g9gtvTo80SDCW52jEv6OY=
12 | - secure: iee/jaG8EIbbUyVDlCqwsZ7BQJbeIluHeYJ1MmZSoiDWUSvQgReIx90jIt/80jw3eY20YITNYpZxW0wwfvaJdpHXlaEUjItPcUo+vKV2eTrsOjkfmy+gQCmJxj8p4y+1broVFXVVv7JnAChKIIv9SFPCddbJcQGuQedjqocThicS2HWX6jV00jbh1TsbjuJkg5ypd7Ax02nSPYf2AIPEKneY9ws0VaGXCKnyRjMlq2daA+VozL5oqHDP20IrbiZihKV12t0ZczF75RWeymSAd21FbPqKONIav1AmDz+wg4T6lm1afPVlYON+/trJattH9DuG4abI2Pj/+rtyI+O3xGYrjxe9YFvvBRyWBqLb6Zg8D4KjvakA/iWeFl7X9G4lc/VJurFJZL6MUCNhBSgYUw7NpnzGU6cpxzj6CMsMPdw5cY+cDELIYW4kz73p8hxOVhOiOYauXuj0Lhshxd00brmExic1ajKI0T18xsKIVp6B9gmrx3K05565c8BnjX8zS8ehfJGQs62lPKAuY9Z7GjlI3wPwm7PGlUsaVgrask3wvK75YA8g7mJxVonT0mlnWDqOQrwf8trNld9XUJRa11fc7jBj6XKpXFJPrH01jCHiIuJRMVZa34RgHSXh79eLMELtXGsV3uY9DrcPzxshfTr+aD4qKBFg67e7GOr2m0k=
13 | - secure: fB+0jq4e00n1Wk6a8NdE3B/aKG7M8M1bUqzEGzo7BPAtE8fJnUYTZWLJw3I6W6lTdwXrbQyxms6opmuVLRbTwAf9GGYO7EoUDegfONxaP2/0R07K00GRoedF6xt7Fetok0RN/ZCWKoM8OQhjCRbSwTQhU31CWUNnvbSdZDQPn0xO2AqZvVSCcHqCsHnMrfb9xTFHZpmknWXcP2uEBMFwlVuA1gHqLxlYeDET2I7bilvAtrc+cUMn0IODF1wQ37O4pP7huVuwT2PAHBZZDEdbNXFRPUc3hM8oqAj2rf9rhucL7tH88XnBB0Dfi6mCAvSsY/4wWNWc18PKKC26s1zGa9T/FAWrWat5VHxL6UJKI9JGL7Z8OkkNNV/PNRVkm2Z99AgYcWQD7kNyuZ3okVVz7f38hLMCS9hG/8JgGZ/Nr6qQrR8VFuMmF7h7TNB4xFVzVolPcvFVUvdNb+sneVoi2UfC+FXG6PruM9t7c+ggrlR0pjamlMH6+9teUWsYvjtHCim6a+edNEGtxro22FjRbSEAHlPxUJExD2iKzkyM4RwjG6smY5u1NYnx+dHnK0141e25p1engK61ZHAiGXZGwLdAf+bUb4ttb4y5wBWoW4Ar5Wi9hUsfZ2MWj0Qr+2FsJoKcoYwVIr8QeoajMptFVm/pDrGyyb2I3aE6uNdxfx4=
14 | - secure: I9RnZF6v2/L0UA+mkYMRW6Pt0Ua27PiVUZ/cWI+LLK+viScrMO3aiWfYnLnGUiseIPf/IXiJrXjCKPUfOKLU+YPf5ijYPK6Ix0v+1WtWIr2coVWmJPUnNqKPQFqb1jnYXNJbNKKNbxl3zNL2T77jq/XYrUvL+e+kmLdbYCxilgdIRgLMDOq3u9pV2o36NLnkX0R0AS/daBBNlI0i5vCVtepRjz0W9OWLqoPkeMK7Vf2qHLpjH9ks1aWND1mbsd/IoFgNEKHf+7yM66XAnbtxR+8LWuSqExLdoXriyqiyl3tILSXX50kRySF0d4id9B+QEb/v6D1nEzLND6f3CDkvo8prruTCcRahCpCEwjIxBY2dJ3Y8V73hdPJkhNWOtpUqjbSU5/OkQJ/rgVVlENmhHBPlWkaL3DOLaEA3KZ2OaAst9qwr9SAD109FkcO0eO/RepqWSHgUEN7j8G8+WjBkPtFbbg9Uogc2TaRWNZsV3IWw0YZGDtow4vyrCdtKUhNz2YOyGhNTQ1GZRSbkp8Sq1Wi6LftmQNDvll+iDEb4yh+VYywfYbonfy76HtOkL4nLWGG91lWDDFeuV5239XTWF1C4cQQGQYwzuuW9s2GjZJnvTn+JuH5R0MdvVqwVpbR0qYDOdZCMnhb2nsE7WlfNWICpDNr7mk4F8SUmqdRgk9M=
15 | - secure: QcT39CnaG7d5Rd+kVLTPVRsvsRt/08qZTP8IVz7sUovKtuSAH2vjhrYWjEMVFG73rlwSp7r7RhLZJcbBKVyy+rsQtQzphACnwa0Q8G5hjZt2mwKv/snWSoyAKOfit6K4nzomIOzXbOnze7oyUI9qOrs/LAUpxkRog/Q5q3WbgT0/87/9rxMJaMEBiQAdDEihgIEzRHix4o8hEEzXdVUzSe5mjZkMtKDDrDGgvf/DQnWH3WKT7OqD/zhCiH0EkCYX5hzYERh8YH+lFGJEaUUhhYfbpO80z3vem29sY+Q6Z++59278BDO9lWeb1jnAgLVqF4Zu49SypL6A9dGW/4tyZKC1uWPrgKGDnn0hCoImCb5arjMZTJMOXG5F4zDaDLDT3U2feZ4lHJB0y4fLN4gblfMjDMShXkTSmeQVY5PT/LiH13eu4+MPJYdnkWyxd4qJilbFWjbPLHjulPHQ+OpJrP7Ex0x3J0ZDHUq8snFPGyfQ+P/7tAUnzxNBXlbD0FqW+bQhjCl/BZIgIjiWEdxpknKWB5SnzSRLDPLUqEwMzleAygw0c3K4wWUKiQ2chp4tLUMOZz7GvobyjmjQHL9tgmfUT+tmV6BBKJzGOHc9zQ/KU2Y/A9iSImDy79h543RJZknszceU4jtcDzcUoNAC81bCx7ClVr6rmlvCUm1w8gM=
16 | install:
17 | - pip install -r requirements.txt
18 | - pip install codecov
19 | script:
20 | - sudo sh test/travis_ci_scripts/travis_ci_build_script.sh
21 | - coverage run -m unittest
22 | deploy:
23 | on:
24 | all_branches: true
25 | provider: script
26 | script: bash test/travis_ci_scripts/deploy.sh
27 | after_success:
28 | - codecov
29 | after_deploy:
30 | - git config credential.helper "store --file=.git/credentials"
31 | - echo "https://${GH_TOKEN}:@github.com" > .git/credentials
32 | - git config --local user.name "${GITHUB_USER}"
33 | - git config --local user.email "${GITHUB_USER_EMAIL}"
34 | - docker run -e GITHUB_USER=nebula-orchestrator -e GITHUB_PROJECT=${GITHUB_PROJECT} -e CHANGELOG_GITHUB_TOKEN=${GH_TOKEN} -v `pwd`:/output naorlivne/github-changelog-generator-dockerized
35 | - git add CHANGELOG.md
36 | - git commit -m '[skip travis] build ${TRAVIS_BUILD_NUMBER} pushed - new version changelog'
37 | - git push origin HEAD:master
38 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [Unreleased](https://github.com/nebula-orchestrator/manager/tree/HEAD)
4 |
5 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.7.0...HEAD)
6 |
7 | **Implemented enhancements:**
8 |
9 | - Bump python-dotenv from 0.16.0 to 0.17.0 [\#218](https://github.com/nebula-orchestrator/manager/pull/218) ([dependabot[bot]](https://github.com/apps/dependabot))
10 | - Bump gunicorn from 20.0.4 to 20.1.0 [\#217](https://github.com/nebula-orchestrator/manager/pull/217) ([dependabot[bot]](https://github.com/apps/dependabot))
11 | - Bump python-dotenv from 0.15.0 to 0.16.0 [\#216](https://github.com/nebula-orchestrator/manager/pull/216) ([dependabot[bot]](https://github.com/apps/dependabot))
12 | - Bump croniter from 1.0.9 to 1.0.10 [\#215](https://github.com/nebula-orchestrator/manager/pull/215) ([dependabot[bot]](https://github.com/apps/dependabot))
13 | - Bump croniter from 1.0.8 to 1.0.9 [\#214](https://github.com/nebula-orchestrator/manager/pull/214) ([dependabot[bot]](https://github.com/apps/dependabot))
14 | - Bump parse-it from 3.5.0 to 3.6.0 [\#213](https://github.com/nebula-orchestrator/manager/pull/213) ([dependabot[bot]](https://github.com/apps/dependabot))
15 | - Bump urllib3 from 1.26.3 to 1.26.4 [\#212](https://github.com/nebula-orchestrator/manager/pull/212) ([dependabot[bot]](https://github.com/apps/dependabot))
16 | - Bump croniter from 1.0.6 to 1.0.8 [\#211](https://github.com/nebula-orchestrator/manager/pull/211) ([dependabot[bot]](https://github.com/apps/dependabot))
17 | - Bump websocket-client from 0.57.0 to 0.58.0 [\#210](https://github.com/nebula-orchestrator/manager/pull/210) ([dependabot[bot]](https://github.com/apps/dependabot))
18 | - Bump cffi from 1.14.4 to 1.14.5 [\#208](https://github.com/nebula-orchestrator/manager/pull/208) ([dependabot[bot]](https://github.com/apps/dependabot))
19 | - Bump pymongo from 3.11.2 to 3.11.3 [\#207](https://github.com/nebula-orchestrator/manager/pull/207) ([dependabot[bot]](https://github.com/apps/dependabot))
20 | - Bump croniter from 1.0.2 to 1.0.6 [\#206](https://github.com/nebula-orchestrator/manager/pull/206) ([dependabot[bot]](https://github.com/apps/dependabot))
21 | - Bump jinja2 from 2.11.2 to 2.11.3 [\#205](https://github.com/nebula-orchestrator/manager/pull/205) ([dependabot[bot]](https://github.com/apps/dependabot))
22 | - Bump urllib3 from 1.26.2 to 1.26.3 [\#203](https://github.com/nebula-orchestrator/manager/pull/203) ([dependabot[bot]](https://github.com/apps/dependabot))
23 | - Bump cachetools from 4.2.0 to 4.2.1 [\#202](https://github.com/nebula-orchestrator/manager/pull/202) ([dependabot[bot]](https://github.com/apps/dependabot))
24 | - Bump gevent from 20.12.1 to 21.1.2 [\#201](https://github.com/nebula-orchestrator/manager/pull/201) ([dependabot[bot]](https://github.com/apps/dependabot))
25 | - Bump pyyaml from 5.3.1 to 5.4.1 [\#200](https://github.com/nebula-orchestrator/manager/pull/200) ([dependabot[bot]](https://github.com/apps/dependabot))
26 | - Bump croniter from 1.0.1 to 1.0.2 [\#199](https://github.com/nebula-orchestrator/manager/pull/199) ([dependabot[bot]](https://github.com/apps/dependabot))
27 | - Bump greenlet from 0.4.17 to 1.0.0 [\#195](https://github.com/nebula-orchestrator/manager/pull/195) ([dependabot[bot]](https://github.com/apps/dependabot))
28 | - Bump dnspython from 2.0.0 to 2.1.0 [\#194](https://github.com/nebula-orchestrator/manager/pull/194) ([dependabot[bot]](https://github.com/apps/dependabot))
29 | - Bump croniter from 0.3.37 to 1.0.1 [\#193](https://github.com/nebula-orchestrator/manager/pull/193) ([dependabot[bot]](https://github.com/apps/dependabot))
30 | - Bump croniter from 0.3.36 to 0.3.37 [\#190](https://github.com/nebula-orchestrator/manager/pull/190) ([dependabot[bot]](https://github.com/apps/dependabot))
31 | - Bump gevent from 20.12.0 to 20.12.1 [\#189](https://github.com/nebula-orchestrator/manager/pull/189) ([dependabot[bot]](https://github.com/apps/dependabot))
32 | - Bump gevent from 20.9.0 to 20.12.0 [\#188](https://github.com/nebula-orchestrator/manager/pull/188) ([dependabot[bot]](https://github.com/apps/dependabot))
33 | - Bump requests from 2.25.0 to 2.25.1 [\#186](https://github.com/nebula-orchestrator/manager/pull/186) ([dependabot[bot]](https://github.com/apps/dependabot))
34 | - Bump cachetools from 4.1.1 to 4.2.0 [\#185](https://github.com/nebula-orchestrator/manager/pull/185) ([dependabot[bot]](https://github.com/apps/dependabot))
35 | - Bump chardet from 3.0.4 to 4.0.0 [\#184](https://github.com/nebula-orchestrator/manager/pull/184) ([dependabot[bot]](https://github.com/apps/dependabot))
36 | - Bump certifi from 2020.11.8 to 2020.12.5 [\#183](https://github.com/nebula-orchestrator/manager/pull/183) ([dependabot[bot]](https://github.com/apps/dependabot))
37 | - Bump parse-it from 3.4.0 to 3.5.0 [\#182](https://github.com/nebula-orchestrator/manager/pull/182) ([dependabot[bot]](https://github.com/apps/dependabot))
38 | - Bump pymongo from 3.11.1 to 3.11.2 [\#181](https://github.com/nebula-orchestrator/manager/pull/181) ([dependabot[bot]](https://github.com/apps/dependabot))
39 | - Bump cffi from 1.14.3 to 1.14.4 [\#180](https://github.com/nebula-orchestrator/manager/pull/180) ([dependabot[bot]](https://github.com/apps/dependabot))
40 | - Bump pymongo from 3.11.0 to 3.11.1 [\#179](https://github.com/nebula-orchestrator/manager/pull/179) ([dependabot[bot]](https://github.com/apps/dependabot))
41 | - Bump flask-httpauth from 4.1.0 to 4.2.0 [\#178](https://github.com/nebula-orchestrator/manager/pull/178) ([dependabot[bot]](https://github.com/apps/dependabot))
42 | - Bump urllib3 from 1.26.1 to 1.26.2 [\#177](https://github.com/nebula-orchestrator/manager/pull/177) ([dependabot[bot]](https://github.com/apps/dependabot))
43 | - Bump requests from 2.24.0 to 2.25.0 [\#176](https://github.com/nebula-orchestrator/manager/pull/176) ([dependabot[bot]](https://github.com/apps/dependabot))
44 | - Bump urllib3 from 1.25.11 to 1.26.1 [\#175](https://github.com/nebula-orchestrator/manager/pull/175) ([dependabot[bot]](https://github.com/apps/dependabot))
45 | - Bump certifi from 2020.6.20 to 2020.11.8 [\#173](https://github.com/nebula-orchestrator/manager/pull/173) ([dependabot[bot]](https://github.com/apps/dependabot))
46 | - Bump croniter from 0.3.35 to 0.3.36 [\#172](https://github.com/nebula-orchestrator/manager/pull/172) ([dependabot[bot]](https://github.com/apps/dependabot))
47 | - Bump toml from 0.10.1 to 0.10.2 [\#171](https://github.com/nebula-orchestrator/manager/pull/171) ([dependabot[bot]](https://github.com/apps/dependabot))
48 | - Bump python-dotenv from 0.14.0 to 0.15.0 [\#170](https://github.com/nebula-orchestrator/manager/pull/170) ([dependabot[bot]](https://github.com/apps/dependabot))
49 | - Bump urllib3 from 1.25.10 to 1.25.11 [\#169](https://github.com/nebula-orchestrator/manager/pull/169) ([dependabot[bot]](https://github.com/apps/dependabot))
50 | - Bump colorama from 0.4.3 to 0.4.4 [\#168](https://github.com/nebula-orchestrator/manager/pull/168) ([dependabot[bot]](https://github.com/apps/dependabot))
51 | - Bump croniter from 0.3.34 to 0.3.35 [\#167](https://github.com/nebula-orchestrator/manager/pull/167) ([dependabot[bot]](https://github.com/apps/dependabot))
52 | - Bump greenlet from 0.4.16 to 0.4.17 [\#164](https://github.com/nebula-orchestrator/manager/pull/164) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
53 | - Bump gevent from 20.6.2 to 20.9.0 [\#163](https://github.com/nebula-orchestrator/manager/pull/163) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
54 | - Bump cffi from 1.14.2 to 1.14.3 [\#162](https://github.com/nebula-orchestrator/manager/pull/162) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
55 | - Bump cffi from 1.14.1 to 1.14.2 [\#161](https://github.com/nebula-orchestrator/manager/pull/161) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
56 | - Bump bcrypt from 3.1.7 to 3.2.0 [\#160](https://github.com/nebula-orchestrator/manager/pull/160) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
57 | - Bump pymongo from 3.10.1 to 3.11.0 [\#159](https://github.com/nebula-orchestrator/manager/pull/159) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
58 | - Bump cffi from 1.14.0 to 1.14.1 [\#158](https://github.com/nebula-orchestrator/manager/pull/158) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
59 | - Bump urllib3 from 1.25.9 to 1.25.10 [\#157](https://github.com/nebula-orchestrator/manager/pull/157) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
60 | - Bump dnspython from 1.16.0 to 2.0.0 [\#156](https://github.com/nebula-orchestrator/manager/pull/156) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
61 | - Bump python-dotenv from 0.13.0 to 0.14.0 [\#155](https://github.com/nebula-orchestrator/manager/pull/155) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
62 | - Bump idna from 2.9 to 2.10 [\#154](https://github.com/nebula-orchestrator/manager/pull/154) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
63 | - Bump cachetools from 4.1.0 to 4.1.1 [\#153](https://github.com/nebula-orchestrator/manager/pull/153) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
64 | - Bump html5lib from 1.0.1 to 1.1 [\#152](https://github.com/nebula-orchestrator/manager/pull/152) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
65 | - Bump croniter from 0.3.33 to 0.3.34 [\#151](https://github.com/nebula-orchestrator/manager/pull/151) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
66 | - Bump certifi from 2020.4.5.2 to 2020.6.20 [\#150](https://github.com/nebula-orchestrator/manager/pull/150) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
67 | - Bump requests from 2.23.0 to 2.24.0 [\#149](https://github.com/nebula-orchestrator/manager/pull/149) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
68 | - Bump gevent from 20.6.1 to 20.6.2 [\#148](https://github.com/nebula-orchestrator/manager/pull/148) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
69 | - Bump croniter from 0.3.32 to 0.3.33 [\#147](https://github.com/nebula-orchestrator/manager/pull/147) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
70 | - Bump gevent from 20.6.0 to 20.6.1 [\#146](https://github.com/nebula-orchestrator/manager/pull/146) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
71 | - Bump gevent from 20.5.2 to 20.6.0 [\#145](https://github.com/nebula-orchestrator/manager/pull/145) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
72 | - Bump certifi from 2020.4.5.1 to 2020.4.5.2 [\#144](https://github.com/nebula-orchestrator/manager/pull/144) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
73 | - Bump flask-httpauth from 4.0.0 to 4.1.0 [\#143](https://github.com/nebula-orchestrator/manager/pull/143) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
74 | - Bump greenlet from 0.4.15 to 0.4.16 [\#142](https://github.com/nebula-orchestrator/manager/pull/142) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
75 | - Bump gevent from 20.5.1 to 20.5.2 [\#141](https://github.com/nebula-orchestrator/manager/pull/141) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
76 | - Bump croniter from 0.3.31 to 0.3.32 [\#140](https://github.com/nebula-orchestrator/manager/pull/140) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
77 | - Bump gevent from 20.5.0 to 20.5.1 [\#139](https://github.com/nebula-orchestrator/manager/pull/139) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
78 | - Bump six from 1.14.0 to 1.15.0 [\#138](https://github.com/nebula-orchestrator/manager/pull/138) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
79 | - Bump toml from 0.10.0 to 0.10.1 [\#136](https://github.com/nebula-orchestrator/manager/pull/136) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
80 | - Bump gevent from 20.4.0 to 20.5.0 [\#135](https://github.com/nebula-orchestrator/manager/pull/135) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
81 | - Bump click from 7.1.1 to 7.1.2 [\#134](https://github.com/nebula-orchestrator/manager/pull/134) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
82 | - Bump pyhcl from 0.4.3 to 0.4.4 [\#133](https://github.com/nebula-orchestrator/manager/pull/133) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
83 | - Bump flask-httpauth from 3.3.0 to 4.0.0 [\#132](https://github.com/nebula-orchestrator/manager/pull/132) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
84 | - Bump gevent from 1.5.0 to 20.4.0 [\#131](https://github.com/nebula-orchestrator/manager/pull/131) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
85 | - Bump urllib3 from 1.25.8 to 1.25.9 [\#130](https://github.com/nebula-orchestrator/manager/pull/130) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
86 | - Bump python-dotenv from 0.12.0 to 0.13.0 [\#129](https://github.com/nebula-orchestrator/manager/pull/129) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
87 | - Bump pyhcl from 0.4.2 to 0.4.3 [\#128](https://github.com/nebula-orchestrator/manager/pull/128) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
88 | - Bump jinja2 from 2.11.1 to 2.11.2 [\#127](https://github.com/nebula-orchestrator/manager/pull/127) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
89 | - Bump gevent from 1.4.0 to 1.5.0 [\#126](https://github.com/nebula-orchestrator/manager/pull/126) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
90 | - Bump cachetools from 4.0.0 to 4.1.0 [\#125](https://github.com/nebula-orchestrator/manager/pull/125) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
91 | - Bump certifi from 2019.11.28 to 2020.4.5.1 [\#124](https://github.com/nebula-orchestrator/manager/pull/124) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
92 | - Bump flask from 1.1.1 to 1.1.2 [\#123](https://github.com/nebula-orchestrator/manager/pull/123) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
93 | - Bump werkzeug from 1.0.0 to 1.0.1 [\#122](https://github.com/nebula-orchestrator/manager/pull/122) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
94 | - Bump pyhcl from 0.4.1 to 0.4.2 [\#121](https://github.com/nebula-orchestrator/manager/pull/121) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
95 | - Bump pyhcl from 0.4.0 to 0.4.1 [\#120](https://github.com/nebula-orchestrator/manager/pull/120) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
96 | - Bump pyyaml from 5.3 to 5.3.1 [\#119](https://github.com/nebula-orchestrator/manager/pull/119) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
97 | - Bump enum34 from 1.1.9 to 1.1.10 [\#117](https://github.com/nebula-orchestrator/manager/pull/117) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
98 | - Bump click from 7.0 to 7.1.1 [\#116](https://github.com/nebula-orchestrator/manager/pull/116) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
99 | - Bump pycparser from 2.19 to 2.20 [\#115](https://github.com/nebula-orchestrator/manager/pull/115) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
100 |
101 | **Fixed bugs:**
102 |
103 | - Dependabot couldn't authenticate with https://pypi.python.org/simple/ [\#165](https://github.com/nebula-orchestrator/manager/issues/165)
104 |
105 | **Merged pull requests:**
106 |
107 | - Create Dependabot config file [\#166](https://github.com/nebula-orchestrator/manager/pull/166) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
108 | - Bump python from 3.8.2-alpine3.10 to 3.8.3-alpine3.10 [\#137](https://github.com/nebula-orchestrator/manager/pull/137) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
109 |
110 | ## [2.7.0](https://github.com/nebula-orchestrator/manager/tree/2.7.0) (2019-08-27)
111 |
112 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.6.2...2.7.0)
113 |
114 | ## [2.6.2](https://github.com/nebula-orchestrator/manager/tree/2.6.2) (2019-08-20)
115 |
116 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.6.1...2.6.2)
117 |
118 | **Implemented enhancements:**
119 |
120 | - Bump parse-it from 3.1.1 to 3.2.0 [\#59](https://github.com/nebula-orchestrator/manager/pull/59) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
121 | - Bump pymongo from 3.8.0 to 3.9.0 [\#58](https://github.com/nebula-orchestrator/manager/pull/58) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
122 | - Bump parse-it from 3.0.0 to 3.1.1 [\#57](https://github.com/nebula-orchestrator/manager/pull/57) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
123 | - Bump parse-it from 2.0.0 to 3.0.0 [\#56](https://github.com/nebula-orchestrator/manager/pull/56) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
124 | - Bump pyyaml from 5.1.1 to 5.1.2 [\#55](https://github.com/nebula-orchestrator/manager/pull/55) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
125 | - Bump parse-it from 1.0.0 to 1.1.0 [\#54](https://github.com/nebula-orchestrator/manager/pull/54) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
126 | - Bump werkzeug from 0.15.4 to 0.15.5 [\#53](https://github.com/nebula-orchestrator/manager/pull/53) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
127 | - Bump parse-it from 0.9.1 to 1.0.0 [\#52](https://github.com/nebula-orchestrator/manager/pull/52) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
128 | - Bump flask from 1.1.0 to 1.1.1 [\#51](https://github.com/nebula-orchestrator/manager/pull/51) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
129 | - Bump flask from 1.0.3 to 1.1.0 [\#50](https://github.com/nebula-orchestrator/manager/pull/50) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
130 | - Bump parse-it from 0.9.0 to 0.9.1 [\#49](https://github.com/nebula-orchestrator/manager/pull/49) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
131 | - Bump parse-it from 0.8.1 to 0.9.0 [\#48](https://github.com/nebula-orchestrator/manager/pull/48) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
132 | - Bump bcrypt from 3.1.6 to 3.1.7 [\#47](https://github.com/nebula-orchestrator/manager/pull/47) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
133 | - Bump certifi from 2019.3.9 to 2019.6.16 [\#46](https://github.com/nebula-orchestrator/manager/pull/46) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
134 | - Bump pyyaml from 5.1 to 5.1.1 [\#45](https://github.com/nebula-orchestrator/manager/pull/45) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
135 | - Bump parse-it from 0.7.0 to 0.8.1 [\#44](https://github.com/nebula-orchestrator/manager/pull/44) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
136 | - Bump cachetools from 3.1.0 to 3.1.1 [\#43](https://github.com/nebula-orchestrator/manager/pull/43) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
137 | - Bump urllib3 from 1.25.2 to 1.25.3 [\#42](https://github.com/nebula-orchestrator/manager/pull/42) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
138 |
139 | ## [2.6.1](https://github.com/nebula-orchestrator/manager/tree/2.6.1) (2019-05-21)
140 |
141 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.5.0...2.6.1)
142 |
143 | **Implemented enhancements:**
144 |
145 | - Add cron jobs endpoints & modify the device\_group endpoints to include that option [\#29](https://github.com/nebula-orchestrator/manager/issues/29)
146 | - Bump parse-it from 0.5.11 to 0.7.0 [\#40](https://github.com/nebula-orchestrator/manager/pull/40) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
147 | - Bump flask-httpauth from 3.2.4 to 3.3.0 [\#39](https://github.com/nebula-orchestrator/manager/pull/39) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
148 | - Bump flask from 1.0.2 to 1.0.3 [\#38](https://github.com/nebula-orchestrator/manager/pull/38) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
149 | - Bump requests from 2.21.0 to 2.22.0 [\#37](https://github.com/nebula-orchestrator/manager/pull/37) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
150 | - Bump websocket-client from 0.54.0 to 0.56.0 [\#36](https://github.com/nebula-orchestrator/manager/pull/36) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
151 | - Bump werkzeug from 0.15.2 to 0.15.4 [\#35](https://github.com/nebula-orchestrator/manager/pull/35) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
152 | - Bump backports-ssl-match-hostname from 3.5.0.1 to 3.7.0.1 [\#34](https://github.com/nebula-orchestrator/manager/pull/34) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
153 | - Bump parse-it from 0.5.5 to 0.5.11 [\#33](https://github.com/nebula-orchestrator/manager/pull/33) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
154 |
155 | ## [2.5.0](https://github.com/nebula-orchestrator/manager/tree/2.5.0) (2019-04-21)
156 |
157 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.4.0...2.5.0)
158 |
159 | **Implemented enhancements:**
160 |
161 | - multiple users\permissions support [\#2](https://github.com/nebula-orchestrator/manager/issues/2)
162 |
163 | ## [2.4.0](https://github.com/nebula-orchestrator/manager/tree/2.4.0) (2019-03-27)
164 |
165 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.3.0...2.4.0)
166 |
167 | ## [2.3.0](https://github.com/nebula-orchestrator/manager/tree/2.3.0) (2019-03-11)
168 |
169 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.2.0...2.3.0)
170 |
171 | **Implemented enhancements:**
172 |
173 | - Optional reporting architecture [\#30](https://github.com/nebula-orchestrator/manager/issues/30)
174 | - Move automatic Docker imags build from Docker Hub to Travis-CI [\#25](https://github.com/nebula-orchestrator/manager/issues/25)
175 | - Multiple authentication methods [\#3](https://github.com/nebula-orchestrator/manager/issues/3)
176 |
177 | ## [2.2.0](https://github.com/nebula-orchestrator/manager/tree/2.2.0) (2019-02-27)
178 |
179 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.1.0...2.2.0)
180 |
181 | **Implemented enhancements:**
182 |
183 | - Migrate to Python 3.x [\#20](https://github.com/nebula-orchestrator/manager/issues/20)
184 |
185 | ## [2.1.0](https://github.com/nebula-orchestrator/manager/tree/2.1.0) (2019-02-17)
186 |
187 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.0.0...2.1.0)
188 |
189 | **Implemented enhancements:**
190 |
191 | - Give sane defaults to some app confiugrations and allow apps to be POST created\updated without them being mandatory declared [\#27](https://github.com/nebula-orchestrator/manager/issues/27)
192 | - Add automated unit tests [\#24](https://github.com/nebula-orchestrator/manager/issues/24)
193 |
194 | ## [2.0.0](https://github.com/nebula-orchestrator/manager/tree/2.0.0) (2019-01-14)
195 |
196 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/2.0.1...2.0.0)
197 |
198 | ## [2.0.1](https://github.com/nebula-orchestrator/manager/tree/2.0.1) (2019-01-14)
199 |
200 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/1.6.0...2.0.1)
201 |
202 | **Implemented enhancements:**
203 |
204 | - Rename api-manager to manager [\#21](https://github.com/nebula-orchestrator/manager/issues/21)
205 | - pod like stracture option [\#6](https://github.com/nebula-orchestrator/manager/issues/6)
206 |
207 | **Fixed bugs:**
208 |
209 | - Allow starting the manager with no conf.json file present [\#22](https://github.com/nebula-orchestrator/manager/issues/22)
210 |
211 | **Merged pull requests:**
212 |
213 | - 2.0.0a [\#23](https://github.com/nebula-orchestrator/manager/pull/23) ([naorlivne](https://github.com/naorlivne))
214 |
215 | ## [1.6.0](https://github.com/nebula-orchestrator/manager/tree/1.6.0) (2018-12-06)
216 |
217 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/1.5.0...1.6.0)
218 |
219 | ## [1.5.0](https://github.com/nebula-orchestrator/manager/tree/1.5.0) (2018-10-07)
220 |
221 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/1.4.0...1.5.0)
222 |
223 | ## [1.4.0](https://github.com/nebula-orchestrator/manager/tree/1.4.0) (2018-08-21)
224 |
225 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/1.3.0...1.4.0)
226 |
227 | **Implemented enhancements:**
228 |
229 | - update all prereqs versions [\#15](https://github.com/nebula-orchestrator/manager/issues/15)
230 |
231 | **Fixed bugs:**
232 |
233 | - RabbitMQ connections are not closed properly [\#16](https://github.com/nebula-orchestrator/manager/issues/16)
234 | - Set /api/status to work without basic Auth [\#5](https://github.com/nebula-orchestrator/manager/issues/5)
235 |
236 | ## [1.3.0](https://github.com/nebula-orchestrator/manager/tree/1.3.0) (2018-07-24)
237 |
238 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/1.2.0...1.3.0)
239 |
240 | **Implemented enhancements:**
241 |
242 | - Return a list of what paramaters are missing rather then a generic message in case of missing parameters on app creation\update [\#12](https://github.com/nebula-orchestrator/manager/issues/12)
243 |
244 | **Fixed bugs:**
245 |
246 | - add protection against missing fanout exchanges [\#9](https://github.com/nebula-orchestrator/manager/issues/9)
247 |
248 | ## [1.2.0](https://github.com/nebula-orchestrator/manager/tree/1.2.0) (2017-10-19)
249 |
250 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/1.1.1...1.2.0)
251 |
252 | **Implemented enhancements:**
253 |
254 | - Version lock all required pip\apt-get dependencies in the Dockerfile [\#11](https://github.com/nebula-orchestrator/manager/issues/11)
255 | - Some Nebula config paramters should be optional/have default [\#8](https://github.com/nebula-orchestrator/manager/issues/8)
256 |
257 | **Fixed bugs:**
258 |
259 | - Remove unneeded modules from requirements.txt file [\#7](https://github.com/nebula-orchestrator/manager/issues/7)
260 |
261 | **Closed issues:**
262 |
263 | - enable "durable" flag in RabbitMQ exchange [\#13](https://github.com/nebula-orchestrator/manager/issues/13)
264 |
265 | ## [1.1.1](https://github.com/nebula-orchestrator/manager/tree/1.1.1) (2017-09-18)
266 |
267 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/1.1.0...1.1.1)
268 |
269 | ## [1.1.0](https://github.com/nebula-orchestrator/manager/tree/1.1.0) (2017-09-18)
270 |
271 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/1.0.0...1.1.0)
272 |
273 | ## [1.0.0](https://github.com/nebula-orchestrator/manager/tree/1.0.0) (2017-08-16)
274 |
275 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/0.9.0...1.0.0)
276 |
277 | ## [0.9.0](https://github.com/nebula-orchestrator/manager/tree/0.9.0) (2017-08-03)
278 |
279 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/0.8.0...0.9.0)
280 |
281 | **Implemented enhancements:**
282 |
283 | - PUT update support [\#1](https://github.com/nebula-orchestrator/manager/issues/1)
284 |
285 | ## [0.8.0](https://github.com/nebula-orchestrator/manager/tree/0.8.0) (2017-06-19)
286 |
287 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/0.7...0.8.0)
288 |
289 | ## [0.7](https://github.com/nebula-orchestrator/manager/tree/0.7) (2017-05-29)
290 |
291 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/v0.7...0.7)
292 |
293 | ## [v0.7](https://github.com/nebula-orchestrator/manager/tree/v0.7) (2017-05-29)
294 |
295 | [Full Changelog](https://github.com/nebula-orchestrator/manager/compare/e3c29fd9741aa9aebedd14adee539af31e821b16...v0.7)
296 |
297 |
298 |
299 | \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
300 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at nebula-orchestrator@googlegroups.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | Being an open source project means any help offered will be greatly appreciated, below is a quick run through of how you
4 | can help
5 |
6 | ## Getting Started
7 |
8 | * Fork the latest branch of the component you want to contribute to
9 | * Make sure you have a [GitHub account](https://github.com/signup/free)
10 | * Use virtualenv to install all requirements from the requirements.txt file, this may require having GCC compiler & libffi-dev depending on your environment setup due to gevent & bcrypt requiring compilation on some OS.
11 | * Fix the issue you want \ add a feature
12 | * Make sure the unittests pass, you will need to have a running mongo to test them against, the following script will allow you to easily start one: test/travis_ci_scripts/travis_ci_build_script.sh
13 | * Create a pull request
14 |
15 | ## Design philosophy
16 | Nebula is designed with the following philosophy in mind, any feature\pull requests will be judged against the following:
17 |
18 | * Follow Linux philosophy and have each component do one thing & one thing only.
19 | * Each component needs to be possible to be scaled out to extremely large sizes.
20 | * Reliability is more important then shiny new features.
21 | * No vendor\cloud lock-in, if it's only available in one cloud it will not be used.
22 | * No latency sensitivity, assume workers to have a below average internet access and are in the other side of the world.
23 | * Fully stateless, all data is to be saved in the backend DB.
24 |
25 | ### Documentation
26 |
27 | Nebula docs are hosted at [readthedocs](http://nebula.readthedocs.io/en/latest/) using [MkDocs](http://www.mkdocs.org/) for their creation, reading them is highly recommended
28 | prior to making any pull requests
29 |
30 | ## What you can help with
31 |
32 | * Documentation - everyone hates them but without them would you be able to figure out how to use Nebula?
33 | * Bug fixes / feature requests - anything off github issues lists
34 | * Submitting tickets - even if you don't have the time\knowledge to fix a bug just opening a github issue about it will greatly help
35 | * Suggesting improvements
36 | * Spreading the word
37 |
38 | ### Summary
39 |
40 | * Your awesome for helping, thanks.
41 |
42 | P.S.
43 | Don't forget to add yourself to to CONTRIBUTORS.md file.
--------------------------------------------------------------------------------
/CONTRIBUTORS.md:
--------------------------------------------------------------------------------
1 | Nebula contributors
2 | ===================
3 |
4 | * **[Naor Livne](https://github.com/naorlivne)**
5 |
6 | * Creator & BDFL
7 | * Original coding
8 | * Design
9 |
10 | * **[All the guys at Vidazoo](https://github.com/Vidazoo)**
11 |
12 | * Design
13 | * Support
14 | * First users\victims
15 |
16 | * **[shippable](https://github.com/shippable.com/)**
17 |
18 | * Free ARM CI/CD
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # it's offical so i'm using it + alpine so damn small
2 | FROM python:3.9.0a5-alpine3.10
3 |
4 | # copy the codebase
5 | COPY . /www
6 | RUN chmod +x /www/manager.py
7 |
8 | # install required packages - requires build-base due to gevent GCC complier requirements
9 | RUN apk add --no-cache build-base libffi-dev
10 | RUN pip install -r /www/requirements.txt
11 |
12 | # adding the gunicorn config
13 | COPY config/config.py /etc/gunicorn/config.py
14 |
15 | #set python to be unbuffered
16 | ENV PYTHONUNBUFFERED=1
17 |
18 | #exposing the port
19 | EXPOSE 80
20 |
21 | # and running it
22 | CMD ["gunicorn" ,"--config", "/etc/gunicorn/config.py", "manager:app"]
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Expected/Wanted Behavior
2 |
3 |
4 | ## Actual Behavior
5 |
6 |
7 | ## Steps to Reproduce the Problem
8 |
9 | 1.
10 | 2.
11 | 3.
12 |
13 | ## Specifications
14 |
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Fixes #
2 |
3 | ## Proposed Changes
4 |
5 | -
6 | -
7 | -
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Nebula manager
2 |
3 | Travis CI unit tests & autobuild: [](https://travis-ci.org/nebula-orchestrator/manager)
4 |
5 | Shippable ARM autobuild: []()
6 |
7 | ## Main website available [here](https://nebula-orchestrator.github.io/), refer to the [documentation](http://nebula.readthedocs.io/en/latest/) for more details about how to install & use.
8 |
9 | Nebula is a open source distributed Docker orchestrator designed for massive scales (tens of thousands of servers/worker devices), unlike Mesos/Swarm/Kubernetes it has the ability to have workers distributed on high latency connections (such as the internet) yet have the pods(containers) be managed centrally with changes taking affect (almost) immediately, this makes Nebula ideal for managing a vast cluster of servers\devices across the globe, some possible use cases are:
10 |
11 | * IoT devices
12 | * appliances\virtual appliances located at clients data centers
13 | * edge computing
14 | * POS systems
15 |
16 | Ever wandered how your going to push an update to that smart fridge your company is working on as it's thousands of devices around the globe?
17 | wish you could have the assurance that your service will always use the latest code\envvars\etc in all of it's edge locations?
18 | want the ability to stop\start a globally distributed service with a single command?
19 |
20 | Nebula was designed from the ground up to answer all of this needs and much more, refer to the [documentation](http://nebula.readthedocs.io/en/latest/) if your interested in seeing on how to use it.
21 |
22 | This repo is the manager component of Nebula container orchestrator, it's the API endpoint through which Nebula apps are managed.
23 |
24 |
--------------------------------------------------------------------------------
/config/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebula-orchestrator/manager/e3ba2ca753c8aeffc6ccb1da865dcec319092955/config/__init__.py
--------------------------------------------------------------------------------
/config/conf.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/config/config.py:
--------------------------------------------------------------------------------
1 | bind = "0.0.0.0:80"
2 | chdir = "/www"
3 | loglevel = "error"
4 | workers = "1"
5 | worker_class = "gevent"
6 | threads = "1"
7 |
8 | errorlog = "-"
9 | accesslog = "-"
10 |
--------------------------------------------------------------------------------
/config/exmaple_conf.json.example:
--------------------------------------------------------------------------------
1 | {
2 | "basic_auth_user": "nebula_api_user",
3 | "basic_auth_password": "nebula_api_pass",
4 | "mongo_url": "mongodb://:@:27017/?ssl=true&replicaSet=&authSource=",
5 | "schema_name": "nebula",
6 | "auth_enabled": true,
7 | "cache_time": 10,
8 | "cache_max_size": 1024,
9 | "mongo_max_pool_size": 25
10 | }
--------------------------------------------------------------------------------
/functions/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebula-orchestrator/manager/e3ba2ca753c8aeffc6ccb1da865dcec319092955/functions/__init__.py
--------------------------------------------------------------------------------
/functions/db/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebula-orchestrator/manager/e3ba2ca753c8aeffc6ccb1da865dcec319092955/functions/db/__init__.py
--------------------------------------------------------------------------------
/functions/db/mongo.py:
--------------------------------------------------------------------------------
1 | import sys, os
2 | from pymongo import MongoClient, ReturnDocument, ASCENDING
3 | from bson.objectid import ObjectId
4 |
5 |
6 | class MongoConnection:
7 |
8 | # connect to db
9 | def __init__(self, mongo_connection_string, schema_name="nebula", max_pool_size=100):
10 | try:
11 | self.client = MongoClient(mongo_connection_string, maxPoolSize=max_pool_size)
12 | self.db = self.client[schema_name]
13 | self.collection = {"apps": self.db["nebula_apps"], "device_groups": self.db["nebula_device_groups"],
14 | "reports": self.db["nebula_reports"], "users": self.db["nebula_users"],
15 | "user_groups": self.db["nebula_user_groups"], "cron_jobs": self.db["nebula_cron_jobs"]}
16 | except Exception as e:
17 | print("error connection to mongodb")
18 | print(e, file=sys.stderr)
19 | os._exit(2)
20 |
21 | # create indexes
22 | def mongo_create_index(self, collection_name, collection_index):
23 | try:
24 | self.collection[collection_name].create_index([(collection_index, ASCENDING)], background=True,
25 | name=collection_index + "_index", unique=True, sparse=True)
26 | except Exception as e:
27 | print("error creating mongodb indexes")
28 | print(e, file=sys.stderr)
29 | os._exit(2)
30 |
31 | # get all app data
32 | def mongo_get_app(self, app_name):
33 | result = self.collection["apps"].find_one({"app_name": app_name}, {'_id': False})
34 | if result is None:
35 | app_exists = False
36 | else:
37 | app_exists = True
38 | return app_exists, result
39 |
40 | # check if app exists
41 | def mongo_check_app_exists(self, app_name):
42 | result, ignored = self.mongo_get_app(app_name)
43 | return result
44 |
45 | # check if device_group exists
46 | def mongo_check_device_group_exists(self, device_group):
47 | result, ignored = self.mongo_get_device_group(device_group)
48 | return result
49 |
50 | # update all app data
51 | def mongo_update_app(self, app_name, starting_ports, containers_per, env_vars, docker_image, running,
52 | networks, volumes, devices, privileged, rolling_restart):
53 | result = self.collection["apps"].find_one_and_update({'app_name': app_name},
54 | {'$inc': {'app_id': 1},
55 | '$set': {'starting_ports': starting_ports,
56 | 'containers_per': containers_per,
57 | 'env_vars': env_vars,
58 | 'docker_image': docker_image,
59 | 'running': running,
60 | 'networks': networks,
61 | "volumes": volumes,
62 | "devices": devices,
63 | "privileged": privileged,
64 | "rolling_restart": rolling_restart
65 | }
66 | },
67 | upsert=True,
68 | return_document=ReturnDocument.AFTER)
69 | return result
70 |
71 | # get latest envvars of app
72 | def mongo_list_app_envvars(self, app_name):
73 | result = self.collection["apps"].find_one({"app_name": app_name}, {'_id': False})
74 | return result["env_vars"]
75 |
76 | # update envvars of an app
77 | def mongo_update_app_envars(self, app_name, env_vars):
78 | result = self.collection["apps"].find_one_and_update({'app_name': app_name},
79 | {'$inc': {'app_id': 1},
80 | '$set': {'env_vars': env_vars}},
81 | return_document=ReturnDocument.AFTER)
82 | return result
83 |
84 | # update some fields of an app
85 | def mongo_update_app_fields(self, app_name, update_fields_dict):
86 | result = self.collection["apps"].find_one_and_update({'app_name': app_name},
87 | {'$inc': {'app_id': 1},
88 | '$set': update_fields_dict},
89 | return_document=ReturnDocument.AFTER)
90 | return result
91 |
92 | # get number of containers per cpu of app
93 | def mongo_list_app_containers_per(self, app_name):
94 | result = self.collection["apps"].find_one({"app_name": app_name}, {'_id': False})
95 | return result["containers_per"]
96 |
97 | # update number of containers per cpu of app
98 | def mongo_update_app_containers_per(self, app_name, containers_per):
99 | result = self.collection["apps"].find_one_and_update({'app_name': app_name},
100 | {'$inc': {'app_id': 1},
101 | '$set': {'containers_per': containers_per}},
102 | return_document=ReturnDocument.AFTER)
103 | return result
104 |
105 | # get list of apps
106 | def mongo_list_apps(self):
107 | apps_list = []
108 | for app in self.collection["apps"].find({"app_name": {"$exists": "true"}}, {'_id': False}):
109 | apps_list.append(app["app_name"])
110 | return apps_list
111 |
112 | # add app
113 | def mongo_add_app(self, app_name, starting_ports, containers_per, env_vars, docker_image, running=True,
114 | networks=None, volumes=None, devices=None, privileged=False, rolling_restart=False):
115 | # creating the list inside the function to avoid mutable value list in the function default value
116 | if volumes is None:
117 | volumes = []
118 | if devices is None:
119 | devices = []
120 | if networks is None:
121 | networks = ["nebula"]
122 | app_doc = {
123 | "app_id": 1,
124 | "app_name": app_name,
125 | "starting_ports": starting_ports,
126 | "containers_per": containers_per,
127 | "env_vars": env_vars,
128 | "docker_image": docker_image,
129 | "running": running,
130 | "networks": networks,
131 | "volumes": volumes,
132 | "devices": devices,
133 | "privileged": privileged,
134 | "rolling_restart": rolling_restart
135 | }
136 | insert_id = self.collection["apps"].insert_one(app_doc).inserted_id
137 | ignored_app_existence_status, result = self.mongo_get_app(app_name)
138 | return result
139 |
140 | # remove app
141 | def mongo_remove_app(self, app_name):
142 | result = self.collection["apps"].delete_one({"app_name": app_name})
143 | return result
144 |
145 | # get app starting ports
146 | def mongo_list_app_starting_ports(self, app_name):
147 | result = self.collection["apps"].find_one({"app_name": app_name}, {'_id': False})
148 | return result["starting_ports"]
149 |
150 | # update app starting ports
151 | def mongo_update_app_starting_ports(self, app_name, starting_ports):
152 | result = self.collection["apps"].find_one_and_update({'app_name': app_name},
153 | {'$inc': {'app_id': 1},
154 | '$set': {'starting_ports': starting_ports}},
155 | return_document=ReturnDocument.AFTER)
156 | return result
157 |
158 | # increase app_id - used to restart the app
159 | def mongo_increase_app_id(self, app_name):
160 | result = self.collection["apps"].find_one_and_update({'app_name': app_name},
161 | {'$inc': {'app_id': 1}},
162 | return_document=ReturnDocument.AFTER)
163 | return result
164 |
165 | # get app running\stopped state
166 | def mongo_list_app_running_state(self, app_name):
167 | result = self.collection["apps"].find_one({"app_name": app_name}, {'_id': False})
168 | return result["running"]
169 |
170 | # update app running\stopped state
171 | def mongo_update_app_running_state(self, app_name, running):
172 | result = self.collection["apps"].find_one_and_update({'app_name': app_name},
173 | {'$inc': {'app_id': 1},
174 | '$set': {'running': running}},
175 | return_document=ReturnDocument.AFTER)
176 | return result
177 |
178 | # add device_group
179 | def mongo_add_device_group(self, device_group, apps, cron_jobs):
180 | app_doc = {
181 | "device_group_id": 1,
182 | "device_group": device_group,
183 | "apps": apps,
184 | "prune_id": 1,
185 | "cron_jobs": cron_jobs
186 | }
187 | insert_id = self.collection["device_groups"].insert_one(app_doc).inserted_id
188 | ignored_device_group_existence_status, result = self.mongo_get_device_group(device_group)
189 | return result
190 |
191 | # increase prune_id - used to prune unused images of devices that are part of a device group
192 | def mongo_increase_prune_id(self, device_group):
193 | result = self.collection["device_groups"].find_one_and_update({'device_group': device_group},
194 | {'$inc': {'prune_id': 1}},
195 | return_document=ReturnDocument.AFTER)
196 | return result
197 |
198 | # list device_group
199 | def mongo_get_device_group(self, device_group):
200 | result = self.collection["device_groups"].find_one({"device_group": device_group}, {'_id': False})
201 | if result is None:
202 | device_group_exists = False
203 | else:
204 | device_group_exists = True
205 | return device_group_exists, result
206 |
207 | # update device_group
208 | def mongo_update_device_group(self, device_group, update_fields_dict):
209 | result = self.collection["device_groups"].find_one_and_update({'device_group': device_group},
210 | {'$inc': {'device_group_id': 1},
211 | '$set': update_fields_dict},
212 | return_document=ReturnDocument.AFTER)
213 | return result
214 |
215 | # delete device_group
216 | def mongo_remove_device_group(self, device_group):
217 | result = self.collection["device_groups"].delete_one({"device_group": device_group})
218 | return result
219 |
220 | # list all device groups
221 | def mongo_list_device_groups(self):
222 | device_groups = []
223 | for device_group in self.collection["device_groups"].find({"device_group": {"$exists": "true"}},
224 | {'_id': False}):
225 | device_groups.append(device_group["device_group"])
226 | return device_groups
227 |
228 | # get the reports of the user that match it's requested filtering in a paginated fashion starting with the last_id
229 | # of the previous user request (or none if it's the first request)
230 | def mango_list_paginated_filtered_reports(self, page_size=10, last_id=None, filters=None):
231 | if filters is None:
232 | filters = {}
233 |
234 | # if this isn't the first request start after the last _id of the previous request the user received
235 | if last_id is not None:
236 | filters['_id'] = {'$gt': ObjectId(last_id)}
237 |
238 | # if there aren't any filters return a page of all reports
239 | if filters == {}:
240 | cursor = self.collection["reports"].find().limit(page_size).sort('_id', ASCENDING)
241 | # if there are filters return a filtered page of the reports
242 | else:
243 | cursor = self.collection["reports"].find(filters).limit(page_size).sort('_id', ASCENDING)
244 |
245 | # Get the data
246 | data = [x for x in cursor]
247 |
248 | if not data:
249 | # No documents left
250 | return None, None
251 |
252 | # Since documents are ordered with _id, last document will have max id.
253 | last_id = data[-1]['_id']
254 |
255 | # Return data and last_id
256 | return data, last_id
257 |
258 | # list all users
259 | def mongo_list_users(self):
260 | users_list = []
261 | for user in self.collection["users"].find({"user_name": {"$exists": "true"}}, {'_id': False}):
262 | users_list.append(user["user_name"])
263 | return users_list
264 |
265 | # check if user exists
266 | def mongo_check_user_exists(self, user_name):
267 | result, ignored = self.mongo_get_user(user_name)
268 | return result
269 |
270 | # check if user exists
271 | def mongo_check_user_group_exists(self, user_group):
272 | result, ignored = self.mongo_get_user_group(user_group)
273 | return result
274 |
275 | # get user info - the password and\or token are returned hashed for security reasons
276 | def mongo_get_user(self, user_name):
277 | result = self.collection["users"].find_one({"user_name": user_name}, {'_id': False})
278 | if result is None:
279 | user_exists = False
280 | else:
281 | user_exists = True
282 | return user_exists, result
283 |
284 | # delete a user
285 | def mongo_delete_user(self, user_name):
286 | result = self.collection["users"].delete_one({"user_name": user_name})
287 | return result
288 |
289 | # create a user - make sure to hash the password & token before using this function as it does not hash anything on
290 | # it's own
291 | def mongo_add_user(self, user_name, password, token):
292 | user_doc = {
293 | "user_name": user_name,
294 | "password": password,
295 | "token": token
296 | }
297 | insert_id = self.collection["users"].insert_one(user_doc).inserted_id
298 | ignored_device_group_existence_status, result = self.mongo_get_user(user_name)
299 | return result
300 |
301 | # update a user - make sure to hash the password & token before using this function as it does not hash anything on
302 | # it's own
303 | def mongo_update_user(self, user_name, update_fields_dict):
304 | result = self.collection["users"].find_one_and_update({'user_name': user_name},
305 | {'$set': update_fields_dict},
306 | return_document=ReturnDocument.AFTER)
307 | return result
308 |
309 | # create a user_group
310 | def mongo_add_user_group(self, user_group, group_members, pruning_allowed, apps, device_groups, admin, cron_jobs):
311 | user_group_doc = {
312 | "user_group": user_group,
313 | "group_members": group_members,
314 | "pruning_allowed": pruning_allowed,
315 | "apps": apps,
316 | "device_groups": device_groups,
317 | "admin": admin,
318 | "cron_jobs": cron_jobs
319 | }
320 | insert_id = self.collection["user_groups"].insert_one(user_group_doc).inserted_id
321 | ignored_device_group_existence_status, result = self.mongo_get_user_group(user_group)
322 | return result
323 |
324 | # update a user_group
325 | def mongo_update_user_group(self, user_group, update_fields_dict):
326 | result = self.collection["user_groups"].find_one_and_update({'user_group': user_group},
327 | {'$set': update_fields_dict},
328 | return_document=ReturnDocument.AFTER)
329 | return result
330 |
331 | # delete a user_group
332 | def mongo_delete_user_group(self, user_group):
333 | result = self.collection["user_groups"].delete_one({"user_group": user_group})
334 | return result
335 |
336 | # list all user_groups
337 | def mongo_list_user_groups(self):
338 | user_groups_list = []
339 | for user_group in self.collection["user_groups"].find({"user_group": {"$exists": "true"}}, {'_id': False}):
340 | user_groups_list.append(user_group["user_group"])
341 | return user_groups_list
342 |
343 | # get user_group info
344 | def mongo_get_user_group(self, user_group):
345 | result = self.collection["user_groups"].find_one({"user_group": user_group}, {'_id': False})
346 | if result is None:
347 | user_group_exists = False
348 | else:
349 | user_group_exists = True
350 | return user_group_exists, result
351 |
352 | # return a aggregated view of all groups that a user is a member of
353 | def mongo_list_user_permissions(self, user_name):
354 | user_permissions = {"apps": {}, "device_groups": {}, "admin": False, "pruning_allowed": False, "cron_jobs": {}}
355 | find_query = {"$and": [{"user_group": {"$exists": "true"}}, {"group_members": user_name}]}
356 | for user_group in self.collection["user_groups"].find(find_query, {'_id': False}):
357 | if user_group["admin"] is True:
358 | user_permissions["admin"] = True
359 | if user_group["pruning_allowed"] is True:
360 | user_permissions["pruning_allowed"] = True
361 | user_permissions["apps"] = {**user_permissions["apps"], **user_group["apps"]}
362 | user_permissions["device_groups"] = {**user_permissions["device_groups"], **user_group["device_groups"]}
363 | user_permissions["cron_jobs"] = {**user_permissions["cron_jobs"], **user_group["cron_jobs"]}
364 | return user_permissions
365 |
366 | # add cron_job
367 | def mongo_add_cron_job(self, cron_job_name, schedule, env_vars, docker_image, running=True, networks=None,
368 | volumes=None, devices=None, privileged=False):
369 | if volumes is None:
370 | volumes = []
371 | if devices is None:
372 | devices = []
373 | if networks is None:
374 | networks = ["nebula"]
375 | cron_job_doc = {
376 | "cron_job_id": 1,
377 | "cron_job_name": cron_job_name,
378 | "schedule": schedule,
379 | "env_vars": env_vars,
380 | "docker_image": docker_image,
381 | 'running': running,
382 | 'networks': networks,
383 | "volumes": volumes,
384 | "devices": devices,
385 | "privileged": privileged
386 | }
387 | insert_id = self.collection["cron_jobs"].insert_one(cron_job_doc).inserted_id
388 | ignored_cron_job_existence_status, result = self.mongo_get_cron_job(cron_job_name)
389 | return result
390 |
391 | # list all cron jobs
392 | def mongo_list_cron_jobs(self):
393 | cron_jobs = []
394 | for cron_job in self.collection["cron_jobs"].find({"cron_job_name": {"$exists": "true"}},
395 | {'_id': False}):
396 | cron_jobs.append(cron_job["cron_job_name"])
397 | return cron_jobs
398 |
399 | # get all cron job data
400 | def mongo_get_cron_job(self, cron_job_name):
401 | result = self.collection["cron_jobs"].find_one({"cron_job_name": cron_job_name}, {'_id': False})
402 | if result is None:
403 | cron_job_exists = False
404 | else:
405 | cron_job_exists = True
406 | return cron_job_exists, result
407 |
408 | # update some fields of an cron_job
409 | def mongo_update_cron_job_fields(self, cron_job_name, update_fields_dict):
410 | result = self.collection["cron_jobs"].find_one_and_update({'cron_job_name': cron_job_name},
411 | {'$inc': {'cron_job_id': 1},
412 | '$set': update_fields_dict},
413 | return_document=ReturnDocument.AFTER)
414 | return result
415 |
416 | # delete a cron_job
417 | def mongo_delete_cron_job(self, cron_job):
418 | result = self.collection["cron_jobs"].delete_one({"cron_job_name": cron_job})
419 | return result
420 |
421 | # check if cron_job exists
422 | def mongo_check_cron_job_exists(self, cron_job):
423 | result, ignored = self.mongo_get_cron_job(cron_job)
424 | return result
425 |
--------------------------------------------------------------------------------
/functions/hashing/hashing.py:
--------------------------------------------------------------------------------
1 | import bcrypt
2 |
3 |
4 | def hash_secret(value_to_hash):
5 | hashed_secret = bcrypt.hashpw(value_to_hash.encode('utf-8'), bcrypt.gensalt())
6 | return hashed_secret.decode('utf-8')
7 |
8 |
9 | def check_secret_matches(value_to_check, hashed_value):
10 | if bcrypt.checkpw(value_to_check.encode('utf-8'), hashed_value.encode('utf-8')):
11 | return True
12 | else:
13 | return False
14 |
--------------------------------------------------------------------------------
/manager.py:
--------------------------------------------------------------------------------
1 | import json, secrets, ast
2 | from flask import json, Flask, request, g, jsonify
3 | from flask_httpauth import HTTPBasicAuth, HTTPTokenAuth, MultiAuth
4 | from functions.db.mongo import *
5 | from functions.hashing.hashing import *
6 | from bson.json_util import dumps
7 | from cachetools import cached, TTLCache
8 | from retrying import retry
9 | from functools import wraps
10 | from croniter import croniter
11 | from parse_it import ParseIt
12 |
13 |
14 | API_VERSION = "v2"
15 |
16 |
17 | # takes an invalid request & figure out what params are missing on a request and returns a list of those, this function
18 | # should only be called in cases where the "invalid_request" has been tried and found to be missing a param as it fails
19 | # hard on failure like the rest of the code (which in this case also means no missing params)
20 | def find_missing_params(invalid_request, required_params):
21 | try:
22 | missing_params = dict()
23 | missing_params["missing_parameters"] = list(set(required_params) - set(invalid_request))
24 |
25 | except Exception as e:
26 | print("unable to find missing params yet the request is returning an error", file=sys.stderr)
27 | os._exit(2)
28 | return missing_params
29 |
30 |
31 | # take a name of a parameter, the dict that parameter may or may not be and a sane default and returns the param from
32 | # the dict if it exists in it or the sane default otherwise
33 | def return_sane_default_if_not_declared(needed_parameter, parameters_dict, sane_default):
34 | try:
35 | if needed_parameter in parameters_dict:
36 | returned_value = parameters_dict[needed_parameter]
37 | else:
38 | returned_value = sane_default
39 | except Exception as e:
40 | print("problem with parameter phrasing", file=sys.stderr)
41 | os._exit(2)
42 | return returned_value
43 |
44 |
45 | # check for edge case of port being outside of the valid port range
46 | def check_ports_valid_range(checked_ports):
47 | for checked_port in checked_ports:
48 | if isinstance(checked_port, int):
49 | if not 1 <= checked_port <= 65535:
50 | return "{\"starting_ports\": \"invalid port\"}", 400
51 | elif isinstance(checked_port, dict):
52 | for host_port, container_port in checked_port.items():
53 | try:
54 | if not 1 <= int(host_port) <= 65535 or not 1 <= int(container_port) <= 65535:
55 | return "{\"starting_ports\": \"invalid port\"}", 400
56 | except ValueError:
57 | return "{\"starting_ports\": \"can only be a list containing integers or dicts\"}", 403
58 | else:
59 | return "{\"starting_ports\": \"can only be a list containing integers or dicts\"}", 403
60 | return "all ports checked are in a valid 1-65535 range", 200
61 |
62 |
63 | # used to filter the hostname & device_group reports filtering to something that MongoDB can process
64 | def get_param_filter(param_name, full_request, filter_param="eq", request_type=str):
65 | filter_param = "$" + filter_param
66 | param_value = full_request.args.get(param_name, type=request_type)
67 | if param_value is not None:
68 | if param_name == "updated":
69 | param_value = ast.literal_eval(param_value)
70 | return {param_name: {filter_param: param_value}}
71 | else:
72 | return None
73 |
74 |
75 | # check if a user is allowed to preform
76 | def check_authorized(permission_needed=None, permission_object_type=None):
77 | # by default don't allow access
78 | allow_access = False
79 |
80 | # if auth is disabled or the user is a local admin always allow access
81 | if (auth_enabled is False) or (g.user_type == "local"):
82 | allow_access = True
83 | # otherwise query the db for the current user permissions and set the default reply to not be allowed
84 | else:
85 | # if the user is admin allow access:
86 | user_permissions = mongo_connection.mongo_list_user_permissions(g.user)
87 | if user_permissions["admin"] is True:
88 | allow_access = True
89 | # elif what we need is pruning check if the "pruning_allowed" permission is set for the user
90 | elif permission_object_type == "pruning":
91 | if user_permissions["pruning_allowed"] is True:
92 | allow_access = True
93 | # in any other case allow access if the permission needed is in the permission list of the user in the db
94 | elif permission_object_type == "apps" or permission_object_type == "device_groups" or \
95 | permission_object_type == "cron_jobs":
96 | for permission_key, permission_value in user_permissions[permission_object_type].items():
97 | if permission_needed == {permission_key: permission_value}:
98 | allow_access = True
99 | break
100 | return allow_access
101 |
102 |
103 | # this wrapper checks if a user is authorized to preform the requested action
104 | def check_authorization_wrapper(permission_needed=None, permission_object_type=None):
105 |
106 | def callable_function(func):
107 | @wraps(func)
108 | def wrapped(*args, **kwargs):
109 | result = jsonify({"access_allowed": False}), 403
110 | if permission_object_type == "pruning":
111 | if check_authorized(permission_needed={"pruning": permission_needed},
112 | permission_object_type=permission_object_type) is True:
113 | result = func(*args, **kwargs)
114 | elif permission_object_type == "apps":
115 | if check_authorized(permission_needed={kwargs['app_name']: permission_needed},
116 | permission_object_type=permission_object_type) is True:
117 | result = func(*args, **kwargs)
118 | elif permission_object_type == "device_groups":
119 | if check_authorized(permission_needed={kwargs['device_group']: permission_needed},
120 | permission_object_type=permission_object_type) is True:
121 | result = func(*args, **kwargs)
122 | elif permission_object_type == "cron_jobs":
123 | if check_authorized(permission_needed={kwargs['cron_job']: permission_needed},
124 | permission_object_type=permission_object_type) is True:
125 | result = func(*args, **kwargs)
126 | elif permission_object_type == "admin":
127 | if check_authorized(permission_needed={"admin": permission_needed},
128 | permission_object_type=permission_object_type) is True:
129 | result = func(*args, **kwargs)
130 | return result
131 | return wrapped
132 |
133 | return callable_function
134 |
135 |
136 | # read config file at startup
137 | print("reading config variables")
138 | parser = ParseIt(config_location="config", recurse=True)
139 |
140 | print("reading config variables")
141 | basic_auth_user = parser.read_configuration_variable("basic_auth_user", default_value=None)
142 | basic_auth_password = parser.read_configuration_variable("basic_auth_password", default_value=None)
143 | auth_token = parser.read_configuration_variable("auth_token", default_value=None)
144 | mongo_url = parser.read_configuration_variable("mongo_url", required=True)
145 | schema_name = parser.read_configuration_variable("schema_name", default_value="nebula")
146 | auth_enabled = parser.read_configuration_variable("auth_enabled", default_value=True)
147 | cache_time = parser.read_configuration_variable("cache_time", default_value=10)
148 | cache_max_size = parser.read_configuration_variable("cache_max_size", default_value=1024)
149 | mongo_max_pool_size = parser.read_configuration_variable("mongo_max_pool_size", default_value=25)
150 |
151 | # login to db at startup
152 | mongo_connection = MongoConnection(mongo_url, schema_name, max_pool_size=mongo_max_pool_size)
153 | print("opened MongoDB connection")
154 |
155 | # ensure mongo is indexed properly
156 | mongo_connection.mongo_create_index("apps", "app_name")
157 | mongo_connection.mongo_create_index("device_groups", "device_group")
158 | mongo_connection.mongo_create_index("users", "user")
159 | mongo_connection.mongo_create_index("user_groups", "user_group")
160 | mongo_connection.mongo_create_index("cron_jobs", "cron_job_name")
161 |
162 | # get current list of apps at startup
163 | nebula_apps = mongo_connection.mongo_list_apps()
164 | print("got list of all mongo apps")
165 |
166 | # open waiting connection
167 | try:
168 | app = Flask(__name__)
169 | # basic auth for api
170 | basic_auth = HTTPBasicAuth(realm='nebula')
171 | token_auth = HTTPTokenAuth('Bearer')
172 | multi_auth = MultiAuth(basic_auth, token_auth)
173 | print("startup completed - now waiting for connections")
174 | except Exception as e:
175 | print("Flask connection configuration failure - dropping container")
176 | print(e, file=sys.stderr)
177 | os._exit(2)
178 |
179 |
180 | # this function checks basic_auth to allow access to authenticated users.
181 | @basic_auth.verify_password
182 | def verify_password(username, password):
183 | # if auth_enabled is set to false then always allow access
184 | if auth_enabled is False:
185 | return True
186 | # else if username and password matches the admin user set in the manager config allow access
187 | elif username == basic_auth_user and password == basic_auth_password:
188 | g.user = username
189 | g.user_type = "local"
190 | return True
191 | # else if the user and password matches any in the DB allow access
192 | elif mongo_connection.mongo_check_user_exists(username) is True:
193 | user_exists, user_json = mongo_connection.mongo_get_user(username)
194 | if check_secret_matches(password, user_json["password"]) is True:
195 | g.user = username
196 | g.user_type = "db"
197 | return True
198 | else:
199 | return False
200 | # on any other case deny access:
201 | else:
202 | return False
203 |
204 |
205 | # this function checks token based auth to allow access to authenticated users.
206 | @token_auth.verify_token
207 | def verify_token(token):
208 | # if auth_enabled is set to false then always allow access
209 | if auth_enabled is False:
210 | return True
211 | # else if the token matches the admin user set in the manager config allow access
212 | elif auth_token == token:
213 | g.user_type = "local"
214 | return True
215 | # else if the token matches any in the DB allow access or deny access if not
216 | else:
217 | allow_access = False
218 | user_list = mongo_connection.mongo_list_users()
219 | for user in user_list:
220 | user_exists, user_json = mongo_connection.mongo_get_user(user)
221 | if check_secret_matches(token, user_json["token"]) is True:
222 | g.user = user
223 | g.user_type = "db"
224 | allow_access = True
225 | return allow_access
226 |
227 |
228 | # api check page - return 200 and a massage just so we know API is reachable
229 | @app.route('/api/' + API_VERSION + '/status', methods=["GET"])
230 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
231 | @multi_auth.login_required
232 | def check_page():
233 | return jsonify({"api_available": True}), 200
234 |
235 |
236 | # create a new app
237 | @app.route('/api/' + API_VERSION + '/apps/', methods=["POST"])
238 | @multi_auth.login_required
239 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="apps")
240 | def create_app(app_name):
241 | # check app does't exists first
242 | app_exists = mongo_connection.mongo_check_app_exists(app_name)
243 | if app_exists is True:
244 | return jsonify({"app_exists": True}), 403
245 | else:
246 | # check the request is passed with all needed parameters
247 | try:
248 | app_json = request.json
249 | except:
250 | return json.dumps(find_missing_params({}, ["docker_image"])), 400
251 | try:
252 | starting_ports = return_sane_default_if_not_declared("starting_ports", app_json, [])
253 | containers_per = return_sane_default_if_not_declared("containers_per", app_json, {"server": 1})
254 | env_vars = return_sane_default_if_not_declared("env_vars", app_json, {})
255 | docker_image = app_json["docker_image"]
256 | running = return_sane_default_if_not_declared("running", app_json, True)
257 | networks = return_sane_default_if_not_declared("networks", app_json, ["nebula", "bridge"])
258 | volumes = return_sane_default_if_not_declared("volumes", app_json, [])
259 | devices = return_sane_default_if_not_declared("devices", app_json, [])
260 | privileged = return_sane_default_if_not_declared("privileged", app_json, False)
261 | rolling_restart = return_sane_default_if_not_declared("rolling_restart", app_json, False)
262 | except:
263 | return json.dumps(find_missing_params(app_json, ["docker_image"])), 400
264 | # check edge case of port being outside of possible port ranges
265 | ports_check_return_message, port_check_return_code = check_ports_valid_range(starting_ports)
266 | if port_check_return_code >= 300:
267 | return ports_check_return_message, port_check_return_code
268 | # update the db
269 | app_json = mongo_connection.mongo_add_app(app_name, starting_ports, containers_per, env_vars, docker_image,
270 | running, networks, volumes, devices, privileged, rolling_restart)
271 | return dumps(app_json), 200
272 |
273 |
274 | # delete an app
275 | @app.route('/api/' + API_VERSION + '/apps/', methods=["DELETE"])
276 | @multi_auth.login_required
277 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="apps")
278 | def delete_app(app_name):
279 | # check app exists first
280 | app_exists = mongo_connection.mongo_check_app_exists(app_name)
281 | if app_exists is False:
282 | return jsonify({"app_exists": False}), 403
283 | # remove from db
284 | mongo_connection.mongo_remove_app(app_name)
285 | return "{}", 200
286 |
287 |
288 | # restart an app
289 | @app.route('/api/' + API_VERSION + '/apps//restart', methods=["POST"])
290 | @multi_auth.login_required
291 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="apps")
292 | def restart_app(app_name):
293 | app_exists, app_json = mongo_connection.mongo_get_app(app_name)
294 | # check app exists first
295 | if app_exists is False:
296 | return jsonify({"app_exists": False}), 403
297 | # check if app already running:
298 | if app_json["running"] is False:
299 | return jsonify({"running_before_restart": False}), 403
300 | # post to db
301 | app_json = mongo_connection.mongo_increase_app_id(app_name)
302 | return dumps(app_json), 202
303 |
304 |
305 | # stop an app
306 | @app.route('/api/' + API_VERSION + '/apps//stop', methods=["POST"])
307 | @multi_auth.login_required
308 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="apps")
309 | def stop_app(app_name):
310 | # check app exists first
311 | app_exists = mongo_connection.mongo_check_app_exists(app_name)
312 | if app_exists is False:
313 | return jsonify({"app_exists": False}), 403
314 | # post to db
315 | app_json = mongo_connection.mongo_update_app_running_state(app_name, False)
316 | return dumps(app_json), 202
317 |
318 |
319 | # start an app
320 | @app.route('/api/' + API_VERSION + '/apps//start', methods=["POST"])
321 | @multi_auth.login_required
322 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="apps")
323 | def start_app(app_name):
324 | # check app exists first
325 | app_exists = mongo_connection.mongo_check_app_exists(app_name)
326 | if app_exists is False:
327 | return jsonify({"app_exists": False}), 403
328 | # post to db
329 | app_json = mongo_connection.mongo_update_app_running_state(app_name, True)
330 | return dumps(app_json), 202
331 |
332 |
333 | # POST update an app - requires all the params to be given in the request body or else will be reset to default values
334 | @app.route('/api/' + API_VERSION + '/apps//update', methods=["POST"])
335 | @multi_auth.login_required
336 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="apps")
337 | def update_app(app_name):
338 | # check app exists first
339 | app_exists = mongo_connection.mongo_check_app_exists(app_name)
340 | if app_exists is False:
341 | return jsonify({"app_exists": False}), 403
342 | # check app got all needed parameters
343 | try:
344 | app_json = request.json
345 | except:
346 | return json.dumps(find_missing_params({}, ["docker_image"])), 400
347 | try:
348 | starting_ports = return_sane_default_if_not_declared("starting_ports", app_json, [])
349 | containers_per = return_sane_default_if_not_declared("containers_per", app_json, {"server": 1})
350 | env_vars = return_sane_default_if_not_declared("env_vars", app_json, [])
351 | docker_image = app_json["docker_image"]
352 | running = return_sane_default_if_not_declared("running", app_json, True)
353 | networks = return_sane_default_if_not_declared("networks", app_json, ["nebula", "bridge"])
354 | volumes = return_sane_default_if_not_declared("volumes", app_json, [])
355 | devices = return_sane_default_if_not_declared("devices", app_json, [])
356 | privileged = return_sane_default_if_not_declared("privileged", app_json, False)
357 | rolling_restart = return_sane_default_if_not_declared("rolling_restart", app_json, False)
358 | except:
359 | return json.dumps(find_missing_params(app_json, ["docker_image"])), 400
360 | # check edge case of port being outside of possible port ranges
361 | ports_check_return_message, port_check_return_code = check_ports_valid_range(starting_ports)
362 | if port_check_return_code >= 300:
363 | return ports_check_return_message, port_check_return_code
364 | # update db
365 | app_json = mongo_connection.mongo_update_app(app_name, starting_ports, containers_per, env_vars, docker_image,
366 | running, networks, volumes, devices, privileged, rolling_restart)
367 | return dumps(app_json), 202
368 |
369 |
370 | # PUT update some fields of an app - params not given will be unchanged from their current value
371 | @app.route('/api/' + API_VERSION + '/apps//update', methods=["PUT", "PATCH"])
372 | @multi_auth.login_required
373 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="apps")
374 | def update_app_fields(app_name):
375 | # check app exists first
376 | app_exists = mongo_connection.mongo_check_app_exists(app_name)
377 | if app_exists is False:
378 | return jsonify({"app_exists": False}), 403
379 | # check app got update parameters
380 | try:
381 | app_json = request.json
382 | if len(app_json) == 0:
383 | return jsonify({"missing_parameters": True}), 400
384 | except:
385 | return jsonify({"missing_parameters": True}), 400
386 | # check edge case of port being outside of possible port ranges in case trying to update port listing
387 | try:
388 | starting_ports = request.json["starting_ports"]
389 | ports_check_return_message, port_check_return_code = check_ports_valid_range(starting_ports)
390 | if port_check_return_code >= 300:
391 | return ports_check_return_message, port_check_return_code
392 | except:
393 | pass
394 | # update db
395 | app_json = mongo_connection.mongo_update_app_fields(app_name, request.json)
396 | return dumps(app_json), 202
397 |
398 |
399 | # list apps
400 | @app.route('/api/' + API_VERSION + '/apps', methods=["GET"])
401 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
402 | @multi_auth.login_required
403 | def list_apps():
404 | nebula_apps_list = mongo_connection.mongo_list_apps()
405 | return jsonify({"apps": nebula_apps_list}), 200
406 |
407 |
408 | # get app info
409 | @app.route('/api/' + API_VERSION + '/apps/', methods=["GET"])
410 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
411 | @multi_auth.login_required
412 | @check_authorization_wrapper(permission_needed="ro", permission_object_type="apps")
413 | def get_app(app_name):
414 | app_exists, app_json = mongo_connection.mongo_get_app(app_name)
415 | if app_exists is True:
416 | return dumps(app_json), 200
417 | elif app_exists is False:
418 | return jsonify({"app_exists": False}), 403
419 |
420 |
421 | # get device_group info
422 | @app.route('/api/' + API_VERSION + '/device_groups//info', methods=["GET"])
423 | @cached(cache=TTLCache(maxsize=cache_max_size, ttl=cache_time))
424 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
425 | @multi_auth.login_required
426 | @check_authorization_wrapper(permission_needed="ro", permission_object_type="device_groups")
427 | def get_device_group_info(device_group):
428 | device_group_exists, device_group_json = mongo_connection.mongo_get_device_group(device_group)
429 | if device_group_exists is False:
430 | return jsonify({"device_group_exists": False}), 403
431 | device_group_config = {"apps": [], "apps_list": [], "prune_id": device_group_json["prune_id"], "cron_jobs": [],
432 | "cron_jobs_list": [], "device_group_id": device_group_json["device_group_id"]}
433 | for device_app in device_group_json["apps"]:
434 | app_exists, app_json = mongo_connection.mongo_get_app(device_app)
435 | if app_exists is True:
436 | device_group_config["apps"].append(app_json)
437 | device_group_config["apps_list"].append(app_json["app_name"])
438 | for device_cron_job in device_group_json["cron_jobs"]:
439 | cron_job_exists, cron_job_json = mongo_connection.mongo_get_cron_job(device_cron_job)
440 | if cron_job_exists is True:
441 | device_group_config["cron_jobs"].append(cron_job_json)
442 | device_group_config["cron_jobs_list"].append(cron_job_json["cron_job_name"])
443 | return dumps(device_group_config), 200
444 |
445 |
446 | # create device_group
447 | @app.route('/api/' + API_VERSION + '/device_groups/', methods=["POST"])
448 | @multi_auth.login_required
449 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="device_groups")
450 | def create_device_group(device_group):
451 | # check app does't exists first
452 | device_group_exists = mongo_connection.mongo_check_device_group_exists(device_group)
453 | if device_group_exists is True:
454 | return jsonify({"device_group_exists": True}), 403
455 | else:
456 | # check the request is passed with all needed parameters
457 | try:
458 | app_json = request.json
459 | cron_jobs = return_sane_default_if_not_declared("cron_jobs", app_json, [])
460 | apps = return_sane_default_if_not_declared("apps", app_json, [])
461 | except:
462 | return json.dumps({"missing_parameters": True}), 400
463 | # check edge case where cron_jobs is not a list
464 | if type(cron_jobs) is not list:
465 | return jsonify({"cron_jobs_is_list": False}), 400
466 | # check edge case where adding an cron_jobs that does not exist
467 | for device_cron_job in cron_jobs:
468 | cron_job_exists, cron_job_json = mongo_connection.mongo_get_cron_job(device_cron_job)
469 | if cron_job_exists is False:
470 | return jsonify({"cron_job_exists": False}), 403
471 | # check edge case where apps is not a list
472 | if type(apps) is not list:
473 | return jsonify({"apps_is_list": False}), 400
474 | # check edge case where adding an app that does not exist
475 | for device_app in apps:
476 | app_exists, app_json = mongo_connection.mongo_get_app(device_app)
477 | if app_exists is False:
478 | return jsonify({"app_exists": False}), 403
479 | # update the db
480 | app_json = mongo_connection.mongo_add_device_group(device_group, apps, cron_jobs)
481 | return dumps(app_json), 200
482 |
483 |
484 | # list device_group
485 | @app.route('/api/' + API_VERSION + '/device_groups/', methods=["GET"])
486 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
487 | @multi_auth.login_required
488 | @check_authorization_wrapper(permission_needed="ro", permission_object_type="device_groups")
489 | def get_device_group(device_group):
490 | device_group_exists, device_group_json = mongo_connection.mongo_get_device_group(device_group)
491 | if device_group_exists is True:
492 | return dumps(device_group_json), 200
493 | elif device_group_exists is False:
494 | return jsonify({"device_group_exists": False}), 403
495 |
496 |
497 | # POST update device_group - requires a full list of apps to be given in the request body
498 | @app.route('/api/' + API_VERSION + '/device_groups//update', methods=["POST"])
499 | @multi_auth.login_required
500 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="device_groups")
501 | def update_device_group(device_group):
502 | # check device_group exists first
503 | device_group_exists = mongo_connection.mongo_check_device_group_exists(device_group)
504 | if device_group_exists is False:
505 | return jsonify({"app_exists": False}), 403
506 | # check app got all needed parameters
507 | try:
508 | app_json = request.json
509 | cron_jobs = return_sane_default_if_not_declared("cron_jobs", app_json, [])
510 | apps = return_sane_default_if_not_declared("apps", app_json, [])
511 | except:
512 | return json.dumps({"missing_parameters": True}), 400
513 | # check edge case where cron_jobs is not a list
514 | if type(cron_jobs) is not list:
515 | return jsonify({"cron_jobs_is_list": False}), 400
516 | # check edge case where adding an cron_jobs that does not exist
517 | for device_cron_job in cron_jobs:
518 | cron_job_exists, cron_job_json = mongo_connection.mongo_get_cron_job(device_cron_job)
519 | if cron_job_exists is False:
520 | return jsonify({"cron_job_exists": False}), 403
521 | # check edge case where apps is not a list
522 | if type(apps) is not list:
523 | return jsonify({"apps_is_list": False}), 400
524 | # check edge case where adding an app that does not exist
525 | for device_app in apps:
526 | app_exists, app_json = mongo_connection.mongo_get_app(device_app)
527 | if app_exists is False:
528 | return jsonify({"app_exists": False}), 403
529 | # update db
530 | update_fields_dict = {"apps": apps, "cron_jobs": cron_jobs}
531 | app_json = mongo_connection.mongo_update_device_group(device_group, update_fields_dict)
532 | return dumps(app_json), 202
533 |
534 |
535 | # PUT update device_group
536 | @app.route('/api/' + API_VERSION + '/device_groups//update', methods=["PUT", "PATCH"])
537 | @multi_auth.login_required
538 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="device_groups")
539 | def update_device_group_some_params(device_group):
540 | # check device_group_ exists first
541 | device_group_exists = mongo_connection.mongo_check_device_group_exists(device_group)
542 | if device_group_exists is False:
543 | return jsonify({"device_group_exists": False}), 403
544 | # check device_group_ got update parameters
545 | try:
546 | device_group_json = request.json
547 | if len(device_group_json) == 0:
548 | return jsonify({"missing_parameters": True}), 400
549 | except:
550 | return jsonify({"missing_parameters": True}), 400
551 | # check edge case of port being outside of possible port ranges in case trying to update port listing
552 | try:
553 | cron_jobs = request.json["cron_jobs"]
554 | # check edge case where cron_jobs is not a list
555 | if type(cron_jobs) is not list:
556 | return jsonify({"cron_jobs_is_list": False}), 400
557 | # check edge case where adding an cron_jobs that does not exist
558 | for device_cron_job in cron_jobs:
559 | cron_job_exists, cron_job_json = mongo_connection.mongo_get_cron_job(device_cron_job)
560 | if cron_job_exists is False:
561 | return jsonify({"cron_job_exists": False}), 403
562 | except:
563 | pass
564 | try:
565 | apps = request.json["apps"]
566 | # check edge case where apps is not a list
567 | if type(apps) is not list:
568 | return jsonify({"apps_is_list": False}), 400
569 | # check edge case where adding an app that does not exist
570 | for device_app in apps:
571 | app_exists, app_json = mongo_connection.mongo_get_app(device_app)
572 | if app_exists is False:
573 | return jsonify({"app_exists": False}), 403
574 | except:
575 | pass
576 | # update db
577 | device_group_json = mongo_connection.mongo_update_device_group(device_group, request.json)
578 | return dumps(device_group_json), 202
579 |
580 |
581 |
582 | # delete device_group
583 | @app.route('/api/' + API_VERSION + '/device_groups/', methods=["DELETE"])
584 | @multi_auth.login_required
585 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="device_groups")
586 | def delete_device_group(device_group):
587 | # check app exists first
588 | device_group_exists = mongo_connection.mongo_check_device_group_exists(device_group)
589 | if device_group_exists is False:
590 | return jsonify({"device_group_exists": False}), 403
591 | # remove from db
592 | mongo_connection.mongo_remove_device_group(device_group)
593 | return "{}", 200
594 |
595 |
596 | # list device_groups
597 | @app.route('/api/' + API_VERSION + '/device_groups', methods=["GET"])
598 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
599 | @multi_auth.login_required
600 | def list_device_groups():
601 | nebula_device_groups_list = mongo_connection.mongo_list_device_groups()
602 | return jsonify({"device_groups": nebula_device_groups_list}), 200
603 |
604 |
605 | # prune unused images on all devices running said device_group
606 | @app.route('/api/' + API_VERSION + '/device_groups//prune', methods=["POST"])
607 | @multi_auth.login_required
608 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="pruning")
609 | def prune_device_group_images(device_group):
610 | # check device_group exists first
611 | device_group_exists = mongo_connection.mongo_check_device_group_exists(device_group)
612 | if device_group_exists is False:
613 | return jsonify({"app_exists": False}), 403
614 | # update db
615 | app_json = mongo_connection.mongo_increase_prune_id(device_group)
616 | return dumps(app_json), 202
617 |
618 |
619 | # prune unused images on all devices
620 | @app.route('/api/' + API_VERSION + '/prune', methods=["POST"])
621 | @multi_auth.login_required
622 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="pruning")
623 | def prune_images_on_all_device_groups():
624 | # get a list of all device_groups
625 | device_groups = mongo_connection.mongo_list_device_groups()
626 | all_device_groups_prune_id = {"prune_ids": {}}
627 | # loop over all device groups
628 | for device_group in device_groups:
629 | # check device_group exists first
630 | device_group_exists = mongo_connection.mongo_check_device_group_exists(device_group)
631 | if device_group_exists is False:
632 | return jsonify({"app_exists": False}), 403
633 | # update db
634 | app_json = mongo_connection.mongo_increase_prune_id(device_group)
635 | all_device_groups_prune_id["prune_ids"][device_group] = app_json["prune_id"]
636 | return dumps(all_device_groups_prune_id), 202
637 |
638 |
639 | # list reports
640 | @app.route('/api/' + API_VERSION + '/reports', methods=["GET"])
641 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
642 | @multi_auth.login_required
643 | def get_report():
644 |
645 | # first we get all the data from the params and pass it through the get_param_filter which will return them in the
646 | # format MongoDB uses to filtering
647 | last_id = request.args.get('last_id')
648 | page_size = request.args.get('page_size', 10, int)
649 | hostname = get_param_filter("hostname", request)
650 | device_group = get_param_filter("device_group", request)
651 | report_creation_time_filter = request.args.get('report_creation_time_filter', "eq", str)
652 | report_creation_time = get_param_filter("report_creation_time", request, filter_param=report_creation_time_filter,
653 | request_type=int)
654 | updated = get_param_filter("updated", request, filter_param="eq", request_type=str)
655 |
656 | # Now we combine all the filters
657 | filters = {}
658 | for filter_option in [hostname, device_group, report_creation_time, updated]:
659 | if filter_option is not None:
660 | filters = {**filters, **filter_option}
661 |
662 | # lastly we return the requests reports to the user
663 | data, last_id = mongo_connection.mango_list_paginated_filtered_reports(page_size=page_size, last_id=last_id,
664 | filters=filters)
665 | reply = {"data": data, "last_id": last_id}
666 | return dumps(reply), 200
667 |
668 |
669 | # set json header - the API is JSON only so the header is set on all requests
670 | @app.after_request
671 | def apply_caching(response):
672 | response.headers["Content-Type"] = "application/json"
673 | return response
674 |
675 |
676 | # list users
677 | @app.route('/api/' + API_VERSION + '/users', methods=["GET"])
678 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
679 | @multi_auth.login_required
680 | def list_users():
681 | nebula_users_list = mongo_connection.mongo_list_users()
682 | return jsonify({"users": nebula_users_list}), 200
683 |
684 |
685 | # get user info
686 | @app.route('/api/' + API_VERSION + '/users/', methods=["GET"])
687 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
688 | @multi_auth.login_required
689 | @check_authorization_wrapper(permission_needed="ro", permission_object_type="admin")
690 | def get_user(user_name):
691 | user_exists, user_json = mongo_connection.mongo_get_user(user_name)
692 | if user_exists is True:
693 | return dumps(user_json), 200
694 | elif user_exists is False:
695 | return jsonify({"user_exists": False}), 403
696 |
697 |
698 | # delete a user
699 | @app.route('/api/' + API_VERSION + '/users/', methods=["DELETE"])
700 | @multi_auth.login_required
701 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="admin")
702 | def delete_user(user_name):
703 | # check user exists first
704 | user_exists = mongo_connection.mongo_check_user_exists(user_name)
705 | if user_exists is False:
706 | return jsonify({"user_exists": False}), 403
707 | # remove from db
708 | mongo_connection.mongo_delete_user(user_name)
709 | return "{}", 200
710 |
711 |
712 | # update a user
713 | @app.route('/api/' + API_VERSION + '/users//update', methods=["PUT", "PATCH"])
714 | @multi_auth.login_required
715 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="admin")
716 | def update_user(user_name):
717 | # check user exists first
718 | user_exists = mongo_connection.mongo_check_user_exists(user_name)
719 | if user_exists is False:
720 | return jsonify({"user_name": False}), 403
721 | # check user got update parameters
722 | try:
723 | user_json = request.json
724 | if len(user_json) == 0:
725 | return jsonify({"missing_parameters": True}), 400
726 | except:
727 | return jsonify({"missing_parameters": True}), 400
728 | # if part of the update includes a token hash it
729 | try:
730 | request.json["token"] = hash_secret(request.json["token"])
731 | except:
732 | pass
733 | # if part of the update includes a password hash it
734 | try:
735 | request.json["password"] = hash_secret(request.json["password"])
736 | except:
737 | pass
738 | # update db
739 | user_json = mongo_connection.mongo_update_user(user_name, request.json)
740 | return dumps(user_json), 200
741 |
742 |
743 | # refresh a user token
744 | @app.route('/api/' + API_VERSION + '/users//refresh', methods=["POST"])
745 | @multi_auth.login_required
746 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="admin")
747 | def refresh_user_token(user_name):
748 | # check user exists first
749 | user_exists = mongo_connection.mongo_check_user_exists(user_name)
750 | if user_exists is False:
751 | return jsonify({"user_name": False}), 403
752 | # get current user data and update the token for him
753 | try:
754 | new_token = secrets.token_urlsafe()
755 | app_exists, user_json = mongo_connection.mongo_get_user(user_name)
756 | user_json["token"] = hash_secret(new_token)
757 | except:
758 | return jsonify({"token_refreshed": False}), 403
759 | # update db
760 | user_json = mongo_connection.mongo_update_user(user_name, user_json)
761 | return jsonify({"token": new_token}), 200
762 |
763 |
764 | # create new user
765 | @app.route('/api/' + API_VERSION + '/users/', methods=["POST"])
766 | @multi_auth.login_required
767 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="admin")
768 | def create_user(user_name):
769 | # check app does't exists first
770 | user_exists = mongo_connection.mongo_check_user_exists(user_name)
771 | if user_exists is True:
772 | return jsonify({"user_exists": True}), 403
773 | else:
774 | # check the request is passed with all needed parameters
775 | try:
776 | user_json = request.json
777 | except:
778 | return jsonify({"missing_parameters": True}), 400
779 | try:
780 | # hash the password & token, if not declared generates them randomly
781 | password = hash_secret(return_sane_default_if_not_declared("password", user_json, secrets.token_urlsafe()))
782 | token = hash_secret(return_sane_default_if_not_declared("token", user_json, secrets.token_urlsafe()))
783 | except:
784 | return jsonify({"missing_parameters": True}), 400
785 | # update the db
786 | user_json = mongo_connection.mongo_add_user(user_name, password, token)
787 | return dumps(user_json), 200
788 |
789 |
790 | # create new user_group
791 | @app.route('/api/' + API_VERSION + '/user_groups/', methods=["POST"])
792 | @multi_auth.login_required
793 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="admin")
794 | def create_user_group(user_group):
795 | # check app does't exists first
796 | user_exists = mongo_connection.mongo_check_user_group_exists(user_group)
797 | if user_exists is True:
798 | return jsonify({"user_group_exists": True}), 403
799 | else:
800 | # check the request is passed with all needed parameters
801 | try:
802 | user_json = request.json
803 | except:
804 | return json.dumps(find_missing_params({}, ["user_group"])), 400
805 | try:
806 | # return the user_group parameters, anything not declared is by default not allowed
807 | group_members = return_sane_default_if_not_declared("group_members", user_json, [])
808 | pruning_allowed = return_sane_default_if_not_declared("pruning_allowed", user_json, False)
809 | apps = return_sane_default_if_not_declared("apps", user_json, {})
810 | device_groups = return_sane_default_if_not_declared("device_groups", user_json, {})
811 | admin = return_sane_default_if_not_declared("admin", user_json, False)
812 | cron_jobs = return_sane_default_if_not_declared("cron_jobs", user_json, {})
813 | except:
814 | return jsonify({"missing_parameters": True}), 400
815 | # update the db
816 | user_json = mongo_connection.mongo_add_user_group(user_group, group_members, pruning_allowed, apps,
817 | device_groups, admin, cron_jobs)
818 | return dumps(user_json), 200
819 |
820 |
821 | # PUT update some fields of a user_group
822 | @app.route('/api/' + API_VERSION + '/user_groups//update', methods=["PUT", "PATCH"])
823 | @multi_auth.login_required
824 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="admin")
825 | def update_user_group_fields(user_group):
826 | # check user_group exists first
827 | user_group_exists = mongo_connection.mongo_check_user_group_exists(user_group)
828 | if user_group is False:
829 | return jsonify({"user_group_exists": False}), 403
830 | # check app got update parameters
831 | try:
832 | app_json = request.json
833 | if len(app_json) == 0:
834 | return jsonify({"missing_parameters": True}), 400
835 | except:
836 | return jsonify({"missing_parameters": True}), 400
837 | # update db
838 | app_json = mongo_connection.mongo_update_user_group(user_group, request.json)
839 | return dumps(app_json), 200
840 |
841 |
842 | # delete a user_group
843 | @app.route('/api/' + API_VERSION + '/user_groups/', methods=["DELETE"])
844 | @multi_auth.login_required
845 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="admin")
846 | def delete_user_group(user_group):
847 | # check user exists first
848 | user_group_exists = mongo_connection.mongo_check_user_group_exists(user_group)
849 | if user_group_exists is False:
850 | return jsonify({"user_group_exists": False}), 403
851 | # remove from db
852 | mongo_connection.mongo_delete_user_group(user_group)
853 | return "{}", 200
854 |
855 |
856 | # list user_groups
857 | @app.route('/api/' + API_VERSION + '/user_groups', methods=["GET"])
858 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
859 | @multi_auth.login_required
860 | def list_user_groups():
861 | nebula_user_groups_list = mongo_connection.mongo_list_user_groups()
862 | return jsonify({"user_groups": nebula_user_groups_list}), 200
863 |
864 |
865 | # get user_group info
866 | @app.route('/api/' + API_VERSION + '/user_groups/', methods=["GET"])
867 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
868 | @multi_auth.login_required
869 | @check_authorization_wrapper(permission_needed="ro", permission_object_type="admin")
870 | def get_user_group(user_group):
871 | user_group_exists, user_json = mongo_connection.mongo_get_user_group(user_group)
872 | if user_group_exists is True:
873 | return dumps(user_json), 200
874 | elif user_group_exists is False:
875 | return jsonify({"user_group_exists": False}), 403
876 |
877 |
878 | # create cron_job
879 | @app.route('/api/' + API_VERSION + '/cron_jobs/', methods=["POST"])
880 | @multi_auth.login_required
881 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="cron_jobs")
882 | def create_cron_job(cron_job):
883 | # check cron_job does't exists first
884 | cron_job_exists = mongo_connection.mongo_check_cron_job_exists(cron_job)
885 | if cron_job_exists is True:
886 | return jsonify({"cron_job_exists": True}), 403
887 | else:
888 | # check the request is passed with all needed parameters
889 | try:
890 | cron_job_json = request.json
891 | schedule = cron_job_json["schedule"]
892 | env_vars = return_sane_default_if_not_declared("env_vars", cron_job_json, {})
893 | docker_image= cron_job_json["docker_image"]
894 | running = return_sane_default_if_not_declared("running", cron_job_json, True)
895 | networks = return_sane_default_if_not_declared("networks", cron_job_json, [])
896 | volumes = return_sane_default_if_not_declared("volumes", cron_job_json, [])
897 | devices = return_sane_default_if_not_declared("devices", cron_job_json, [])
898 | privileged = return_sane_default_if_not_declared("privileged", cron_job_json, False)
899 | except:
900 | return json.dumps(find_missing_params(cron_job_json, ["docker_image", "schedule"])), 400
901 | # check edge case where schedule is not valid
902 | if croniter.is_valid(schedule) is False:
903 | return jsonify({"schedule_valid": False}), 400
904 | # update the db
905 | cron_job_json = mongo_connection.mongo_add_cron_job(cron_job, schedule, env_vars, docker_image, running,
906 | networks, volumes, devices, privileged)
907 | return dumps(cron_job_json), 200
908 |
909 |
910 | # list cron_jobs
911 | @app.route('/api/' + API_VERSION + '/cron_jobs', methods=["GET"])
912 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
913 | @multi_auth.login_required
914 | def list_cron_jobs():
915 | nebula_cron_jobs_list = mongo_connection.mongo_list_cron_jobs()
916 | return jsonify({"cron_jobs": nebula_cron_jobs_list}), 200
917 |
918 |
919 | # list cron_job
920 | @app.route('/api/' + API_VERSION + '/cron_jobs/', methods=["GET"])
921 | @retry(stop_max_attempt_number=3, wait_exponential_multiplier=200, wait_exponential_max=500)
922 | @multi_auth.login_required
923 | @check_authorization_wrapper(permission_needed="ro", permission_object_type="cron_jobs")
924 | def get_cron_job(cron_job):
925 | cron_job_exists, cron_job_json = mongo_connection.mongo_get_cron_job(cron_job)
926 | if cron_job_exists is True:
927 | return dumps(cron_job_json), 200
928 | elif cron_job_exists is False:
929 | return jsonify({"cron_job_exists": False}), 403
930 |
931 |
932 | # PUT update some fields of an cron job - params not given will be unchanged from their current value
933 | @app.route('/api/' + API_VERSION + '/cron_jobs//update', methods=["PUT", "PATCH"])
934 | @multi_auth.login_required
935 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="cron_jobs")
936 | def update_cron_job_fields(cron_job):
937 | # check cron_job exists first
938 | cron_job_exists = mongo_connection.mongo_check_cron_job_exists(cron_job)
939 | if cron_job_exists is False:
940 | return jsonify({"cron_job_exists": False}), 403
941 | # check cron_job got update parameters
942 | try:
943 | cron_job_json = request.json
944 | if len(cron_job_json) == 0:
945 | return jsonify({"missing_parameters": True}), 400
946 | except:
947 | return jsonify({"missing_parameters": True}), 400
948 | # check edge case of port being outside of possible port ranges in case trying to update port listing
949 | try:
950 | schedule = request.json["schedule"]
951 | # check edge case where schedule is not valid
952 | if croniter.is_valid(schedule) is False:
953 | return jsonify({"schedule_valid": False}), 400
954 | except:
955 | pass
956 | # update db
957 | cron_job_json = mongo_connection.mongo_update_cron_job_fields(cron_job, request.json)
958 | return dumps(cron_job_json), 202
959 |
960 |
961 | # POST update a cron job - replace all params
962 | @app.route('/api/' + API_VERSION + '/cron_jobs//update', methods=["POST"])
963 | @multi_auth.login_required
964 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="cron_jobs")
965 | def update_cron_job_all_fields(cron_job):
966 | # check cron_job exists first
967 | cron_job_exists = mongo_connection.mongo_check_cron_job_exists(cron_job)
968 | if cron_job_exists is False:
969 | return jsonify({"cron_job_exists": False}), 403
970 | # check cron_job got update parameters
971 | try:
972 | cron_job_json = request.json
973 | if len(cron_job_json) == 0:
974 | return jsonify({"missing_parameters": True}), 400
975 | if cron_job_json["docker_image"] is None or cron_job_json["schedule"] is None:
976 | return json.dumps(find_missing_params(cron_job_json, ["docker_image", "schedule"])), 400
977 | except:
978 | return jsonify({"missing_parameters": True}), 400
979 | # set default for undeclared params
980 | try:
981 | cron_job_json["env_vars"] = return_sane_default_if_not_declared("env_vars", cron_job_json, {})
982 | cron_job_json["running"] = return_sane_default_if_not_declared("running", cron_job_json, True)
983 | cron_job_json["volumes"] = return_sane_default_if_not_declared("volumes", cron_job_json, [])
984 | cron_job_json["devices"] = return_sane_default_if_not_declared("devices", cron_job_json, [])
985 | cron_job_json["privileged"] = return_sane_default_if_not_declared("privileged", cron_job_json, False)
986 | cron_job_json["networks"] = return_sane_default_if_not_declared("networks", cron_job_json, ["nebula", "bridge"])
987 | except:
988 | return json.dumps(find_missing_params(cron_job_json, ["docker_image", "schedule"])), 400
989 | # check edge case of port being outside of possible port ranges in case trying to update port listing
990 | try:
991 | schedule = request.json["schedule"]
992 | # check edge case where schedule is not valid
993 | if croniter.is_valid(schedule) is False:
994 | return jsonify({"schedule_valid": False}), 400
995 | except:
996 | pass
997 | # update db
998 | cron_job_json = mongo_connection.mongo_update_cron_job_fields(cron_job, request.json)
999 | return dumps(cron_job_json), 202
1000 |
1001 |
1002 | # delete a cron_job
1003 | @app.route('/api/' + API_VERSION + '/cron_jobs/', methods=["DELETE"])
1004 | @multi_auth.login_required
1005 | @check_authorization_wrapper(permission_needed="rw", permission_object_type="admin")
1006 | def delete_cron_job(cron_job):
1007 | # check user exists first
1008 | cron_job_exists = mongo_connection.mongo_check_cron_job_exists(cron_job)
1009 | if cron_job_exists is False:
1010 | return jsonify({"cron_job_exists": False}), 403
1011 | # remove from db
1012 | mongo_connection.mongo_delete_cron_job(cron_job)
1013 | return "{}", 200
1014 |
1015 |
1016 | # used for when running with the 'ENV' envvar set to dev to open a new thread with flask builtin web server
1017 | def run_dev(dev_host='0.0.0.0', dev_port=5000, dev_threaded=True):
1018 | try:
1019 | app.run(host=dev_host, port=dev_port, threaded=dev_threaded)
1020 | except Exception as e:
1021 | print("Flask connection failure - dropping container")
1022 | print(e, file=sys.stderr)
1023 | os._exit(2)
1024 |
1025 |
1026 | # will usually run in gunicorn but for debugging set the "ENV" envvar to "dev" to run from flask built in web server
1027 | # opens in a new thread, DO NOT SET AS 'dev' FOR PRODUCTION USE!!!
1028 | if os.getenv("ENV", "prod") == "dev":
1029 | try:
1030 | run_dev()
1031 | except Exception as e:
1032 | print("Flask connection failure - dropping container")
1033 | print(e, file=sys.stderr)
1034 | os._exit(2)
1035 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | backports.ssl-match-hostname==3.7.0.1
2 | bcrypt==4.3.0
3 | cachetools==5.5.2
4 | certifi==2025.1.31
5 | cffi==1.17.1
6 | chardet==5.2.0
7 | Click==8.1.8
8 | colorama==0.4.6
9 | configobj==5.0.9
10 | croniter==6.0.0
11 | dnspython==2.7.0
12 | dpath==2.2.0
13 | enum34==1.1.10
14 | Flask==3.1.0
15 | Flask-HTTPAuth==4.8.0
16 | gevent==24.11.1
17 | greenlet==3.1.1
18 | gunicorn==23.0.0
19 | html5lib==1.1
20 | idna==3.10
21 | ipaddress==1.0.23
22 | itsdangerous==2.2.0
23 | Jinja2==3.1.5
24 | MarkupSafe==3.0.2
25 | parse-it==2025.3.1.21.46
26 | ply==3.11
27 | pycparser==2.22
28 | pyhcl==0.4.5
29 | pymongo==4.11.2
30 | python-dateutil==2.9.0.post0
31 | python-dotenv==1.0.1
32 | PyYAML==6.0.2
33 | requests==2.32.3
34 | retrying==1.3.4
35 | six==1.17.0
36 | toml==0.10.2
37 | urllib3==2.3.0
38 | webencodings==0.5.1
39 | websocket-client==1.8.0
40 | Werkzeug==3.1.3
41 | xmltodict==0.14.2
42 |
--------------------------------------------------------------------------------
/shippable.yml:
--------------------------------------------------------------------------------
1 | language: python
2 |
3 | python:
4 | - 3.7
5 |
6 | integrations:
7 | hub:
8 | - integrationName: docker_hub
9 | type: dockerRegistryLogin
10 |
11 | env:
12 | global:
13 | - DOCKER_HUB_ORG=nebulaorchestrator
14 | - DOCKER_HUB_REPO=manager
15 |
16 | build:
17 | ci:
18 | - if [ "$BRANCH" == "master" ] && [ "$IS_PULL_REQUEST" == false ]; then docker build -t $DOCKER_HUB_ORG/$DOCKER_HUB_REPO:arm64v8 .; fi
19 | - if [ "$BRANCH" != "master" ] && [ "$IS_PULL_REQUEST" == false ]; then docker build -t $DOCKER_HUB_ORG/$DOCKER_HUB_REPO:$BRANCH-arm64v8 .; fi
20 | post_ci:
21 | - if [ "$BRANCH" == "master" ] && [ "$IS_PULL_REQUEST" == false ]; then docker push $DOCKER_HUB_ORG/$DOCKER_HUB_REPO:arm64v8; fi
22 | - if [ "$BRANCH" != "master" ] && [ "$IS_PULL_REQUEST" == false ]; then docker push $DOCKER_HUB_ORG/$DOCKER_HUB_REPO:$BRANCH-arm64v8; fi
23 |
24 | runtime:
25 | nodePool: shippable_shared_aarch64
--------------------------------------------------------------------------------
/test/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebula-orchestrator/manager/e3ba2ca753c8aeffc6ccb1da865dcec319092955/test/__init__.py
--------------------------------------------------------------------------------
/test/test_nebula_python_manager.py:
--------------------------------------------------------------------------------
1 | from unittest import TestCase
2 | from manager import *
3 |
4 |
5 | class BaseTests(TestCase):
6 |
7 | def test_find_missing_params(self):
8 | test_reply = find_missing_params({}, ["docker_image"])
9 | self.assertEqual(test_reply, {"missing_parameters": ["docker_image"]})
10 |
11 | def test_return_sane_default_if_not_declared_param_declared(self):
12 | test_reply = return_sane_default_if_not_declared("test_param", {"test_param": "test_value"}, "param_default")
13 | self.assertEqual(test_reply, "test_value")
14 |
15 | def test_return_sane_default_if_not_declared_param_not_declared_default_exists(self):
16 | test_reply = return_sane_default_if_not_declared("test_param", {}, "param_default")
17 | self.assertEqual(test_reply, "param_default")
18 |
19 | def test_check_ports_valid_range_port_in_range(self):
20 | test_reply, text_reply_code = check_ports_valid_range([80, 81])
21 | self.assertEqual(text_reply_code, 200)
22 |
23 | def test_check_ports_valid_range_port_not_in_range(self):
24 | test_reply, text_reply_code = check_ports_valid_range([80, 643681, 81])
25 | self.assertEqual(text_reply_code, 400)
26 |
--------------------------------------------------------------------------------
/test/test_nebula_python_manager_functions_db_mongo.py:
--------------------------------------------------------------------------------
1 | from unittest import TestCase
2 | from functions.db.mongo import *
3 | from functions.hashing.hashing import *
4 |
5 |
6 | def mongo_connection():
7 | mongo_url = os.getenv("MONGO_URL", "mongodb://nebula:nebula@127.0.0.1:27017/nebula?authSource=admin")
8 | connection = MongoConnection(mongo_url)
9 | return connection
10 |
11 |
12 | def create_temp_app(mongo_connection_object, app):
13 | app_conf = {
14 | "starting_ports": [80],
15 | "containers_per": {"server": 1},
16 | "env_vars": {"TEST": "test123"},
17 | "docker_image": "nginx"
18 | }
19 | reply = mongo_connection_object.mongo_add_app(app, app_conf["starting_ports"], app_conf["containers_per"],
20 | app_conf["env_vars"], app_conf["docker_image"])
21 | return reply
22 |
23 |
24 | def create_temp_cron_job(mongo_connection_object, cron_job):
25 | cron_job_conf = {
26 | "env_vars": {"TEST": "test123"},
27 | "docker_image": "nginx",
28 | "running": True,
29 | "volumes": [],
30 | "networks": ["nebula"],
31 | "devices": [],
32 | "privileged": False,
33 | "schedule": "0 * * * *"
34 | }
35 | reply = mongo_connection_object.mongo_add_cron_job(cron_job, cron_job_conf["schedule"], cron_job_conf["env_vars"],
36 | cron_job_conf["docker_image"], cron_job_conf["running"],
37 | cron_job_conf["networks"], cron_job_conf["volumes"],
38 | cron_job_conf["devices"], cron_job_conf["privileged"])
39 | return reply
40 |
41 |
42 | class MongoTests(TestCase):
43 |
44 | def test_mongo_cron_job_flow(self):
45 | mongo_connection_object = mongo_connection()
46 |
47 | # ensure no test app is already created in the unit test DB
48 | mongo_connection_object.mongo_delete_cron_job("unit_test_cron_job")
49 |
50 | # check create test cron job works
51 | test_reply = create_temp_cron_job(mongo_connection_object, "unit_test_cron_job")
52 | self.assertEqual(test_reply["cron_job_id"], 1)
53 | self.assertEqual(test_reply["cron_job_name"], "unit_test_cron_job")
54 | self.assertEqual(test_reply["devices"], [])
55 | self.assertEqual(test_reply["docker_image"], "nginx")
56 | self.assertEqual(test_reply["env_vars"], {"TEST": "test123"})
57 | self.assertEqual(test_reply["networks"], ["nebula"])
58 | self.assertFalse(test_reply["privileged"])
59 | self.assertTrue(test_reply["running"])
60 | self.assertEqual(test_reply["volumes"], [])
61 | self.assertEqual(test_reply["schedule"], "0 * * * *")
62 |
63 | # check getting test cron job data works
64 | cron_job_exists, test_reply = mongo_connection_object.mongo_get_cron_job("unit_test_cron_job")
65 | self.assertTrue(cron_job_exists)
66 | self.assertEqual(test_reply["cron_job_id"], 1)
67 | self.assertEqual(test_reply["cron_job_name"], "unit_test_cron_job")
68 | self.assertEqual(test_reply["devices"], [])
69 | self.assertEqual(test_reply["docker_image"], "nginx")
70 | self.assertEqual(test_reply["env_vars"], {"TEST": "test123"})
71 | self.assertEqual(test_reply["networks"], ["nebula"])
72 | self.assertFalse(test_reply["privileged"])
73 | self.assertTrue(test_reply["running"])
74 | self.assertEqual(test_reply["volumes"], [])
75 | self.assertEqual(test_reply["schedule"], "0 * * * *")
76 |
77 | # check getting test app data non existing app
78 | cron_job_exists, test_reply = mongo_connection_object.mongo_get_cron_job("unit_test_cron_job_doesnt_exist")
79 | self.assertFalse(cron_job_exists)
80 |
81 | # check if app exists works
82 | test_reply = mongo_connection_object.mongo_check_cron_job_exists("unit_test_cron_job")
83 | self.assertTrue(test_reply)
84 | test_reply = mongo_connection_object.mongo_check_cron_job_exists("unit_test_cron_job_doesnt_exist")
85 | self.assertFalse(test_reply)
86 |
87 | # check updating app somefield works
88 | test_reply = mongo_connection_object.mongo_update_cron_job_fields("unit_test_cron_job", {
89 | "env_vars":
90 | {"TESTING": "testing12345"},
91 | "running": False
92 | })
93 | self.assertEqual(test_reply["env_vars"], {"TESTING": "testing12345"})
94 | self.assertFalse(test_reply["running"])
95 |
96 | # check getting list of cron jobs works
97 | test_reply = mongo_connection_object.mongo_list_cron_jobs()
98 | self.assertEqual(test_reply, ["unit_test_cron_job"])
99 |
100 | # check update test app works
101 | test_reply = mongo_connection_object.mongo_get_cron_job("unit_test_cron_job")
102 | cron_job_exists, test_cron_json = test_reply
103 | test_cron_job_id = test_cron_json["cron_job_id"]
104 | updated_app_conf = {
105 | "schedule": "0 0 0 0 0"
106 | }
107 | test_reply = mongo_connection_object.mongo_update_cron_job_fields("unit_test_cron_job", updated_app_conf)
108 | self.assertTrue(cron_job_exists)
109 | self.assertEqual(test_reply["cron_job_id"], test_cron_job_id + 1)
110 | self.assertEqual(test_reply["cron_job_name"], "unit_test_cron_job")
111 | self.assertEqual(test_reply["devices"], [])
112 | self.assertEqual(test_reply["docker_image"], "nginx")
113 | self.assertEqual(test_reply["env_vars"], {"TESTING": "testing12345"})
114 | self.assertEqual(test_reply["networks"], ["nebula"])
115 | self.assertFalse(test_reply["privileged"])
116 | self.assertFalse(test_reply["running"])
117 | self.assertEqual(test_reply["volumes"], [])
118 | self.assertEqual(test_reply["schedule"], "0 0 0 0 0")
119 |
120 | # check delete test app works
121 | test_reply = mongo_connection_object.mongo_delete_cron_job("unit_test_cron_job")
122 | self.assertEqual(test_reply.deleted_count, 1)
123 |
124 | def test_mongo_app_flow(self):
125 | mongo_connection_object = mongo_connection()
126 |
127 | # ensure no test app is already created in the unit test DB
128 | mongo_connection_object.mongo_remove_app("unit_test_app")
129 |
130 | # check create test app works
131 | test_reply = create_temp_app(mongo_connection_object, "unit_test_app")
132 | self.assertEqual(test_reply["app_id"], 1)
133 | self.assertEqual(test_reply["app_name"], "unit_test_app")
134 | self.assertEqual(test_reply["containers_per"], {"server": 1})
135 | self.assertEqual(test_reply["devices"], [])
136 | self.assertEqual(test_reply["docker_image"], "nginx")
137 | self.assertEqual(test_reply["env_vars"], {"TEST": "test123"})
138 | self.assertEqual(test_reply["networks"], ["nebula"])
139 | self.assertFalse(test_reply["privileged"])
140 | self.assertFalse(test_reply["rolling_restart"])
141 | self.assertTrue(test_reply["running"])
142 | self.assertEqual(test_reply["volumes"], [])
143 |
144 | # check getting test app data works
145 | app_exists, test_reply = mongo_connection_object.mongo_get_app("unit_test_app")
146 | self.assertTrue(app_exists)
147 | self.assertEqual(test_reply["app_id"], 1)
148 | self.assertEqual(test_reply["app_name"], "unit_test_app")
149 | self.assertEqual(test_reply["containers_per"], {"server": 1})
150 | self.assertEqual(test_reply["devices"], [])
151 | self.assertEqual(test_reply["docker_image"], "nginx")
152 | self.assertEqual(test_reply["env_vars"], {"TEST": "test123"})
153 | self.assertEqual(test_reply["networks"], ["nebula"])
154 | self.assertFalse(test_reply["privileged"])
155 | self.assertFalse(test_reply["rolling_restart"])
156 | self.assertTrue(test_reply["running"])
157 | self.assertEqual(test_reply["volumes"], [])
158 |
159 | # check getting test app data non existing app
160 | app_exists, test_reply = mongo_connection_object.mongo_get_app("unit_test_app_that_doesnt_exist")
161 | self.assertFalse(app_exists)
162 |
163 | # check if app exists works
164 | test_reply = mongo_connection_object.mongo_check_app_exists("unit_test_app")
165 | self.assertTrue(test_reply)
166 | test_reply = mongo_connection_object.mongo_check_app_exists("unit_test_app_that_doesnt_exist")
167 | self.assertFalse(test_reply)
168 |
169 | # check getting app envvars works
170 | test_reply = mongo_connection_object.mongo_list_app_envvars("unit_test_app")
171 | self.assertEqual(test_reply, {"TEST": "test123"})
172 |
173 | # check updating app envvars works
174 | test_reply = mongo_connection_object.mongo_update_app_envars("unit_test_app", {"NEW_TEST": "new_test123"})
175 | self.assertEqual(test_reply["env_vars"], {"NEW_TEST": "new_test123"})
176 |
177 | # check updating app somefield works
178 | test_reply = mongo_connection_object.mongo_update_app_fields("unit_test_app", {
179 | "env_vars":
180 | {"TESTING": "testing123"},
181 | "running": False
182 | })
183 | self.assertEqual(test_reply["env_vars"], {"TESTING": "testing123"})
184 | self.assertFalse(test_reply["running"])
185 |
186 | # check getting app number of containers per cpu works
187 | test_reply = mongo_connection_object.mongo_list_app_containers_per("unit_test_app")
188 | self.assertEqual(test_reply, {"server": 1})
189 |
190 | # check updating app number of containers per cpu works
191 | test_reply = mongo_connection_object.mongo_update_app_containers_per("unit_test_app", {"server": 2})
192 | self.assertEqual(test_reply["containers_per"], {"server": 2})
193 |
194 | # check getting app starting ports works
195 | test_reply = mongo_connection_object.mongo_list_app_starting_ports("unit_test_app")
196 | self.assertEqual(test_reply, [80])
197 |
198 | # check updating app starting ports works
199 | test_reply = mongo_connection_object.mongo_update_app_starting_ports("unit_test_app", {"81": "80"})
200 | self.assertEqual(test_reply["starting_ports"], {"81": "80"})
201 |
202 | # check increase app id works
203 | test_reply = mongo_connection_object.mongo_increase_app_id("unit_test_app")
204 | test_app_id = test_reply["app_id"]
205 | test_reply = mongo_connection_object.mongo_increase_app_id("unit_test_app")
206 | self.assertEqual(test_reply["app_id"], test_app_id + 1)
207 |
208 | # check getting app running state works
209 | test_reply = mongo_connection_object.mongo_list_app_running_state("unit_test_app")
210 | self.assertFalse(test_reply)
211 |
212 | # check updating app running state works
213 | test_reply = mongo_connection_object.mongo_update_app_running_state("unit_test_app", True)
214 | self.assertTrue(test_reply)
215 |
216 | # check getting list of apps works
217 | test_reply = mongo_connection_object.mongo_list_apps()
218 | self.assertEqual(test_reply, ["unit_test_app"])
219 |
220 | # check update test app works
221 | test_reply = mongo_connection_object.mongo_increase_app_id("unit_test_app")
222 | test_app_id = test_reply["app_id"]
223 | updated_app_conf = {
224 | "starting_ports": [80],
225 | "containers_per": {"server": 1},
226 | "env_vars": {"TEST": "test123"},
227 | "docker_image": "nginx",
228 | "running": True,
229 | "networks": ["nebula"],
230 | "volumes": [],
231 | "devices": [],
232 | "privileged": True,
233 | "rolling_restart": True
234 | }
235 | test_reply = mongo_connection_object.mongo_update_app("unit_test_app", updated_app_conf["starting_ports"],
236 | updated_app_conf["containers_per"],
237 | updated_app_conf["env_vars"],
238 | updated_app_conf["docker_image"],
239 | updated_app_conf["running"],
240 | updated_app_conf["networks"],
241 | updated_app_conf["volumes"],
242 | updated_app_conf["devices"],
243 | updated_app_conf["privileged"],
244 | updated_app_conf["rolling_restart"])
245 | self.assertEqual(test_reply["app_id"], test_app_id + 1)
246 | self.assertEqual(test_reply["app_name"], "unit_test_app")
247 | self.assertEqual(test_reply["containers_per"], {"server": 1})
248 | self.assertEqual(test_reply["devices"], [])
249 | self.assertEqual(test_reply["docker_image"], "nginx")
250 | self.assertEqual(test_reply["env_vars"], {"TEST": "test123"})
251 | self.assertEqual(test_reply["networks"], ["nebula"])
252 | self.assertTrue(test_reply["privileged"])
253 | self.assertTrue(test_reply["rolling_restart"])
254 | self.assertTrue(test_reply["running"])
255 | self.assertEqual(test_reply["volumes"], [])
256 |
257 | # check delete test app works
258 | test_reply = mongo_connection_object.mongo_remove_app("unit_test_app")
259 | self.assertEqual(test_reply.deleted_count, 1)
260 |
261 | def test_mongo_device_group_flow(self):
262 | mongo_connection_object = mongo_connection()
263 |
264 | # ensure no test app is already created in the unit test DB
265 | mongo_connection_object.mongo_remove_device_group("unit_test_device_group")
266 |
267 | # check create device group works
268 | test_reply = mongo_connection_object.mongo_add_device_group("unit_test_device_group", [], [])
269 | self.assertEqual(test_reply["apps"], [])
270 | self.assertEqual(test_reply["cron_jobs"], [])
271 | self.assertEqual(test_reply["device_group"], "unit_test_device_group")
272 | self.assertEqual(test_reply["device_group_id"], 1)
273 | self.assertEqual(test_reply["prune_id"], 1)
274 |
275 | # check list device group works
276 | device_group_exists, test_reply = mongo_connection_object.mongo_get_device_group("unit_test_device_group")
277 | self.assertTrue(device_group_exists)
278 | self.assertEqual(test_reply["apps"], [])
279 | self.assertEqual(test_reply["device_group"], "unit_test_device_group")
280 | self.assertEqual(test_reply["device_group_id"], 1)
281 | self.assertEqual(test_reply["prune_id"], 1)
282 |
283 | # check list device groups works
284 | test_reply = mongo_connection_object.mongo_list_device_groups()
285 | self.assertEqual(test_reply, ["unit_test_device_group"])
286 |
287 | # check update device group works
288 | test_reply = mongo_connection_object.mongo_update_device_group("unit_test_device_group", {"apps": [],
289 | "cron_jobs": []})
290 | self.assertEqual(test_reply["device_group"], "unit_test_device_group")
291 | self.assertEqual(test_reply["device_group_id"], 2)
292 | self.assertEqual(test_reply["prune_id"], 1)
293 |
294 | # check device group exists works
295 | test_reply = mongo_connection_object.mongo_check_device_group_exists("unit_test_device_group")
296 | self.assertTrue(test_reply)
297 |
298 | # check increase prune id works
299 | test_reply = mongo_connection_object.mongo_increase_prune_id("unit_test_device_group")
300 | test_prune_id = test_reply["prune_id"]
301 | test_reply = mongo_connection_object.mongo_increase_prune_id("unit_test_device_group")
302 | self.assertEqual(test_reply["prune_id"], test_prune_id + 1)
303 |
304 | # check delete device group works
305 | test_reply = mongo_connection_object.mongo_remove_device_group("unit_test_device_group")
306 | self.assertEqual(test_reply.deleted_count, 1)
307 |
308 | def test_mongo_user_flow(self):
309 | mongo_connection_object = mongo_connection()
310 |
311 | # ensure no test user is already created in the unit test DB
312 | mongo_connection_object.mongo_delete_user("unit_test_user")
313 |
314 | # check create user works
315 | test_reply = mongo_connection_object.mongo_add_user("unit_test_user", "unit_test_pass", "unit_test_token")
316 | self.assertEqual(test_reply["user_name"], "unit_test_user")
317 | self.assertEqual("unit_test_pass", test_reply["password"])
318 | self.assertEqual("unit_test_token", test_reply["token"])
319 |
320 | # check list user works
321 | user_exists, test_reply = mongo_connection_object.mongo_get_user("unit_test_user")
322 | self.assertTrue(user_exists)
323 | self.assertEqual("unit_test_pass", test_reply["password"])
324 | self.assertEqual("unit_test_token", test_reply["token"])
325 |
326 | # check list user works
327 | test_reply = mongo_connection_object.mongo_list_users()
328 | self.assertEqual(test_reply, ["unit_test_user"])
329 |
330 | # check update user works
331 | test_reply = mongo_connection_object.mongo_update_user("unit_test_user", {"token": "new_unit_test_token"})
332 | self.assertEqual("new_unit_test_token", test_reply["token"])
333 |
334 | # check user exists works
335 | test_reply = mongo_connection_object.mongo_check_user_exists("unit_test_user")
336 | self.assertTrue(test_reply)
337 |
338 | # check delete user works
339 | test_reply = mongo_connection_object.mongo_delete_user("unit_test_user")
340 | self.assertEqual(test_reply.deleted_count, 1)
341 |
342 | def test_mongo_user_group_flow(self):
343 | mongo_connection_object = mongo_connection()
344 |
345 | # ensure no test user_group is already created in the unit test DB
346 | mongo_connection_object.mongo_delete_user_group("unit_test_user_group")
347 | mongo_connection_object.mongo_delete_user_group("unit_test_user_group_2")
348 |
349 | # check create user_group works
350 | test_reply = mongo_connection_object.mongo_add_user_group(user_group="unit_test_user_group",
351 | group_members=[
352 | "unit_test_member_1",
353 | "unit_test_member_2"
354 | ],
355 | pruning_allowed=False,
356 | apps={
357 | "unit_test_app_1": "rw",
358 | "unit_test_app_2": "ro"
359 | },
360 | device_groups={
361 | "unit_test_dg_1": "rw",
362 | "unit_test_dg_2": "ro"
363 | },
364 | admin=True,
365 | cron_jobs={
366 | "unit_test_cj_1": "rw",
367 | "unit_test_cj_2": "ro"
368 | }
369 | )
370 | self.assertEqual(test_reply["user_group"], "unit_test_user_group")
371 | self.assertEqual(test_reply["group_members"], ["unit_test_member_1", "unit_test_member_2"])
372 | self.assertFalse(test_reply["pruning_allowed"])
373 | self.assertEqual(test_reply["apps"], {"unit_test_app_1": "rw", "unit_test_app_2": "ro"})
374 | self.assertEqual(test_reply["device_groups"], {"unit_test_dg_1": "rw", "unit_test_dg_2": "ro"})
375 | self.assertEqual(test_reply["cron_jobs"], {"unit_test_cj_1": "rw", "unit_test_cj_2": "ro"})
376 | self.assertTrue(test_reply["admin"])
377 |
378 | # check list user_group works
379 | user_group_exists, test_reply = mongo_connection_object.mongo_get_user_group("unit_test_user_group")
380 | self.assertTrue(user_group_exists)
381 | self.assertEqual(test_reply["user_group"], "unit_test_user_group")
382 | self.assertEqual(test_reply["group_members"], ["unit_test_member_1", "unit_test_member_2"])
383 | self.assertFalse(test_reply["pruning_allowed"])
384 | self.assertEqual(test_reply["apps"], {"unit_test_app_1": "rw", "unit_test_app_2": "ro"})
385 | self.assertEqual(test_reply["device_groups"], {"unit_test_dg_1": "rw", "unit_test_dg_2": "ro"})
386 | self.assertTrue(test_reply["admin"])
387 |
388 | # check list user_group works
389 | test_reply = mongo_connection_object.mongo_list_user_groups()
390 | self.assertEqual(test_reply, ["unit_test_user_group"])
391 |
392 | # check update user_group works
393 | test_reply = mongo_connection_object.mongo_update_user_group("unit_test_user_group",
394 | {"pruning_allowed": True})
395 | self.assertTrue(test_reply["pruning_allowed"])
396 |
397 | # check mongo list user permissions work
398 | mongo_connection_object.mongo_add_user_group(user_group="unit_test_user_group_2",
399 | group_members=[
400 | "unit_test_member_1",
401 | "unit_test_member_2"
402 | ],
403 | pruning_allowed=False,
404 | apps={
405 | "unit_test_app_3": "rw",
406 | "unit_test_app_4": "ro"
407 | },
408 | device_groups={
409 | "unit_test_dg_3": "rw",
410 | "unit_test_dg_4": "ro"
411 | },
412 | admin=True,
413 | cron_jobs={
414 | "unit_test_cj_3": "rw",
415 | "unit_test_cj_4": "ro"
416 | }
417 | )
418 | test_reply = mongo_connection_object.mongo_list_user_permissions("unit_test_member_1")
419 | self.assertTrue(test_reply["admin"])
420 | self.assertTrue(test_reply["pruning_allowed"])
421 | apps_result = {
422 | 'unit_test_app_1': 'rw',
423 | 'unit_test_app_2': 'ro',
424 | 'unit_test_app_3': 'rw',
425 | 'unit_test_app_4': 'ro'
426 | }
427 | device_groups_results = {
428 | 'unit_test_dg_1': 'rw',
429 | 'unit_test_dg_2': 'ro',
430 | 'unit_test_dg_3': 'rw',
431 | 'unit_test_dg_4': 'ro'
432 | }
433 | cron_jobs_results = {
434 | 'unit_test_cj_1': 'rw',
435 | 'unit_test_cj_2': 'ro',
436 | 'unit_test_cj_3': 'rw',
437 | 'unit_test_cj_4': 'ro'
438 | }
439 | self.assertEqual(test_reply["apps"], apps_result)
440 | self.assertEqual(test_reply["device_groups"], device_groups_results)
441 | self.assertEqual(test_reply["cron_jobs"], cron_jobs_results)
442 |
443 | # check user_group exists works
444 | test_reply = mongo_connection_object.mongo_check_user_group_exists("unit_test_user_group")
445 | self.assertTrue(test_reply)
446 |
447 | # check delete user_group works
448 | test_reply = mongo_connection_object.mongo_delete_user_group("unit_test_user_group")
449 | self.assertEqual(test_reply.deleted_count, 1)
450 |
--------------------------------------------------------------------------------
/test/test_nebula_python_manager_functions_hashing.py:
--------------------------------------------------------------------------------
1 | from unittest import TestCase
2 | from functions.hashing.hashing import *
3 |
4 |
5 | class HashTests(TestCase):
6 |
7 | def test_hashing_matches(self):
8 | # check hashing compare right password works
9 | test_hash = hash_secret("test")
10 | secret_matches = check_secret_matches("test", test_hash)
11 | self.assertTrue(secret_matches)
12 |
13 | def test_hashing_does_not_matches(self):
14 | # check hashing compare right password works
15 | test_hash = hash_secret("test")
16 | secret_matches = check_secret_matches("a_wrong_value", test_hash)
17 | self.assertFalse(secret_matches)
18 |
--------------------------------------------------------------------------------
/test/travis_ci_scripts/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USER" --password-stdin
4 |
5 | if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == false ]; then
6 | docker build -t $DOCKER_HUB_ORG/$DOCKER_HUB_REPO .
7 | docker push $DOCKER_HUB_ORG/$DOCKER_HUB_REPO
8 | elif [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_PULL_REQUEST" == false ]; then
9 | docker build -t $DOCKER_HUB_ORG/$DOCKER_HUB_REPO:$TRAVIS_BRANCH .
10 | docker push $DOCKER_HUB_ORG/$DOCKER_HUB_REPO:$TRAVIS_BRANCH
11 | else
12 | echo "something is wrong with the deployment"
13 | exit 2
14 | fi
15 |
--------------------------------------------------------------------------------
/test/travis_ci_scripts/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | mongo:
5 | container_name: mongo
6 | hostname: mongo
7 | image: mongo:4.0.1
8 | ports:
9 | - "27017:27017"
10 | restart: unless-stopped
11 | environment:
12 | MONGO_INITDB_ROOT_USERNAME: nebula
13 | MONGO_INITDB_ROOT_PASSWORD: nebula
14 |
--------------------------------------------------------------------------------
/test/travis_ci_scripts/travis_ci_build_script.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # run the following to start the API, MongoDB
4 | sudo docker-compose -f test/travis_ci_scripts/docker-compose.yml pull
5 | sudo docker-compose -f test/travis_ci_scripts/docker-compose.yml up -d
6 |
--------------------------------------------------------------------------------