Skip to content

Commit

Permalink
fix: add --no-progress to key regeneration commands (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
vilit1 authored Sep 5, 2024
1 parent 10df84d commit b258601
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Release History

**IoT Hub updates**

* Fix `az iot hub message-endpoint create` to correctly pass the endpoint subscription when provided.

* Deprecate use of SHA1 hashes for certificate thumbprints. SHA256 hashes will be used for all certificate thumbprints.

* Addition of bulk key regeneration for `az iot hub device-identity renew-key` and `az iot hub module-identity renew-key`.
Expand Down
12 changes: 12 additions & 0 deletions azext_iot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,12 @@ def load_arguments(self, _):
help="Etag or entity tag corresponding to the last state of the resource. "
"If no etag is provided the value '*' is used. This arguement only applies to `swap`.",
)
context.argument(
"no_progress",
options_list=["--no-progress"],
arg_type=get_three_state_flag(),
help="Hide the progress bar for bulk key regeneration.",
)

with self.argument_context("iot hub device-identity export") as context:
context.argument(
Expand Down Expand Up @@ -646,6 +652,12 @@ def load_arguments(self, _):
help="Etag or entity tag corresponding to the last state of the resource. "
"If no etag is provided the value '*' is used. This arguement only applies to `swap`.",
)
context.argument(
"no_progress",
options_list=["--no-progress"],
arg_type=get_three_state_flag(),
help="Hide the progress bar for bulk key regeneration.",
)

with self.argument_context("iot hub distributed-tracing update") as context:
context.argument(
Expand Down
9 changes: 7 additions & 2 deletions azext_iot/operations/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ def iot_device_key_regenerate(
device_ids,
renew_key_type,
include_modules=False,
no_progress=False,
resource_group_name=None,
login=None,
etag=None,
Expand Down Expand Up @@ -567,6 +568,7 @@ def iot_device_key_regenerate(
service_sdk=service_sdk,
renew_key_type=renew_key_type,
items=devices + modules,
no_progress=no_progress
)

# avoid breaking changes by having one device return the device identity
Expand Down Expand Up @@ -990,6 +992,7 @@ def iot_device_module_key_regenerate(
device_id,
module_ids,
renew_key_type,
no_progress=None,
resource_group_name=None,
login=None,
etag=None,
Expand Down Expand Up @@ -1042,7 +1045,8 @@ def iot_device_module_key_regenerate(
service_sdk=service_sdk,
renew_key_type=renew_key_type,
items=modules,
device_id=device_id
device_id=device_id,
no_progress=no_progress
)

if len(module_ids) == 1 and module_ids[0] != "*":
Expand Down Expand Up @@ -1074,6 +1078,7 @@ def _iot_key_regenerate_batch(
renew_key_type,
items,
device_id=None,
no_progress=False,
):
from time import sleep
overall_result = {
Expand All @@ -1093,7 +1098,7 @@ def _iot_key_regenerate_batch(
else:
batches.append(items[:])
items = []
for batch in tqdm(batches, desc="Bulk key regeneration is in progress", ascii=' #'):
for batch in tqdm(batches, desc="Bulk key regeneration is in progress", ascii=' #', disable=no_progress):
# call
result = None
tries = 0
Expand Down
2 changes: 1 addition & 1 deletion scripts/smoke_tests/commands_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ $commands += "az iot hub configuration show -g $resource_group_name -c $hub_conf
# IoT Hub Device
$commands += "az iot hub device-identity create -g $resource_group_name -n $iothub_name -d $device_id --ee"
$commands += "az iot hub device-identity show -g $resource_group_name -n $iothub_name -d $device_id"
$commands += "az iot hub device-identity renew-key -g $resource_group_name -n $iothub_name -d $device_id --kt primary"
$commands += "az iot hub device-identity renew-key -g $resource_group_name -n $iothub_name -d $device_id --kt primary --no-progress"
$commands += "az iot hub device-twin show -g $resource_group_name -n $iothub_name -d $device_id"
$commands += "az iot hub device-twin update -g $resource_group_name -n $iothub_name -d $device_id --desired $desired_twin_properties"
$commands += "az iot hub generate-sas-token -g $resource_group_name -d $device_id -n $iothub_name"
Expand Down

0 comments on commit b258601

Please sign in to comment.