diff --git a/ifupdown2/addons/bridge.py b/ifupdown2/addons/bridge.py index 00b1eaa..bcedb11 100644 --- a/ifupdown2/addons/bridge.py +++ b/ifupdown2/addons/bridge.py @@ -1125,7 +1125,7 @@ class bridge(Addon, moduleBase): err += 1 continue hwaddress = self.cache.get_link_address(bridgeport) - if not self._valid_ethaddr(hwaddress): + if not ifupdownflags.flags.DRYRUN and not self._valid_ethaddr(hwaddress): self.log_warn('%s: skipping port %s, ' %(ifaceobj.name, bridgeport) + 'invalid ether addr %s' %hwaddress) diff --git a/ifupdown2/ifupdown/ifupdownmain.py b/ifupdown2/ifupdown/ifupdownmain.py index 01163e2..59435c8 100644 --- a/ifupdown2/ifupdown/ifupdownmain.py +++ b/ifupdown2/ifupdown/ifupdownmain.py @@ -1804,7 +1804,7 @@ class ifupdownMain: auto = False break - if auto and not os.path.exists("/sys/class/net/%s" % ifname): + if not ifupdownflags.flags.DRYRUN and auto and not os.path.exists("/sys/class/net/%s" % ifname): self.logger.warning("%s: interface not recognized - please check interface configuration" % ifname) def _get_filtered_ifacenames_with_classes(self, auto, allow_classes, excludepats, ifacenames): diff --git a/ifupdown2/ifupdown/utils.py b/ifupdown2/ifupdown/utils.py index 08091e5..77aaed9 100644 --- a/ifupdown2/ifupdown/utils.py +++ b/ifupdown2/ifupdown/utils.py @@ -289,10 +289,11 @@ class utils(): @classmethod def _log_command_exec(cls, cmd, stdin): + dry_run = "DRY-RUN: " if ifupdownflags.flags.DRYRUN else "" if stdin: - cls.logger.info('executing %s [%s]' % (cmd, stdin)) + cls.logger.info('%sexecuting %s [%s]' % (dry_run, cmd, stdin)) else: - cls.logger.info('executing %s' % cmd) + cls.logger.info('%sexecuting %s' % (dry_run, cmd)) @classmethod def _format_error(cls, cmd, cmd_returncode, cmd_output, stdin): diff --git a/ifupdown2/lib/nlcache.py b/ifupdown2/lib/nlcache.py index 6b188bd..a7869e4 100644 --- a/ifupdown2/lib/nlcache.py +++ b/ifupdown2/lib/nlcache.py @@ -2801,7 +2801,7 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject except Exception as e: raise Exception("%s: netlink: cannot create bridge or set attributes: %s" % (ifname, str(e))) - def link_set_bridge_info_data_dry_run(self, ifname, ifla_info_data): + def link_set_bridge_info_data_dry_run(self, ifname, ifla_info_data, link_just_created): self.log_info_ifname_dry_run(ifname, "netlink: ip link add dev %s type bridge (with attributes)" % ifname) self.logger.debug("attributes: %s" % ifla_info_data) @@ -3054,7 +3054,7 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject except Exception as e: raise Exception("netlink: %s: cannot set %s (bridge slave) with options: %s" % (kind, ifname, str(e))) - def link_set_brport_with_info_slave_data_dry_run(self, ifname, _, __, ifla_info_slave_data): + def link_set_brport_with_info_slave_data_dry_run(self, ifname, kind, ifla_info_data, ifla_info_slave_data): self.log_info_ifname_dry_run(ifname, "netlink: ip link set dev %s: bridge port attributes" % ifname) self.logger.debug("attributes: %s" % ifla_info_slave_data)