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

Fixed the problem with the slaacSupport #245

Merged
merged 7 commits into from
May 14, 2024
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
111 changes: 60 additions & 51 deletions plugins/modules/network_settings_workflow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,17 @@
type: str
ipv6_prefix:
description: >
Ipv6 prefix value is true, the ip6 prefix length input field is enabled,
if it is false ipv6 total Host input is enable.
Determines whether to enable the 'ipv6_prefix_length' or 'ipv6_total_host' input field.
If IPv6 prefix value is true, the IPv6 prefix length input field is required,
If it is false ipv6 total Host input is required.
type: bool
ipv6_prefix_length:
description: IPv6 prefix length is required when the ipv6_prefix value is true.
description: Specifies the IPv6 prefix length. Required when 'ipv6_prefix' is set to true.
type: int
ipv6_total_host:
description: The total number of hosts for IPv6 is required if the 'ipv6_prefix' is set to false.
description:
MUTHU-RAKESH-27 marked this conversation as resolved.
Show resolved Hide resolved
- Specifies the total number of IPv6 hosts. Required when 'ipv6_prefix' is set to false.
- Must specify a number of IPv6 IP addresses that is less than 256.
type: int
prev_name:
description: The former name associated with the reserved IP sub-pool.
Expand Down Expand Up @@ -873,60 +876,61 @@ def get_reserve_pool_params(self, pool_info):
"name": pool_info.get("groupName"),
"site_id": pool_info.get("siteId"),
}
if len(pool_info.get("ipPools")) == 1:
pool_info_ippools = pool_info.get("ipPools")
pool_info_length = len(pool_info_ippools)

# If the reserved pool has only IPv4, pool_info_length will be 1.
# If the reserved pool has both IPv4 and IPv6, pool_info_length will be 2.
if pool_info_length == 1:
MUTHU-RAKESH-27 marked this conversation as resolved.
Show resolved Hide resolved
reserve_pool.update({
"ipv4DhcpServers": pool_info.get("ipPools")[0].get("dhcpServerIps"),
"ipv4DnsServers": pool_info.get("ipPools")[0].get("dnsServerIps"),
"ipv4DhcpServers": pool_info_ippools[0].get("dhcpServerIps"),
"ipv4DnsServers": pool_info_ippools[0].get("dnsServerIps"),
"ipv6AddressSpace": "False"
})
if pool_info.get("ipPools")[0].get("gateways") != []:
reserve_pool.update({"ipv4GateWay": pool_info.get("ipPools")[0].get("gateways")[0]})
if pool_info_ippools[0].get("gateways") != []:
reserve_pool.update({"ipv4GateWay": pool_info_ippools[0].get("gateways")[0]})
else:
reserve_pool.update({"ipv4GateWay": ""})
reserve_pool.update({"ipv6AddressSpace": "False"})
elif len(pool_info.get("ipPools")) == 2:
if not pool_info.get("ipPools")[0].get("ipv6"):
reserve_pool.update({
"ipv4DhcpServers": pool_info.get("ipPools")[0].get("dhcpServerIps"),
"ipv4DnsServers": pool_info.get("ipPools")[0].get("dnsServerIps"),
"ipv6AddressSpace": "True",
"ipv6DhcpServers": pool_info.get("ipPools")[1].get("dhcpServerIps"),
"ipv6DnsServers": pool_info.get("ipPools")[1].get("dnsServerIps"),

})
else:

if pool_info.get("ipPools")[0].get("gateways") != []:
reserve_pool.update({"ipv4GateWay":
pool_info.get("ipPools")[0].get("gateways")[0]})
else:
reserve_pool.update({"ipv4GateWay": ""})
# If the ipv6 flag is set in the second element, ipv4_index will be 0 and ipv6_index will be 1.
# If the ipv6 flag is set in the first element, ipv4_index will be 1 and ipv6_index will be 0.
if not pool_info_ippools[0].get("ipv6"):
MUTHU-RAKESH-27 marked this conversation as resolved.
Show resolved Hide resolved
ipv4_index = 0
ipv6_index = 1
else:
ipv4_index = 1
ipv6_index = 0

