Skip to main content

NebulaPythonSDK is a Pythonic SDK to manage Nebula container orchestrator

Project description

Nebula-Python-SDK

Travis CI unit tests & auto PyPi push status: Build Status

Code coverage: codecov

An SDK for managing nebula via python.

translates all of Nebula API calls to something more pythonic.

Source code is available at github

How To Use

first get NebulaPythonSDK onto your machine

# Install from PyPi
pip install NebulaPythonSDK

now use it in your code

# Load API wrapper from library
from NebulaPythonSDK import Nebula

# Create API object.
# port defaults to 80, protocol defaults to "http" & request_timeout defaults to 60 if any of them is not set.
connection = Nebula(username="your_nebula_user", password="your_nebula_pass", host="nebula.example.com", port=80, protocol="http", request_timeout=60)

# List apps
app_list = connection.list_apps()

# List app info
app_config = connection.list_app_info("app_name")

# Create app
app_conf = {
    "containers_per_cpu": 8,
    "env_vars": {
        "test": "blabla",
        "test3t2t32": "tesg4ehgee"
    },
    "docker_ulimits": [],
    "networks": ["nebula"],
    "running": True,
    "rolling_restart": False,
    "volumes": ["/tmp:/tmp/1", "/var/tmp/:/var/tmp/1:ro"],
    "containers_per": {
        "cpu": 6
    },
    "starting_ports": [
        {
            "81": 80
        }
    ],
    "docker_image": "httpd",
    "privileged": False,
    "devices": []
}
connection.create_app("app_name", app_conf)

# create device group
device_group_config = {"apps": ["app_name"]}
connection.create_device_group("device_group_name", device_group_config)

# list device group
connection.list_device_group("device_group_name")

# list device group info
connection.list_device_group_info("device_group_name")

# ping api
connection.check_api()

# delete app
connection.delete_app("app_name")

# stop app
connection.stop_app("app_name")

# start app
connection.start_app("app_name")

# restart app
connection.restart_app("app_name")

# update app
connection.update_app("app_name", app_conf)

# prune images on all device groups
connection.prune_images()

# delete device_group
connection.delete_device_group("device_group_name")

# prune images on a selected device groups
connection.prune__device_group_images("device_group_name")

# update device group
connection.update_device_group("device_group_name", device_group_config)

# list paginated reports
connection.list_reports()

# create a user
user_config = {"password": "user_password", "token": "user_token"}
connection.create_user("user_name", user_config)

# list user info
connection.list_user("user_name")

# list all users
connection.list_users()

# update a user
user_config = {"password": "new_password", "token": "new_token"}
connection.update_user("user_name", user_config)

# refresh a user token
connection.refresh_user_token("user_name")

# delete a user
connection.delete_user("user_name")

# create a user group
user_group_config = {
                        "group_members": [
                            "user_name"
                            ], 
                        "pruning_allowed": True, 
                        "apps": {
                            "app_name": "rw"
                            }, 
                        "device_groups": {
                            "device_group_name": "ro"
                            }, 
                        "admin": False
                    }
connection.create_user_group("user_group_name", user_group_config)

# list user group info
connection.list_user_group("user_group_name")

# list all users group
connection.list_user_groups()

# update a user group
user_group_config = {"admin": False}
connection.update_user_group("user_group_name", user_group_config)

# delete a user group
connection.delete_user_group("user_group_name")

# list all cron jobs
connection.list_cron_jobs()

# delete a cron job
connection.delete_cron_job("cron_job_name")

# list a cron job
connection.list_cron_job_info("cron_job_name")

# create a cron job
cron_job_config = {
  "env_vars": {"test": "test123"},
  "docker_image" : "nginx",
  "running": True,
  "volumes": [],
  "networks": ["nebula", "bridge"],
  "devices": [],
  "privileged": False,
  "schedule": "0 * * * *"
}
connection.create_cron_job("cron_job_name", cron_job_config)

# update a cron job
cron_job_config = {
  "schedule": "5 * * * *"
}
connection.create_cron_job("cron_job_name", cron_job_config)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NebulaPythonSDK-2.6.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

NebulaPythonSDK-2.6.2-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file NebulaPythonSDK-2.6.2.tar.gz.

File metadata

  • Download URL: NebulaPythonSDK-2.6.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for NebulaPythonSDK-2.6.2.tar.gz
Algorithm Hash digest
SHA256 2f1fcc43415d07e3433c463a65c120c5c67b2dada5b1c4cf0f6b0597dd659d80
MD5 fbb51c8558e11af25b2c11a0a91d0f43
BLAKE2b-256 d69ca771c5928165e14ae5dfb7d59c8c312c1af7bb6f42ed2c3930273ce15b7a

See more details on using hashes here.

Provenance

File details

Details for the file NebulaPythonSDK-2.6.2-py3-none-any.whl.

File metadata

  • Download URL: NebulaPythonSDK-2.6.2-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for NebulaPythonSDK-2.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ad6c75c1a2b0cf2409535b38154ebd8f28ac79979111ece52ee2b57bfe2b3f7b
MD5 5cc7932ef2be4a3a678d9cb08e97b679
BLAKE2b-256 8ad24f49d1f0ee7bee3b4ff69944184f56f4c2793a9fb110e483b669cfb432b1

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page