diff --git a/.travis.yml b/.travis.yml index de711b2..8a2ba4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: python python: + - "3.7" - "3.6" - - "3.5" - - "3.4" - "2.7" install: - pip install -r requirements_travis.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index f291c15..9d69300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/iotedgedev/__init__.py b/iotedgedev/__init__.py index d5d4303..f97d25c 100644 --- a/iotedgedev/__init__.py +++ b/iotedgedev/__init__.py @@ -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' diff --git a/iotedgedev/azurecli.py b/iotedgedev/azurecli.py index 14c7ba0..45afc6c 100644 --- a/iotedgedev/azurecli.py +++ b/iotedgedev/azurecli.py @@ -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) diff --git a/iotedgedev/cli.py b/iotedgedev/cli.py index d10a808..5a2fa00 100644 --- a/iotedgedev/cli.py +++ b/iotedgedev/cli.py @@ -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 diff --git a/iotedgedev/constants.py b/iotedgedev/constants.py index d8fe2f0..9873d3a 100644 --- a/iotedgedev/constants.py +++ b/iotedgedev/constants.py @@ -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" diff --git a/iotedgedev/simulator.py b/iotedgedev/simulator.py index 45e60d7..1be8496 100644 --- a/iotedgedev/simulator.py +++ b/iotedgedev/simulator.py @@ -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) diff --git a/setup.cfg b/setup.cfg index c47886b..39c1c59 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.1.0 +current_version = 2.1.1 commit = True tag = True diff --git a/setup.py b/setup.py index 0070e51..f71285c 100644 --- a/setup.py +++ b/setup.py @@ -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, diff --git a/tests/test_iotedgedev.py b/tests/test_iotedgedev.py index cc0de5a..ad84075 100644 --- a/tests/test_iotedgedev.py +++ b/tests/test_iotedgedev.py @@ -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 diff --git a/tests/test_simulator.py b/tests/test_simulator.py index 29db7e8..1ee0e4a 100644 --- a/tests/test_simulator.py +++ b/tests/test_simulator.py @@ -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: diff --git a/tox.ini b/tox.ini index a3137bf..0ba729d 100644 --- a/tox.ini +++ b/tox.ini @@ -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} diff --git a/vsts_ci/darwin/continuous-build-darwin.yml b/vsts_ci/darwin/continuous-build-darwin.yml index d69273b..edd47dd 100644 --- a/vsts_ci/darwin/continuous-build-darwin.yml +++ b/vsts_ci/darwin/continuous-build-darwin.yml @@ -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 diff --git a/vsts_ci/linux/continuous-build-linux.yml b/vsts_ci/linux/continuous-build-linux.yml index 5bad6bd..eeccfbe 100644 --- a/vsts_ci/linux/continuous-build-linux.yml +++ b/vsts_ci/linux/continuous-build-linux.yml @@ -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" diff --git a/vsts_ci/win32/continuous-build-win32.yml b/vsts_ci/win32/continuous-build-win32.yml index eba5dfa..653c079 100644 --- a/vsts_ci/win32/continuous-build-win32.yml +++ b/vsts_ci/win32/continuous-build-win32.yml @@ -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)"