-
Notifications
You must be signed in to change notification settings - Fork 3.4k
{Network} workaround for load balancers about change of 'zone' #17088
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3287,7 +3287,7 @@ def create_lb_inbound_nat_rule( | |
| backend_port, frontend_ip_name=None, floating_ip=None, idle_timeout=None, enable_tcp_reset=None): | ||
| InboundNatRule = cmd.get_models('InboundNatRule') | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = ncf.load_balancers.get(resource_group_name, load_balancer_name) | ||
| lb = lb_get(ncf.load_balancers, resource_group_name, load_balancer_name) | ||
| if not frontend_ip_name: | ||
| frontend_ip_name = _get_default_name(lb, 'frontend_ip_configurations', '--frontend-ip-name') | ||
| frontend_ip = get_property(lb.frontend_ip_configurations, frontend_ip_name) # pylint: disable=no-member | ||
|
|
@@ -3303,6 +3303,21 @@ def create_lb_inbound_nat_rule( | |
| return get_property(poller.result().inbound_nat_rules, item_name) | ||
|
|
||
|
|
||
| # workaround for : https://github.com/Azure/azure-cli/issues/17071 | ||
| def lb_get(client, resource_group_name, load_balancer_name): | ||
| lb = client.get(resource_group_name, load_balancer_name) | ||
| return lb_get_operation(lb) | ||
|
|
||
|
|
||
| # workaround for : https://github.com/Azure/azure-cli/issues/17071 | ||
| def lb_get_operation(lb): | ||
| for item in lb.frontend_ip_configurations: | ||
| if item.zones is not None and len(item.zones) >= 3: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible that zones is [1, 2], [1, 2, 3, 4]?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (1)'zones' don't support input more than 1 |
||
| item.zones = None | ||
|
Comment on lines
+3315
to
+3316
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If user set zones [1, 2, 3] on purpose, the output of zones will be None?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a test and it does not influence.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can user set zones as [1, 2, 3] in current version? If they can what's the response now?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (1)'zones' don't support input more than 1 |
||
|
|
||
| return lb | ||
|
|
||
|
|
||
| def set_lb_inbound_nat_rule( | ||
| cmd, instance, parent, item_name, protocol=None, frontend_port=None, | ||
| frontend_ip_name=None, backend_port=None, floating_ip=None, idle_timeout=None, enable_tcp_reset=None): | ||
|
|
@@ -3329,7 +3344,7 @@ def create_lb_inbound_nat_pool( | |
| floating_ip=None, idle_timeout=None): | ||
| InboundNatPool = cmd.get_models('InboundNatPool') | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = ncf.load_balancers.get(resource_group_name, load_balancer_name) | ||
| lb = lb_get(ncf.load_balancers, resource_group_name, load_balancer_name) | ||
| if not frontend_ip_name: | ||
| frontend_ip_name = _get_default_name(lb, 'frontend_ip_configurations', '--frontend-ip-name') | ||
| frontend_ip = get_property(lb.frontend_ip_configurations, frontend_ip_name) \ | ||
|
|
@@ -3380,7 +3395,7 @@ def create_lb_frontend_ip_configuration( | |
| FrontendIPConfiguration, SubResource, Subnet = cmd.get_models( | ||
| 'FrontendIPConfiguration', 'SubResource', 'Subnet') | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = ncf.load_balancers.get(resource_group_name, load_balancer_name) | ||
| lb = lb_get(ncf.load_balancers, resource_group_name, load_balancer_name) | ||
|
|
||
| if private_ip_address_allocation is None: | ||
| private_ip_address_allocation = 'static' if private_ip_address else 'dynamic' | ||
|
|
@@ -3454,7 +3469,7 @@ def _process_vnet_name_and_id(vnet): | |
| if not isinstance(addr, dict): | ||
| raise CLIError('Each address in config file must be a dictionary. Please see example as a reference.') | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = ncf.load_balancers.get(resource_group_name, load_balancer_name) | ||
| lb = lb_get(ncf.load_balancers, resource_group_name, load_balancer_name) | ||
| (BackendAddressPool, | ||
| LoadBalancerBackendAddress, | ||
| VirtualNetwork) = cmd.get_models('BackendAddressPool', | ||
|
|
@@ -3495,7 +3510,7 @@ def _process_vnet_name_and_id(vnet): | |
| def delete_lb_backend_address_pool(cmd, resource_group_name, load_balancer_name, backend_address_pool_name): | ||
| from azure.cli.core.commands import LongRunningOperation | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = ncf.load_balancers.get(resource_group_name, load_balancer_name) | ||
| lb = lb_get(ncf.load_balancers, resource_group_name, load_balancer_name) | ||
|
|
||
| def delete_basic_lb_backend_address_pool(): | ||
| new_be_pools = [pool for pool in lb.backend_address_pools | ||
|
|
@@ -3596,7 +3611,7 @@ def create_cross_region_lb_frontend_ip_configuration( | |
| FrontendIPConfiguration, SubResource = cmd.get_models( | ||
| 'FrontendIPConfiguration', 'SubResource') | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = ncf.load_balancers.get(resource_group_name, load_balancer_name) | ||
| lb = lb_get(ncf.load_balancers, resource_group_name, load_balancer_name) | ||
|
|
||
| new_config = FrontendIPConfiguration( | ||
| name=item_name, | ||
|
|
@@ -3694,6 +3709,7 @@ def create_cross_region_lb_rule( | |
| LoadBalancingRule = cmd.get_models('LoadBalancingRule') | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = cached_get(cmd, ncf.load_balancers.get, resource_group_name, load_balancer_name) | ||
| lb = lb_get_operation(lb) | ||
| if not frontend_ip_name: | ||
| frontend_ip_name = _get_default_name(lb, 'frontend_ip_configurations', '--frontend-ip-name') | ||
| if not backend_address_pool_name: | ||
|
|
@@ -3788,7 +3804,7 @@ def create_lb_outbound_rule(cmd, resource_group_name, load_balancer_name, item_n | |
| outbound_ports=None, enable_tcp_reset=None, idle_timeout=None): | ||
| OutboundRule, SubResource = cmd.get_models('OutboundRule', 'SubResource') | ||
| client = network_client_factory(cmd.cli_ctx).load_balancers | ||
| lb = client.get(resource_group_name, load_balancer_name) | ||
| lb = lb_get(client, resource_group_name, load_balancer_name) | ||
| rule = OutboundRule( | ||
| protocol=protocol, enable_tcp_reset=enable_tcp_reset, idle_timeout_in_minutes=idle_timeout, | ||
| backend_address_pool=SubResource(id=backend_address_pool), | ||
|
|
@@ -3820,7 +3836,7 @@ def create_lb_probe(cmd, resource_group_name, load_balancer_name, item_name, pro | |
| path=None, interval=None, threshold=None): | ||
| Probe = cmd.get_models('Probe') | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = ncf.load_balancers.get(resource_group_name, load_balancer_name) | ||
| lb = lb_get(ncf.load_balancers, resource_group_name, load_balancer_name) | ||
| new_probe = Probe( | ||
| protocol=protocol, port=port, interval_in_seconds=interval, number_of_probes=threshold, | ||
| request_path=path, name=item_name) | ||
|
|
@@ -3848,6 +3864,7 @@ def create_lb_rule( | |
| LoadBalancingRule = cmd.get_models('LoadBalancingRule') | ||
| ncf = network_client_factory(cmd.cli_ctx) | ||
| lb = cached_get(cmd, ncf.load_balancers.get, resource_group_name, load_balancer_name) | ||
| lb = lb_get_operation(lb) | ||
| if not frontend_ip_name: | ||
| frontend_ip_name = _get_default_name(lb, 'frontend_ip_configurations', '--frontend-ip-name') | ||
| if not backend_address_pool_name: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
delete_lb_resource_property_entry_There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job. Will be fixed in another PR