if pool_info.get("ipPools")[1].get("gateways") != []:
reserve_pool.update({"ipv6GateWay":
pool_info.get("ipPools")[1].get("gateways")[0]})
else:
reserve_pool.update({"ipv6GateWay": ""})
reserve_pool.update({
"ipv4DhcpServers": pool_info_ippools[ipv4_index].get("dhcpServerIps"),
"ipv4DnsServers": pool_info_ippools[ipv4_index].get("dnsServerIps"),
"ipv6AddressSpace": "True",
"ipv6Prefix": "True",
MUTHU-RAKESH-27 marked this conversation as resolved.
Show resolved Hide resolved
"ipv6DnsServers": pool_info_ippools[ipv6_index].get("dnsServerIps"),
"ipv6DhcpServers": pool_info_ippools[ipv6_index].get("dhcpServerIps")
})
if pool_info_ippools[ipv4_index].get("gateways") != []:
reserve_pool.update({"ipv4GateWay":
pool_info_ippools[ipv4_index].get("gateways")[0]})
else:
reserve_pool.update({"ipv4GateWay": ""})

elif not pool_info.get("ipPools")[1].get("ipv6"):
if pool_info_ippools[ipv6_index].get("gateways") != []:
reserve_pool.update({
"ipv4DhcpServers": pool_info.get("ipPools")[1].get("dhcpServerIps"),
"ipv4DnsServers": pool_info.get("ipPools")[1].get("dnsServerIps"),
"ipv6AddressSpace": "True",
"ipv6DnsServers": pool_info.get("ipPools")[0].get("dnsServerIps"),
"ipv6DhcpServers": pool_info.get("ipPools")[0].get("dhcpServerIps")
"ipv6GateWay": pool_info_ippools[ipv6_index].get("gateways")[0]
})
if pool_info.get("ipPools")[1].get("gateways") != []:
reserve_pool.update({"ipv4GateWay":
pool_info.get("ipPools")[1].get("gateways")[0]})
else:
reserve_pool.update({"ipv4GateWay": ""})
else:
reserve_pool.update({"ipv6GateWay": ""})

ippools_info = pool_info_ippools[ipv6_index].get("context")
slaac_support_info = get_dict_result(ippools_info, "contextKey", "slaacSupport")
if slaac_support_info is None or slaac_support_info.get("contextValue") == "false":
reserve_pool.update({"slaacSupport": False})
else:
reserve_pool.update({"slaacSupport": True})

if pool_info.get("ipPools")[0].get("gateways") != []:
reserve_pool.update({"ipv6GateWay":
pool_info.get("ipPools")[0].get("gateways")[0]})
else:
reserve_pool.update({"ipv6GateWay": ""})
reserve_pool.update({"slaacSupport": True})
self.log("Formatted reserve pool details: {0}".format(reserve_pool), "DEBUG")
return reserve_pool

Expand Down Expand Up @@ -1528,7 +1532,8 @@ def get_want_reserve_pool(self, reserve_pool):
"ipv6Subnet": item.get("ipv6_subnet"),
"ipv6DnsServers": item.get("ipv6_dns_servers"),
"ipv4TotalHost": item.get("ipv4_total_host"),
"ipv6TotalHost": item.get("ipv6_total_host")
"ipv6TotalHost": item.get("ipv6_total_host"),
"slaacSupport": item.get("slaac_support")
}
# Check for missing mandatory parameters in the playbook
if pool_values.get("ipv6AddressSpace") is True:
Expand Down Expand Up @@ -1600,13 +1605,17 @@ def get_want_reserve_pool(self, reserve_pool):
if pool_values.get(key) is None:
del pool_values[key]
else:
keys_to_delete = ['type', 'ipv4GlobalPool',
'ipv4Prefix', 'ipv4PrefixLength',
'ipv4TotalHost', 'ipv4Subnet']
keys_to_delete = ['type', 'ipv4GlobalPool', 'ipv4Prefix', 'ipv4PrefixLength',
'ipv4TotalHost', 'ipv4Subnet', 'slaacSupport']
for key in keys_to_delete:
if key in pool_values:
del pool_values[key]

copy_pool_values = copy.deepcopy(pool_values)
for item in copy_pool_values:
if pool_values.get(item) is None:
del pool_values[item]

want_reserve.append(pool_values)
reserve_pool_index += 1

Expand Down Expand Up @@ -2050,7 +2059,7 @@ def update_reserve_pool(self, reserve_pool):
self.check_execution_response_status(response).check_return_status()
self.log("Reserved ip subpool '{0}' updated successfully.".format(name), "INFO")
result_reserve_pool.get("response") \
.update({name: self.have.get("reservePool")[reserve_pool_index].get("details")})
.update({name: reserve_params})
result_reserve_pool.get("response").get(name) \
.update({"Id": self.have.get("reservePool")[reserve_pool_index].get("id")})
result_reserve_pool.get("msg") \
Expand Down