Fix error when start simulator with setup option (#418)

* Fix error when start simulator with --setup option

* Bump version to 2.1.1

* Install fixed version of Azure CLI IoT extension

* Do not support 3.8 due to Azure CLI IoT extension incompatible
This commit is contained in:
Chaoyi Yuan 2019-12-16 13:25:19 +08:00 коммит произвёл GitHub
Родитель d43febbc90
Коммит 98c906bb62
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 53 добавлений и 24 удалений

Просмотреть файл

@ -1,8 +1,7 @@
language: python
python:
- "3.7"
- "3.6"
- "3.5"
- "3.4"
- "2.7"
install:
- pip install -r requirements_travis.txt

Просмотреть файл

@ -1,6 +1,11 @@
# Changelog
All notable changes to this project since 0.82.0 will be documented in this file.
## [2.1.1] - 2019-12-11
### Changed
- Fix getconfig fails if template contains a placeholder that is not enclosed in quotes.[[#414](https://github.com/Azure/iotedgedev/issues/414)]
- Fix wrong instruction to `iotedgedev iothub setup` with extra flags.[[#417](https://github.com/Azure/iotedgedev/issues/417)]
## [2.1.0] - 2019-10-28
### Added
- Validate schema of deployment template and generated deployment manifest in `genconfig` command

Просмотреть файл

@ -4,5 +4,5 @@
__author__ = 'Microsoft Corporation'
__email__ = 'vsciet@microsoft.com'
__version__ = '2.1.0'
__version__ = '2.1.1'
__AIkey__ = '95b20d64-f54f-4de3-8ad5-165a75a6c6fe'

Просмотреть файл

@ -209,6 +209,12 @@ class AzureCli:
"--yes"],
f("Error while adding extension {name}."), suppress_output=True)
def add_extension_with_source(self, source_url):
return self.invoke_az_cli_outproc(["extension", "add", "--source", source_url,
"--yes"],
f("Error while add extension from source {source_url}."),
suppress_output=True)
def extension_exists(self, name):
return self.invoke_az_cli_outproc(["extension", "show", "--name", name, "--output", "table"],
f("Error while checking for extension {name}."), suppress_output=True)

Просмотреть файл

@ -10,6 +10,7 @@ import click
from fstrings import f
from .azurecli import AzureCli
from .constants import Constants
from .decorators import add_module_options, with_telemetry
from .dockercls import Docker
from .edge import Edge
@ -223,6 +224,7 @@ main.add_command(push)
help="Specify the deployment manifest file")
@with_telemetry
def deploy(manifest_file):
ensure_azure_cli_iot_ext()
edge = Edge(envvars, output, azure_cli)
edge.deploy(manifest_file)
@ -341,12 +343,16 @@ main.add_command(setup_simulator)
default=53000,
show_default=True,
help="Port of the service for sending message.")
@click.option("--iothub-connection-string",
"-c",
help="Set Azure IoT Hub connection string when setup IoT Edge simulator. Note: Use double quotes when supplying this input.",
required=False)
@with_telemetry
def start_simulator(setup, solution, build, manifest_file, platform, verbose, inputs, port):
def start_simulator(setup, solution, build, manifest_file, platform, verbose, inputs, port, iothub_connection_string):
sim = Simulator(envvars, output)
if setup:
sim.setup(socket.getfqdn())
sim.setup(socket.getfqdn(), iothub_connection_string)
if solution or not inputs:
sim.start_solution(manifest_file, platform, verbose, build)
@ -400,6 +406,7 @@ def modulecred(local, output_file):
help="Specify number of seconds to monitor for messages")
@with_telemetry
def monitor(timeout):
ensure_azure_cli_iot_ext()
utility = Utility(envvars, output)
ih = IoTHub(envvars, utility, output, azure_cli)
ih.monitor_events(timeout)
@ -408,6 +415,16 @@ def monitor(timeout):
main.add_command(monitor)
def ensure_azure_cli_iot_ext():
if not azure_cli.extension_exists("azure-cli-iot-ext"):
try:
# Install fixed version of Azure CLI IoT extension
azure_cli.add_extension_with_source(Constants.azure_cli_iot_ext_source_url)
except Exception:
# Fall back to install latest Azure CLI IoT extension when fail
azure_cli.add_extension("azure-cli-iot-ext")
def validate_option(ctx, param, value):
global default_subscriptionId
global azure_cli_processing_complete
@ -467,8 +484,7 @@ def validate_option(ctx, param, value):
if param.name == "iothub_name":
output.param("IOT HUB", value, f("Setting IoT Hub to '{value}'..."), azure_cli_processing_complete)
envvars.IOTHUB_NAME = value
if not azure_cli.extension_exists("azure-cli-iot-ext"):
azure_cli.add_extension("azure-cli-iot-ext")
ensure_azure_cli_iot_ext()
if not azure_cli.iothub_exists(value, envvars.RESOURCE_GROUP_NAME):
# check if the active subscription already contains a free IoT Hub
# if yes ask if the user wants to create an S1

