Skip to content

Commit

Permalink
[AKS] az aks nodepool snapshot update: Add aks nodepool snapshot up…
Browse files Browse the repository at this point in the history
…date command (Azure#26790)
  • Loading branch information
pineapplethevoyager authored Jul 7, 2023
1 parent 9d75c5c commit 8235008
Show file tree
Hide file tree
Showing 6 changed files with 900 additions and 269 deletions.
10 changes: 10 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,16 @@
short-summary: List nodepool snapshots.
"""

helps['aks nodepool snapshot update'] = """
type: command
short-summary: Update tags on a snapshot of a nodepool.
examples:
- name: Update tags on a nodepool snapshot.
text: az aks nodepool snapshot update -g MyResourceGroup -n snapshot1 --tags "foo=bar" "key1=val1"
- name: Clear tags on a nodepool snapshot.
text: az aks nodepool snapshot update -g MyResourceGroup -n snapshot1 --tags ""
"""

helps['aks nodepool snapshot create'] = """
type: command
short-summary: Create a nodepool snapshot.
Expand Down
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ def load_arguments(self, _):
c.argument('nodepool_id', required=True, validator=validate_nodepool_id, help='The nodepool id.')
c.argument('aks_custom_headers')

with self.argument_context('aks nodepool snapshot update') as c:
c.argument('snapshot_name', options_list=['--name', '-n'], help='The nodepool snapshot name.', validator=validate_snapshot_name)
c.argument('tags', tags_type, help='The tags to set to the snapshot.')

for scope in ['aks nodepool snapshot show', 'aks nodepool snapshot delete', 'aks snapshot show', 'aks snapshot delete']:
with self.argument_context(scope) as c:
c.argument('snapshot_name', options_list=['--name', '-n'], required=True, validator=validate_snapshot_name, help='The nodepool snapshot name.')
Expand Down
1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/acs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def load_command_table(self, _):
table_transformer=aks_show_nodepool_snapshot_table_format)
g.custom_command('create', 'aks_nodepool_snapshot_create', supports_no_wait=True)
g.custom_command('delete', 'aks_nodepool_snapshot_delete', supports_no_wait=True)
g.custom_command('update', 'aks_nodepool_snapshot_update')
g.wait_command('wait')

with self.command_group('aks oidc-issuer', managed_clusters_sdk, client_factory=cf_managed_clusters) as g:
Expand Down
14 changes: 14 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2426,6 +2426,20 @@ def aks_nodepool_snapshot_create(cmd, # pylint: disable=too-many-locals,too-m
return client.create_or_update(resource_group_name, snapshot_name, snapshot, headers=aks_custom_headers)


def aks_nodepool_snapshot_update(cmd, client, resource_group_name, snapshot_name, tags): # pylint: disable=unused-argument
TagsObject = cmd.get_models(
"TagsObject",
resource_type=ResourceType.MGMT_CONTAINERSERVICE,
operation_group="snapshots",
)
tagsObject = TagsObject(
tags=tags
)

snapshot = client.update_tags(resource_group_name, snapshot_name, tagsObject)
return snapshot


def aks_nodepool_snapshot_show(cmd, client, resource_group_name, snapshot_name): # pylint: disable=unused-argument
snapshot = client.get(resource_group_name, snapshot_name)
return snapshot
Expand Down
Loading

0 comments on commit 8235008

Please sign in to comment.