Skip to main content

Library used to create Azure IoT Edge deployment templates with python code

Project description

IDG - IoT Deployment Generator

PyPI version

Library used to create Azure IoT Edge deployment templates with python code.

Table of contents

Table of contents generated with markdown-toc

Library dependencies

None

Installation

In order to install the library you need to execute following command:

pip install IoT-Deployment-Generator

Required imports

It is the best to use following imports when working with IDG:

from IDG.deployment import Deployment
from IDG.module import Module

Module development

Running tests

First please install tox package

pip install tox

Then use following command to test module:

python -m tox

Module documentation

Creating module

In order to create module you need to specify its name, version and image.

module = Module("module_name", "1.0.0", "image_str")
  • image_str represents image which is used inside deployment template.
    • As it is template you can refer to modules inside solution to load them. exxample: ${MODULEDIR<../some_module>}

Changing miscellaneous settings of module

Below you will find all settings you can change inside module:

module.type = "docker"
module.status = "running"
module.restartPolicy = "always"

Setting HostConfig for module

module.createOptions["HostConfig"] = {
        "Binds": [
        "volumeA:/somewhere"
    ],
    "PortBindings": {
        "8080/tcp": [{
            "HostPort": "9080"
        }]
    }
}

another syntax:

module.HostConfig = {
        "Binds": [
        "volumeA:/somewhere"
    ],
    "PortBindings": {
        "8080/tcp": [{
            "HostPort": "9080"
        }]
    }
}

Setting NetorkingConfig for module

module.createOptions["NetworkingConfig"] = {
        "EndpointsConfig": {
        "host": {}
    }
}

another syntax:

module.NetworkingConfig = {
        "EndpointsConfig": {
        "host": {}
    }
}

Setting desired properties for module

module.desiredProperties = {
    "propertyA" : 123,
    "propertyB" : "IamB"
}

Adding environment variable to module

module.addEnvVariable("env_name", "env_value")

Removing environment variable from module

module.removeEnvVariable("env_name")

Cloning module

clonedModule = module.clone()

Cloned module is going to be a deep copy of initial module.

Deployment documentation

Creating deployment

Contains default deployment settings with edgeAgent and edgeHub initial settings.

deployment = Deployment()

Changing miscellaneous settings of deployment

Below you will find all settings you can change inside deployment:

deployment.minDockerVersion = "v1.25"
deployment.edgeAgentVersion = "1.0"
deployment.edgeHubVersion = "1.0"
deployment.loggingOptions = ""

Adding module to deployment

deployment.addModule(module)

Removing module from deployment

deployment.removeModule("module_name")

it is going to remove module which has module_name inside module.name

Adding registry credential to deployment

deployment.addRegistryCredentials("credential_name", "repo_address", "repo_username", "repo_pass")

Adding route to deployment

deployment.routeSettings.addRoute("routeName", "ROM /messages/modules/someModule/outputs/* into $upstream")

Changing storeAndForwardConfiguration inside edgeHub configuration

deployment.routeSettings.timeToLiveSecs = 7200

Merging deployment

If you have 2 separate deployments you can merge them.


deploymentA = Deployment()
deploymentB = Deployment()

merged = deploymentA.merge(deploymentB)

In this case following things are going to happen:

  • merged is going to have all modules from deploymentA and every module from deploymentB which name does not exist in deploymentA
  • merged is going to have all routes from deploymentA and every route from deploymentB which name does not exist in deploymentA
  • merged is going to have all registry credentials from deploymentA and every credential from deploymentB which name does not exist in deploymentA
  • Other value settings are going to be taken solely from deploymentA.
  • deploymentA and deploymentB are unaffected by this operation.

Converting deployment into string

stringifiedJson = deployment.toJson()

Saving deployment to deployment template file

deployment.saveToFile("deployment.debug.template.json")

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

IoT Deployment Generator-0.0.14.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

IoT_Deployment_Generator-0.0.14-py3-none-any.whl (8.3 kB view hashes)

Uploaded Python 3

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