Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
from collections import defaultdict


def get_postgres_location_capability_info(cmd, location):
def get_postgres_location_capability_info(cmd, location, is_offer_restriction_check_required=False):
list_location_capability_client = cf_postgres_flexible_location_capabilities(cmd.cli_ctx, '_')
list_location_capability_result = list_location_capability_client.execute(location)
return _postgres_parse_list_capability(list_location_capability_result)
return _postgres_parse_list_capability(list_location_capability_result, is_offer_restriction_check_required)


def get_postgres_server_capability_info(cmd, resource_group, server_name):
def get_postgres_server_capability_info(cmd, resource_group, server_name, is_offer_restriction_check_required=False):
list_server_capability_client = cf_postgres_flexible_server_capabilities(cmd.cli_ctx, '_')
list_server_capability_result = list_server_capability_client.list(resource_group_name=resource_group, server_name=server_name)
return _postgres_parse_list_capability(list_server_capability_result)
return _postgres_parse_list_capability(list_server_capability_result, is_offer_restriction_check_required)


def get_performance_tiers_for_storage(storage_edition, storage_size):
Expand All @@ -41,7 +41,8 @@ def get_performance_tiers(storage_edition):
return performance_tiers


def _postgres_parse_list_capability(result):
# pylint: disable=too-many-locals
def _postgres_parse_list_capability(result, is_offer_restriction_check_required=False):
result = _get_list_from_paged_response(result)

if not result:
Expand All @@ -54,10 +55,10 @@ def _postgres_parse_list_capability(result):
geo_backup = [feature for feature in supported_features if feature.name == "GeoBackup"]
index_tuning = [feature for feature in supported_features if feature.name == "IndexTuning"]

if restricted == "Enabled":
if restricted == "Enabled" and not is_offer_restriction_check_required:
raise InvalidArgumentValueError("The location is restricted for provisioning of flexible servers. Please try using another region.")

if restricted != "Disabled":
if restricted != "Disabled" and not is_offer_restriction_check_required:
raise InvalidArgumentValueError("No available SKUs in this location.")

single_az = zone_redundant[0].status != "Enabled" if zone_redundant else True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ def index_tuning_update(cmd, client, resource_group_name, server_name, index_tun
postgres_source_client = get_postgresql_flexible_management_client(cmd.cli_ctx, subscription)
source_server_object = postgres_source_client.servers.get(resource_group_name, server_name)
location = ''.join(source_server_object.location.lower().split())
list_location_capability_info = get_postgres_location_capability_info(cmd, location)
list_location_capability_info = get_postgres_location_capability_info(cmd, location, is_offer_restriction_check_required=True)
index_tuning_supported = list_location_capability_info['index_tuning_supported']
if not index_tuning_supported:
raise CLIError("Index tuning is not supported for the server.")
Expand Down
Loading