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

{Compute} Detach Azure Stack from Profiles #30384

Merged
merged 29 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
463e567
detach azure stack
yanzhudd Nov 19, 2024
5742420
fix linter
yanzhudd Nov 20, 2024
e288f1c
fix
yanzhudd Nov 25, 2024
5e2ae6a
fix
yanzhudd Nov 25, 2024
22c2288
Merge branch 'dev' of https://github.com/Azure/azure-cli into detach-…
yanzhudd Nov 25, 2024
9925484
fix linter & style check
yanzhudd Nov 25, 2024
4840df9
fix linter
yanzhudd Nov 25, 2024
b7c5058
fix
yanzhudd Nov 25, 2024
c1b0ccb
[AKS] `az aks create/update`: Add support for feature Advanced Contai…
snguyen64 Nov 20, 2024
63474f5
{Network} `az network dns zone`: Fix for the zone import logic (#30383)
WhiteHorseV Nov 20, 2024
f7a5e48
{Pylint} Fix used-before-assignment (#30348)
jiasli Nov 20, 2024
371867d
{Pylint} Fix raising-bad-type (#30346)
jiasli Nov 20, 2024
9396442
{Pylint} Fix useless-object-inheritance (#30331)
atombrella Nov 20, 2024
e519611
[Core] PREVIEW: Support managed identity on Azure Arc-enabled Linux s…
jiasli Nov 20, 2024
4416855
{Pylint} Fix unused-private-member (#30347)
jiasli Nov 20, 2024
2a7f6e2
[Profile] Drop support for old-style managed identity account (#30321)
jiasli Nov 20, 2024
c930d57
{CI} Enable CodegenCoverage and drop kusto (#30375)
wangzelin007 Nov 21, 2024
34d9c1e
{Keyvault} Set `verify_challenge_resource` to `False` (#30386)
evelyn-ys Nov 21, 2024
7d96a58
{Network} `az network dns record-set naptr`: Naptr feature tests and …
WhiteHorseV Nov 25, 2024
5ac68e4
[Storage] `az storage account migration`: Add warning for long wait, …
calvinhzy Nov 25, 2024
12d621a
fix linter & style check
yanzhudd Nov 25, 2024
ad0de32
fix linter
yanzhudd Nov 25, 2024
c68960a
fix
yanzhudd Nov 25, 2024
20e7087
fix linter
yanzhudd Nov 25, 2024
8680057
Merge branch 'detach-azure-stack' of https://github.com/yanzhudd/azur…
yanzhudd Nov 25, 2024
3f3d615
fix
yanzhudd Nov 26, 2024
aa910c3
remove redundant spaces in examples
yanzhudd Nov 27, 2024
6dde94a
Merge branch 'dev' of https://github.com/Azure/azure-cli into detach-…
yanzhudd Nov 27, 2024
c9ec2cf
Merge branch 'detach-azure-stack' of https://github.com/yanzhudd/azur…
yanzhudd Nov 27, 2024
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
77 changes: 76 additions & 1 deletion src/azure-cli/azure/cli/command_modules/vm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,79 @@ def load_arguments(self, command):
pass


COMMAND_LOADER_CLS = ComputeCommandsLoader
class AzureStackComputeCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
compute_custom = CliCommandType(
operations_tmpl='azure.cli.command_modules.vm.azure_stack.custom#{}',
operation_group='virtual_machines'
)
super().__init__(cli_ctx=cli_ctx,
resource_type=ResourceType.MGMT_COMPUTE,
operation_group='virtual_machines',
custom_command_type=compute_custom)

def load_command_table(self, args):
from azure.cli.command_modules.vm.azure_stack.commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
except ImportError:
aaz = None

if aaz:
load_aaz_command_table(
loader=self,
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
try:
# When generated commands are required uncomment the following two lines.
from .generated.commands import load_command_table as load_command_table_generated
load_command_table_generated(self, args)
from .manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass

profile = self.get_module_by_profile("commands")
if profile and hasattr(profile, 'load_command_table'):
profile.load_command_table(self, args)

return self.command_table

def load_arguments(self, command):
from azure.cli.command_modules.vm.azure_stack._params import load_arguments
load_arguments(self, command)
try:
from .generated._params import load_arguments as load_arguments_generated
load_arguments_generated(self, command)
from .manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass

profile = self.get_module_by_profile("_params")
if profile and hasattr(profile, 'load_arguments'):
profile.load_arguments(self, command)

def get_module_name_by_profile(self, module_name):
from azure.cli.core.aaz.utils import get_aaz_profile_module_name
profile_module_name = get_aaz_profile_module_name(profile_name=self.cli_ctx.cloud.profile)
if module_name:
return f'azure.cli.command_modules.vm.azure_stack.{profile_module_name}.{module_name}'
return f'azure.cli.command_modules.vm.azure_stack.{profile_module_name}'

def get_module_by_profile(self, name):
import importlib
module_name = self.get_module_name_by_profile(name)
return importlib.import_module(module_name)


def get_command_loader(cli_ctx):
if cli_ctx.cloud.profile.lower() != "latest":
return AzureStackComputeCommandsLoader

return ComputeCommandsLoader
44 changes: 34 additions & 10 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,10 @@ def load_arguments(self, _):
c.argument('enable_auto_os_upgrade', enable_auto_os_upgrade_type)
c.argument('upgrade_policy_mode', help='Specify the mode of an upgrade to virtual machines in the scale set.', arg_type=get_enum_type(UpgradeMode))

for scope, help_prefix in [('vmss update', 'Update the'), ('vmss wait', 'Wait on the')]:
with self.argument_context(scope) as c:
c.argument('instance_id', id_part='child_name_1', help="{0} VM instance with this ID. If missing, {0} VMSS.".format(help_prefix))
with self.argument_context('vmss update') as c:
c.argument('instance_id', id_part='child_name_1', help="Update the VM instance with this ID. If missing, update the VMSS.")
with self.argument_context('vmss wait') as c:
c.argument('instance_id', id_part='child_name_1', help="Wait on the VM instance with this ID. If missing, wait on the VMSS.")

for scope in ['vmss update-instances', 'vmss delete-instances']:
with self.argument_context(scope) as c:
Expand Down Expand Up @@ -926,15 +927,18 @@ def load_arguments(self, _):
arg_type=get_three_state_flag(),
help='If set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.')

for scope in ['vm', 'vmss']:
with self.argument_context('{} run-command'.format(scope)) as c:
c.argument('command_id', completer=get_vm_run_command_completion_list, help="The command id. Use 'az {} run-command list' to get the list".format(scope))
if scope == 'vmss':
c.argument('vmss_name', vmss_name_type)

for scope in ['vm', 'vmss']:
with self.argument_context('{} run-command invoke'.format(scope)) as c:
c.argument('parameters', nargs='+', help="space-separated parameters in the format of '[name=]value'")
c.argument('scripts', nargs='+', help="Space-separated script lines. Use @{file} to load script from a file")

for scope in ['vm', 'vmss']:
with self.argument_context('{} stop'.format(scope)) as c:
c.argument('skip_shutdown', action='store_true', help='Skip shutdown and power-off immediately.', min_api='2019-03-01')

Expand Down Expand Up @@ -1083,6 +1087,7 @@ def load_arguments(self, _):
c.argument('os_disk_secure_vm_disk_encryption_set', min_api='2021-11-01', help='Specify the customer managed disk encryption set resource ID or name for the managed disk that is used for customer managed key encrypted Confidential VM OS disk and VM guest blob.')
c.argument('disable_integrity_monitoring_autoupgrade', action='store_true', min_api='2020-12-01', help='Disable auto upgrade of guest attestation extension for Trusted Launch enabled VMs and VMSS.')

for scope in ['vm create', 'vmss create']:
with self.argument_context(scope, arg_group='Authentication') as c:
c.argument('generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing. The keys will be stored in the ~/.ssh directory')
c.argument('ssh_key_type', arg_type=get_enum_type(['RSA', 'Ed25519']), default='RSA', min_api='2023-09-01', help='Specify the type of SSH public and private key files to be generated if missing.')
Expand All @@ -1092,6 +1097,7 @@ def load_arguments(self, _):
c.argument('ssh_dest_key_path', help='Destination file path on the VM for the SSH key. If the file already exists, the specified key(s) are appended to the file. Destination path for SSH public keys is currently limited to its default value "/home/username/.ssh/authorized_keys" due to a known issue in Linux provisioning agent.')
c.argument('authentication_type', help='Type of authentication to use with the VM. Defaults to password for Windows and SSH public key for Linux. "all" enables both ssh and password authentication. ', arg_type=get_enum_type(['ssh', 'password', 'all']))

for scope in ['vm create', 'vmss create']:
with self.argument_context(scope, arg_group='Storage') as c:
if DiskStorageAccountTypes:
allowed_values = ", ".join([sku.value for sku in DiskStorageAccountTypes])
Expand Down Expand Up @@ -1129,6 +1135,7 @@ def load_arguments(self, _):
c.argument('specialized', arg_type=get_three_state_flag(), help='Indicate whether the source image is specialized.')
c.argument('encryption_at_host', arg_type=get_three_state_flag(), help='Enable Host Encryption for the VM or VMSS. This will enable the encryption for all the disks including Resource/Temp disk at host itself.')

for scope in ['vm create', 'vmss create']:
with self.argument_context(scope, arg_group='Network') as c:
c.argument('vnet_name', help='Name of the virtual network when creating a new one or referencing an existing one.')
c.argument('vnet_address_prefix', help='The IP address prefix to use when creating a new VNet in CIDR format.')
Expand All @@ -1149,6 +1156,7 @@ def load_arguments(self, _):
'value to apply on all resources, or use <Name>=<Value> to configure '
'the delete behavior for individual resources. Possible options are Delete and Detach.')

for scope in ['vm create', 'vmss create']:
with self.argument_context(scope, arg_group='Marketplace Image Plan') as c:
c.argument('plan_name', help='plan name')
c.argument('plan_product', help='plan product')
Expand Down Expand Up @@ -1528,13 +1536,29 @@ def load_arguments(self, _):
c.argument('ppg_type', options_list=['--type', '-t'], arg_type=get_enum_type(self.get_models('ProximityPlacementGroupType')), min_api='2018-04-01', help="The type of the proximity placement group.")
c.argument('intent_vm_sizes', nargs='*', min_api='2021-11-01', help="Specify possible sizes of virtual machines that can be created in the proximity placement group.")

for scope, item in [('vm create', 'VM'), ('vmss create', 'VMSS'),
('vm availability-set create', 'availability set'),
('vm update', 'VM'), ('vmss update', 'VMSS'),
('vm availability-set update', 'availability set')]:
with self.argument_context(scope, min_api='2018-04-01') as c:
c.argument('proximity_placement_group', options_list=['--ppg'], help="The name or ID of the proximity placement group the {} should be associated with.".format(item),
validator=_validate_proximity_placement_group) # only availability set does not have a command level validator, so this should be added.
with self.argument_context('vm create', min_api='2018-04-01') as c:
c.argument('proximity_placement_group', options_list=['--ppg'], help="The name or ID of the proximity placement group the VM should be associated with.",
validator=_validate_proximity_placement_group)

with self.argument_context('vmss create', min_api='2018-04-01') as c:
c.argument('proximity_placement_group', options_list=['--ppg'], help="The name or ID of the proximity placement group the VMSS should be associated with.",
validator=_validate_proximity_placement_group)

with self.argument_context('vm availability-set create', min_api='2018-04-01') as c:
c.argument('proximity_placement_group', options_list=['--ppg'], help="The name or ID of the proximity placement group the availability set should be associated with.",
validator=_validate_proximity_placement_group)

with self.argument_context('vm update', min_api='2018-04-01') as c:
c.argument('proximity_placement_group', options_list=['--ppg'], help="The name or ID of the proximity placement group the VM should be associated with.",
validator=_validate_proximity_placement_group)

with self.argument_context('vmss update', min_api='2018-04-01') as c:
c.argument('proximity_placement_group', options_list=['--ppg'], help="The name or ID of the proximity placement group the VMSS should be associated with.",
validator=_validate_proximity_placement_group)

with self.argument_context('vm availability-set update', min_api='2018-04-01') as c:
c.argument('proximity_placement_group', options_list=['--ppg'], help="The name or ID of the proximity placement group the availability set should be associated with.",
validator=_validate_proximity_placement_group)
zhoxing-ms marked this conversation as resolved.
Show resolved Hide resolved
# endregion

# region VM Monitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class List(AAZCommand):
:example: List capacity reservation groups
az capacity reservation group list -g rg

:example: List the capacity reservation groups containing VM instances and VMSS instance which are associated to capacity reservation group
:example: List the capacity reservation groups containing VM instances and VMSS instance which are associated to capacity reservation group
az capacity reservation group list -g rg --vm-instance --vmss-instance
"""

Expand Down Expand Up @@ -200,6 +200,7 @@ def _build_schema_on_200(cls):
)
properties.instance_view = AAZObjectType(
serialized_name="instanceView",
flags={"read_only": True},
)
properties.sharing_profile = AAZObjectType(
serialized_name="sharingProfile",
Expand Down Expand Up @@ -404,6 +405,7 @@ def _build_schema_on_200(cls):
)
properties.instance_view = AAZObjectType(
serialized_name="instanceView",
flags={"read_only": True},
)
properties.sharing_profile = AAZObjectType(
serialized_name="sharingProfile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class __CMDGroup(AAZCommandGroup):
"""Manage Azure Managed Disks.

Azure Virtual Machines use disks as a place to store an operating system, applications, and data. All Azure virtual machines have at least two disks: An operating system disk, and a temporary disk. The operating system disk is created from an image, and both the operating system disk and the image are actually virtual hard disks (VHDs) stored in an Azure storage account. Virtual machines also can have one or more data disks, that are also stored as VHDs.
Azure Unmanaged Data Disks have a maximum size of 4095 GB. To use disks larger than 4095 GB use [Azure Managed Disks](https://docs.microsoft.com/azure/virtual-machines/managed-disks-overview)
Azure Unmanaged Data Disks have a maximum size of 4095 GB. To use disks larger than 4095 GB use [Azure Managed Disks](https://learn.microsoft.com/azure/virtual-machines/managed-disks-overview)
"""
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class __CMDGroup(AAZCommandGroup):
"""Manage Azure Network Security Groups (NSGs).

You can control network traffic to resources in a virtual network using a network security group. A network security group contains a list of security rules that allow or deny inbound or outbound network traffic based on source or destination IP addresses, Application Security Groups, ports, and protocols. For more information visit https://docs.microsoft.com/azure/virtual-network/virtual-networks-create-nsg-arm-cli.
You can control network traffic to resources in a virtual network using a network security group. A network security group contains a list of security rules that allow or deny inbound or outbound network traffic based on source or destination IP addresses, Application Security Groups, ports, and protocols. For more information visit https://learn.microsoft.com/azure/virtual-network/virtual-networks-create-nsg-arm-cli.
"""
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class __CMDGroup(AAZCommandGroup):
"""Manage public IP addresses.

To learn more about public IP addresses visit https://docs.microsoft.com/azure/virtual-network/virtual-network-public-ip-address.
To learn more about public IP addresses visit https://learn.microsoft.com/azure/virtual-network/virtual-network-public-ip-address.
"""
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class __CMDGroup(AAZCommandGroup):
"""Check if a private IP address is available for use within a virtual network.

To learn more about Virtual Networks visit https://docs.microsoft.com/azure/virtual-network/virtual-network-manage-network.
To learn more about Virtual Networks visit https://learn.microsoft.com/azure/virtual-network/virtual-network-manage-network.
"""
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class __CMDGroup(AAZCommandGroup):
"""Manage subnets in an Azure Virtual Network.

To learn more about subnets visit https://docs.microsoft.com/azure/virtual-network/virtual-network-manage-subnet.
To learn more about subnets visit https://learn.microsoft.com/azure/virtual-network/virtual-network-manage-subnet.
"""
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class __CMDGroup(AAZCommandGroup):
Azure Managed and Unmanaged Data Disks have a maximum size of 4095 GB (with the exception of
larger disks in preview). Azure Unmanaged Disks also have a maximum capacity of 4095 GB.
For more information, see:
- Azure Disks - https://docs.microsoft.com/azure/virtual-machines/managed-disks-overview.
- Azure Disks - https://learn.microsoft.com/azure/virtual-machines/managed-disks-overview.
- Larger Managed Disks in Public Preview - https://azure.microsoft.com/blog/introducing-the-
public-preview-of-larger-managed-disks-sizes/
- Ultra SSD Managed Disks in Public Preview - https://docs.microsoft.com/azure/virtual-
- Ultra SSD Managed Disks in Public Preview - https://learn.microsoft.com/azure/virtual-
machines/disks-types.
"""
pass
Expand Down
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(
"capacity",
)
class __CMDGroup(AAZCommandGroup):
"""Manage capacity.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# 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 *
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(
"capacity reservation",
)
class __CMDGroup(AAZCommandGroup):
"""Manage capacity reservation.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# 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 *
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(
"capacity reservation group",
)
class __CMDGroup(AAZCommandGroup):
"""Manage capacity reservation group.
"""
pass


__all__ = ["__CMDGroup"]
Loading