-
Notifications
You must be signed in to change notification settings - Fork 3.4k
{Compute} az vm: Migrate commands to aaz-based implementation
#32718
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
84db569
Migrate vm create command
william051200 0d3dd48
Generated sshkey code from aaz
william051200 5e1143d
Migrate vm create validator
william051200 9bb86a5
Update vm create command
william051200 33acc58
Migrate vm show command
william051200 aa0eb49
Update vm create command function name
william051200 3b439b9
Migrate vm update command
william051200 fced1a4
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 6ced81c
Regenerate sshkey code from aaz
william051200 85d79fc
Edit code
william051200 4799891
Update vm image show version to match with SDK version
william051200 e766283
Edit code style
william051200 52e85c3
Edit code style
william051200 9bd40ff
Fix code style
william051200 4cbf8b4
Update aaz vm image list and show version
william051200 d882bf2
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 55d22fb
Updated vm image show version
william051200 9d59e80
Updated compute image show version
william051200 cee4839
Updated test case and recordings
william051200 fc2c831
Updated vm image list version
william051200 984c7df
Update image collected from az vm image handling
william051200 439533d
Update test case and recordings
william051200 5f4780d
update vm image list handling
william051200 6784adf
Updated test case recording version
william051200 59395c6
Updated test case recording version
william051200 326429f
Update test case recordings
william051200 73b3659
Update vm image list API and add handling to API
william051200 185d39c
Update test case recording
william051200 f77ef39
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 f120cc2
Fix code style
william051200 b35d9e7
Update test case and test case recording
william051200 0296c0e
Fix code style
william051200 6229fa9
edit test case and recording
william051200 35b4039
Resolve conflicts
william051200 a2e8c3b
Fix date time bug
william051200 516ab9f
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 4e2cc1f
Revert unrelated changes
william051200 4342d20
Add handling to prevent missing aux token
william051200 3349cc5
Update test case and re-record test case
william051200 45a92a8
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 5b76eb2
Re-ecord test case
william051200 a8fb68a
Merge remote-tracking branch 'origin/dev' into vm-migration
william051200 29effae
Re-record test case
william051200 caea656
Regenerate vm image list code
william051200 eb05666
Revert code
william051200 5823064
Update code
william051200 2b47c68
Update code
william051200 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
182 changes: 125 additions & 57 deletions
182
src/azure-cli/azure/cli/command_modules/vm/_validators.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/sshkey/__cmd_group.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| @register_command_group( | ||
| "sshkey", | ||
| ) | ||
| class __CMDGroup(AAZCommandGroup): | ||
| """Manage Ssh Public Key | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| __all__ = ["__CMDGroup"] |
16 changes: 16 additions & 0 deletions
16
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/sshkey/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from .__cmd_group import * | ||
| from ._create import * | ||
| from ._delete import * | ||
| from ._list import * | ||
| from ._show import * | ||
| from ._update import * |
264 changes: 264 additions & 0 deletions
264
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/sshkey/_create.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,264 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| @register_command( | ||
| "sshkey create", | ||
| ) | ||
| class Create(AAZCommand): | ||
| """Create a new SSH public key resource. | ||
|
|
||
| :example: Create a new SSH public key resource. | ||
| az sshkey create --resource-group myResourceGroup --ssh-public-key-name mySshPublicKeyName --location westus --public-key {ssh-rsa public key} | ||
| """ | ||
|
|
||
| _aaz_info = { | ||
| "version": "2025-04-01", | ||
| "resources": [ | ||
| ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/sshpublickeys/{}", "2025-04-01"], | ||
| ] | ||
| } | ||
|
|
||
| def _handler(self, command_args): | ||
| super()._handler(command_args) | ||
| self._execute_operations() | ||
| return self._output() | ||
|
|
||
| _args_schema = None | ||
|
|
||
| @classmethod | ||
| def _build_arguments_schema(cls, *args, **kwargs): | ||
| if cls._args_schema is not None: | ||
| return cls._args_schema | ||
| cls._args_schema = super()._build_arguments_schema(*args, **kwargs) | ||
|
|
||
| # define Arg Group "" | ||
|
|
||
| _args_schema = cls._args_schema | ||
| _args_schema.resource_group = AAZResourceGroupNameArg( | ||
| required=True, | ||
| ) | ||
| _args_schema.ssh_public_key_name = AAZStrArg( | ||
| options=["-n", "--name", "--ssh-public-key-name"], | ||
| help="The name of the SSH public key.", | ||
| required=True, | ||
| ) | ||
|
|
||
| # define Arg Group "Parameters" | ||
|
|
||
| _args_schema = cls._args_schema | ||
| _args_schema.location = AAZResourceLocationArg( | ||
| arg_group="Parameters", | ||
| help="The geo-location where the resource lives", | ||
| required=True, | ||
| fmt=AAZResourceLocationArgFormat( | ||
| resource_group_arg="resource_group", | ||
| ), | ||
| ) | ||
| _args_schema.tags = AAZDictArg( | ||
| options=["--tags"], | ||
| arg_group="Parameters", | ||
| help="Resource tags.", | ||
| ) | ||
|
|
||
| tags = cls._args_schema.tags | ||
| tags.Element = AAZStrArg() | ||
|
|
||
| # define Arg Group "Properties" | ||
|
|
||
| _args_schema = cls._args_schema | ||
| _args_schema.public_key = AAZStrArg( | ||
| options=["--public-key"], | ||
| arg_group="Properties", | ||
| help="SSH public key used to authenticate to a virtual machine through ssh. If this property is not initially provided when the resource is created, the publicKey property will be populated when generateKeyPair is called. If the public key is provided upon resource creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format.", | ||
| ) | ||
| return cls._args_schema | ||
|
|
||
| def _execute_operations(self): | ||
| self.pre_operations() | ||
| self.SshPublicKeysCreate(ctx=self.ctx)() | ||
| self.post_operations() | ||
|
|
||
| @register_callback | ||
| def pre_operations(self): | ||
| pass | ||
|
|
||
| @register_callback | ||
| def post_operations(self): | ||
| pass | ||
|
|
||
| def _output(self, *args, **kwargs): | ||
| result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) | ||
| return result | ||
|
|
||
| class SshPublicKeysCreate(AAZHttpOperation): | ||
| CLIENT_TYPE = "MgmtClient" | ||
|
|
||
| def __call__(self, *args, **kwargs): | ||
| request = self.make_request() | ||
| session = self.client.send_request(request=request, stream=False, **kwargs) | ||
| if session.http_response.status_code in [200, 201]: | ||
| return self.on_200_201(session) | ||
|
|
||
| return self.on_error(session.http_response) | ||
|
|
||
| @property | ||
| def url(self): | ||
| return self.client.format_url( | ||
| "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", | ||
| **self.url_parameters | ||
| ) | ||
|
|
||
| @property | ||
| def method(self): | ||
| return "PUT" | ||
|
|
||
| @property | ||
| def error_format(self): | ||
| return "ODataV4Format" | ||
|
|
||
| @property | ||
| def url_parameters(self): | ||
| parameters = { | ||
| **self.serialize_url_param( | ||
| "resourceGroupName", self.ctx.args.resource_group, | ||
| required=True, | ||
| ), | ||
| **self.serialize_url_param( | ||
| "sshPublicKeyName", self.ctx.args.ssh_public_key_name, | ||
| required=True, | ||
| ), | ||
| **self.serialize_url_param( | ||
| "subscriptionId", self.ctx.subscription_id, | ||
| required=True, | ||
| ), | ||
| } | ||
| return parameters | ||
|
|
||
| @property | ||
| def query_parameters(self): | ||
| parameters = { | ||
| **self.serialize_query_param( | ||
| "api-version", "2025-04-01", | ||
| required=True, | ||
| ), | ||
| } | ||
| return parameters | ||
|
|
||
| @property | ||
| def header_parameters(self): | ||
| parameters = { | ||
| **self.serialize_header_param( | ||
| "Content-Type", "application/json", | ||
| ), | ||
| **self.serialize_header_param( | ||
| "Accept", "application/json", | ||
| ), | ||
| } | ||
| return parameters | ||
|
|
||
| @property | ||
| def content(self): | ||
| _content_value, _builder = self.new_content_builder( | ||
| self.ctx.args, | ||
| typ=AAZObjectType, | ||
| typ_kwargs={"flags": {"required": True, "client_flatten": True}} | ||
| ) | ||
| _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) | ||
| _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) | ||
| _builder.set_prop("tags", AAZDictType, ".tags") | ||
|
|
||
| properties = _builder.get(".properties") | ||
| if properties is not None: | ||
| properties.set_prop("publicKey", AAZStrType, ".public_key") | ||
|
|
||
| tags = _builder.get(".tags") | ||
| if tags is not None: | ||
| tags.set_elements(AAZStrType, ".") | ||
|
|
||
| return self.serialize_content(_content_value) | ||
|
|
||
| def on_200_201(self, session): | ||
| data = self.deserialize_http_content(session) | ||
| self.ctx.set_var( | ||
| "instance", | ||
| data, | ||
| schema_builder=self._build_schema_on_200_201 | ||
| ) | ||
|
|
||
| _schema_on_200_201 = None | ||
|
|
||
| @classmethod | ||
| def _build_schema_on_200_201(cls): | ||
| if cls._schema_on_200_201 is not None: | ||
| return cls._schema_on_200_201 | ||
|
|
||
| cls._schema_on_200_201 = AAZObjectType() | ||
|
|
||
| _schema_on_200_201 = cls._schema_on_200_201 | ||
| _schema_on_200_201.id = AAZStrType( | ||
| flags={"read_only": True}, | ||
| ) | ||
| _schema_on_200_201.location = AAZStrType( | ||
| flags={"required": True}, | ||
| ) | ||
| _schema_on_200_201.name = AAZStrType( | ||
| flags={"read_only": True}, | ||
| ) | ||
| _schema_on_200_201.properties = AAZObjectType( | ||
| flags={"client_flatten": True}, | ||
| ) | ||
| _schema_on_200_201.system_data = AAZObjectType( | ||
| serialized_name="systemData", | ||
| flags={"read_only": True}, | ||
| ) | ||
| _schema_on_200_201.tags = AAZDictType() | ||
| _schema_on_200_201.type = AAZStrType( | ||
| flags={"read_only": True}, | ||
| ) | ||
|
|
||
| properties = cls._schema_on_200_201.properties | ||
| properties.public_key = AAZStrType( | ||
| serialized_name="publicKey", | ||
| ) | ||
|
|
||
| system_data = cls._schema_on_200_201.system_data | ||
| system_data.created_at = AAZStrType( | ||
| serialized_name="createdAt", | ||
| ) | ||
| system_data.created_by = AAZStrType( | ||
| serialized_name="createdBy", | ||
| ) | ||
| system_data.created_by_type = AAZStrType( | ||
| serialized_name="createdByType", | ||
| ) | ||
| system_data.last_modified_at = AAZStrType( | ||
| serialized_name="lastModifiedAt", | ||
| ) | ||
| system_data.last_modified_by = AAZStrType( | ||
| serialized_name="lastModifiedBy", | ||
| ) | ||
| system_data.last_modified_by_type = AAZStrType( | ||
| serialized_name="lastModifiedByType", | ||
| ) | ||
|
|
||
| tags = cls._schema_on_200_201.tags | ||
| tags.Element = AAZStrType() | ||
|
|
||
| return cls._schema_on_200_201 | ||
|
|
||
|
|
||
| class _CreateHelper: | ||
| """Helper class for Create""" | ||
|
|
||
|
|
||
| __all__ = ["Create"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.