initial sweeping changes to call all usages of various interface related variables and functions (netif, interface, if, ifc, etc) to use a consistent name iface

This commit is contained in:
Blake Harnden 2020-06-16 09:30:16 -07:00
parent 0462c1b084
commit 0725199d6d
93 changed files with 1955 additions and 2156 deletions

View file

@ -55,8 +55,8 @@ class IPForwardService(UtilService):
""" % {
"sysctl": constants.SYSCTL_BIN
}
for ifc in node.netifs():
name = utils.sysctl_devname(ifc.name)
for iface in node.get_ifaces():
name = utils.sysctl_devname(iface.name)
cfg += "%s -w net.ipv4.conf.%s.forwarding=1\n" % (
constants.SYSCTL_BIN,
name,
@ -77,10 +77,10 @@ class DefaultRouteService(UtilService):
@classmethod
def generate_config(cls, node, filename):
routes = []
netifs = node.netifs(sort=True)
if netifs:
netif = netifs[0]
for x in netif.addrlist:
ifaces = node.get_ifaces()
if ifaces:
iface = ifaces[0]
for x in iface.addrlist:
net = netaddr.IPNetwork(x).cidr
if net.size > 1:
router = net[1]
@ -104,14 +104,12 @@ class DefaultMulticastRouteService(UtilService):
cfg += "# the first interface is chosen below; please change it "
cfg += "as needed\n"
for ifc in node.netifs():
if hasattr(ifc, "control") and ifc.control is True:
continue
for iface in node.get_ifaces(control=False):
if os.uname()[0] == "Linux":
rtcmd = "ip route add 224.0.0.0/4 dev"
else:
raise Exception("unknown platform")
cfg += "%s %s\n" % (rtcmd, ifc.name)
cfg += "%s %s\n" % (rtcmd, iface.name)
cfg += "\n"
break
return cfg
@ -129,10 +127,8 @@ class StaticRouteService(UtilService):
cfg += "# auto-generated by StaticRoute service (utility.py)\n#\n"
cfg += "# NOTE: this service must be customized to be of any use\n"
cfg += "# Below are samples that you can uncomment and edit.\n#\n"
for ifc in node.netifs():
if hasattr(ifc, "control") and ifc.control is True:
continue
cfg += "\n".join(map(cls.routestr, ifc.addrlist))
for iface in node.get_ifaces(control=False):
cfg += "\n".join(map(cls.routestr, iface.addrlist))
cfg += "\n"
return cfg
@ -259,10 +255,8 @@ max-lease-time 7200;
ddns-update-style none;
"""
for ifc in node.netifs():
if hasattr(ifc, "control") and ifc.control is True:
continue
cfg += "\n".join(map(cls.subnetentry, ifc.addrlist))
for iface in node.get_ifaces(control=False):
cfg += "\n".join(map(cls.subnetentry, iface.addrlist))
cfg += "\n"
return cfg
@ -320,13 +314,11 @@ class DhcpClientService(UtilService):
cfg += "side DNS\n# resolution based on the DHCP server response.\n"
cfg += "#mkdir -p /var/run/resolvconf/interface\n"
for ifc in node.netifs():
if hasattr(ifc, "control") and ifc.control is True:
continue
cfg += "#ln -s /var/run/resolvconf/interface/%s.dhclient" % ifc.name
for iface in node.get_ifaces(control=False):
cfg += "#ln -s /var/run/resolvconf/interface/%s.dhclient" % iface.name
cfg += " /var/run/resolvconf/resolv.conf\n"
cfg += "/sbin/dhclient -nw -pf /var/run/dhclient-%s.pid" % ifc.name
cfg += " -lf /var/run/dhclient-%s.lease %s\n" % (ifc.name, ifc.name)
cfg += "/sbin/dhclient -nw -pf /var/run/dhclient-%s.pid" % iface.name
cfg += " -lf /var/run/dhclient-%s.lease %s\n" % (iface.name, iface.name)
return cfg
@ -585,10 +577,8 @@ export LANG
"""
% node.name
)
for ifc in node.netifs():
if hasattr(ifc, "control") and ifc.control is True:
continue
body += "<li>%s - %s</li>\n" % (ifc.name, ifc.addrlist)
for iface in node.get_ifaces(control=False):
body += "<li>%s - %s</li>\n" % (iface.name, iface.addrlist)
return "<html><body>%s</body></html>" % body
@ -619,14 +609,14 @@ DUMPOPTS="-s 12288 -C 10 -n"
if [ "x$1" = "xstart" ]; then
"""
for ifc in node.netifs():
if hasattr(ifc, "control") and ifc.control is True:
for iface in node.get_ifaces():
if hasattr(iface, "control") and iface.control is True:
cfg += "# "
redir = "< /dev/null"
cfg += "tcpdump ${DUMPOPTS} -w %s.%s.pcap -i %s %s &\n" % (
node.name,
ifc.name,
ifc.name,
iface.name,
iface.name,
redir,
)
cfg += """
@ -654,10 +644,8 @@ class RadvdService(UtilService):
using the network address of each interface.
"""
cfg = "# auto-generated by RADVD service (utility.py)\n"
for ifc in node.netifs():
if hasattr(ifc, "control") and ifc.control is True:
continue
prefixes = list(map(cls.subnetentry, ifc.addrlist))
for iface in node.get_ifaces(control=False):
prefixes = list(map(cls.subnetentry, iface.addrlist))
if len(prefixes) < 1:
continue
cfg += (
@ -670,7 +658,7 @@ interface %s
AdvDefaultPreference low;
AdvHomeAgentFlag off;
"""
% ifc.name
% iface.name
)
for prefix in prefixes:
if prefix == "":