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
18 changes: 9 additions & 9 deletions src/azure-cli/azure/cli/command_modules/acs/_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def configure_load_balancer_profile(managed_outbound_ip_count, managed_outbound_
outbound_ip_prefixes, outbound_ports, idle_timeout,
backend_pool_type, profile, models):
"""configure a load balancer with customer supplied values"""
if any([managed_outbound_ip_count,
managed_outbound_ipv6_count,
if any([managed_outbound_ip_count is not None,
managed_outbound_ipv6_count is not None,
outbound_ips,
outbound_ip_prefixes]):
outbound_ip_resources = _get_load_balancer_outbound_ips(outbound_ips, models)
Expand Down Expand Up @@ -93,7 +93,7 @@ def configure_load_balancer_profile(managed_outbound_ip_count, managed_outbound_
)
elif profile.outbound_ip_prefixes is not None:
profile.outbound_ip_prefixes = None
if managed_outbound_ip_count or managed_outbound_ipv6_count:
if managed_outbound_ip_count is not None or managed_outbound_ipv6_count is not None:
if profile.managed_outbound_i_ps is None:
if isinstance(models, SimpleNamespace):
ManagedClusterLoadBalancerProfileManagedOutboundIPs = (
Expand All @@ -104,13 +104,13 @@ def configure_load_balancer_profile(managed_outbound_ip_count, managed_outbound_
"ManagedClusterLoadBalancerProfileManagedOutboundIPs"
)
profile.managed_outbound_i_ps = ManagedClusterLoadBalancerProfileManagedOutboundIPs()
if managed_outbound_ip_count:
if managed_outbound_ip_count is not None:
profile.managed_outbound_i_ps.count = managed_outbound_ip_count
if managed_outbound_ipv6_count:
if managed_outbound_ipv6_count is not None:
profile.managed_outbound_i_ps.count_ipv6 = managed_outbound_ipv6_count
elif profile.managed_outbound_i_ps is not None:
profile.managed_outbound_i_ps = None
if outbound_ports:
if outbound_ports is not None:
profile.allocated_outbound_ports = outbound_ports
if idle_timeout:
profile.idle_timeout_in_minutes = idle_timeout
Expand All @@ -121,11 +121,11 @@ def configure_load_balancer_profile(managed_outbound_ip_count, managed_outbound_

def is_load_balancer_profile_provided(managed_outbound_ip_count, managed_outbound_ipv6_count, outbound_ips, ip_prefixes,
outbound_ports, backend_pool_type, idle_timeout):
return any([managed_outbound_ip_count,
managed_outbound_ipv6_count,
return any([managed_outbound_ip_count is not None,
managed_outbound_ipv6_count is not None,
outbound_ips,
ip_prefixes,
outbound_ports,
outbound_ports is not None,
idle_timeout,
backend_pool_type])

Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/acs/_natgateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def update_nat_gateway_profile(managed_outbound_ip_count, idle_timeout, profile,


def is_nat_gateway_profile_provided(managed_outbound_ip_count, idle_timeout):
return any([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:
if managed_outbound_ip_count is not None:
ManagedClusterManagedOutboundIPProfile = models.ManagedClusterManagedOutboundIPProfile
profile.managed_outbound_ip_profile = ManagedClusterManagedOutboundIPProfile(
count=managed_outbound_ip_count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6576,7 +6576,13 @@ def check_raw_parameters(self):
self.context.get_cluster_autoscaler_profile() is None and
self.context.get_api_server_authorized_ip_ranges() is None and
self.context.get_nodepool_labels() is None and
self.context.get_nodepool_taints() is None
self.context.get_nodepool_taints() is None and
self.context.get_load_balancer_managed_outbound_ip_count() is None and
self.context.get_load_balancer_managed_outbound_ipv6_count() is None and
self.context.get_load_balancer_idle_timeout() is None and
self.context.get_load_balancer_outbound_ports() is None and
self.context.get_nat_gateway_managed_outbound_ip_count() is None and
self.context.get_nat_gateway_idle_timeout() is None
)

if not is_changed and is_default:
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6203,6 +6203,15 @@ def test_aks_create_loadbalancer_then_update(self, resource_group, resource_grou
self.check('networkProfile.loadBalancerProfile.idleTimeoutInMinutes', 10)
])

# update
update_cmd = 'aks update --resource-group={resource_group} --name={name} ' \
'--load-balancer-outbound-ports 0'
self.cmd(update_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('networkProfile.loadBalancerProfile.allocatedOutboundPorts', 0),
self.check('networkProfile.loadBalancerProfile.idleTimeoutInMinutes', 10)
])

# delete
self.cmd(
'aks delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,50 @@ def test_update_load_balancer_profile(self):
self.assertEqual(p.idle_timeout_in_minutes, 3600)
self.assertEqual(p.backend_pool_type, "nodeIP")

def test_update_load_balancer_profile_reset_empty(self):
cmd = MockCmd(MockCLI())
managed_outbound_ip_count = 0
managed_outbound_ipv6_count = None
outbound_ips = None
outbound_ip_prefixes = None
outbound_ports = 0
idle_timeout = 3600
backend_pool_type = "nodeIP"

# store all the models used by load balancer
load_balancer_models = AKSManagedClusterModels(cmd, ResourceType.MGMT_CONTAINERSERVICE).load_balancer_models
ManagedClusterLoadBalancerProfile = (
load_balancer_models.ManagedClusterLoadBalancerProfile
)
ManagedClusterLoadBalancerProfileManagedOutboundIPs = (
load_balancer_models.ManagedClusterLoadBalancerProfileManagedOutboundIPs
)
ManagedClusterLoadBalancerProfileOutboundIPs = (
load_balancer_models.ManagedClusterLoadBalancerProfileOutboundIPs
)
profile = ManagedClusterLoadBalancerProfile()
profile.managed_outbound_i_ps = ManagedClusterLoadBalancerProfileManagedOutboundIPs(
count=2,
count_ipv6=3
)

p = loadbalancer.configure_load_balancer_profile(
managed_outbound_ip_count,
managed_outbound_ipv6_count,
outbound_ips,
outbound_ip_prefixes,
outbound_ports,
idle_timeout,
backend_pool_type,
profile,
load_balancer_models,
)

self.assertEqual(p.managed_outbound_i_ps.count, 0)
self.assertEqual(p.allocated_outbound_ports, 0)
self.assertEqual(p.idle_timeout_in_minutes, 3600)
self.assertEqual(p.backend_pool_type, "nodeIP")

def test_configure_load_balancer_profile_error(self):
cmd = MockCmd(MockCLI())
managed_outbound_ip_count = 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def test_nonempty_arguments(self):
result = natgateway.is_nat_gateway_profile_provided(1, 4)
self.assertTrue(result)

def test_nonempty_arguments(self):
result = natgateway.is_nat_gateway_profile_provided(0, None)
self.assertTrue(result)

if __name__ == "__main__":
unittest.main()