diff options
author | Daniel Watkins <oddbloke@ubuntu.com> | 2020-06-30 14:19:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-30 14:19:38 -0400 |
commit | 882f1a5f2d5bafd08e6900a2782c3affa67c9d86 (patch) | |
tree | 9cd90da0ae7068b3326617d093680ea7b5866cb8 /cloudinit/sources/helpers | |
parent | 66e114a660c53400e389f119781f378311b65108 (diff) | |
download | vyos-cloud-init-882f1a5f2d5bafd08e6900a2782c3affa67c9d86.tar.gz vyos-cloud-init-882f1a5f2d5bafd08e6900a2782c3affa67c9d86.zip |
networking: refactor is_physical from cloudinit.net (#457)
As the first refactor PR, this also includes the initial structure for tests.
LP: #1884619
Diffstat (limited to 'cloudinit/sources/helpers')
-rw-r--r-- | cloudinit/sources/helpers/digitalocean.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cloudinit/sources/helpers/digitalocean.py b/cloudinit/sources/helpers/digitalocean.py index f5bbe46a..b545c4d6 100644 --- a/cloudinit/sources/helpers/digitalocean.py +++ b/cloudinit/sources/helpers/digitalocean.py @@ -16,7 +16,7 @@ NIC_MAP = {'public': 'eth0', 'private': 'eth1'} LOG = logging.getLogger(__name__) -def assign_ipv4_link_local(nic=None): +def assign_ipv4_link_local(distro, nic=None): """Bring up NIC using an address using link-local (ip4LL) IPs. On DigitalOcean, the link-local domain is per-droplet routed, so there is no risk of collisions. However, to be more safe, the ip4LL @@ -24,7 +24,7 @@ def assign_ipv4_link_local(nic=None): """ if not nic: - nic = get_link_local_nic() + nic = get_link_local_nic(distro) LOG.debug("selected interface '%s' for reading metadata", nic) if not nic: @@ -54,8 +54,12 @@ def assign_ipv4_link_local(nic=None): return nic -def get_link_local_nic(): - nics = [f for f in cloudnet.get_devicelist() if cloudnet.is_physical(f)] +def get_link_local_nic(distro): + nics = [ + f + for f in cloudnet.get_devicelist() + if distro.networking.is_physical(f) + ] if not nics: return None return min(nics, key=lambda d: cloudnet.read_sys_net_int(d, 'ifindex')) |