Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add List Operation for aks #7771

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Pending
5.0.0b4
++++++++
* Add additional unit test cases for mutable fips flags in agentpool update.
* Add `az operation list` command to list all operations of a specific managed cluster.
wenhug marked this conversation as resolved.
Show resolved Hide resolved

5.0.0b3
++++++++
Expand Down
11 changes: 9 additions & 2 deletions src/aks-preview/azext_aks_preview/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ def parser(entry):
def aks_operation_show_table_format(result):
def parser(entry):
percentComplete = ""
if entry["percentComplete"]:
percentComplete = str(entry["percentComplete"]) + "%"
if entry["status"].lower() == "succeeded":
entry["percentComplete"] = "100"
if entry["percentComplete"] == "":
entry["percentComplete"] = "0"
percentComplete = str(entry["percentComplete"]) + "%"
entry["percentComplete"] = percentComplete
parsed = compile_jmes("""{
name: name,
Expand All @@ -87,6 +90,10 @@ def parser(entry):
return parser(result)


def aks_operation_list_table_format(result):
return [aks_operation_show_table_format(r) for r in result]


def aks_agentpool_show_table_format(result):
"""Format an agent pool as summary results for display with "-o table"."""
return [_aks_agentpool_table_format(result)]
Expand Down
12 changes: 12 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,18 @@
short-summary: Name of the resource group.
"""

helps['aks operation list'] = """
type: command
short-summary: List all operations on managed Kubernetes cluster.
parameters:
- name: --name -n
type: string
short-summary: The name of the managed cluster
- name: --resource-group -g
type: string
short-summary: Name of the resource group.
"""

helps['aks operation-abort'] = """
type: command
short-summary: Abort last running operation on managed cluster.
Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
aks_machine_list_table_format,
aks_machine_show_table_format,
aks_operation_show_table_format,
aks_operation_list_table_format,
aks_list_nodepool_snapshot_table_format,
aks_list_snapshot_table_format,
aks_list_table_format,
Expand Down Expand Up @@ -272,6 +273,9 @@ def load_command_table(self, _):
g.custom_command(
"show-latest", "aks_operation_show_latest", table_transformer=aks_operation_show_table_format
)
g.custom_command(
"list", "aks_operation_list", table_transformer=aks_operation_list_table_format
)

# AKS draft commands
with self.command_group(
Expand Down
7 changes: 7 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,13 @@ def aks_operation_show_latest(cmd,
return client.get(resource_group_name, name, "latest")


def aks_operation_list(cmd,
client,
resource_group_name,
name,):
return client.list(resource_group_name, name)


def aks_operation_abort(cmd, # pylint: disable=unused-argument
client,
resource_group_name,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,17 @@ def test_aks_operations_cmds(self, resource_group, resource_group_location):
assert operation_show["error"] is None
assert operation_show["name"] == operation_id

list_cmd = (
"aks operation list "
"--resource-group={resource_group} --name={name} -o json"
)
operation_list = self.cmd(list_cmd).get_output_in_json()
assert len(operation_list) > 0
assert operation_list[0]["id"] == operation_show_latest["id"]
assert operation_list[0]["status"] == "Succeeded"
assert operation_list[0]["error"] is None
assert operation_list[0]["name"] == operation_id

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(
random_name_length=17, name_prefix="clitest", location="westcentralus"
Expand Down
Loading