-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
{AKS} Support reset default value for loadbalancer profile and natgat…
…eway profile
- Loading branch information
1 parent
e884e54
commit 578b53f
Showing
8 changed files
with
1,200 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from types import SimpleNamespace | ||
|
||
|
||
def create_nat_gateway_profile(managed_outbound_ip_count, idle_timeout, models: SimpleNamespace): | ||
"""parse and build NAT gateway profile""" | ||
if not is_nat_gateway_profile_provided(managed_outbound_ip_count, idle_timeout): | ||
return None | ||
|
||
profile = models.ManagedClusterNATGatewayProfile() | ||
return configure_nat_gateway_profile(managed_outbound_ip_count, idle_timeout, profile, models) | ||
|
||
|
||
def update_nat_gateway_profile(managed_outbound_ip_count, idle_timeout, profile, models: SimpleNamespace): | ||
"""parse and update an existing NAT gateway profile""" | ||
if not is_nat_gateway_profile_provided(managed_outbound_ip_count, idle_timeout): | ||
return profile | ||
if not profile: | ||
profile = models.ManagedClusterNATGatewayProfile() | ||
return configure_nat_gateway_profile(managed_outbound_ip_count, idle_timeout, profile, models) | ||
|
||
|
||
def is_nat_gateway_profile_provided(managed_outbound_ip_count, idle_timeout): | ||
return any([managed_outbound_ip_count is not None, idle_timeout]) | ||
|
||
|
||
def configure_nat_gateway_profile(managed_outbound_ip_count, idle_timeout, profile, models: SimpleNamespace): | ||
"""configure a NAT Gateway with customer supplied values""" | ||
if managed_outbound_ip_count is not None: | ||
ManagedClusterManagedOutboundIPProfile = models.ManagedClusterManagedOutboundIPProfile | ||
profile.managed_outbound_ip_profile = ManagedClusterManagedOutboundIPProfile( | ||
count=managed_outbound_ip_count | ||
) | ||
|
||
if idle_timeout: | ||
profile.idle_timeout_in_minutes = idle_timeout | ||
|
||
return profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.