mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
Fix support for SubnetMappings and EIPs in NLB (#42979)
* Fix support for SubnetMappings and EIPs in NLB * Fix style failures
This commit is contained in:
parent
8c64b4af7c
commit
fbac32c5d0
1 changed files with 27 additions and 13 deletions
|
@ -152,27 +152,31 @@ class ElasticLoadBalancerV2(object):
|
||||||
:return: bool True if they match otherwise False
|
:return: bool True if they match otherwise False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
subnet_id_list = []
|
subnet_mapping_id_list = []
|
||||||
subnets = []
|
subnet_mappings = []
|
||||||
|
|
||||||
# Check if we're dealing with subnets or subnet_mappings
|
# Check if we're dealing with subnets or subnet_mappings
|
||||||
if self.subnets is not None:
|
if self.subnets is not None:
|
||||||
# We need to first get the subnet ID from the list
|
# Convert subnets to subnet_mappings format for comparison
|
||||||
subnets = self.subnets
|
for subnet in self.subnets:
|
||||||
|
subnet_mappings.append({'SubnetId': subnet})
|
||||||
|
|
||||||
if self.subnet_mappings is not None:
|
if self.subnet_mappings is not None:
|
||||||
# Make a list from the subnet_mappings dict
|
# Use this directly since we're comparing as a mapping
|
||||||
subnets_from_mappings = []
|
subnet_mappings = self.subnet_mappings
|
||||||
for subnet_mapping in self.subnet_mappings:
|
|
||||||
subnets.append(subnet_mapping['SubnetId'])
|
|
||||||
|
|
||||||
|
# Build a subnet_mapping style struture of what's currently
|
||||||
|
# on the load balancer
|
||||||
for subnet in self.elb['AvailabilityZones']:
|
for subnet in self.elb['AvailabilityZones']:
|
||||||
subnet_id_list.append(subnet['SubnetId'])
|
this_mapping = {'SubnetId': subnet['SubnetId']}
|
||||||
|
for address in subnet['LoadBalancerAddresses']:
|
||||||
|
if 'AllocationId' in address:
|
||||||
|
this_mapping['AllocationId'] = address['AllocationId']
|
||||||
|
break
|
||||||
|
|
||||||
if set(subnet_id_list) != set(subnets):
|
subnet_mapping_id_list.append(this_mapping)
|
||||||
return False
|
|
||||||
else:
|
return set(frozenset(mapping.items()) for mapping in subnet_mapping_id_list) == set(frozenset(mapping.items()) for mapping in subnet_mappings)
|
||||||
return True
|
|
||||||
|
|
||||||
def modify_subnets(self):
|
def modify_subnets(self):
|
||||||
"""
|
"""
|
||||||
|
@ -359,6 +363,8 @@ class NetworkLoadBalancer(ElasticLoadBalancerV2):
|
||||||
# Other parameters
|
# Other parameters
|
||||||
if self.subnets is not None:
|
if self.subnets is not None:
|
||||||
params['Subnets'] = self.subnets
|
params['Subnets'] = self.subnets
|
||||||
|
if self.subnet_mappings is not None:
|
||||||
|
params['SubnetMappings'] = self.subnet_mappings
|
||||||
params['Scheme'] = self.scheme
|
params['Scheme'] = self.scheme
|
||||||
if self.tags:
|
if self.tags:
|
||||||
params['Tags'] = self.tags
|
params['Tags'] = self.tags
|
||||||
|
@ -400,6 +406,14 @@ class NetworkLoadBalancer(ElasticLoadBalancerV2):
|
||||||
AWSRetry.jittered_backoff()(self.connection.delete_load_balancer)(LoadBalancerArn=self.elb['LoadBalancerArn'])
|
AWSRetry.jittered_backoff()(self.connection.delete_load_balancer)(LoadBalancerArn=self.elb['LoadBalancerArn'])
|
||||||
self.module.fail_json_aws(e)
|
self.module.fail_json_aws(e)
|
||||||
|
|
||||||
|
def modify_subnets(self):
|
||||||
|
"""
|
||||||
|
Modify elb subnets to match module parameters (unsupported for NLB)
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.module.fail_json(msg='Modifying subnets and elastic IPs is not supported for Network Load Balancer')
|
||||||
|
|
||||||
|
|
||||||
class ELBListeners(object):
|
class ELBListeners(object):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue