Skip to content

Commit

Permalink
fix aaz command --no-wait issue (#23092)
Browse files Browse the repository at this point in the history
  • Loading branch information
kairu-ms authored Jul 4, 2022
1 parent 91af333 commit 57b0d5e
Show file tree
Hide file tree
Showing 5 changed files with 1,019 additions and 264 deletions.
17 changes: 13 additions & 4 deletions src/azure-cli-core/azure/cli/core/aaz/_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ def __call__(self, *args, **kwargs):

def _handler(self, command_args):
# command_args will be parsed by AAZCommandCtx
self.ctx = AAZCommandCtx(cli_ctx=self.cli_ctx, schema=self.get_arguments_schema(), command_args=command_args)
self.ctx = AAZCommandCtx(
cli_ctx=self.cli_ctx,
schema=self.get_arguments_schema(),
command_args=command_args,
no_wait_arg='no_wait' if self.supports_no_wait else None,
)
self.ctx.format_args()

def _cli_arguments_loader(self):
Expand Down Expand Up @@ -190,11 +195,15 @@ def processor(schema, result):

return value.to_serialized_data(processor=processor)

@staticmethod
def build_lro_poller(executor, extract_result):
def build_lro_poller(self, executor, extract_result):
""" Build AAZLROPoller instance to support long running operation
"""
return AAZLROPoller(polling_generator=executor, result_callback=extract_result)
polling_generator = executor()
if self.ctx.lro_no_wait:
# run until yield the first polling
_ = next(polling_generator)
return None
return AAZLROPoller(polling_generator=polling_generator, result_callback=extract_result)

def build_paging(self, executor, extract_result):
""" Build AAZPaged instance to support paging
Expand Down
8 changes: 5 additions & 3 deletions src/azure-cli-core/azure/cli/core/aaz/_command_ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class AAZCommandCtx:

def __init__(self, cli_ctx, schema, command_args):
def __init__(self, cli_ctx, schema, command_args, no_wait_arg=None):
self._cli_ctx = cli_ctx
self._profile = Profile(cli_ctx=cli_ctx)
self._subscription_id = None
Expand All @@ -31,8 +31,10 @@ def __init__(self, cli_ctx, schema, command_args):
self._vars_schema = AAZObjectType()
self.vars = AAZObject(schema=self._vars_schema, data={})
self.generic_update_args = command_args.get(AAZGenericUpdateAction.DEST, None)

self.next_link = AAZUndefined # support paging
# support no wait
self.lro_no_wait = command_args.get(no_wait_arg, False) if no_wait_arg else False
# support paging
self.next_link = AAZUndefined

def format_args(self):
# TODO: apply format for argument values
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/aaz/_poller.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _start(self):
the operation.
"""
try:
for polling_method in self._polling_generator():
for polling_method in self._polling_generator:
self._polling_method = polling_method
try:
self._polling_method.run()
Expand Down
Loading

0 comments on commit 57b0d5e

Please sign in to comment.