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

Added 'aks nodepool snapshot update' command #6433

Merged
merged 22 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
789b0a4
Added 'aks nodepool snapshot update' command
pineapplethevoyager Jun 23, 2023
908e94f
add new release version
pineapplethevoyager Jun 23, 2023
0ae5b1e
fixed tag test
pineapplethevoyager Jun 26, 2023
288b021
fixed snapshot naming for nodepool
pineapplethevoyager Jun 26, 2023
00a3e0f
Version update
pineapplethevoyager Jun 27, 2023
95281be
update test
pineapplethevoyager Jun 28, 2023
59ed3cd
Merge remote-tracking branch 'upstream/main'
pineapplethevoyager Jun 28, 2023
2a09f9c
test update
pineapplethevoyager Jun 28, 2023
4401ce5
removing already removed history
pineapplethevoyager Jun 28, 2023
39c3a84
whitespace fix
pineapplethevoyager Jun 28, 2023
f46f0ae
undo file changes
pineapplethevoyager Jun 28, 2023
b70467b
add no wait support
pineapplethevoyager Jun 28, 2023
b5bd116
test updates
pineapplethevoyager Jun 28, 2023
f8907fc
removed no wait and changed var name
pineapplethevoyager Jun 29, 2023
abb15e6
Update src/aks-preview/azext_aks_preview/_params.py
pineapplethevoyager Jun 30, 2023
143a6cd
Update src/aks-preview/azext_aks_preview/_help.py
pineapplethevoyager Jun 30, 2023
7e97cce
Revert "Update src/aks-preview/azext_aks_preview/_help.py"
pineapplethevoyager Jun 30, 2023
39b0ab1
Revert "Update src/aks-preview/azext_aks_preview/_params.py"
pineapplethevoyager Jun 30, 2023
47f90ba
Merge remote-tracking branch 'upstream/main'
pineapplethevoyager Jun 30, 2023
2c4d6df
remaking PR changes with updated branch
pineapplethevoyager Jun 30, 2023
a7bce56
Merge remote-tracking branch 'upstream/main'
pineapplethevoyager Jul 5, 2023
b570bf9
Update src/aks-preview/azext_aks_preview/_params.py
pineapplethevoyager Jul 7, 2023
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
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
++++++

0.5.146
+++++++
* Add support for new snapshot command `az aks nodepool snapshot update`

0.5.145
pineapplethevoyager marked this conversation as resolved.
Show resolved Hide resolved
+++++++
* Add support for option --aks-custom-headers to some aks commands
Expand Down
11 changes: 11 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,17 @@
short-summary: List nodepool snapshots.
"""

helps['aks nodepool snapshot update'] = """
type: command
short-summary: update tags on a snapshot of a nodepool.
pineapplethevoyager marked this conversation as resolved.
Show resolved Hide resolved

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
6 changes: 6 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,12 @@ def load_arguments(self, _):
help='The nodepool id.', validator=validate_nodepool_id)
c.argument('aks_custom_headers')

for scope in ['aks nodepool snapshot update']:
with self.argument_context(scope) as c:
c.argument('snapshot_name', options_list=[
'--name', '-n'], required=True, help='The nodepool snapshot name.', validator=validate_snapshot_name)
c.argument('tags', tags_type, required=True, help='The tags to set to the snapshot.')
pineapplethevoyager marked this conversation as resolved.
Show resolved Hide resolved
pineapplethevoyager marked this conversation as resolved.
Show resolved Hide resolved

for scope in ['aks nodepool snapshot show', 'aks nodepool snapshot delete']:
with self.argument_context(scope) as c:
c.argument('snapshot_name', options_list=[
Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def load_command_table(self, _):
table_transformer=aks_show_nodepool_snapshot_table_format)
g.custom_command('create', 'aks_nodepool_snapshot_create',
pineapplethevoyager marked this conversation as resolved.
Show resolved Hide resolved
supports_no_wait=True)
g.custom_command('update', 'aks_nodepool_snapshot_update')
pineapplethevoyager marked this conversation as resolved.
Show resolved Hide resolved
g.custom_command('delete', 'aks_nodepool_snapshot_delete',
supports_no_wait=True)

Expand Down
14 changes: 14 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,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=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=CUSTOM_MGMT_AKS_PREVIEW,
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
1,449 changes: 645 additions & 804 deletions src/aks-preview/azext_aks_preview/tests/latest/recordings/test_aks_nodepool_snapshot.yaml
100755 → 100644

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,9 @@ def test_aks_nodepool_snapshot(self, resource_group, resource_group_location):
nodepool_name = self.create_random_name('c', 6)
nodepool_name2 = self.create_random_name('c', 6)
snapshot_name = self.create_random_name('s', 16)
tagVar = "test"
tagVal = "value"
tags = tagVar+"="+tagVal

self.kwargs.update({
'resource_group': resource_group,
Expand All @@ -1959,7 +1962,8 @@ def test_aks_nodepool_snapshot(self, resource_group, resource_group_location):
'snapshot_name': snapshot_name,
'k8s_version': create_version,
'upgrade_k8s_version': upgrade_version,
'ssh_key_value': self.generate_ssh_keys()
'ssh_key_value': self.generate_ssh_keys(),
'tags': tags
})

# create an aks cluster not using snapshot
Expand Down Expand Up @@ -1993,6 +1997,12 @@ def test_aks_nodepool_snapshot(self, resource_group, resource_group_location):
})
print("The snapshot resource id %s " % snapshot_resource_id)

# update tags on nodepool snapshot
FumingZhang marked this conversation as resolved.
Show resolved Hide resolved
update_snapshot_cmd = 'aks nodepool snapshot update --resource-group {resource_group} --name {snapshot_name} --tags {tags} -o json'
pineapplethevoyager marked this conversation as resolved.
Show resolved Hide resolved
response = self.cmd(update_snapshot_cmd, checks=[
self.check('tags', {tagVar: tagVal})
]).get_output_in_json()

# delete the original AKS cluster
self.cmd(
'aks delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()])
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from setuptools import setup, find_packages

VERSION = "0.5.145"
VERSION = "0.5.146"

CLASSIFIERS = [
"Development Status :: 4 - Beta",
Expand Down
Loading