@@ -118,18 +118,18 @@ def get_key_vault_base_url(cli_ctx, vault_name):
118118
119119
120120def list_sku_info (cli_ctx , location = None ):
121- from ._client_factory import _compute_client_factory
121+ from .aaz . latest . vm import ListSkus as _ListSkus
122122
123123 def _match_location (loc , locations ):
124124 return next ((x for x in locations if x .lower () == loc .lower ()), None )
125125
126- client = _compute_client_factory (cli_ctx )
127- result = client .resource_skus .list ()
126+ result = _ListSkus (cli_ctx = cli_ctx )(command_args = {})
128127 if location :
129- result = [r for r in result if _match_location (location , r . locations )]
128+ result = [r for r in result if _match_location (location , r [ ' locations' ] )]
130129 return result
131130
132131
132+ # pylint: disable=line-too-long
133133def is_sku_available (cmd , sku_info , zone ):
134134 """
135135 The SKU is unavailable in the following cases:
@@ -140,19 +140,19 @@ def is_sku_available(cmd, sku_info, zone):
140140 is_available = True
141141 is_restrict_zone = False
142142 is_restrict_location = False
143- if not sku_info .restrictions :
143+ if not sku_info .get ( ' restrictions' , []) :
144144 return is_available
145- for restriction in sku_info . restrictions :
146- if restriction .reason_code == 'NotAvailableForSubscription' :
145+ for restriction in sku_info [ ' restrictions' ] :
146+ if restriction .get ( ' reason_code' , '' ) == 'NotAvailableForSubscription' :
147147 # The attribute location_info is not supported in versions 2017-03-30 and earlier
148148 if cmd .supported_api_version (max_api = '2017-03-30' ):
149149 is_available = False
150150 break
151- if restriction . type == 'Zone' and not (
152- set (sku_info . location_info [0 ].zones or []) - set (restriction . restriction_info . zones or [] )):
151+ if restriction [ ' type' ] == 'Zone' and not (
152+ set (sku_info [ ' location_info' ] [0 ].get ( ' zones' , [])) - set (restriction [ ' restriction_info' ]. get ( ' zones' , []) )):
153153 is_restrict_zone = True
154- if restriction . type == 'Location' and (
155- sku_info . location_info [0 ]. location in (restriction . restriction_info . locations or [] )):
154+ if restriction [ ' type' ] == 'Location' and (
155+ sku_info [ ' location_info' ] [0 ][ ' location' ] in (restriction [ ' restriction_info' ]. get ( ' locations' , []) )):
156156 is_restrict_location = True
157157
158158 if is_restrict_location or (is_restrict_zone and zone ):
0 commit comments