зеркало из https://github.com/Azure/iotedgedev.git
Add iotedgehubdev integration (#233)
* Add iotedgehubdev class * Build solution before start iotedgehubdev * Update templates to fix route error * Fail fast if device connection string is not set before setup * Allow start iotedgehubdev in verbose mode * Add modulecred command * Add gateway_host option to setup command * Add start command * Remove references to runtime * Remove runtime.template.json from template.zip * Only start local registry when pushing images so config/deployment.json only generated after build * Check if the solution is built before starting simulator * Instruct users to setup for starting * Add tests * Enlarge monitor timeout when testing simulator * Fix a issue with spaces in paths * Prevent deploy command overwriting configs * Promote setup, start and stop commands to root * Update unit of monitor timeout to seconds * Fix unfinished conflict resolve
This commit is contained in:
Родитель
fbeec1313d
Коммит
9e91d44f69
|
@ -76,6 +76,7 @@ config
|
|||
/build
|
||||
|
||||
|
||||
py27
|
||||
py36
|
||||
.pypirc
|
||||
tests/test_solution
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import sys
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
import sys
|
||||
from io import StringIO
|
||||
|
||||
from azure.cli.core import get_default_cli
|
||||
from fstrings import f
|
||||
|
||||
output_io_cls = StringIO
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import absolute_import
|
|||
|
||||
import hashlib
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
|
||||
import click
|
||||
|
@ -17,7 +18,7 @@ from .iothub import IoTHub
|
|||
from .modules import Modules
|
||||
from .organizedgroup import OrganizedGroup
|
||||
from .output import Output
|
||||
from .runtime import Runtime
|
||||
from .simulator import Simulator
|
||||
from .solution import Solution
|
||||
from .utility import Utility
|
||||
|
||||
|
@ -43,11 +44,6 @@ def solution():
|
|||
pass
|
||||
|
||||
|
||||
@main.group(context_settings=CONTEXT_SETTINGS, help="Manage IoT Edge runtime", order=1)
|
||||
def runtime():
|
||||
pass
|
||||
|
||||
|
||||
@main.group(context_settings=CONTEXT_SETTINGS, help="Manage IoT Edge simulator", order=1)
|
||||
def simulator():
|
||||
pass
|
||||
|
@ -116,7 +112,6 @@ def e2e(ctx):
|
|||
envvars.load(force=True)
|
||||
ctx.invoke(push)
|
||||
ctx.invoke(deploy)
|
||||
ctx.invoke(start_runtime)
|
||||
ctx.invoke(monitor)
|
||||
|
||||
|
||||
|
@ -197,8 +192,7 @@ main.add_command(push)
|
|||
|
||||
@solution.command(context_settings=CONTEXT_SETTINGS, help="Deploy solution to IoT Edge device")
|
||||
def deploy():
|
||||
utility = Utility(envvars, output)
|
||||
edge = Edge(envvars, utility, output, azure_cli)
|
||||
edge = Edge(envvars, output, azure_cli)
|
||||
edge.deploy()
|
||||
|
||||
|
||||
|
@ -217,81 +211,100 @@ def genconfig():
|
|||
main.add_command(genconfig)
|
||||
|
||||
|
||||
@runtime.command(context_settings=CONTEXT_SETTINGS,
|
||||
name="start",
|
||||
help="Start IoT Edge runtime")
|
||||
def start_runtime():
|
||||
utility = Utility(envvars, output)
|
||||
dock = Docker(envvars, utility, output)
|
||||
run = Runtime(envvars, utility, output, dock)
|
||||
|
||||
run.start()
|
||||
@simulator.command(context_settings=CONTEXT_SETTINGS,
|
||||
name="setup",
|
||||
short_help="Setup IoT Edge simulator. This must be done before starting",
|
||||
help="Setup IoT Edge simulator. This must be done before starting")
|
||||
@click.option("--gateway-host",
|
||||
"-g",
|
||||
help="GatewayHostName value for the module to connect.",
|
||||
required=False,
|
||||
default=socket.getfqdn(),
|
||||
show_default=True)
|
||||
def setup_simulator(gateway_host):
|
||||
sim = Simulator(envvars, output)
|
||||
sim.setup(gateway_host)
|
||||
|
||||
|
||||
@runtime.command(context_settings=CONTEXT_SETTINGS,
|
||||
name="restart",
|
||||
help="Restart IoT Edge runtime")
|
||||
def restart_runtime():
|
||||
utility = Utility(envvars, output)
|
||||
dock = Docker(envvars, utility, output)
|
||||
run = Runtime(envvars, utility, output, dock)
|
||||
|
||||
run.restart()
|
||||
|
||||
|
||||
@runtime.command(context_settings=CONTEXT_SETTINGS,
|
||||
name="stop",
|
||||
help="Stop IoT Edge runtime")
|
||||
def stop_runtime():
|
||||
utility = Utility(envvars, output)
|
||||
dock = Docker(envvars, utility, output)
|
||||
run = Runtime(envvars, utility, output, dock)
|
||||
|
||||
run.stop()
|
||||
|
||||
|
||||
@runtime.command(context_settings=CONTEXT_SETTINGS,
|
||||
name="status",
|
||||
help="Show IoT Edge runtime status")
|
||||
def status_runtime():
|
||||
utility = Utility(envvars, output)
|
||||
dock = Docker(envvars, utility, output)
|
||||
run = Runtime(envvars, utility, output, dock)
|
||||
|
||||
run.status()
|
||||
main.add_command(setup_simulator)
|
||||
|
||||
|
||||
@simulator.command(context_settings=CONTEXT_SETTINGS,
|
||||
name="start",
|
||||
help="Start IoT Edge simulator")
|
||||
def start_simulator():
|
||||
utility = Utility(envvars, output)
|
||||
dock = Docker(envvars, utility, output)
|
||||
run = Runtime(envvars, utility, output, dock)
|
||||
|
||||
run.start()
|
||||
short_help="Start IoT Edge simulator",
|
||||
help="Start IoT Edge simulator. To start in solution mode, use `iotedgdev simulator start -s [-v] [-b]`. "
|
||||
"To start in single module mode, use `iotedgedev simulator start -i input1,input2 [-p 53000]`")
|
||||
@click.option("--solution",
|
||||
"-s",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
show_default=True,
|
||||
help="Start IoT Edge simulator in solution mode using the deployment.json in config folder.")
|
||||
@click.option("--verbose",
|
||||
"-v",
|
||||
required=False,
|
||||
is_flag=True,
|
||||
default=False,
|
||||
show_default=True,
|
||||
help="Show the solution container logs.")
|
||||
@click.option("--build",
|
||||
"-b",
|
||||
required=False,
|
||||
is_flag=True,
|
||||
default=False,
|
||||
show_default=True,
|
||||
help="Build the solution before starting IoT Edge simulator in solution mode.")
|
||||
@click.option("--inputs",
|
||||
"-i",
|
||||
required=False,
|
||||
help="Start IoT Edge simulator in single module mode "
|
||||
"using the specified comma-separated inputs of the target module, e.g., `input1,input2`.")
|
||||
@click.option("--port",
|
||||
"-p",
|
||||
required=False,
|
||||
default=53000,
|
||||
show_default=True,
|
||||
help="Port of the service for sending message.")
|
||||
def start_simulator(solution, build, verbose, inputs, port):
|
||||
sim = Simulator(envvars, output)
|
||||
if solution or not inputs:
|
||||
sim.start_solution(verbose, build)
|
||||
else:
|
||||
sim.start_single(inputs, port)
|
||||
|
||||
|
||||
@simulator.command(context_settings=CONTEXT_SETTINGS,
|
||||
name="restart",
|
||||
help="Restart IoT Edge simulator")
|
||||
def restart_simulator():
|
||||
utility = Utility(envvars, output)
|
||||
dock = Docker(envvars, utility, output)
|
||||
run = Runtime(envvars, utility, output, dock)
|
||||
|
||||
run.restart()
|
||||
main.add_command(start_simulator)
|
||||
|
||||
|
||||
@simulator.command(context_settings=CONTEXT_SETTINGS,
|
||||
name="stop",
|
||||
help="Stop IoT Edge simulator")
|
||||
def stop_simulator():
|
||||
utility = Utility(envvars, output)
|
||||
dock = Docker(envvars, utility, output)
|
||||
run = Runtime(envvars, utility, output, dock)
|
||||
sim = Simulator(envvars, output)
|
||||
sim.stop()
|
||||
|
||||
run.stop()
|
||||
|
||||
main.add_command(stop_simulator)
|
||||
|
||||
|
||||
@simulator.command(context_settings=CONTEXT_SETTINGS,
|
||||
# short_help hack to prevent Click truncating help text (https://github.com/pallets/click/issues/486)
|
||||
short_help="Get the credentials of target module such as connection string and certificate file path.",
|
||||
help="Get the credentials of target module such as connection string and certificate file path.")
|
||||
@click.option("--local",
|
||||
"-l",
|
||||
help="Set `localhost` to `GatewayHostName` for module to run on host natively.",
|
||||
is_flag=True,
|
||||
required=False,
|
||||
default=False,
|
||||
show_default=True)
|
||||
@click.option("--output-file",
|
||||
"-o",
|
||||
help="Specify the output file to save the credentials. If the file exists, its content will be overwritten.",
|
||||
required=False)
|
||||
def modulecred(local, output_file):
|
||||
sim = Simulator(envvars, output)
|
||||
sim.modulecred(local, output_file)
|
||||
|
||||
|
||||
@iothub.command(context_settings=CONTEXT_SETTINGS,
|
||||
|
@ -301,7 +314,7 @@ def stop_simulator():
|
|||
@click.option("--timeout",
|
||||
"-t",
|
||||
required=False,
|
||||
help="Specify number of milliseconds to monitor for messages")
|
||||
help="Specify number of seconds to monitor for messages")
|
||||
def monitor(timeout):
|
||||
utility = Utility(envvars, output)
|
||||
ih = IoTHub(envvars, utility, output, azure_cli)
|
||||
|
@ -375,7 +388,8 @@ def validate_option(ctx, param, value):
|
|||
if envvars.IOTHUB_SKU == "F1":
|
||||
free_iot_name, free_iot_rg = azure_cli.get_free_iothub()
|
||||
if free_iot_name:
|
||||
output.info("You already have a Free IoT Hub SKU in your subscription, so you must either use that existing IoT Hub or create a new S1 IoT Hub. "
|
||||
output.info("You already have a Free IoT Hub SKU in your subscription, "
|
||||
"so you must either use that existing IoT Hub or create a new S1 IoT Hub. "
|
||||
"Enter (F) to use the existing Free IoT Hub or enter (S) to create a new S1 IoT Hub:")
|
||||
user_response = sys.stdin.readline().strip().upper()
|
||||
if user_response == "S":
|
||||
|
|
|
@ -3,7 +3,7 @@ class ConnectionString:
|
|||
self.ConnectionString = value
|
||||
self.data = dict()
|
||||
|
||||
if self.ConnectionString:
|
||||
if self.ConnectionString:
|
||||
parts = self.ConnectionString.split(';')
|
||||
if len(parts) > 0:
|
||||
for part in parts:
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
class Edge:
|
||||
def __init__(self, envvars, utility, output, azure_cli):
|
||||
def __init__(self, envvars, output, azure_cli):
|
||||
self.envvars = envvars
|
||||
self.utility = utility
|
||||
self.utility.set_config()
|
||||
self.output = output
|
||||
self.azure_cli = azure_cli
|
||||
|
||||
|
||||
def deploy(self):
|
||||
|
||||
self.output.header("DEPLOYING CONFIGURATION")
|
||||
|
@ -14,7 +12,7 @@ class Edge:
|
|||
self.envvars.verify_envvar_has_val("DEVICE_CONNECTION_STRING", self.envvars.DEVICE_CONNECTION_INFO)
|
||||
self.envvars.verify_envvar_has_val("DEPLOYMENT_CONFIG_FILE", self.envvars.DEPLOYMENT_CONFIG_FILE)
|
||||
|
||||
self.azure_cli.set_modules(self.envvars.DEVICE_CONNECTION_INFO.DeviceId, self.envvars.IOTHUB_CONNECTION_INFO.ConnectionString, self.envvars.IOTHUB_CONNECTION_INFO.HubName, self.envvars.DEPLOYMENT_CONFIG_FILE_PATH)
|
||||
self.azure_cli.set_modules(self.envvars.DEVICE_CONNECTION_INFO.DeviceId, self.envvars.IOTHUB_CONNECTION_INFO.ConnectionString,
|
||||
self.envvars.IOTHUB_CONNECTION_INFO.HubName, self.envvars.DEPLOYMENT_CONFIG_FILE_PATH)
|
||||
|
||||
self.output.footer("DEPLOYMENT COMPLETE")
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from .compat import PY35
|
||||
|
||||
|
||||
class IoTHub:
|
||||
def __init__(self, envvars, utility, output, azure_cli):
|
||||
self.envvars = envvars
|
||||
|
@ -9,13 +10,12 @@ class IoTHub:
|
|||
self.utility = utility
|
||||
self.azure_cli = azure_cli
|
||||
|
||||
|
||||
def monitor_events(self, timeout=0):
|
||||
|
||||
self.envvars.verify_envvar_has_val("IOTHUB_CONNECTION_STRING", self.envvars.IOTHUB_CONNECTION_STRING)
|
||||
self.envvars.verify_envvar_has_val("DEVICE_CONNECTION_STRING", self.envvars.DEVICE_CONNECTION_STRING)
|
||||
|
||||
if not timeout:
|
||||
if timeout is None:
|
||||
timeout = 0
|
||||
|
||||
self.output.header("MONITOR EVENTS")
|
||||
|
@ -24,11 +24,11 @@ class IoTHub:
|
|||
if PY35:
|
||||
self.monitor_events_cli(timeout)
|
||||
else:
|
||||
self.monitor_events_node(timeout)
|
||||
self.monitor_events_node(timeout)
|
||||
|
||||
def monitor_events_node(self, timeout=0):
|
||||
try:
|
||||
|
||||
|
||||
if timeout == 0:
|
||||
self.utility.call_proc(['iothub-explorer', '--login', self.envvars.IOTHUB_CONNECTION_STRING,
|
||||
'monitor-events', self.envvars.DEVICE_CONNECTION_INFO.DeviceId], shell=not self.envvars.is_posix())
|
||||
|
|
|
@ -14,13 +14,14 @@ class Modules:
|
|||
self.envvars = envvars
|
||||
self.output = output
|
||||
self.utility = Utility(self.envvars, self.output)
|
||||
self.dock = Docker(self.envvars, self.utility, self.output)
|
||||
self.dock.init_registry()
|
||||
|
||||
def add(self, name, template):
|
||||
self.output.header("ADDING MODULE {0}".format(name))
|
||||
|
||||
cwd = self.envvars.MODULES_PATH
|
||||
if not os.path.exists(cwd):
|
||||
os.makedirs(cwd)
|
||||
|
||||
if name.startswith("_") or name.endswith("_"):
|
||||
self.output.error("Module name cannot start or end with the symbol _")
|
||||
return
|
||||
|
@ -119,6 +120,7 @@ class Modules:
|
|||
self.output.info("PROCESSING DOCKERFILE: {0}".format(dockerfile), suppress=no_build)
|
||||
self.output.info("BUILDING DOCKER IMAGE: {0}".format(tag), suppress=no_build)
|
||||
|
||||
docker = Docker(self.envvars, self.utility, self.output)
|
||||
# BUILD DOCKER IMAGE
|
||||
if not no_build:
|
||||
# TODO: apply build options
|
||||
|
@ -127,20 +129,22 @@ class Modules:
|
|||
context_path = os.path.abspath(os.path.join(self.envvars.MODULES_PATH, module))
|
||||
dockerfile_relative = os.path.relpath(dockerfile, context_path)
|
||||
# a hack to workaround Python Docker SDK's bug with Linux container mode on Windows
|
||||
if self.dock.get_os_type() == "linux" and sys.platform == "win32":
|
||||
if docker.get_os_type() == "linux" and sys.platform == "win32":
|
||||
dockerfile = dockerfile.replace("\\", "/")
|
||||
dockerfile_relative = dockerfile_relative.replace("\\", "/")
|
||||
|
||||
build_result = self.dock.docker_client.images.build(tag=tag, path=context_path, dockerfile=dockerfile_relative)
|
||||
build_result = docker.docker_client.images.build(tag=tag, path=context_path, dockerfile=dockerfile_relative)
|
||||
|
||||
self.output.info("DOCKER IMAGE DETAILS: {0}".format(build_result))
|
||||
|
||||
if not no_push:
|
||||
docker.init_registry()
|
||||
|
||||
# PUSH TO CONTAINER REGISTRY
|
||||
self.output.info("PUSHING DOCKER IMAGE: " + tag)
|
||||
registry_key = None
|
||||
for key, registry in self.envvars.CONTAINER_REGISTRY_MAP.items():
|
||||
#Split the repository tag in the module.json (ex: Localhost:5000/filtermodule)
|
||||
# Split the repository tag in the module.json (ex: Localhost:5000/filtermodule)
|
||||
if registry.server.lower() == tag.split('/')[0].lower():
|
||||
registry_key = key
|
||||
break
|
||||
|
@ -148,10 +152,10 @@ class Modules:
|
|||
self.output.error("Could not find registry server with name {0}. Please make sure your envvar is set.".format(tag.split('/')[0].lower()))
|
||||
self.output.info("module json reading {0}".format(tag))
|
||||
|
||||
response = self.dock.docker_client.images.push(repository=tag, stream=True, auth_config={
|
||||
response = docker.docker_client.images.push(repository=tag, stream=True, auth_config={
|
||||
"username": self.envvars.CONTAINER_REGISTRY_MAP[registry_key].username,
|
||||
"password": self.envvars.CONTAINER_REGISTRY_MAP[registry_key].password})
|
||||
self.dock.process_api_response(response)
|
||||
docker.process_api_response(response)
|
||||
self.output.footer("BUILD COMPLETE", suppress=no_build)
|
||||
self.output.footer("PUSH COMPLETE", suppress=no_push)
|
||||
self.utility.set_config(force=True, replacements=replacements)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
class ModuleType(Enum):
|
||||
System = 1
|
||||
User = 2
|
||||
Both = 3
|
||||
Both = 3
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
class Runtime:
|
||||
def __init__(self, envvars, utility, output, dock):
|
||||
self.envvars = envvars
|
||||
self.utility = utility
|
||||
self.utility.set_config()
|
||||
self.dock = dock
|
||||
self.output = output
|
||||
|
||||
def start(self):
|
||||
self.output.header("Starting Edge Runtime")
|
||||
self.utility.exe_proc(["iotedgectl", "--verbose",
|
||||
self.envvars.RUNTIME_VERBOSITY, "start"])
|
||||
|
||||
def stop(self):
|
||||
self.output.header("Stopping Edge Runtime")
|
||||
self.utility.exe_proc(["iotedgectl", "--verbose",
|
||||
self.envvars.RUNTIME_VERBOSITY, "stop"])
|
||||
|
||||
def setup(self):
|
||||
self.output.header("Setting Up Edge Runtime")
|
||||
self.envvars.verify_envvar_has_val("RUNTIME_CONFIG_FILE", self.envvars.RUNTIME_CONFIG_FILE)
|
||||
self.utility.exe_proc(["iotedgectl", "--verbose", self.envvars.RUNTIME_VERBOSITY,
|
||||
"setup", "--config-file", self.envvars.RUNTIME_CONFIG_FILE_PATH])
|
||||
|
||||
def status(self):
|
||||
self.output.header("Getting Edge Runtime Status")
|
||||
self.utility.exe_proc(["iotedgectl", "--verbose", self.envvars.RUNTIME_VERBOSITY,
|
||||
"status"])
|
||||
|
||||
def restart(self):
|
||||
self.stop()
|
||||
self.dock.remove_modules()
|
||||
self.setup()
|
||||
self.start()
|
|
@ -0,0 +1,59 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from .modules import Modules
|
||||
from .utility import Utility
|
||||
|
||||
|
||||
class Simulator:
|
||||
def __init__(self, envvars, output):
|
||||
self.envvars = envvars
|
||||
self.output = output
|
||||
self.utility = Utility(self.envvars, self.output)
|
||||
|
||||
def setup(self, gateway_host):
|
||||
self.output.header("Setting Up IoT Edge Simulator")
|
||||
self.envvars.verify_envvar_has_val("DEVICE_CONNECTION_STRING", self.envvars.DEVICE_CONNECTION_STRING)
|
||||
|
||||
cmd = ["iotedgehubdev", "setup", "-c", self.envvars.DEVICE_CONNECTION_STRING]
|
||||
if gateway_host:
|
||||
cmd.extend(["-g", gateway_host])
|
||||
self.utility.exe_proc(cmd)
|
||||
|
||||
def start_single(self, inputs, port):
|
||||
self.output.header("Starting IoT Edge Simulator in Single Mode")
|
||||
|
||||
cmd = ["iotedgehubdev", "start", "-i", inputs]
|
||||
if port:
|
||||
cmd.extend(["-p", str(port)])
|
||||
self.utility.exe_proc(cmd)
|
||||
|
||||
def start_solution(self, verbose=True, build=False):
|
||||
if build:
|
||||
mod = Modules(self.envvars, self.output)
|
||||
mod.build()
|
||||
|
||||
if not os.path.exists(self.envvars.DEPLOYMENT_CONFIG_FILE_PATH):
|
||||
self.output.error("Deployment manifest {0} not found. Please build the solution before starting IoT Edge simulator.".format(self.envvars.DEPLOYMENT_CONFIG_FILE_PATH))
|
||||
sys.exit(1)
|
||||
|
||||
self.output.header("Starting IoT Edge Simulator in Solution Mode")
|
||||
|
||||
cmd = ["iotedgehubdev", "start", "-d", self.envvars.DEPLOYMENT_CONFIG_FILE_PATH]
|
||||
if verbose:
|
||||
cmd.append("-v")
|
||||
self.utility.call_proc(cmd)
|
||||
|
||||
def stop(self):
|
||||
self.output.header("Stopping IoT Edge Simulator")
|
||||
self.utility.call_proc(["iotedgehubdev", "stop"])
|
||||
|
||||
def modulecred(self, local, output_file):
|
||||
self.output.header("Getting Target Module Credentials")
|
||||
|
||||
cmd = ["iotedgehubdev", "modulecred"]
|
||||
if local:
|
||||
cmd.append("-l")
|
||||
if output_file:
|
||||
cmd.extend(["-o", output_file])
|
||||
self.utility.exe_proc(cmd)
|
|
@ -14,7 +14,7 @@ DEVICE_CONNECTION_STRING=""
|
|||
# Azure Container Registry: "jong.azurecr.io", Also set USERNAME/PASSWORD
|
||||
# Docker Hub: "jongallant" - Your Docker hub username. Enter your Docker hub username into the CONTAINER_REGISTRY_USERNAME setting. Also set the PASSWORD.
|
||||
|
||||
CONTAINER_REGISTRY_SERVER="localhost:5000"
|
||||
CONTAINER_REGISTRY_SERVER="localhost:5000"
|
||||
CONTAINER_REGISTRY_USERNAME=""
|
||||
CONTAINER_REGISTRY_PASSWORD=""
|
||||
|
||||
|
@ -53,14 +53,15 @@ RUNTIME_LOG_LEVEL="info"
|
|||
|
||||
BYPASS_MODULES=""
|
||||
# "" - to build all modules
|
||||
# "*" - to bypass all modules
|
||||
# "filtermodule, module1" - Comma delimited list of modules to bypass when building
|
||||
|
||||
ACTIVE_DOCKER_PLATFORMS=""
|
||||
# "" - to only build Dockerfiles specified in DEPLOYMENT_CONFIG_TEMPLATE_FILE
|
||||
# "*" - to build all Dockerfiles
|
||||
# "amd64,amd64.debug" - Comma delimited list of Dockerfiles to build
|
||||
# "" - to only build platforms specified in DEPLOYMENT_CONFIG_TEMPLATE_FILE
|
||||
# "*" - to build all platforms
|
||||
# "amd64,amd64.debug" - Comma delimited list of platforms to build
|
||||
|
||||
CONTAINER_TAG=""
|
||||
CONTAINER_TAG=""
|
||||
|
||||
DOTNET_VERBOSITY="q"
|
||||
# q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
}
|
||||
},
|
||||
"modules": {
|
||||
"temp-sensor-module": {
|
||||
"tempSensor": {
|
||||
"version": "1.0",
|
||||
"type": "docker",
|
||||
"status": "running",
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"deployment": {
|
||||
"docker": {
|
||||
"edgeRuntimeImage": "mcr.microsoft.com/azureiotedge-agent:${RUNTIME_TAG}",
|
||||
"loggingOptions": {
|
||||
"log-driver": "json-file",
|
||||
"log-opts": {
|
||||
"max-size": "10m"
|
||||
}
|
||||
},
|
||||
"registries": [
|
||||
{
|
||||
"address": "${CONTAINER_REGISTRY_SERVER}",
|
||||
"password": "${CONTAINER_REGISTRY_PASSWORD}",
|
||||
"username": "${CONTAINER_REGISTRY_USERNAME}"
|
||||
}
|
||||
],
|
||||
"uri": "unix:///var/run/docker.sock"
|
||||
},
|
||||
"type": "docker"
|
||||
},
|
||||
"deviceConnectionString": "${DEVICE_CONNECTION_STRING}",
|
||||
"homeDir": "${RUNTIME_HOME_DIR}",
|
||||
"configDir": "${RUNTIME_CONFIG_DIR}",
|
||||
"hostName": "${RUNTIME_HOST_NAME}",
|
||||
"logLevel": "${RUNTIME_LOG_LEVEL}",
|
||||
"schemaVersion": "1",
|
||||
"security": {
|
||||
"certificates": {
|
||||
"option": "selfSigned",
|
||||
"preInstalled": {
|
||||
"deviceCACertificateFilePath": "",
|
||||
"serverCertificateFilePath": ""
|
||||
},
|
||||
"selfSigned": {
|
||||
"forceNoPasswords": true,
|
||||
"forceRegenerate": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Двоичные данные
iotedgedev/template/template.zip
Двоичные данные
iotedgedev/template/template.zip
Двоичный файл не отображается.
|
@ -1,5 +1,4 @@
|
|||
import fnmatch
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -47,7 +46,7 @@ class Utility:
|
|||
def check_dependency(self, params, description, shell=False):
|
||||
try:
|
||||
self.exe_proc(params, shell=shell, suppress_out=True)
|
||||
except:
|
||||
except FileNotFoundError:
|
||||
self.output.error("{0} is required by the Azure IoT Edge Dev Tool. For installation instructions, see https://aka.ms/iotedgedevwiki.".format(description))
|
||||
sys.exit(-1)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ azure-cli-extension
|
|||
azure-cli-configure
|
||||
azure-cli-resource
|
||||
azure-cli-cloud
|
||||
|
||||
iotedgehubdev
|
||||
|
||||
|
||||
|
||||
|
|
8
setup.py
8
setup.py
|
@ -12,11 +12,13 @@ from setuptools.command.develop import develop
|
|||
def _execute():
|
||||
check_call("pip install azure-cli --no-deps".split())
|
||||
|
||||
|
||||
class PostInstall(install):
|
||||
def run(self):
|
||||
atexit.register(_execute)
|
||||
install.run(self)
|
||||
|
||||
|
||||
class PostDevelop(develop):
|
||||
def run(self):
|
||||
atexit.register(_execute)
|
||||
|
@ -41,7 +43,8 @@ requirements = [
|
|||
'azure-cli-extension',
|
||||
'azure-cli-configure',
|
||||
'azure-cli-resource',
|
||||
'azure-cli-cloud'
|
||||
'azure-cli-cloud',
|
||||
'iotedgehubdev'
|
||||
]
|
||||
|
||||
setup_requirements = [
|
||||
|
@ -54,7 +57,8 @@ test_requirements = [
|
|||
setup(
|
||||
name='iotedgedev',
|
||||
version='0.81.0',
|
||||
description="The Azure IoT Edge Dev Tool greatly simplifies the IoT Edge development process by automating many routine manual tasks, such as building, deploying, pushing modules and configuring the IoT Edge Runtime.",
|
||||
description="The Azure IoT Edge Dev Tool greatly simplifies the IoT Edge development process by automating many routine manual tasks, "
|
||||
"such as building, deploying, pushing modules and configuring the IoT Edge Runtime.",
|
||||
long_description="See https://github.com/azure/iotedgedev for usage instructions.",
|
||||
author="Jon Gallant",
|
||||
author_email='info@jongallant.com',
|
||||
|
|
|
@ -5,8 +5,8 @@ import shutil
|
|||
import pytest
|
||||
from click.testing import CliRunner
|
||||
from dotenv import load_dotenv
|
||||
from iotedgedev.compat import PY35
|
||||
|
||||
from iotedgedev.compat import PY35
|
||||
from iotedgedev.connectionstring import (DeviceConnectionString,
|
||||
IoTHubConnectionString)
|
||||
|
||||
|
@ -164,19 +164,6 @@ def test_deploy_modules(request):
|
|||
assert 'DEPLOYMENT COMPLETE' in result.output
|
||||
|
||||
|
||||
# @pytest.fixture
|
||||
# def test_start_runtime(request):
|
||||
|
||||
# os.chdir(test_solution_dir)
|
||||
|
||||
# cli = __import__("iotedgedev.cli", fromlist=['main'])
|
||||
# runner = CliRunner()
|
||||
# result = runner.invoke(cli.main, ['start'])
|
||||
# print(result.output)
|
||||
|
||||
# assert 'Runtime started' in result.output
|
||||
|
||||
|
||||
def test_monitor(request, capfd):
|
||||
|
||||
os.chdir(test_solution_dir)
|
||||
|
@ -195,19 +182,6 @@ def test_monitor(request, capfd):
|
|||
assert not err
|
||||
|
||||
|
||||
# @pytest.fixture
|
||||
# def test_stop(request):
|
||||
|
||||
# os.chdir(test_solution_dir)
|
||||
|
||||
# cli = __import__("iotedgedev.cli", fromlist=['main'])
|
||||
# runner = CliRunner()
|
||||
# result = runner.invoke(cli.main, ['stop'])
|
||||
# print(result.output)
|
||||
|
||||
# assert 'Runtime stopped' in result.output
|
||||
|
||||
|
||||
def test_e2e(test_push_modules, test_deploy_modules):
|
||||
print('Testing E2E')
|
||||
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
import os
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
from iotedgedev.compat import PY35
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
root_dir = os.getcwd()
|
||||
tests_dir = os.path.join(root_dir, 'tests')
|
||||
env_file = os.path.join(root_dir, '.env')
|
||||
test_solution = 'test_solution'
|
||||
test_solution_dir = os.path.join(tests_dir, test_solution)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def create_solution(request):
|
||||
cli = __import__('iotedgedev.cli', fromlist=['main'])
|
||||
|
||||
runner = CliRunner()
|
||||
os.chdir(tests_dir)
|
||||
result = runner.invoke(cli.main, ['solution', 'create', test_solution])
|
||||
print(result.output)
|
||||
|
||||
assert 'AZURE IOT EDGE SOLUTION CREATED' in result.output
|
||||
|
||||
shutil.copyfile(env_file, os.path.join(test_solution_dir, '.env'))
|
||||
os.chdir(test_solution_dir)
|
||||
|
||||
def clean():
|
||||
os.chdir(root_dir)
|
||||
shutil.rmtree(test_solution_dir, ignore_errors=True)
|
||||
runner.invoke(cli.main, ['simulator', 'stop'])
|
||||
|
||||
request.addfinalizer(clean)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def test_setup():
|
||||
cli = __import__('iotedgedev.cli', fromlist=['main'])
|
||||
runner = CliRunner()
|
||||
|
||||
result = runner.invoke(cli.main, ['simulator', 'setup'])
|
||||
print(result.output)
|
||||
|
||||
assert 'Setup IoT Edge Simulator successfully.' in result.output
|
||||
|
||||
|
||||
def test_start_single():
|
||||
cli = __import__('iotedgedev.cli', fromlist=['main'])
|
||||
runner = CliRunner()
|
||||
|
||||
result = runner.invoke(cli.main, ['simulator', 'start', '-i', 'setup'])
|
||||
print(result.output)
|
||||
|
||||
assert 'IoT Edge Simulator has been started in single module mode.' in result.output
|
||||
|
||||
|
||||
def test_modulecred():
|
||||
cli = __import__('iotedgedev.cli', fromlist=['main'])
|
||||
runner = CliRunner()
|
||||
|
||||
result = runner.invoke(cli.main, ['simulator', 'modulecred'])
|
||||
print(result.output)
|
||||
|
||||
assert 'EdgeHubConnectionString=HostName=' in result.output
|
||||
assert 'EdgeModuleCACertificateFile=' in result.output
|
||||
|
||||
|
||||
def test_stop(capfd):
|
||||
cli = __import__('iotedgedev.cli', fromlist=['main'])
|
||||
runner = CliRunner()
|
||||
|
||||
result = runner.invoke(cli.main, ['simulator', 'stop'])
|
||||
print(result.output)
|
||||
out, err = capfd.readouterr()
|
||||
print(out)
|
||||
print(err)
|
||||
|
||||
assert 'IoT Edge Simulator has been stopped successfully.' in out
|
||||
|
||||
|
||||
def test_start_solution(capfd):
|
||||
cli = __import__('iotedgedev.cli', fromlist=['main'])
|
||||
runner = CliRunner()
|
||||
|
||||
result = runner.invoke(cli.main, ['simulator', 'start', '-s', '-b'])
|
||||
print(result.output)
|
||||
out, err = capfd.readouterr()
|
||||
print(out)
|
||||
print(err)
|
||||
|
||||
assert 'BUILD COMPLETE' in result.output
|
||||
assert 'IoT Edge Simulator has been started in solution mode.' in out
|
||||
|
||||
|
||||
def test_monitor(capfd):
|
||||
cli = __import__('iotedgedev.cli', fromlist=['main'])
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli.main, ['monitor', '--timeout', '20'])
|
||||
out, err = capfd.readouterr()
|
||||
print(out)
|
||||
print(err)
|
||||
print(result.output)
|
||||
|
||||
if not PY35:
|
||||
assert 'Monitoring events from device' in out
|
||||
else:
|
||||
assert not err
|
||||
assert 'timeCreated' in out
|
Загрузка…
Ссылка в новой задаче