Просмотреть файл

@ -9,3 +9,4 @@ class Constants:
moduledir_placeholder_pattern = r'\${MODULEDIR<(.+)>(\..+)?}'
deployment_template_schema_url = "http://json.schemastore.org/azure-iot-edge-deployment-template-2.0"
deployment_manifest_schema_url = "http://json.schemastore.org/azure-iot-edge-deployment-2.0"
azure_cli_iot_ext_source_url = "https://github.com/Azure/azure-iot-cli-extension/releases/download/v0.8.6/azure_cli_iot_ext-0.8.6-py2.py3-none-any.whl"

Просмотреть файл

@ -14,7 +14,7 @@ class Simulator:
self.output = output
self.utility = Utility(self.envvars, self.output)
def setup(self, gateway_host, iothub_connection_string):
def setup(self, gateway_host, iothub_connection_string=""):
self.output.header("Setting Up IoT Edge Simulator")
self.envvars.verify_envvar_has_val("DEVICE_CONNECTION_STRING", self.envvars.DEVICE_CONNECTION_STRING)

Просмотреть файл

@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.1.0
current_version = 2.1.1
commit = True
tag = True

Просмотреть файл

@ -59,7 +59,7 @@ test_requirements = [
setup(
name='iotedgedev',
version='2.1.0',
version='2.1.1',
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='Microsoft Corporation',
@ -76,6 +76,7 @@ setup(
license='MIT license',
zip_safe=False,
keywords='azure iot edge dev tool',
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <3.8',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
@ -84,7 +85,8 @@ setup(
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6'
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
],
test_suite='tests',
tests_require=test_requirements,

Просмотреть файл

@ -217,7 +217,7 @@ def test_deploy_modules():
result = runner_invoke(['deploy'])
assert 'DEPLOYMENT COMPLETE' in result.output
assert 'ERROR' not in result.output
assert 'ERROR' not in result.output.replace('ERROR: Error while checking for extension', '')
@pytest.fixture

Просмотреть файл

@ -93,6 +93,16 @@ def test_start_solution(capfd):
assert 'IoT Edge Simulator has been started in solution mode.' in out
@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_start_solution_with_setup(capfd):
result = runner_invoke(['simulator', 'start', '--setup', '-s', '-b', '-f', 'deployment.template.json'])
out, err = capfd.readouterr()
assert 'Setup IoT Edge Simulator successfully.' in result.output
assert 'BUILD COMPLETE' in result.output
assert 'IoT Edge Simulator has been started in solution mode.' in out
@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_monitor(capfd):
try:

Просмотреть файл

@ -1,5 +1,5 @@
[tox]
envlist = py27, py36, py37
envlist = py27, py36, py37, py38
#[travis]
#python =
@ -15,7 +15,7 @@ envlist = py27, py36, py37
deps =
pytest
-rrequirements_dev.txt
commands = pytest -s -v
commands = pytest -s -v {posargs}
#setenv =
# PYTHONPATH = {toxinidir}

Просмотреть файл

@ -28,11 +28,6 @@ steps:
yo --version
displayName: "Install Yeoman and Azure IoT Edge Node.js module generator packages"
- powershell: |
az extension add --name azure-cli-iot-ext
az --version
displayName: "Install Azure Cli iot extension"
- script: |
pip install --upgrade pip
pip install --upgrade tox

Просмотреть файл

@ -18,7 +18,6 @@ steps:
pip install --upgrade pip
pip install --upgrade tox
sudo npm i -g iothub-explorer
az extension add --name azure-cli-iot-ext
az --version
displayName: "Update and install required tools"

Просмотреть файл

@ -13,10 +13,6 @@ steps:
npm i -g iothub-explorer yo generator-azure-iot-edge-module
displayName: "Install IoT Hub explorer, Yeoman and Azure IoT Edge Node.js module generator packages"
- pwsh: |
az extension add --name azure-cli-iot-ext
displayName: "Install Azure CLI IoT Extension"
- pwsh: |
pip install tox
tox -e "$(TOXENV)"