diff options
author | Douglas Jordan <dojordan@microsoft.com> | 2018-01-24 16:10:08 -0700 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-01-24 16:10:08 -0700 |
commit | c03bdd3d8ed762cada813c5e95a40b14d2047b57 (patch) | |
tree | 708422bb64a8804f649ad7558d5088f9e11011a4 /cloudinit/net/network_state.py | |
parent | 30597f28512fafbe25486df5865b628d859486c6 (diff) | |
download | vyos-cloud-init-c03bdd3d8ed762cada813c5e95a40b14d2047b57.tar.gz vyos-cloud-init-c03bdd3d8ed762cada813c5e95a40b14d2047b57.zip |
Azure VM Preprovisioning support.
This change will enable azure vms to report provisioning has completed
twice, first to tell the fabric it has completed then a second time to
enable customer settings. The datasource for the second provisioning is
the Instance Metadata Service (IMDS),and the VM will poll indefinitely for
the new ovf-env.xml from IMDS.
This branch introduces EphemeralDHCPv4 which encapsulates common logic
used by both DataSourceEc2 an DataSourceAzure for temporary DHCP
interactions without side-effects.
LP: #1734991
Diffstat (limited to 'cloudinit/net/network_state.py')
-rw-r--r-- | cloudinit/net/network_state.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py index 31738c73..fe667d88 100644 --- a/cloudinit/net/network_state.py +++ b/cloudinit/net/network_state.py @@ -961,4 +961,16 @@ def mask_to_net_prefix(mask): return ipv4_mask_to_net_prefix(mask) +def mask_and_ipv4_to_bcast_addr(mask, ip): + """Calculate the broadcast address from the subnet mask and ip addr. + + Supports ipv4 only.""" + ip_bin = int(''.join([bin(int(x) + 256)[3:] for x in ip.split('.')]), 2) + mask_dec = ipv4_mask_to_net_prefix(mask) + bcast_bin = ip_bin | (2**(32 - mask_dec) - 1) + bcast_str = '.'.join([str(bcast_bin >> (i << 3) & 0xFF) + for i in range(4)[::-1]]) + return bcast_str + + # vi: ts=4 expandtab |