LP: #1902425 - keep trying new addresses when assigning on deploy.
Previously, the logic would retry only 2 times in case of any issue (call
error, IP in use).
If the call succeeds but the IP is in use, it should keep trying new addresses
until a free one is found.
LP: #1896684 - If no subnet gateway, only use in-subnet dns addresses
If DHCP is not providing any gateway, it should not provide any
DNS server addresses that aren't directly reachable.
Similarly, if the network preseed is not configuring any gateway,
it should not provide per-interface DNS server addresses, nor default
dns server addresses, that aren't directly reachable.
Only apply rack DNS server address if subnet.allow_dns == True
LP: #1893690 - Remove duplicate hardware UUIDs when detected.
Some Dell hardware uses the service number for the hardware UUID. This
value is not unqiue and causes commissioning to fail. MAAS uses the
hardware UUID to identify the machine when booting. Some hardware like
IBM Z series LPARs only identify themselves this way while PXE booting
tries the UUID first and then falls back on using a MAC address. If a
duplicate is detected remove the UUID from both machines.
Bug:1883748. Handle PermissionError in atomic_write()
If for any reason the permissions of the original file cannot be cloned
and set in the temporary file the PermissionError will be raised, before
this patch the exception will be unhandled leaving the temporary file
behind, which for situations where the the region or rack controllers
will retry the generation of said file (e.g. maas-proxy.conf) will
produce hundreds of files in a few minutes.
(cherry picked from commit 3fed50d6daeb21f9f4c67b42739e8512eb7b62ab)