-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[AKS] Add machine cli preview #9045
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
yanzhudd
merged 16 commits into
Azure:main
from
zjpjack-github:jizen/create_machine_clipreview
Sep 9, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
89da2f4
aks machine add
bf172c2
add machine cli preview
a98cf18
Merge branch 'main' into jizen/create_machine_clipreview
3aae0b4
update test_aks_commands.py
c581247
add more parameters for put machine
06a56d2
aks add machine
2aaa745
Merge branch 'main' into jizen/create_machine_clipreview
b7f1b9d
update VERSION
8e1dfbb
some minor fix
8e46e33
revert some unrelated change
05f4c33
remove more unused code
276440e
fix some style and linter issues
73aa4b3
fix more linter issues
01cd561
update test recording using 0702preview
5a073c0
add license header in machine.py
7079435
Merge branch 'main' into jizen/create_machine_clipreview
FumingZhang 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
There are no files selected for viewing
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
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
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
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
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
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,136 @@ | ||
| # pylint: disable=too-many-lines | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from azext_aks_preview._client_factory import CUSTOM_MGMT_AKS_PREVIEW | ||
|
|
||
| from azure.cli.core.azclierror import RequiredArgumentMissingError | ||
|
|
||
| from azure.cli.core.util import sdk_no_wait | ||
|
|
||
|
|
||
| def add_machine(cmd, client, raw_parameters, no_wait): | ||
| resource_group_name = raw_parameters.get("resource_group_name") | ||
| cluster_name = raw_parameters.get("cluster_name") | ||
| nodepool_name = raw_parameters.get("nodepool_name") | ||
| machine_name = raw_parameters.get("machine_name") | ||
|
|
||
zjpjack-github marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| machine = constructMachine(cmd, raw_parameters, machine_name) | ||
|
|
||
| return sdk_no_wait( | ||
| no_wait, | ||
| client.begin_create_or_update, | ||
| resource_group_name, | ||
| cluster_name, | ||
| nodepool_name, | ||
| machine_name, | ||
| machine, | ||
| ) | ||
|
|
||
|
|
||
| def constructMachine(cmd, raw_parameters, machine_name): | ||
| machine_name = raw_parameters.get("machine_name") | ||
| if machine_name is None: | ||
| raise RequiredArgumentMissingError( | ||
| "Please specify --machine-name." | ||
| ) | ||
| MachineProperties = cmd.get_models( | ||
| "MachineProperties", | ||
| resource_type=CUSTOM_MGMT_AKS_PREVIEW, | ||
| operation_group="machines" | ||
| ) | ||
| tags = raw_parameters.get("tags") | ||
| priority = raw_parameters.get("priority") | ||
| machineProperties = MachineProperties( | ||
| tags=tags, | ||
| priority=priority, | ||
| network=set_machine_network(cmd, raw_parameters), | ||
| hardware=set_machine_hardware_profile(cmd, raw_parameters), | ||
| kubernetes=set_machine_kubernetes_profile(cmd, raw_parameters), | ||
| operating_system=set_machine_os_profile(cmd, raw_parameters) | ||
| ) | ||
| Machine = cmd.get_models( | ||
| "Machine", | ||
| resource_type=CUSTOM_MGMT_AKS_PREVIEW, | ||
| operation_group="machines" | ||
| ) | ||
| zones = raw_parameters.get("zones", []) | ||
| machine = Machine( | ||
| zones=zones, | ||
| properties=machineProperties | ||
| ) | ||
| return machine | ||
|
|
||
|
|
||
| def set_machine_hardware_profile(cmd, raw_parameters): | ||
| vm_size = raw_parameters.get("vm_size") | ||
| if vm_size is None: | ||
| raise RequiredArgumentMissingError( | ||
| "Please specify --vm-size." | ||
| ) | ||
| MachineHardwareProfile = cmd.get_models( | ||
zjpjack-github marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "MachineHardwareProfile", | ||
| resource_type=CUSTOM_MGMT_AKS_PREVIEW, | ||
| operation_group="machines" | ||
| ) | ||
| machine_hardware_profile = MachineHardwareProfile( | ||
| vm_size=vm_size | ||
| ) | ||
| return machine_hardware_profile | ||
|
|
||
|
|
||
| def set_machine_network(cmd, raw_parameters): | ||
| MachineNetworkProperties = cmd.get_models( | ||
| "MachineNetworkProperties", | ||
| resource_type=CUSTOM_MGMT_AKS_PREVIEW, | ||
| operation_group="machines" | ||
| ) | ||
| vnet_subnet_id = raw_parameters.get("vnet_subnet_id") | ||
| pod_subnet_id = raw_parameters.get("pod_subnet_id") | ||
| enable_node_public_ip = raw_parameters.get("enable_node_public_ip") | ||
| node_public_ip_prefix_id = raw_parameters.get("node_public_ip_prefix_id") | ||
| node_public_ip_tags = raw_parameters.get("node_public_ip_tags") | ||
| machineNetworkProperties = MachineNetworkProperties( | ||
| vnet_subnet_id=vnet_subnet_id, | ||
| pod_subnet_id=pod_subnet_id, | ||
| enable_node_public_ip=enable_node_public_ip, | ||
| node_public_ip_prefix_id=node_public_ip_prefix_id, | ||
| node_public_ip_tags=node_public_ip_tags | ||
| ) | ||
| return machineNetworkProperties | ||
|
|
||
|
|
||
| def set_machine_kubernetes_profile(cmd, raw_parameters): | ||
| kubernetes_version = raw_parameters.get("kubernetes_version") | ||
| MachineKubernetesProfile = cmd.get_models( | ||
| "MachineKubernetesProfile", | ||
| resource_type=CUSTOM_MGMT_AKS_PREVIEW, | ||
| operation_group="machines" | ||
| ) | ||
| machineKubernetesProfile = MachineKubernetesProfile( | ||
| orchestrator_version=kubernetes_version | ||
| ) | ||
| return machineKubernetesProfile | ||
|
|
||
|
|
||
| def set_machine_os_profile(cmd, raw_parameters): | ||
| MachineOSProfile = cmd.get_models( | ||
| "MachineOSProfile", | ||
| resource_type=CUSTOM_MGMT_AKS_PREVIEW, | ||
| operation_group="machines" | ||
| ) | ||
| os_type = raw_parameters.get("os_type") | ||
| os_sku = raw_parameters.get("os_sku") | ||
| enable_fips = False | ||
| if raw_parameters.get("enable_fips_image"): | ||
| enable_fips = True | ||
| if raw_parameters.get("disable_fips_image"): | ||
| enable_fips = False | ||
| machineOSProfile = MachineOSProfile( | ||
| os_type=os_type, | ||
| os_sku=os_sku, | ||
| enable_fips=enable_fips | ||
| ) | ||
| return machineOSProfile | ||
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.