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

{AKS} Fix nat gateway models import error #3988

Merged
merged 2 commits into from
Oct 19, 2021
Merged
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
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