Skip to content
16 changes: 10 additions & 6 deletions src/azure-cli/azure/cli/command_modules/aro/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from base64 import b64decode
import textwrap

from azure.core.exceptions import HttpResponseError
from azure.core.exceptions import HttpResponseError, \
ResourceNotFoundError as CoreResourceNotFoundError
from azure.mgmt.core.tools import resource_id, parse_resource_id
import azure.mgmt.redhatopenshift.models as openshiftcluster

Expand Down Expand Up @@ -462,11 +463,14 @@ def get_network_resources_from_subnets(cli_ctx, subnets, fail, oc):
Please retry, if issue persists: raise azure support ticket""")
logger.info("Failed to validate subnet '%s'", sn)

subnet = subnet_show(cli_ctx=cli_ctx)(command_args={
"name": sid['resource_name'],
"vnet_name": sid['name'],
"resource_group": sid['resource_group']
})
try:
subnet = subnet_show(cli_ctx=cli_ctx)(command_args={
"name": sid['resource_name'],
"vnet_name": sid['name'],
"resource_group": sid['resource_group']}
)
except CoreResourceNotFoundError:
continue

if subnet.get("routeTable", None):
subnet_resources.add(subnet["routeTable"]["id"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from azure.cli.core.azclierror import InvalidArgumentValueError
from azure.core.paging import ItemPaged
from ._client_factory import cf_postgres_flexible_location_capabilities, cf_postgres_flexible_server_capabilities
from collections import defaultdict


def get_postgres_location_capability_info(cmd, location):
Expand Down Expand Up @@ -99,12 +100,17 @@ def _postgres_parse_list_capability(result):
for version in result[0].supported_server_versions:
versions.add(version.name)

supported_server_versions = defaultdict(list)
for version in result[0].supported_server_versions:
supported_server_versions[version.name] = version.supported_versions_to_upgrade

return {
'sku_info': tiers_dict,
'single_az': single_az,
'geo_backup_supported': geo_backup_supported,
'zones': zones,
'server_versions': versions,
'supported_server_versions': supported_server_versions,
'index_tuning_supported': index_tuning_supported
}

Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/rdbms/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def _flexible_server_params(command_group):
)

pg_version_upgrade_arg_type = CLIArgumentType(
arg_type=get_enum_type(['12', '13', '14', '15', '16']),
arg_type=get_enum_type(['12', '13', '14', '15', '16', '17']),
options_list=['--version', '-v'],
help='Server major version.'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ._client_factory import cf_postgres_flexible_replica
from ._flexible_server_util import run_subprocess, \
fill_action_template, get_git_root_dir, resolve_poller, GITHUB_ACTION_PATH
from ._flexible_server_location_capabilities_util import get_postgres_server_capability_info
from .validators import validate_public_access_server, validate_resource_group, check_resource_group, validate_citus_cluster

logger = get_logger(__name__)
Expand Down Expand Up @@ -304,6 +305,19 @@ def flexible_server_version_upgrade(cmd, client, resource_group_name, server_nam
"We recommend selecting PostgreSQL 13 or a later version for "
"all future operations.")

list_server_capability_info = get_postgres_server_capability_info(cmd, resource_group_name, server_name)
eligible_versions = list_server_capability_info['supported_server_versions'][str(current_version)]

if version not in eligible_versions:
# version not supported
error_message = ""
if len(eligible_versions) > 0:
error_message = "Server is running version {}. It can only be upgraded to the following versions: {} ".format(str(current_version), eligible_versions)
else:
error_message = "Server is running version {}. It cannot be upgraded to any higher version. ".format(str(current_version))

raise CLIError(error_message)

replica_operations_client = cf_postgres_flexible_replica(cmd.cli_ctx, '_')
version_mapped = version

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ def _compute_client_factory(cli_ctx, **kwargs):
aux_subscriptions=kwargs.get('aux_subscriptions'))


def cf_avail_set(cli_ctx, _):
return _compute_client_factory(cli_ctx).availability_sets


def cf_vm(cli_ctx, _):
return _compute_client_factory(cli_ctx).virtual_machines

Expand Down
31 changes: 0 additions & 31 deletions src/azure-cli/azure/cli/command_modules/vm/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,17 +1026,6 @@
text: az vm list-sizes -l westus
"""

helps['vm availability-set convert'] = """
type: command
short-summary: Convert an Azure Availability Set to contain VMs with managed disks.
examples:
- name: Convert an availabiity set to use managed disks by name.
text: az vm availability-set convert -g MyResourceGroup -n MyAvSet
- name: Convert an availability set to use managed disks by ID.
text: >
az vm availability-set convert --ids $(az vm availability-set list -g MyResourceGroup --query "[].id" -o tsv)
"""

