Skip to content

Commit

Permalink
{AKS} Fix nat gateway models import error (#3988)
Browse files Browse the repository at this point in the history
* import nat models in a traditional way

* update version
  • Loading branch information
FumingZhang authored Oct 19, 2021
1 parent d473417 commit 0f51679
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@
logger = get_logger(__name__)


def prepare_nat_gateway_models():
from .vendored_sdks.azure_mgmt_preview_aks.v2021_09_01.models import ManagedClusterNATGatewayProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2021_09_01.models import ManagedClusterManagedOutboundIPProfile
nat_gateway_models = {}
nat_gateway_models["ManagedClusterNATGatewayProfile"] = ManagedClusterNATGatewayProfile
nat_gateway_models["ManagedClusterManagedOutboundIPProfile"] = ManagedClusterManagedOutboundIPProfile
return nat_gateway_models


def which(binary):
path_var = os.getenv('PATH')
if platform.system() == 'Windows':
Expand Down Expand Up @@ -988,9 +997,11 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
load_balancer_outbound_ports,
load_balancer_idle_timeout)

from azext_aks_preview.decorator import AKSPreviewModels
# store all the models used by nat gateway
nat_gateway_models = AKSPreviewModels(cmd, CUSTOM_MGMT_AKS_PREVIEW).nat_gateway_models
# TODO: uncomment the following after next cli release
# from azext_aks_preview.decorator import AKSPreviewModels
# # store all the models used by nat gateway
# nat_gateway_models = AKSPreviewModels(cmd, CUSTOM_MGMT_AKS_PREVIEW).nat_gateway_models
nat_gateway_models = prepare_nat_gateway_models()
nat_gateway_profile = create_nat_gateway_profile(
nat_gateway_managed_outbound_ip_count,
nat_gateway_idle_timeout,
Expand Down Expand Up @@ -1485,9 +1496,11 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
instance.network_profile.load_balancer_profile)

if update_natgw_profile:
from azext_aks_preview.decorator import AKSPreviewModels
# store all the models used by nat gateway
nat_gateway_models = AKSPreviewModels(cmd, CUSTOM_MGMT_AKS_PREVIEW).nat_gateway_models
# TODO: uncomment the following after next cli release
# from azext_aks_preview.decorator import AKSPreviewModels
# # store all the models used by nat gateway
# nat_gateway_models = AKSPreviewModels(cmd, CUSTOM_MGMT_AKS_PREVIEW).nat_gateway_models
nat_gateway_models = prepare_nat_gateway_models()
instance.network_profile.nat_gateway_profile = update_nat_gateway_profile(
nat_gateway_managed_outbound_ip_count,
nat_gateway_idle_timeout,
Expand Down

0 comments on commit 0f51679

Please sign in to comment.