Library used to create Azure IoT Edge deployment templates with python code
Project description
IDG - IoT Deployment Generator
Library used to create Azure IoT Edge deployment templates with python code.
Table of contents
- IDG - IoT Deployment Generator
- Table of contents
- Library dependencies
- Installation
- Required imports
- Module development
- Module documentation
- Deployment documentation
- Creating deployment
- Changing miscellaneous settings of deployment
- Adding module to deployment
- Removing module from deployment
- Adding registry credential to deployment
- Adding route to deployment
- Changing storeAndForwardConfiguration inside edgeHub configuration
- Merging deployment
- Converting deployment into string
- Saving deployment to deployment template file
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>}
- As it is template you can refer to modules inside solution to load them. exxample:
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 fromdeploymentA
and every module fromdeploymentB
which name does not exist indeploymentA
merged
is going to have all routes fromdeploymentA
and every route fromdeploymentB
which name does not exist indeploymentA
merged
is going to have all registry credentials fromdeploymentA
and every credential fromdeploymentB
which name does not exist indeploymentA
- Other value settings are going to be taken solely from
deploymentA
. deploymentA
anddeploymentB
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
Built Distribution
File details
Details for the file IoT Deployment Generator-0.0.14.tar.gz
.
File metadata
- Download URL: IoT Deployment Generator-0.0.14.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.20.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82c2688d04c10a4147e7952e2a64403f38bb7f47e2ef9c7b5306b1e6b9494c89 |
|
MD5 | 920550f83c5de00e8f59aefd07294d81 |
|
BLAKE2b-256 | b9a1bdfadc543be94ad787c3809b20d9ca6389c319c60f1b5d50269e5ebc8d55 |
File details
Details for the file IoT_Deployment_Generator-0.0.14-py3-none-any.whl
.
File metadata
- Download URL: IoT_Deployment_Generator-0.0.14-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.20.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06e19f9a15b9c142e7ae3223a63531f2c799d3205a9b2ca2deb532c43bfc7527 |
|
MD5 | abb577a75e5cc83ec9067a5771554924 |
|
BLAKE2b-256 | 883210f9ad65d95eff10fa7b96a77c3dae0a0014de987a8ce1645f1f29946640 |