Library used to create Azure IoT Edge deployment templates with python code.
- 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
None
In order to install the library you need to execute following command:
pip install IoT-Deployment-Generator
It is the best to use following imports when working with IDG:
from IDG.deployment import Deployment
from IDG.module import Module
First please install tox package
pip install tox
Then use following command to test module:
python -m tox
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:
Below you will find all settings you can change inside module:
module.type = "docker"
module.status = "running"
module.restartPolicy = "always"
module.createOptions["HostConfig"] = {
"Binds": [
"volumeA:/somewhere"
],
"PortBindings": {
"8080/tcp": [{
"HostPort": "9080"
}]
}
}
another syntax:
module.HostConfig = {
"Binds": [
"volumeA:/somewhere"
],
"PortBindings": {
"8080/tcp": [{
"HostPort": "9080"
}]
}
}
module.createOptions["NetworkingConfig"] = {
"EndpointsConfig": {
"host": {}
}
}
another syntax:
module.NetworkingConfig = {
"EndpointsConfig": {
"host": {}
}
}
module.desiredProperties = {
"propertyA" : 123,
"propertyB" : "IamB"
}
module.addEnvVariable("env_name", "env_value")
module.removeEnvVariable("env_name")
clonedModule = module.clone()
Cloned module is going to be a deep copy of initial module.
Contains default deployment settings with edgeAgent and edgeHub initial settings.
deployment = 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 = ""
deployment.addModule(module)
deployment.removeModule("module_name")
it is going to remove module which has module_name
inside module.name
deployment.addRegistryCredentials("credential_name", "repo_address", "repo_username", "repo_pass")
deployment.routeSettings.addRoute("routeName", "ROM /messages/modules/someModule/outputs/* into $upstream")
deployment.routeSettings.timeToLiveSecs = 7200
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.
stringifiedJson = deployment.toJson()
deployment.saveToFile("deployment.debug.template.json")