helps['vm availability-set create'] = """
type: command
short-summary: Create an Azure Availability Set.
Expand All @@ -1046,26 +1035,6 @@
text: az vm availability-set create -n MyAvSet -g MyResourceGroup --platform-fault-domain-count 2 --platform-update-domain-count 2
"""

helps['vm availability-set list'] = """
type: command
short-summary: List availability sets.
examples:
- name: List availability sets.
text: az vm availability-set list -g MyResourceGroup
"""

helps['vm availability-set update'] = """
type: command
short-summary: Update an Azure Availability Set.
examples:
- name: Update an availability set.
text: az vm availability-set update -n MyAvSet -g MyResourceGroup
- name: Update an availability set tag.
text: az vm availability-set update -n MyAvSet -g MyResourceGroup --set tags.foo=value
- name: Remove an availability set tag.
text: az vm availability-set update -n MyAvSet -g MyResourceGroup --remove tags.foo
"""

helps['vm boot-diagnostics'] = """
type: group
short-summary: Troubleshoot the startup of an Azure Virtual Machine.
Expand Down
14 changes: 3 additions & 11 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,9 @@ def load_arguments(self, _):
c.argument('platform_fault_domain_count', type=int, help='Fault Domain count.')
c.argument('validate', help='Generate and validate the ARM template without creating any resources.', action='store_true')
c.argument('unmanaged', action='store_true', min_api='2016-04-30-preview', help='contained VMs should use unmanaged disks')

with self.argument_context('vm availability-set update') as c:
if self.supported_api_version(max_api='2016-04-30-preview', operation_group='virtual_machines'):
c.argument('name', name_arg_type, id_part='name', completer=get_resource_name_completion_list('Microsoft.Compute/availabilitySets'), help='Name of the availability set')
c.argument('availability_set_name', options_list=['--availability-set-name'])

for scope in ['vm availability-set create', 'vm availability-set update']:
with self.argument_context(scope) as c:
c.argument('additional_scheduled_events', options_list=['--additional-scheduled-events', '--additional-events'], arg_type=get_three_state_flag(), min_api='2024-07-01', help='The configuration parameter used while creating event grid and resource graph scheduled event setting.')
c.argument('enable_user_reboot_scheduled_events', options_list=['--enable-user-reboot-scheduled-events', '--enable-reboot'], arg_type=get_three_state_flag(), min_api='2024-07-01', help='The configuration parameter used while publishing scheduled events additional publishing targets.')
c.argument('enable_user_redeploy_scheduled_events', options_list=['--enable-user-redeploy-scheduled-events', '--enable-redeploy'], arg_type=get_three_state_flag(), min_api='2024-07-01', help='The configuration parameter used while creating user initiated redeploy scheduled event setting creation.')
c.argument('additional_scheduled_events', options_list=['--additional-scheduled-events', '--additional-events'], arg_type=get_three_state_flag(), min_api='2024-07-01', help='The configuration parameter used while creating event grid and resource graph scheduled event setting.')
c.argument('enable_user_reboot_scheduled_events', options_list=['--enable-user-reboot-scheduled-events', '--enable-reboot'], arg_type=get_three_state_flag(), min_api='2024-07-01', help='The configuration parameter used while publishing scheduled events additional publishing targets.')
c.argument('enable_user_redeploy_scheduled_events', options_list=['--enable-user-redeploy-scheduled-events', '--enable-redeploy'], arg_type=get_three_state_flag(), min_api='2024-07-01', help='The configuration parameter used while creating user initiated redeploy scheduled event setting creation.')
# endregion

# region VirtualMachines
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/vm/_vm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def list_sku_info(cli_ctx, location=None):
from .aaz.latest.vm import ListSkus as _ListSkus

def _match_location(loc, locations):
return next((x for x in locations if x.lower() == loc.lower()), None)
return next((x for x in locations if str(x).lower() == str(loc).lower()), None)

result = _ListSkus(cli_ctx=cli_ctx)(command_args={})
if location:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@

from .__cmd_group import *
from ._delete import *
from ._list import *
from ._list_sizes import *
from ._show import *
from ._update import *
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class Delete(AAZCommand):
"""

_aaz_info = {
"version": "2022-11-01",
"version": "2024-07-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/availabilitysets/{}", "2022-11-01"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/availabilitysets/{}", "2024-07-01"],
]
}

Expand Down Expand Up @@ -118,7 +118,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2022-11-01",
"api-version", "2024-07-01",
required=True,
),
}
Expand Down
Loading
Loading