mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Merge branch 'master' into issue-43/support-for-vxlan-ipv6-attributes
This commit is contained in:
@@ -52,6 +52,12 @@ You might need to manually download dependencies. Mandatory dependencies:
|
||||
|
||||
$ apt-get install build-essential devscripts dh-systemd fakeroot python-all python-docutils iproute2 python-ipaddr python-setuptools
|
||||
|
||||
To build the deb file successfully, the following additional packages are required:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ apt-get install dh-python python3-all python3-setuptools python3-docutils
|
||||
|
||||
Suggested dependencies:
|
||||
|
||||
.. code-block:: console
|
||||
@@ -121,6 +127,7 @@ Contributors
|
||||
* Maximilian Wilhelm <max@sdn.clinic>
|
||||
* Sven Auhagen <sven.auhagen@voleatech.de>
|
||||
* skorpy <magnus@skorpy.space>
|
||||
* Alexandre Derumier <aderumier@odiso.com>
|
||||
* Sam Tannous <stannous@cumulusnetworks.com>
|
||||
* Wilson Kok <wkok@cumulusnetworks.com>
|
||||
* John Berezovik <berezovik@gmail.com>
|
||||
|
3
debian/changelog
vendored
3
debian/changelog
vendored
@@ -11,6 +11,7 @@ ifupdown2 (3.0.0-1) unstable; urgency=medium
|
||||
* New: bridge-vlan-vni-map attribute (single vxlan device)
|
||||
* New: vrf-slave: keep vlan down if lower device has "link-down yes"
|
||||
* New: vxlan: support for vxlan-svcnodeip6 and vxlan-mcastgrp6 (fixes #43)
|
||||
* New: support for add ovs-ports-condone-regex attribute (openvswitch)
|
||||
* Fix: dry-run exceptions
|
||||
* Fix: bond enslavement ordering
|
||||
* Fix: process MTU before addrgen
|
||||
@@ -22,7 +23,7 @@ ifupdown2 (3.0.0-1) unstable; urgency=medium
|
||||
* Fix: mstpctl: check mstpctl-stp and bridge-stp and fix bridge cache update
|
||||
* Removing python-argcomplete dependency
|
||||
|
||||
-- Julien Fortin <julien@cumulusnetworks.com> Thu, 14 May 2020 23:23:23 +0200
|
||||
-- Julien Fortin <julien@cumulusnetworks.com> Wed, 24 Jun 2020 23:42:42 +0200
|
||||
|
||||
ifupdown2 (2.0.2-1) unstable; urgency=medium
|
||||
|
||||
|
3
debian/control
vendored
3
debian/control
vendored
@@ -3,13 +3,12 @@ Section: admin
|
||||
Priority: optional
|
||||
Maintainer: Julien Fortin <julien@cumulusnetworks.com>
|
||||
Build-Depends: debhelper (>=9),
|
||||
dh-systemd,
|
||||
dh-python,
|
||||
python3,
|
||||
python3-all,
|
||||
python3-setuptools,
|
||||
python3-docutils
|
||||
Standards-Version: 4.5.0.1
|
||||
Standards-Version: 4.5.0.2
|
||||
Homepage: https://github.com/cumulusnetworks/ifupdown2
|
||||
X-Python-Version: >= 3.7
|
||||
|
||||
|
@@ -42,9 +42,9 @@ def get_pci_interfaces():
|
||||
try:
|
||||
subprocess.check_call(cmd, shell=True, stdout=FNULL)
|
||||
ports.append(interface)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
FNULL.close()
|
||||
@@ -63,7 +63,7 @@ def get_swp_interfaces():
|
||||
ports.append(line.split()[0])
|
||||
except ValueError:
|
||||
continue
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
ports = get_pci_interfaces()
|
||||
except Exception as e:
|
||||
|
@@ -29,7 +29,7 @@ import sys
|
||||
try:
|
||||
from ifupdown2.lib.log import LogManager, root_logger
|
||||
from ifupdown2.lib.status import Status
|
||||
except:
|
||||
except Exception:
|
||||
from lib.log import LogManager, root_logger
|
||||
from lib.status import Status
|
||||
|
||||
@@ -47,7 +47,7 @@ try:
|
||||
|
||||
from ifupdown2.ifupdown.client import Client
|
||||
from ifupdown2.ifupdown.exceptions import ArgvParseHelp, ArgvParseError
|
||||
except:
|
||||
except Exception:
|
||||
import ifupdown.config as config
|
||||
|
||||
config.__version__ = __import__("__init__").__version__
|
||||
@@ -63,7 +63,7 @@ def daemon_mode():
|
||||
try:
|
||||
with open(config.IFUPDOWN2_CONF_PATH) as f:
|
||||
return "use_daemon=yes" in f.read()
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ def stand_alone():
|
||||
try:
|
||||
from ifupdown2.ifupdown.main import Ifupdown2
|
||||
from ifupdown2.lib.nlcache import NetlinkListenerWithCache, NetlinkListenerWithCacheErrorNotInitialized
|
||||
except:
|
||||
except Exception:
|
||||
from ifupdown.main import Ifupdown2
|
||||
from lib.nlcache import NetlinkListenerWithCache, NetlinkListenerWithCacheErrorNotInitialized
|
||||
ifupdown2 = Ifupdown2(daemon=False, uid=os.geteuid())
|
||||
@@ -103,7 +103,8 @@ def stand_alone():
|
||||
status = ifupdown2.main()
|
||||
finally:
|
||||
try:
|
||||
NetlinkListenerWithCache.get_instance().cleanup()
|
||||
if NetlinkListenerWithCache.is_init():
|
||||
NetlinkListenerWithCache.get_instance().cleanup()
|
||||
except NetlinkListenerWithCacheErrorNotInitialized:
|
||||
status = Status.Client.STATUS_NLERROR
|
||||
LogManager.get_instance().write("exit status %s" % status)
|
||||
|
@@ -406,7 +406,7 @@ class address(Addon, moduleBase):
|
||||
if old_hwaddress and utils.mac_str_to_int(old_hwaddress) != utils.mac_str_to_int(hwaddress):
|
||||
self.iproute2.bridge_fdb_del(bridgename, old_hwaddress, vlan)
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self.iproute2.bridge_fdb_add(bridgename, hwaddress, vlan)
|
||||
else:
|
||||
@@ -880,6 +880,10 @@ class address(Addon, moduleBase):
|
||||
self.logger.error('%s: %s' %(ifaceobj.name, str(e)))
|
||||
|
||||
def process_mtu(self, ifaceobj, ifaceobj_getfunc):
|
||||
|
||||
if ifaceobj.link_privflags & ifaceLinkPrivFlags.OPENVSWITCH:
|
||||
return
|
||||
|
||||
mtu_str = ifaceobj.get_attr_value_first('mtu')
|
||||
mtu_from_policy = False
|
||||
|
||||
@@ -969,7 +973,7 @@ class address(Addon, moduleBase):
|
||||
dhclientcmd.release6(ifaceobj.name)
|
||||
self.cache.force_address_flush_family(ifaceobj.name, socket.AF_INET6)
|
||||
force_reapply = True
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.process_mtu(ifaceobj, ifaceobj_getfunc)
|
||||
@@ -1220,7 +1224,7 @@ class address(Addon, moduleBase):
|
||||
|
||||
if clagd_vxlan_anycast_ip in intf_running_addrs:
|
||||
user_config_addrs.append(clagd_vxlan_anycast_ip)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Set ifaceobjcurr method and family
|
||||
@@ -1236,7 +1240,7 @@ class address(Addon, moduleBase):
|
||||
ifaceobjcurr.update_config_with_status('address', str(address), address not in intf_running_addrs)
|
||||
try:
|
||||
intf_running_addrs.remove(address)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# if any ip address is left in 'intf_running_addrs' it means that they
|
||||
@@ -1279,7 +1283,7 @@ class address(Addon, moduleBase):
|
||||
for default_addr in self.default_loopback_addresses:
|
||||
try:
|
||||
intf_running_addrs.remove(default_addr)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
ifaceobjrunning.addr_family.append('inet')
|
||||
ifaceobjrunning.addr_method = 'loopback'
|
||||
|
@@ -434,7 +434,7 @@ class addressvirtual(Addon, moduleBase):
|
||||
# so for now we should only use the iproute2 API.
|
||||
# try:
|
||||
# self.netlink.link_add_macvlan(ifname, macvlan_ifname)
|
||||
# except:
|
||||
# except Exception:
|
||||
self.iproute2.link_add_macvlan(ifname, macvlan_ifname, macvlan_mode)
|
||||
link_created = True
|
||||
|
||||
@@ -708,7 +708,7 @@ class addressvirtual(Addon, moduleBase):
|
||||
for vrr_config in old_ifaceobj.get_attr_value("vrrp") or []:
|
||||
try:
|
||||
old_vrr_ids.add(vrr_config.split()[0])
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if old_vrr_ids:
|
||||
|
@@ -413,13 +413,13 @@ class bond(Addon, moduleBase):
|
||||
|
||||
try:
|
||||
miimon = int(ifaceobj.get_attr_value_first('bond-miimon'))
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
miimon = int(policymanager.policymanager_api.get_iface_default(
|
||||
module_name=self.__class__.__name__,
|
||||
ifname=ifaceobj.name,
|
||||
attr='bond-miimon'))
|
||||
except:
|
||||
except Exception:
|
||||
miimon = 0
|
||||
|
||||
if not miimon:
|
||||
@@ -618,7 +618,7 @@ class bond(Addon, moduleBase):
|
||||
|
||||
try:
|
||||
bond_slaves.remove(lower_dev)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
else:
|
||||
@@ -746,7 +746,7 @@ class bond(Addon, moduleBase):
|
||||
running_bond_slaves = self.cache.get_slaves(ifaceobj.name)
|
||||
|
||||
self._query_check_bond_slaves(ifaceobjcurr, 'bond-slaves', user_bond_slaves, running_bond_slaves)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
del iface_attrs[iface_attrs.index('bond-ports')]
|
||||
@@ -757,7 +757,7 @@ class bond(Addon, moduleBase):
|
||||
running_bond_slaves = self.cache.get_slaves(ifaceobj.name)
|
||||
|
||||
self._query_check_bond_slaves(ifaceobjcurr, 'bond-ports', user_bond_slaves, running_bond_slaves)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for attr in iface_attrs:
|
||||
|
@@ -678,7 +678,7 @@ class bridge(Addon, moduleBase):
|
||||
self.bridge_allow_multiple_vlans = utils.get_boolean_from_string(
|
||||
self.sysctl_get('net.bridge.bridge-allow-multiple-vlans')
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
# Cumulus Linux specific variable. Failure probably means that
|
||||
# ifupdown2 is running a a different system.
|
||||
self.bridge_allow_multiple_vlans = True
|
||||
@@ -1027,7 +1027,7 @@ class bridge(Addon, moduleBase):
|
||||
if not waitportvals: return
|
||||
try:
|
||||
waitporttime = int(waitportvals[0])
|
||||
except:
|
||||
except Exception:
|
||||
self.log_warn('%s: invalid waitport value \'%s\''
|
||||
%(ifaceobj.name, waitportvals[0]))
|
||||
return
|
||||
@@ -1172,7 +1172,7 @@ class bridge(Addon, moduleBase):
|
||||
# to avoid any side effect we remove the dummy brport from the
|
||||
# list of supposedly newly configured ports.
|
||||
newly_enslaved_ports.remove(dummy_brport)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return newly_enslaved_ports
|
||||
@@ -1201,7 +1201,7 @@ class bridge(Addon, moduleBase):
|
||||
if not maxwait: return
|
||||
try:
|
||||
maxwait = int(maxwait)
|
||||
except:
|
||||
except Exception:
|
||||
self.log_warn('%s: invalid maxwait value \'%s\'' %(ifaceobj.name,
|
||||
maxwait))
|
||||
return
|
||||
@@ -1240,7 +1240,7 @@ class bridge(Addon, moduleBase):
|
||||
else:
|
||||
a = int(part)
|
||||
result.append(a)
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.warning('unable to parse vids \'%s\''
|
||||
%''.join(rangelist))
|
||||
pass
|
||||
@@ -1365,7 +1365,7 @@ class bridge(Addon, moduleBase):
|
||||
try:
|
||||
running_stp_state = self.read_file_oneline(stp_state_file)
|
||||
return running_stp_state and running_stp_state != '0'
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def _is_config_stp_state_on(self, ifaceobj):
|
||||
@@ -1461,7 +1461,7 @@ class bridge(Addon, moduleBase):
|
||||
# i.e. our default value is 31 but the kernel default seems to be 3125
|
||||
cached_ifla_info_data[Link.IFLA_BR_MCAST_STARTUP_QUERY_INTVL] //= 100
|
||||
cached_ifla_info_data[Link.IFLA_BR_MCAST_STARTUP_QUERY_INTVL] *= 100
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for attr_name, nl_attr in self._ifla_br_attributes_map.items():
|
||||
@@ -1704,7 +1704,7 @@ class bridge(Addon, moduleBase):
|
||||
for vlan in user_config_vids:
|
||||
try:
|
||||
vids_list.remove(vlan)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return vids_list
|
||||
@@ -1929,7 +1929,7 @@ class bridge(Addon, moduleBase):
|
||||
# part of ifla_info_slave_data.
|
||||
try:
|
||||
del brport_ifla_info_slave_data[Link.IFLA_BRPORT_LEARNING]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
#
|
||||
@@ -2061,7 +2061,7 @@ class bridge(Addon, moduleBase):
|
||||
if '=' in br_config:
|
||||
try:
|
||||
br_config = self.parse_interface_list_value(br_config)
|
||||
except:
|
||||
except Exception:
|
||||
self.log_error('error while parsing \'%s %s\'' % (attr_name, br_config))
|
||||
continue
|
||||
|
||||
@@ -2113,7 +2113,7 @@ class bridge(Addon, moduleBase):
|
||||
elif self.arp_nd_suppress_only_on_vxlan and brport_ifaceobj.link_kind & ifaceLinkKind.VXLAN:
|
||||
# ignore the case of VXLAN brport - handled later in the code
|
||||
continue
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
elif nl_attr == Link.IFLA_BRPORT_GROUP_FWD_MASK:
|
||||
# special handking for group_fwd_mask because Cisco proprietary
|
||||
@@ -2265,7 +2265,7 @@ class bridge(Addon, moduleBase):
|
||||
# we need to remove this attribute from the request dictionary
|
||||
try:
|
||||
del brport_ifla_info_slave_data[Link.IFLA_BRPORT_NEIGH_SUPPRESS]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
#
|
||||
@@ -2318,7 +2318,7 @@ class bridge(Addon, moduleBase):
|
||||
|
||||
try:
|
||||
vlans_str, vni_str = vlan_vni_map.split("=")
|
||||
except:
|
||||
except Exception:
|
||||
return self.__warn_bridge_vlan_vni_map_syntax_error(vlan_vni_map)
|
||||
|
||||
vlans = self._ranges_to_ints([vlans_str])
|
||||
@@ -2623,7 +2623,7 @@ class bridge(Addon, moduleBase):
|
||||
|
||||
try:
|
||||
self.netlink.link_del(self.get_dummy_brport_name_for_bridge(ifname))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -2794,7 +2794,7 @@ class bridge(Addon, moduleBase):
|
||||
bridge_attributes_map = dict(self._ifla_br_attributes_map)
|
||||
try:
|
||||
del bridge_attributes_map[Link.IFLA_BR_STP_STATE]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
#
|
||||
@@ -2809,7 +2809,7 @@ class bridge(Addon, moduleBase):
|
||||
|
||||
try:
|
||||
del bridge_attributes_map[Link.IFLA_BR_VLAN_STATS_ENABLED]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
lambda_nl_value_int_divide100 = lambda x: str(x // 100)
|
||||
@@ -3078,7 +3078,7 @@ class bridge(Addon, moduleBase):
|
||||
if utils.get_boolean_from_string(bridge_always_up):
|
||||
try:
|
||||
link_exists = self.cache.link_exists(self.get_dummy_brport_name_for_bridge(ifname))
|
||||
except:
|
||||
except Exception:
|
||||
link_exists = False
|
||||
|
||||
ifaceobjcurr.update_config_with_status(
|
||||
@@ -3219,7 +3219,7 @@ class bridge(Addon, moduleBase):
|
||||
if utils.get_boolean_from_string(ifaceobj.get_attr_value_first("bridge-always-up")):
|
||||
try:
|
||||
running_port_list.remove(self.get_dummy_brport_name_for_bridge(ifaceobj.name))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
bridge_all_ports = []
|
||||
@@ -3242,7 +3242,7 @@ class bridge(Addon, moduleBase):
|
||||
if port_list[i] in running_port_list:
|
||||
ordered.append(port_list[i])
|
||||
port_list = ordered
|
||||
except:
|
||||
except Exception:
|
||||
port_list = running_port_list
|
||||
|
||||
difference = set(running_port_list).symmetric_difference(bridge_all_ports)
|
||||
@@ -3524,7 +3524,7 @@ class bridge(Addon, moduleBase):
|
||||
|
||||
try:
|
||||
vlans_str, vni_str = bridge_vlan_vni_map.split("=")
|
||||
except:
|
||||
except Exception:
|
||||
ifaceobjcurr.update_config_with_status("bridge-vlan-vni-map", bridge_vlan_vni_map, 1)
|
||||
return self.__warn_bridge_vlan_vni_map_syntax_error(bridge_vlan_vni_map)
|
||||
|
||||
@@ -3541,7 +3541,7 @@ class bridge(Addon, moduleBase):
|
||||
try:
|
||||
for vlan in vlans_list:
|
||||
cached_vlans.remove(vlan)
|
||||
except:
|
||||
except Exception:
|
||||
ifaceobjcurr.update_config_with_status("bridge-vlan-vni-map", bridge_vlan_vni_map, 1)
|
||||
fail = True
|
||||
continue
|
||||
@@ -3549,7 +3549,7 @@ class bridge(Addon, moduleBase):
|
||||
try:
|
||||
for vni in vnis_list:
|
||||
cached_vnis.remove(vni)
|
||||
except:
|
||||
except Exception:
|
||||
ifaceobjcurr.update_config_with_status("bridge-vlan-vni-map", bridge_vlan_vni_map, 1)
|
||||
fail = True
|
||||
continue
|
||||
@@ -3616,7 +3616,7 @@ class bridge(Addon, moduleBase):
|
||||
try:
|
||||
config_per_port_dict = self.parse_interface_list_value(user_config_l2protocol_tunnel)
|
||||
brport_list = list(config_per_port_dict.keys())
|
||||
except:
|
||||
except Exception:
|
||||
ifaceobjcurr.update_config_with_status('bridge-l2protocol-tunnel', user_config_l2protocol_tunnel, 1)
|
||||
return
|
||||
else:
|
||||
|
@@ -72,7 +72,7 @@ class bridgevlan(Addon, moduleBase):
|
||||
try:
|
||||
(bridgename, vlan) = self._get_bridge_n_vlan(ifaceobj)
|
||||
vlanid = int(vlan, 10)
|
||||
except:
|
||||
except Exception:
|
||||
self.log_error("%s: bridge vlan interface name does not correspond "
|
||||
"to format (eg. br0.100)" % ifaceobj.name, ifaceobj)
|
||||
raise
|
||||
@@ -105,7 +105,7 @@ class bridgevlan(Addon, moduleBase):
|
||||
try:
|
||||
(bridgename, vlan) = self._get_bridge_n_vlan(ifaceobj)
|
||||
vlanid = int(vlan, 10)
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.warning("%s: bridge vlan interface name does not "
|
||||
"correspond to format (eg. br0.100)" % ifaceobj.name)
|
||||
raise
|
||||
|
@@ -61,7 +61,7 @@ class dhcp(Addon, moduleBase):
|
||||
attr="dhclient_retry_on_failure"
|
||||
)
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
self.dhclient_retry_on_failure = self.DHCLIENT_RETRY_ON_FAILURE
|
||||
|
||||
if self.dhclient_retry_on_failure < 0:
|
||||
@@ -93,7 +93,7 @@ class dhcp(Addon, moduleBase):
|
||||
|
||||
if ip:
|
||||
ips.add(ip)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return ips
|
||||
|
||||
@@ -149,7 +149,7 @@ class dhcp(Addon, moduleBase):
|
||||
ifname=ifaceobj.name, attr='dhcp6-ll-wait')
|
||||
try:
|
||||
timeout = int(dhcp6_ll_wait)+1
|
||||
except:
|
||||
except Exception:
|
||||
timeout = 10
|
||||
pass
|
||||
dhcp6_duid = policymanager.policymanager_api.get_iface_default(module_name=self.__class__.__name__, \
|
||||
@@ -171,7 +171,7 @@ class dhcp(Addon, moduleBase):
|
||||
try:
|
||||
if not ifupdownflags.flags.PERFMODE:
|
||||
self.dhclientcmd.stop(ifaceobj.name)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.dhclient_start_and_check(
|
||||
@@ -199,7 +199,7 @@ class dhcp(Addon, moduleBase):
|
||||
'.autoconf', autoconf)
|
||||
try:
|
||||
self.dhclientcmd.stop6(ifaceobj.name, duid=dhcp6_duid)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
#add delay before starting IPv6 dhclient to
|
||||
#make sure the configured interface/link is up.
|
||||
@@ -227,7 +227,7 @@ class dhcp(Addon, moduleBase):
|
||||
if not family in ifaceobj.addr_family and dhclientX_running:
|
||||
ifaceobj.addr_family = [family]
|
||||
self._dhcp_down(ifaceobj)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
ifaceobj.addr_family = addr_family
|
||||
@@ -319,22 +319,43 @@ class dhcp(Addon, moduleBase):
|
||||
(ifaceobj.addr_method != 'dhcp' and
|
||||
ifaceobj.addr_method != 'dhcp6')):
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
if not self.is_dhcp_allowed_on(ifaceobj, syntax_check=False):
|
||||
return
|
||||
|
||||
disable_syslog_on_exit = False
|
||||
try:
|
||||
if not ifupdownflags.flags.PERFMODE:
|
||||
disable_syslog_on_exit = not LogManager.get_instance().is_syslog_enabled_syslog()
|
||||
LogManager.get_instance().enable_syslog()
|
||||
self.logger.info("%s: enabling syslog for dhcp configuration" % ifaceobj.name)
|
||||
log_manager = LogManager.get_instance()
|
||||
|
||||
syslog_log_level = logging.INFO
|
||||
disable_syslog_on_exit = None
|
||||
|
||||
if operation in ["up", "down"]:
|
||||
# if syslog is already enabled we shouldn't disable it
|
||||
if log_manager.is_syslog_enabled():
|
||||
# save current syslog level
|
||||
syslog_log_level = log_manager.get_syslog_log_level()
|
||||
# prevent syslog from being disabled on exit
|
||||
disable_syslog_on_exit = False
|
||||
else:
|
||||
# enabling syslog
|
||||
log_manager.enable_syslog()
|
||||
# syslog will be disabled once we are done
|
||||
disable_syslog_on_exit = True
|
||||
|
||||
# update the current syslog handler log level if higher than INFO
|
||||
if syslog_log_level >= logging.INFO:
|
||||
log_manager.set_level_syslog(logging.INFO)
|
||||
|
||||
self.logger.info("%s: enabling syslog for dhcp configuration" % ifaceobj.name)
|
||||
|
||||
try:
|
||||
if operation == 'query-checkcurr':
|
||||
op_handler(self, ifaceobj, query_ifaceobj)
|
||||
else:
|
||||
op_handler(self, ifaceobj)
|
||||
finally:
|
||||
if disable_syslog_on_exit:
|
||||
LogManager.get_instance().disable_syslog()
|
||||
# disable syslog handler or re-set the proper log-level
|
||||
if disable_syslog_on_exit is True:
|
||||
log_manager.get_instance().disable_syslog()
|
||||
elif disable_syslog_on_exit is False:
|
||||
log_manager.set_level_syslog(syslog_log_level)
|
||||
|
@@ -100,7 +100,7 @@ class link(Addon, moduleBase):
|
||||
self.iproute2.link_add_veth(ifaceobj.name, peer_name)
|
||||
|
||||
elif link_type:
|
||||
self.netlink.link_add(ifname=ifaceobj.name, kind=link_type)
|
||||
self.iproute2.link_add(ifaceobj.name, link_type)
|
||||
|
||||
def _down(self, ifaceobj):
|
||||
if not ifaceobj.get_attr_value_first('link-type'):
|
||||
|
@@ -424,7 +424,7 @@ class mstpctl(Addon, moduleBase):
|
||||
try:
|
||||
running_val = self.mstpctlcmd.get_bridge_attr(
|
||||
ifaceobj.name, jsonAttr)
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.info('%s: could not get running %s value'
|
||||
%(ifaceobj.name, attrname))
|
||||
running_val = None
|
||||
@@ -612,7 +612,7 @@ class mstpctl(Addon, moduleBase):
|
||||
try:
|
||||
running_val = self.mstpctlcmd.get_bridge_port_attr(bridgename,
|
||||
ifaceobj.name, jsonAttr)
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.info('%s %s: could not get running %s value'
|
||||
%(bridgename, ifaceobj.name, attrname))
|
||||
running_val = None
|
||||
@@ -892,7 +892,7 @@ class mstpctl(Addon, moduleBase):
|
||||
jsonAttr = self.get_mod_subattr(k, 'jsonAttr')
|
||||
try:
|
||||
running_val = self.mstpctlcmd.get_bridge_port_attr(ifaceobj.name, bport, jsonAttr)
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.info('%s %s: could not get running %s value'
|
||||
%(ifaceobj.name, bport, attr))
|
||||
running_val = None
|
||||
@@ -1015,7 +1015,7 @@ class mstpctl(Addon, moduleBase):
|
||||
try:
|
||||
running_val = self.mstpctlcmd.get_bridge_port_attr(bifaceobj.name,
|
||||
ifaceobj.name, jsonAttr)
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.info('%s %s: could not get running %s value'
|
||||
%(bifaceobj.name, ifaceobj.name, attr))
|
||||
running_val = None
|
||||
|
@@ -13,7 +13,7 @@ try:
|
||||
from ifupdown2.ifupdown.exceptions import moduleNotSupported
|
||||
import ifupdown2.ifupdown.ifupdownflags as ifupdownflags
|
||||
|
||||
except:
|
||||
except Exception:
|
||||
from lib.addon import Addon
|
||||
|
||||
from ifupdown.iface import *
|
||||
@@ -37,6 +37,12 @@ class openvswitch(Addon, moduleBase):
|
||||
'help': 'Interfaces to be part of this ovs bridge.',
|
||||
'validvals': ['<interface-list>'],
|
||||
'required': False,
|
||||
"multivalue": True,
|
||||
"example": [
|
||||
"ovs-ports swp1.100 swp2.100 swp3.100",
|
||||
"ovs-ports glob swp1-3.100",
|
||||
"ovs-ports regex (swp[1|2|3].100)"
|
||||
]
|
||||
},
|
||||
'ovs-type': {
|
||||
'help': 'ovs interface type',
|
||||
@@ -63,6 +69,11 @@ class openvswitch(Addon, moduleBase):
|
||||
'example': ['ovs_extra set bridge ${IFACE} other-config:hwaddr=00:59:cf:9c:84:3a -- br-set-external-id ${IFACE} bridge-id ${IFACE}']
|
||||
|
||||
},
|
||||
'ovs-ports-condone-regex': {
|
||||
"help": "ovs ports to ignore/condone when reloading config / removing interfaces",
|
||||
"required": False,
|
||||
"example": ["ovs-ports-condone-regex ^[a-zA-Z0-9]+_v[0-9]{1,4}$"]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,10 +93,15 @@ class openvswitch(Addon, moduleBase):
|
||||
return False
|
||||
|
||||
def _get_ovs_ports (self, ifaceobj):
|
||||
ovs_ports = ifaceobj.get_attr_value_first('ovs-ports')
|
||||
ovs_ports = []
|
||||
|
||||
for port in ifaceobj.get_attr_value('ovs-ports') or []:
|
||||
ovs_ports.extend(port.split())
|
||||
|
||||
if ovs_ports:
|
||||
return sorted (ovs_ports.split ())
|
||||
return None
|
||||
return self.parse_port_list(ifaceobj.name, ' '.join(ovs_ports))
|
||||
else:
|
||||
return None
|
||||
|
||||
def _get_running_ovs_ports (self, iface):
|
||||
output = utils.exec_command("/usr/bin/ovs-vsctl list-ports %s" %iface)
|
||||
@@ -94,6 +110,14 @@ class openvswitch(Addon, moduleBase):
|
||||
return ovs_ports
|
||||
return None
|
||||
|
||||
def _get_ovs_port_condone_regex(self, ifaceobj, get_string = False):
|
||||
ovs_port_condone_regex = ifaceobj.get_attr_value_first('ovs-ports-condone-regex')
|
||||
if ovs_port_condone_regex:
|
||||
if get_string:
|
||||
return ovs_port_condone_regex
|
||||
return re.compile (r"%s" % ovs_port_condone_regex)
|
||||
return None
|
||||
|
||||
def _ovs_vsctl(self, ifaceobj, cmdlist):
|
||||
|
||||
if cmdlist:
|
||||
@@ -122,6 +146,7 @@ class openvswitch(Addon, moduleBase):
|
||||
ovsoptions = ifaceobj.get_attr_value_first ('ovs-options')
|
||||
ovsextra = ifaceobj.get_attr_value('ovs-extra')
|
||||
ovsmtu = ifaceobj.get_attr_value_first ('ovs-mtu')
|
||||
ovsportscondoneregex = self._get_ovs_port_condone_regex(ifaceobj)
|
||||
|
||||
cmd_list = []
|
||||
|
||||
@@ -137,11 +162,16 @@ class openvswitch(Addon, moduleBase):
|
||||
# on update, delete active ports not in the new port list
|
||||
ovs_ports = self._get_ovs_ports(ifaceobj)
|
||||
running_ovs_ports = self._get_running_ovs_ports(iface)
|
||||
|
||||
missingports = []
|
||||
if running_ovs_ports is not None and ovs_ports is not None:
|
||||
missingports = list(set(running_ovs_ports) - set(ovs_ports))
|
||||
|
||||
if missingports is not None:
|
||||
for port in missingports:
|
||||
if ovsportscondoneregex and ovsportscondoneregex.match(port):
|
||||
self.logger.info("%s: port %s will stay enslaved as it matches with ovs-ports-condone-regex" % (ifaceobj.name, port))
|
||||
continue
|
||||
cmd = "--if-exists del-port %s %s"%(iface, port)
|
||||
cmd_list.append(cmd)
|
||||
|
||||
@@ -171,6 +201,9 @@ class openvswitch(Addon, moduleBase):
|
||||
self._ovs_vsctl(ifaceobj, [cmd])
|
||||
|
||||
def get_dependent_ifacenames (self, ifaceobj, ifaceobjs_all=None):
|
||||
if not self._is_ovs_bridge(ifaceobj):
|
||||
return None
|
||||
ifaceobj.link_privflags |= ifaceLinkPrivFlags.OPENVSWITCH
|
||||
return None
|
||||
|
||||
def _up (self, ifaceobj):
|
||||
|
@@ -13,7 +13,7 @@ try:
|
||||
from ifupdown2.ifupdown.exceptions import moduleNotSupported
|
||||
import ifupdown2.ifupdown.ifupdownflags as ifupdownflags
|
||||
|
||||
except:
|
||||
except Exception:
|
||||
from lib.addon import Addon
|
||||
|
||||
from ifupdown.iface import *
|
||||
@@ -217,6 +217,8 @@ class openvswitch_port(Addon, moduleBase):
|
||||
if not self._is_ovs_port (ifaceobj):
|
||||
return None
|
||||
|
||||
ifaceobj.link_privflags |= ifaceLinkPrivFlags.OPENVSWITCH
|
||||
|
||||
ovsbridge = ifaceobj.get_attr_value_first ('ovs-bridge')
|
||||
return [ovsbridge]
|
||||
|
||||
|
@@ -205,7 +205,7 @@ class tunnel(Addon, moduleBase):
|
||||
"""
|
||||
try:
|
||||
user_config[attr_name] = ipnetwork.IPNetwork(user_config[attr_name])
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _query_check(self, ifaceobj, ifaceobjcurr):
|
||||
|
@@ -465,7 +465,7 @@ class vrf(Addon, moduleBase):
|
||||
dhclient_cmd_prefix = '%s %s' %(self.vrf_exec_cmd_prefix,
|
||||
vrfname)
|
||||
self.dhclientcmd.release(ifaceobj.name, dhclient_cmd_prefix)
|
||||
except:
|
||||
except Exception:
|
||||
# ignore any dhclient release errors
|
||||
pass
|
||||
|
||||
|
@@ -52,7 +52,7 @@ class vrrpd(moduleBase):
|
||||
try:
|
||||
cmdl = [utils.pidof_cmd, cmdname]
|
||||
pidstr = utils.exec_commandl(cmdl, stderr=None).strip('\n')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if not pidstr:
|
||||
return []
|
||||
@@ -70,7 +70,7 @@ class vrrpd(moduleBase):
|
||||
self.logger.info('(%d) (%d)' %(len(pcmdline), len(tmpcmdline)))
|
||||
if pcmdline and pcmdline == tmpcmdline:
|
||||
targetpids.append(pid)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return targetpids
|
||||
|
||||
|
@@ -161,7 +161,7 @@ class vxlan(Addon, moduleBase):
|
||||
self.logger.warning('%s: vxlan-local-tunnelip and clagd-vxlan-anycast-ip are identical (%s)'
|
||||
% (ifname, local_ip))
|
||||
return False
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return True
|
||||
|
||||
@@ -276,7 +276,7 @@ class vxlan(Addon, moduleBase):
|
||||
|
||||
if vxlan_ageing_str:
|
||||
return int(vxlan_ageing_str)
|
||||
except:
|
||||
except Exception:
|
||||
self.log_error("%s: invalid vxlan-ageing '%s'" % (ifname, vxlan_ageing_str), ifaceobj)
|
||||
|
||||
def __config_vxlan_ageing(self, ifname, ifaceobj, link_exists, user_request_vxlan_info_data, cached_vxlan_ifla_info_data):
|
||||
@@ -334,7 +334,7 @@ class vxlan(Addon, moduleBase):
|
||||
|
||||
self.logger.info("%s: set vxlan-port %s" % (ifname, vxlan_port))
|
||||
user_request_vxlan_info_data[Link.IFLA_VXLAN_PORT] = vxlan_port
|
||||
except:
|
||||
except Exception:
|
||||
self.log_error("%s: invalid vxlan-port '%s'" % (ifname, vxlan_port_str), ifaceobj)
|
||||
|
||||
def __config_vxlan_ttl(self, ifname, ifaceobj, user_request_vxlan_info_data, cached_vxlan_ifla_info_data):
|
||||
@@ -367,7 +367,7 @@ class vxlan(Addon, moduleBase):
|
||||
self.logger.info("%s: set vxlan-ttl %s" % (ifname, vxlan_ttl_str if vxlan_ttl_str else vxlan_ttl))
|
||||
|
||||
user_request_vxlan_info_data[Link.IFLA_VXLAN_TTL] = vxlan_ttl
|
||||
except:
|
||||
except Exception:
|
||||
self.log_error("%s: invalid vxlan-ttl '%s'" % (ifname, vxlan_ttl_str), ifaceobj)
|
||||
|
||||
def __config_vxlan_local_tunnelip(self, ifname, ifaceobj, link_exists, user_request_vxlan_info_data, cached_vxlan_ifla_info_data):
|
||||
@@ -686,7 +686,7 @@ class vxlan(Addon, moduleBase):
|
||||
except NetlinkCacheIfnameNotFoundError:
|
||||
try:
|
||||
vxlan_physdev_ifindex = int(self.sysfs.read_file_oneline("/sys/class/net/%s/ifindex" % vxlan_physdev))
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.error("%s: physdev %s doesn't exists" % (ifaceobj.name, vxlan_physdev))
|
||||
return
|
||||
|
||||
@@ -851,7 +851,7 @@ class vxlan(Addon, moduleBase):
|
||||
"00:00:00:00:00:00",
|
||||
None, True, addr
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for addr in add_list:
|
||||
@@ -861,7 +861,7 @@ class vxlan(Addon, moduleBase):
|
||||
"00:00:00:00:00:00",
|
||||
None, True, addr
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _down(self, ifaceobj):
|
||||
|
@@ -112,7 +112,7 @@ class Parse:
|
||||
if self.executable_name.endswith(key):
|
||||
return value
|
||||
raise ArgvParseError("Unexpected executable. Should be '%s'" % "' or '".join(list(self.valid_ops.keys())))
|
||||
except:
|
||||
except Exception:
|
||||
raise ArgvParseError("Unexpected executable. Should be '%s'" % "' or '".join(list(self.valid_ops.keys())))
|
||||
|
||||
def get_args(self):
|
||||
|
@@ -180,12 +180,12 @@ class Client(SocketIO):
|
||||
try:
|
||||
self.uds.close()
|
||||
self.uds = None
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.socket_receiver.server_close()
|
||||
self.socket_receiver = None
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def __signal_handler(self, sig, frame):
|
||||
|
@@ -54,7 +54,7 @@ class graph():
|
||||
for y in dlist:
|
||||
try:
|
||||
indegrees[y] = indegrees.get(y) - 1
|
||||
except:
|
||||
except Exception:
|
||||
cls.logger.debug('topological_sort_graphs_all: did not find %s' %y)
|
||||
indegrees[y] = 0
|
||||
pass
|
||||
|
@@ -92,6 +92,7 @@ class ifaceLinkPrivFlags():
|
||||
MGMT_INTF = 0x100000000
|
||||
SINGLE_VXLAN = 0x1000000000
|
||||
ES_BOND = 0x10000000000
|
||||
OPENVSWITCH = 0x10000000000
|
||||
|
||||
@classmethod
|
||||
def get_str(cls, flag):
|
||||
@@ -124,6 +125,9 @@ class ifaceLinkPrivFlags():
|
||||
if flag & cls.ES_BOND:
|
||||
string_list.append("es bond")
|
||||
|
||||
if flag & cls.OPENVSWITCH:
|
||||
string_list.append("openvswitch interface")
|
||||
|
||||
return ", ".join(string_list)
|
||||
|
||||
|
||||
@@ -538,7 +542,7 @@ class iface():
|
||||
if attr_value_list:
|
||||
try:
|
||||
return attr_value_list[attr_index]
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
return None
|
||||
|
||||
@@ -572,7 +576,7 @@ class iface():
|
||||
""" add attribute name and value to the interface config """
|
||||
try:
|
||||
del self.config[attr_name]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def update_config_dict(self, attrdict):
|
||||
|
@@ -118,7 +118,7 @@ class ifupdownMain:
|
||||
return
|
||||
try:
|
||||
self.netlink.link_up(ifaceobj.name)
|
||||
except:
|
||||
except Exception:
|
||||
if ifaceobj.addr_method == 'manual':
|
||||
pass
|
||||
else:
|
||||
@@ -158,7 +158,7 @@ class ifupdownMain:
|
||||
self.netlink.link_down(ifaceobj.name)
|
||||
else:
|
||||
self.logger.info("%s: ifupdown2 cannot bring loopback interface down" % ifaceobj.name)
|
||||
except:
|
||||
except Exception:
|
||||
if ifaceobj.addr_method == 'manual':
|
||||
pass
|
||||
else:
|
||||
@@ -189,14 +189,14 @@ class ifupdownMain:
|
||||
ifupdown2.ifupdown.ifupdownflags.reset()
|
||||
ifupdownConfig.reset()
|
||||
ifupdown2.ifupdownaddons.mstpctlutil.mstpctlutil.reset()
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
ifupdown.statemanager.reset()
|
||||
ifupdown.policymanager.reset()
|
||||
ifupdown.ifupdownflags.reset()
|
||||
ifupdownConfig.reset()
|
||||
ifupdownaddons.mstpctlutil.mstpctlutil.reset()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def ignore_error(self, errmsg):
|
||||
@@ -421,12 +421,12 @@ class ifupdownMain:
|
||||
mgmt_iface_default_prefix = ifupdown2.ifupdown.policymanager.policymanager_api.get_module_globals(
|
||||
module_name='main', attr='mgmt_intf_prefix'
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
mgmt_iface_default_prefix = ifupdown.policymanager.policymanager_api.get_module_globals(
|
||||
module_name='main', attr='mgmt_intf_prefix'
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if not mgmt_iface_default_prefix:
|
||||
mgmt_iface_default_prefix = "eth"
|
||||
@@ -750,7 +750,7 @@ class ifupdownMain:
|
||||
difaceobj = self.get_ifaceobj_first(diface)
|
||||
# If the dependent iface isn't a veth link - which shouldn't
|
||||
# happen - ignore it to be save.
|
||||
if difaceobj and difaceobj.get_attr_value_first('link-type') != "veth":
|
||||
if not difaceobj or (difaceobj and difaceobj.get_attr_value_first('link-type') != "veth"):
|
||||
continue
|
||||
|
||||
# If the peer has a desired peer name set and this is us,
|
||||
@@ -846,7 +846,7 @@ class ifupdownMain:
|
||||
for d in difaceobjs:
|
||||
d.dec_refcnt()
|
||||
d.upperifaces.remove(i)
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.debug('error removing %s from %s upperifaces' %(i, d))
|
||||
pass
|
||||
self.logger.debug("populate_dependency_info: deleting blacklisted interface %s" %i)
|
||||
@@ -1082,7 +1082,7 @@ class ifupdownMain:
|
||||
for arg in value.replace(",", " ").split():
|
||||
if arg not in ['all', 'stp', 'lldp', 'lacp', 'cdp', 'pvst']:
|
||||
return False
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -1215,7 +1215,7 @@ class ifupdownMain:
|
||||
if prev:
|
||||
return False
|
||||
prev = True
|
||||
except:
|
||||
except Exception:
|
||||
prev = False
|
||||
return not prev
|
||||
except Exception as e:
|
||||
@@ -1440,14 +1440,14 @@ class ifupdownMain:
|
||||
self.logger.info('module %s not loaded (%s)'
|
||||
%(mname, str(e)))
|
||||
continue
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
self.modules[mname] = minstance
|
||||
try:
|
||||
self.module_attrs[mname] = minstance.get_modinfo()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
# Assign all modules to query operations
|
||||
@@ -1512,7 +1512,7 @@ class ifupdownMain:
|
||||
print('%sexample:' %(indent + ' '))
|
||||
for e in examples:
|
||||
print('%s%s' %(indent + ' ', e))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
print('')
|
||||
|
||||
@@ -1534,7 +1534,7 @@ class ifupdownMain:
|
||||
if self.modules.get(module) or module in self.overridden_ifupdown_scripts:
|
||||
continue
|
||||
self.script_ops[op].append(msubdir + '/' + module)
|
||||
except:
|
||||
except Exception:
|
||||
# continue reading
|
||||
pass
|
||||
|
||||
@@ -1731,7 +1731,7 @@ class ifupdownMain:
|
||||
return ifupdown2.ifupdown.policymanager.policymanager_api.get_iface_default(
|
||||
module_name='main', ifname=ifacename,
|
||||
attr='exclude-companion')
|
||||
except:
|
||||
except Exception:
|
||||
return ifupdown.policymanager.policymanager_api.get_iface_default(
|
||||
module_name='main', ifname=ifacename,
|
||||
attr='exclude-companion')
|
||||
@@ -2070,7 +2070,7 @@ class ifupdownMain:
|
||||
|
||||
try:
|
||||
iface_read_ret = self.read_iface_config()
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
if not self.ifaceobjdict:
|
||||
self.logger.warning("nothing to reload ..exiting.")
|
||||
@@ -2164,7 +2164,7 @@ class ifupdownMain:
|
||||
|
||||
try:
|
||||
iface_read_ret = self.read_iface_config()
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
if not self.ifaceobjdict:
|
||||
|
@@ -16,21 +16,26 @@ import configparser
|
||||
|
||||
try:
|
||||
from ifupdown2.ifupdown.argv import Parse
|
||||
from ifupdown2.ifupdown.utils import utils
|
||||
from ifupdown2.ifupdown.config import IFUPDOWN2_CONF_PATH
|
||||
from ifupdown2.ifupdown.ifupdownmain import ifupdownMain
|
||||
|
||||
from ifupdown2.lib.dry_run import DryRunManager
|
||||
from ifupdown2.lib.status import Status
|
||||
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
from ifupdown.argv import Parse
|
||||
from ifupdown.utils import utils
|
||||
from ifupdown.config import IFUPDOWN2_CONF_PATH
|
||||
from ifupdown.ifupdownmain import ifupdownMain
|
||||
from lib.status import Status
|
||||
|
||||
from lib.dry_run import DryRunManager
|
||||
|
||||
|
||||
log = logging.getLogger()
|
||||
configmap_g = None
|
||||
lockfile = "/run/network/.lock"
|
||||
|
||||
|
||||
class Ifupdown2:
|
||||
@@ -64,6 +69,11 @@ class Ifupdown2:
|
||||
try:
|
||||
self.read_config()
|
||||
self.init(stdin_buffer)
|
||||
|
||||
if self.op != 'query' and not utils.lockFile(lockfile):
|
||||
log.error("Another instance of this program is already running.")
|
||||
return Status.Client.STATUS_ALREADY_RUNNING
|
||||
|
||||
self.handlers.get(self.op)(self.args)
|
||||
except Exception as e:
|
||||
if not str(e):
|
||||
@@ -186,7 +196,7 @@ class Ifupdown2:
|
||||
printdependency=args.printdependency,
|
||||
syntaxcheck=args.syntaxcheck, type=args.type,
|
||||
skipupperifaces=args.skipupperifaces)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
def run_down(self, args):
|
||||
@@ -212,7 +222,7 @@ class Ifupdown2:
|
||||
printdependency=args.printdependency,
|
||||
usecurrentconfig=args.usecurrentconfig,
|
||||
type=args.type)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
def run_query(self, args):
|
||||
@@ -257,7 +267,7 @@ class Ifupdown2:
|
||||
excludepats=args.excludepats,
|
||||
printdependency=args.printdependency,
|
||||
format=args.format, type=args.type)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
def run_reload(self, args):
|
||||
@@ -278,5 +288,5 @@ class Ifupdown2:
|
||||
usecurrentconfig=args.usecurrentconfig,
|
||||
syntaxcheck=args.syntaxcheck,
|
||||
currentlyup=args.currentlyup)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
@@ -82,7 +82,7 @@ class networkInterfaces():
|
||||
def _currentfile(self):
|
||||
try:
|
||||
return self._filestack[-1]
|
||||
except:
|
||||
except Exception:
|
||||
return self.interfacesfile
|
||||
|
||||
def _parse_error(self, filename, lineno, msg):
|
||||
@@ -209,7 +209,7 @@ class networkInterfaces():
|
||||
'iface %s: unsupported keyword (%s)'
|
||||
%(ifacename, attrname))
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
attrvallist = iface_config.get(newattrname, [])
|
||||
if newattrname in ['scope', 'netmask', 'broadcast', 'preferred-lifetime']:
|
||||
@@ -461,6 +461,11 @@ class networkInterfaces():
|
||||
% str(e))
|
||||
rendered_filedata = None
|
||||
if rendered_filedata:
|
||||
|
||||
if isinstance(rendered_filedata, bytes):
|
||||
# some template engine might return bytes but we want str
|
||||
rendered_filedata = rendered_filedata.decode()
|
||||
|
||||
self.process_interfaces(rendered_filedata)
|
||||
return
|
||||
self.process_interfaces(filedata)
|
||||
|
@@ -33,7 +33,7 @@ class pickling():
|
||||
with open(filename, 'wb') as f:
|
||||
for obj in list_of_objects:
|
||||
pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
@classmethod
|
||||
@@ -41,7 +41,7 @@ class pickling():
|
||||
""" pickle iface object """
|
||||
try:
|
||||
pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
@classmethod
|
||||
@@ -51,7 +51,7 @@ class pickling():
|
||||
while True:
|
||||
try: yield pickle.load(f)
|
||||
except EOFError: break
|
||||
except: raise
|
||||
except Exception: raise
|
||||
|
||||
class stateManager():
|
||||
""" state manager for managing ifupdown iface obj state
|
||||
@@ -200,7 +200,7 @@ class stateManager():
|
||||
for ifaceobjs in list(self.ifaceobjdict.values()):
|
||||
[pickling.save_obj(f, i) for i in ifaceobjs]
|
||||
open('%s/%s' %(self.state_rundir, self.state_runlockfile), 'w').close()
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
def dump_pretty(self, ifacenames, format='native'):
|
||||
|
@@ -194,7 +194,7 @@ class utils():
|
||||
def get_int_from_boolean_and_string(value):
|
||||
try:
|
||||
return int(value)
|
||||
except:
|
||||
except Exception:
|
||||
return int(utils.get_boolean_from_string(value))
|
||||
|
||||
@staticmethod
|
||||
|
@@ -29,9 +29,9 @@ class dhclient(utilsBase):
|
||||
try:
|
||||
if e.errno == errno.EACCES:
|
||||
return os.path.exists("/proc/%s" % self.read_file_oneline(pidfilename))
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
return False
|
||||
|
||||
|
@@ -120,7 +120,7 @@ class moduleBase(object):
|
||||
try:
|
||||
utils.exec_command('%s -x %s' %
|
||||
(utils.pidof_cmd, procName))
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@@ -132,14 +132,14 @@ class moduleBase(object):
|
||||
lines = f.readlines()
|
||||
for line in lines[2:]:
|
||||
ifacenames.append(line.split()[0].strip(': '))
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
return ifacenames
|
||||
|
||||
def parse_regex(self, ifacename, expr, ifacenames=None):
|
||||
try:
|
||||
proc_ifacenames = self.get_ifaces_from_proc()
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.warning('%s: error reading ifaces from proc' %ifacename)
|
||||
|
||||
for proc_ifacename in proc_ifacenames:
|
||||
@@ -292,7 +292,7 @@ class moduleBase(object):
|
||||
self.logger.info('reading \'%s\'' %filename)
|
||||
with open(filename, 'r') as f:
|
||||
return f.readlines()
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
return None
|
||||
|
||||
@@ -302,7 +302,7 @@ class moduleBase(object):
|
||||
self.logger.info('reading \'%s\'' %filename)
|
||||
with open(filename, 'r') as f:
|
||||
return f.readline().strip('\n')
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
return None
|
||||
|
||||
@@ -325,7 +325,7 @@ class moduleBase(object):
|
||||
return self._bridge_stp_user_space
|
||||
try:
|
||||
self._bridge_stp_user_space = self.sysctl_get('net.bridge.bridge-stp-user-space')
|
||||
except:
|
||||
except Exception:
|
||||
self._bridge_stp_user_space = 0
|
||||
|
||||
return self._bridge_stp_user_space
|
||||
@@ -379,14 +379,14 @@ class moduleBase(object):
|
||||
if 'aliases' in attrvals:
|
||||
retattrs.extend(attrvals['aliases'])
|
||||
return retattrs
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def get_mod_attr(self, attrname):
|
||||
""" returns module attr info """
|
||||
try:
|
||||
return self._modinfo.get('attrs', {}).get(attrname)
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def get_mod_subattr(self, attrname, subattrname):
|
||||
@@ -394,14 +394,14 @@ class moduleBase(object):
|
||||
try:
|
||||
return reduce(lambda d, k: d[k], ['attrs', attrname, subattrname],
|
||||
self._modinfo)
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def get_modinfo(self):
|
||||
""" return module info """
|
||||
try:
|
||||
return self._modinfo
|
||||
except:
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
def get_attr_default_value(self, attrname):
|
||||
@@ -411,7 +411,7 @@ class moduleBase(object):
|
||||
""" return the ifupdown scripts replaced by the current module """
|
||||
try:
|
||||
return self.overrides_ifupdown_scripts
|
||||
except:
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
def _get_reserved_vlan_range(self):
|
||||
@@ -482,7 +482,7 @@ class moduleBase(object):
|
||||
return -1
|
||||
try:
|
||||
vid = int(vid_str)
|
||||
except:
|
||||
except Exception:
|
||||
return -1
|
||||
return vid
|
||||
|
||||
@@ -499,7 +499,7 @@ class moduleBase(object):
|
||||
vid_str = ifaceobj.get_attr_value_first('vlan-id')
|
||||
try:
|
||||
if vid_str: return int(vid_str)
|
||||
except:
|
||||
except Exception:
|
||||
return -1
|
||||
|
||||
return self._get_vlan_id_from_ifacename(ifaceobj.name)
|
||||
|
@@ -96,7 +96,7 @@ class mstpctlutil(utilsBase):
|
||||
"%s batch -" % utils.mstpctl_cmd,
|
||||
stdin="\n".join(self.__batch)
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
finally:
|
||||
self.__batch_mode = False
|
||||
@@ -114,7 +114,7 @@ class mstpctlutil(utilsBase):
|
||||
def is_mstpd_running(self):
|
||||
try:
|
||||
utils.exec_command('%s mstpd'%utils.pidof_cmd)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@@ -122,7 +122,7 @@ class mstpctlutil(utilsBase):
|
||||
def _extract_bridge_port_prio(self, portid):
|
||||
try:
|
||||
return str(int(portid[0], 16) * 16)
|
||||
except:
|
||||
except Exception:
|
||||
return mstpctlutil._DEFAULT_PORT_PRIO
|
||||
|
||||
def _get_bridge_and_port_attrs_from_cache(self, bridgename):
|
||||
@@ -288,5 +288,5 @@ class mstpctlutil(utilsBase):
|
||||
utils.exec_command('%s showbridge %s' %
|
||||
(utils.mstpctl_cmd, bridgename))
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
@@ -31,7 +31,7 @@ class systemUtils():
|
||||
try:
|
||||
utils.exec_command('%s %s' %
|
||||
(utils.pidof_cmd, procname))
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@@ -57,7 +57,7 @@ class systemUtils():
|
||||
try:
|
||||
utils.exec_command('%s %s' %
|
||||
(utils.pidof_cmd, processname))
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@@ -56,7 +56,7 @@ class utilsBase(object):
|
||||
self.logger.debug('reading \'%s\'' %filename)
|
||||
with open(filename, 'r') as f:
|
||||
return f.readlines()
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
return None
|
||||
|
||||
@@ -65,7 +65,7 @@ class utilsBase(object):
|
||||
self.logger.debug('reading \'%s\'' %filename)
|
||||
with open(filename, 'r') as f:
|
||||
return f.readline().strip('\n')
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
return None
|
||||
|
||||
|
@@ -77,7 +77,7 @@ def WeakMethod(f):
|
||||
def _weakref_call_back_delete(reference):
|
||||
try:
|
||||
DryRunManager.get_instance().unregister_dry_run_handler_weakref_callback(reference)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ class DryRun(object):
|
||||
handler_code_weakref=WeakMethod(base_attr_value),
|
||||
dry_run_code_weakref=WeakMethod(attr_value)
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def log_info_ifname_dry_run(self, ifname, string):
|
||||
@@ -215,7 +215,7 @@ class DryRunManager(object):
|
||||
"""
|
||||
try:
|
||||
del self.__entries[reference]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def dry_run_mode_on(self):
|
||||
|
@@ -56,7 +56,7 @@ class IO(BaseObject):
|
||||
self.logger.info("reading '%s'" % path)
|
||||
with open(path, "r") as f:
|
||||
return f.readline().strip("\n")
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def read_file_oneline_dry_run(self, path):
|
||||
@@ -69,7 +69,7 @@ class IO(BaseObject):
|
||||
self.logger.info("reading '%s'" % path)
|
||||
with open(path, "r") as f:
|
||||
return f.readlines()
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
|
@@ -54,7 +54,7 @@ import socket #
|
||||
#
|
||||
try: #
|
||||
import ifupdown2.nlmanager.nlpacket as nlpacket #
|
||||
except: #
|
||||
except Exception: #
|
||||
import nlmanager.nlpacket as nlpacket #
|
||||
################################################################################
|
||||
|
||||
@@ -119,7 +119,7 @@ class IPRoute2(Cache, Requirements):
|
||||
# i.e.: packet.flags shouldn't contain NLM_F_* values but IFF_* (in case of Link object)
|
||||
# otherwise call to cache.link_is_up() will probably return True
|
||||
packet.decode_service_header()
|
||||
except:
|
||||
except Exception:
|
||||
# we can ignore all errors
|
||||
pass
|
||||
|
||||
@@ -168,7 +168,7 @@ class IPRoute2(Cache, Requirements):
|
||||
"%s -force -batch -" % prefix,
|
||||
stdin="\n".join(commands)
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
finally:
|
||||
self.__batch_mode = False
|
||||
@@ -254,6 +254,14 @@ class IPRoute2(Cache, Requirements):
|
||||
|
||||
###
|
||||
|
||||
def link_add(self, ifname, link_type):
|
||||
utils.exec_command(
|
||||
"%s link add %s type %s"
|
||||
% (utils.ip_cmd, ifname, link_type)
|
||||
)
|
||||
|
||||
###
|
||||
|
||||
def link_add_macvlan(self, ifname, macvlan_ifname, macvlan_mode):
|
||||
utils.exec_command(
|
||||
"%s link add link %s name %s type macvlan mode %s"
|
||||
@@ -344,7 +352,7 @@ class IPRoute2(Cache, Requirements):
|
||||
m = self.VXLAN_PEER_REGEX_PATTERN.search(l)
|
||||
if m and m.group(1) != svcnodeip:
|
||||
cur_peers.append(m.group(1))
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.warning('error parsing ip link output')
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode != 1:
|
||||
@@ -497,10 +505,19 @@ class IPRoute2(Cache, Requirements):
|
||||
if self.__compare_user_config_vs_running_state(running_address_list, address_list):
|
||||
return
|
||||
|
||||
try:
|
||||
self.__execute_or_batch(utils.ip_cmd, "addr flush dev %s" % ifname)
|
||||
except Exception as e:
|
||||
self.logger.warning("%s: flushing all ip address failed: %s" % (ifname, str(e)))
|
||||
# if primary address is not same, there is no need to keep any - reset all addresses
|
||||
if running_address_list and address_list and address_list[0] != running_address_list[0]:
|
||||
skip = []
|
||||
else:
|
||||
skip = address_list
|
||||
|
||||
for addr in running_address_list or []:
|
||||
try:
|
||||
if addr in skip:
|
||||
continue
|
||||
self.__execute_or_batch(utils.ip_cmd, "addr del %s dev %s" % (addr, ifname))
|
||||
except Exception as e:
|
||||
self.logger.warning("%s: removing ip address failed: %s" % (ifname, str(e)))
|
||||
for addr in address_list:
|
||||
try:
|
||||
if metric:
|
||||
@@ -528,7 +545,7 @@ class IPRoute2(Cache, Requirements):
|
||||
try:
|
||||
entries = fdb_entry.split()
|
||||
fdbs.setdefault(entries[2], []).append(entries[0])
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return fdbs
|
||||
except Exception:
|
||||
@@ -618,6 +635,13 @@ class IPRoute2(Cache, Requirements):
|
||||
if "exists" not in str(e).lower():
|
||||
self.logger.error(e)
|
||||
|
||||
@staticmethod
|
||||
def bridge_vlan_add_vid_list(ifname, vids):
|
||||
for v in vids:
|
||||
utils.exec_command(
|
||||
"%s vlan add vid %s dev %s" % (utils.bridge_cmd, v, ifname)
|
||||
)
|
||||
|
||||
def bridge_vlan_add_vid_list_self(self, ifname, vids, is_bridge=True):
|
||||
target = "self" if is_bridge else ""
|
||||
for v in vids:
|
||||
@@ -721,7 +745,7 @@ class IPRoute2(Cache, Requirements):
|
||||
vrf_table = self.cache.get_vrf_table(upper_iface)
|
||||
if vrf_table:
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
ip_route_del = []
|
||||
|
@@ -121,7 +121,11 @@ class LogManager:
|
||||
|
||||
for handler in self.__root_logger.handlers:
|
||||
handler.setLevel(log_level)
|
||||
self.__root_logger.setLevel(log_level)
|
||||
|
||||
# make sure that the root logger has the lowest logging level possible
|
||||
# otherwise some messages might not go through
|
||||
if self.__root_logger.level > log_level:
|
||||
self.__root_logger.setLevel(log_level)
|
||||
|
||||
def enable_console(self):
|
||||
""" Add console handler to root logger """
|
||||
@@ -141,9 +145,19 @@ class LogManager:
|
||||
if self.__syslog_handler:
|
||||
self.__root_logger.removeHandler(self.__syslog_handler)
|
||||
|
||||
def is_syslog_enabled_syslog(self):
|
||||
def is_syslog_enabled(self):
|
||||
return self.__syslog_handler in self.__root_logger.handlers
|
||||
|
||||
def get_syslog_log_level(self):
|
||||
return self.__syslog_handler.level if self.__syslog_handler else None
|
||||
|
||||
def set_level_syslog(self, level):
|
||||
if self.__syslog_handler:
|
||||
self.__syslog_handler.setLevel(level)
|
||||
|
||||
if self.__root_logger.level > level:
|
||||
self.__root_logger.setLevel(level)
|
||||
|
||||
def close_log_stream(self):
|
||||
""" Close socket to disconnect client.
|
||||
We first have to perform this little hack: it seems like the socket is
|
||||
|
@@ -283,7 +283,7 @@ class _NetlinkCache:
|
||||
"""
|
||||
try:
|
||||
del self._link_cache[slave].attributes[Link.IFLA_MASTER]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -389,7 +389,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._cache_lock:
|
||||
self._link_cache[ifname].flags = flags
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def override_link_mtu(self, ifname, mtu):
|
||||
@@ -402,7 +402,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._cache_lock:
|
||||
self._link_cache[ifname].attributes[Link.IFLA_MTU].value = mtu
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def override_cache_unslave_link(self, slave, master):
|
||||
@@ -456,7 +456,7 @@ class _NetlinkCache:
|
||||
# log.error('-----------')
|
||||
# log.error('-----------')
|
||||
# log.error('-----------')
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
# TODO: save log_level at entry and re-apply it after the dump
|
||||
nllistener.log.setLevel(WARNING)
|
||||
@@ -485,7 +485,7 @@ class _NetlinkCache:
|
||||
msg.debug = True
|
||||
msg.dump()
|
||||
msg.debug = save_debug
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
# TODO: save log_level at entry and re-apply it after the dump
|
||||
nllistener.log.setLevel(WARNING)
|
||||
@@ -1081,7 +1081,7 @@ class _NetlinkCache:
|
||||
|
||||
else:
|
||||
vlans.append(vlan_id)
|
||||
except:
|
||||
except Exception:
|
||||
log.exception("get_bridge_vids")
|
||||
return pvid, vlans
|
||||
|
||||
@@ -1103,7 +1103,7 @@ class _NetlinkCache:
|
||||
|
||||
if vlan_flag & Link.BRIDGE_VLAN_INFO_PVID:
|
||||
return vlan_id
|
||||
except:
|
||||
except Exception:
|
||||
log.exception("get_pvid")
|
||||
return pvid
|
||||
|
||||
@@ -1209,7 +1209,7 @@ class _NetlinkCache:
|
||||
if ifname in self._rtm_newlink_nomasterq:
|
||||
try:
|
||||
del link.attributes[Link.IFLA_MASTER]
|
||||
except:
|
||||
except Exception:
|
||||
self._rtm_newlink_nomasterq.remove(ifname)
|
||||
|
||||
# we need to check if the device was previously enslaved
|
||||
@@ -1347,7 +1347,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._cache_lock:
|
||||
self._link_cache[ifname].attributes[Link.IFLA_LINKINFO].value[Link.IFLA_INFO_DATA].update(ifla_info_data)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def add_bridge_vlan(self, msg):
|
||||
@@ -1378,7 +1378,7 @@ class _NetlinkCache:
|
||||
|
||||
if not ifla_master or not ifla_master in self._ifname_by_ifindex:
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Example IFLA_AF_SPEC
|
||||
@@ -1424,14 +1424,14 @@ class _NetlinkCache:
|
||||
# structure as well.
|
||||
old_master = self._slaves_master.get(slave)
|
||||
|
||||
if old_master:
|
||||
if old_master and old_master != master:
|
||||
try:
|
||||
self._masters_and_slaves.get(old_master, []).remove(slave)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._slaves_master[slave] = master
|
||||
except:
|
||||
except Exception:
|
||||
# since this is an optimization function we can ignore all error
|
||||
pass
|
||||
|
||||
@@ -1455,7 +1455,7 @@ class _NetlinkCache:
|
||||
|
||||
for slave in slave_list:
|
||||
self._slaves_master[slave] = master
|
||||
except:
|
||||
except Exception:
|
||||
# since this is an optimization function we can ignore all error
|
||||
pass
|
||||
|
||||
@@ -1522,17 +1522,17 @@ class _NetlinkCache:
|
||||
# have their bridge-vlans and _slaves_master entries cleared.
|
||||
for slave in list(self._masters_and_slaves[ifname]):
|
||||
self.__unslave_nolock(slave, master=ifname)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
del self._bridge_vlan_cache[ifname]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
del self._bridge_vlan_vni_cache[ifname]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -1628,7 +1628,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._cache_lock:
|
||||
self._addr_cache[ifname][family] = []
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def address_flush_link(self, ifname):
|
||||
@@ -1640,7 +1640,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._cache_lock:
|
||||
self._addr_cache[ifname] = {4: [], 6: []}
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def force_remove_addr(self, ifname, addr):
|
||||
@@ -1661,15 +1661,15 @@ class _NetlinkCache:
|
||||
try:
|
||||
if cache_addr.attributes[Address.IFA_ADDRESS].value == addr:
|
||||
obj_to_remove = cache_addr
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
if cache_addr.attributes[Address.IFA_LOCAL].value == addr:
|
||||
obj_to_remove = cache_addr
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
if obj_to_remove:
|
||||
self._addr_cache[ifname][addr.version].remove(obj_to_remove)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def remove_address(self, addr_to_remove):
|
||||
@@ -1680,10 +1680,10 @@ class _NetlinkCache:
|
||||
# to find which one to remove from the cache
|
||||
try:
|
||||
ip_version = addr_to_remove.get_attribute_value(Address.IFA_ADDRESS).version
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
ip_version = addr_to_remove.get_attribute_value(Address.IFA_LOCAL).version
|
||||
except:
|
||||
except Exception:
|
||||
# print debug error
|
||||
return
|
||||
|
||||
@@ -1735,7 +1735,7 @@ class _NetlinkCache:
|
||||
with self._cache_lock:
|
||||
intf_addresses = self._addr_cache[ifname]
|
||||
return bool(intf_addresses.get(4, None) or intf_addresses.get(6, None))
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
############################################################################
|
||||
@@ -1755,7 +1755,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._netconf_cache_lock:
|
||||
self._netconf_cache[msg.family][msg.get_attribute_value(msg.NETCONFA_IFINDEX)] = msg
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def remove_netconf(self, msg):
|
||||
@@ -1765,7 +1765,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._netconf_cache_lock:
|
||||
del self._netconf_cache[msg.family][msg.get_attribute_value(msg.NETCONFA_IFINDEX)]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def get_netconf_forwarding(self, family, ifname):
|
||||
@@ -1775,7 +1775,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._netconf_cache_lock:
|
||||
return self._netconf_cache[family][self.get_ifindex(ifname)].get_attribute_value(Netconf.NETCONFA_FORWARDING)
|
||||
except:
|
||||
except Exception:
|
||||
# if KeyError and family == AF_INET6: ipv6 is probably disabled on this device
|
||||
return None
|
||||
|
||||
@@ -1786,7 +1786,7 @@ class _NetlinkCache:
|
||||
try:
|
||||
with self._netconf_cache_lock:
|
||||
return self._netconf_cache[AF_MPLS][self.get_ifindex(ifname)].get_attribute_value(Netconf.NETCONFA_INPUT)
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
############################################################################
|
||||
@@ -1834,7 +1834,7 @@ class _NetlinkCache:
|
||||
ip6.append(ip_network_obj)
|
||||
else:
|
||||
ip4.append(ip_network_obj)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
# always return ip4 first, followed by ip6
|
||||
@@ -1902,11 +1902,11 @@ class _NetlinkCache:
|
||||
ifa_address = cache_addr.attributes[Address.IFA_ADDRESS].value
|
||||
if ifa_address.ip == addr.ip and ifa_address.prefixlen == addr.prefixlen:
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
ifa_local = cache_addr.attributes[Address.IFA_LOCAL].value
|
||||
return ifa_local.ip == addr.ip and ifa_local.prefixlen == addr.prefixlen
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
except (KeyError, AttributeError):
|
||||
pass
|
||||
@@ -1974,6 +1974,10 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject
|
||||
raise NetlinkListenerWithCacheErrorNotInitialized("NetlinkListenerWithCache not initialized")
|
||||
return NetlinkListenerWithCache.__instance
|
||||
|
||||
@staticmethod
|
||||
def is_init():
|
||||
return bool(NetlinkListenerWithCache.__instance)
|
||||
|
||||
def __init__(self, log_level):
|
||||
"""
|
||||
|
||||
@@ -2153,7 +2157,7 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject
|
||||
self.logger.error('NetlinkListenerWithCache: WORKQ_SERVICE_ERROR')
|
||||
else:
|
||||
raise Exception("Unsupported workq event %s" % event)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
finally:
|
||||
# il faut surement mettre un try/except autour de la boucle au dessus
|
||||
@@ -2279,7 +2283,7 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject
|
||||
# i.e.: packet.flags shouldn't contain NLM_F_* values but IFF_* (in case of Link object)
|
||||
# otherwise call to cache.link_is_up() will probably return True
|
||||
packet.decode_service_header()
|
||||
except:
|
||||
except Exception:
|
||||
# we can ignore all errors
|
||||
pass
|
||||
|
||||
@@ -2302,7 +2306,7 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject
|
||||
|
||||
try:
|
||||
result = self.tx_nlpacket_get_response_with_error(nl_packet)
|
||||
except:
|
||||
except Exception:
|
||||
# an error was caught, we need to unregister the event and raise again
|
||||
self.cache.unregister_wait_event()
|
||||
raise
|
||||
@@ -2571,7 +2575,7 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject
|
||||
# any stale value in our cache
|
||||
self.cache.force_remove_link(ifname)
|
||||
return result
|
||||
except:
|
||||
except Exception:
|
||||
# Something went wrong while sending the RTM_DELLINK request
|
||||
# we need to clear ifname from the ignore_rtm_newlinkq list
|
||||
self.cache.remove_from_ignore_rtm_newlinkq(ifname)
|
||||
@@ -3178,7 +3182,7 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject
|
||||
for addr in self.cache.get_ip_addresses(ifname):
|
||||
try:
|
||||
self.addr_del(ifname, addr)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
########################
|
||||
|
@@ -39,6 +39,7 @@ class Status(object):
|
||||
STATUS_EXCEPTION_MAIN = 99
|
||||
|
||||
STATUS_ARGV_ERROR = 90
|
||||
STATUS_ALREADY_RUNNING = 89
|
||||
|
||||
class Daemon(object):
|
||||
STATUS_SUCCESS = 0
|
||||
|
@@ -79,7 +79,7 @@ class __Sysfs(IO, Requirements):
|
||||
if not uppers:
|
||||
return []
|
||||
return [os.path.basename(u)[6:] for u in uppers]
|
||||
except:
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
@@ -89,7 +89,7 @@ class __Sysfs(IO, Requirements):
|
||||
if not lowers:
|
||||
return []
|
||||
return [os.path.basename(l)[6:] for l in lowers]
|
||||
except:
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
def link_is_up(self, ifname):
|
||||
@@ -163,7 +163,7 @@ class __Sysfs(IO, Requirements):
|
||||
try:
|
||||
stp_state_int = int(stp_state)
|
||||
return "yes" if stp_state_int > 0 else "no"
|
||||
except:
|
||||
except Exception:
|
||||
return "unknown"
|
||||
|
||||
def bridge_get_mcqv4src(self, bridge):
|
||||
|
@@ -44,7 +44,7 @@ class NetlinkListener(Thread):
|
||||
# As defined in asm/socket.h
|
||||
_SO_ATTACH_FILTER = 26
|
||||
|
||||
RECV_BUFFER = 4096 # 1024 * 1024
|
||||
RECV_BUFFER = 65536 # 1024 * 1024
|
||||
|
||||
def __init__(self, manager, groups, pid_offset=1, error_notification=False, rcvbuf_sz=10000000, bpf_filter=None):
|
||||
"""
|
||||
@@ -113,7 +113,7 @@ class NetlinkListener(Thread):
|
||||
self.rx_socket.bind((pid | (pid_offset << 22), self.groups))
|
||||
self.pid_offset = pid_offset
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
# if we reach this line it means we've reach NLMANAGER_BIND_RETRY limit
|
||||
# and couldn't successfully bind the rx_socket... We will try one more
|
||||
|
@@ -166,13 +166,13 @@ class NetlinkManager(object):
|
||||
)
|
||||
self.pid = self.pid + i
|
||||
return
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
# if we reach this code it means all our bind calls failed. We are trying to
|
||||
# bind the socket one last time on the original parameters if not we will not
|
||||
# be catching the exception
|
||||
self.tx_socket.bind((self.pid, 0))
|
||||
except:
|
||||
except Exception:
|
||||
if self.tx_socket:
|
||||
self.tx_socket.close()
|
||||
self.tx_socket = None
|
||||
|
0
ifupdown2/sbin/start-networking
Normal file → Executable file
0
ifupdown2/sbin/start-networking
Normal file → Executable file
Reference in New Issue
Block a user