Fix ovs-tcpdump import error

This commit is contained in:
openeuler-netdev 2020-09-24 17:24:22 +08:00
parent 0b00102fbc
commit 7a67e14dd2
2 changed files with 54 additions and 2 deletions

View File

@ -0,0 +1,41 @@
diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in
index 11624c5..cdba1d5 100755
--- a/utilities/ovs-tcpdump.in
+++ b/utilities/ovs-tcpdump.in
@@ -24,7 +24,21 @@ import subprocess
import sys
import time
-import netifaces
+try:
+ from netifaces import interfaces
+except ImportError:
+ if sys.platform in ['linux', 'linux2']:
+ def interfaces():
+ devices = []
+ with open("/proc/net/dev", "r") as f_netdev:
+ for line in f_netdev:
+ if ":" not in line:
+ continue
+ devices.append(line.split(":")[0].strip())
+ return devices
+ else:
+ print("ERROR: Please install netifaces Python library.")
+ sys.exit(1)
try:
from ovs.db import idl
@@ -438,11 +452,11 @@ def main():
mirror_interface = _make_mirror_name[sys.platform](interface)
if sys.platform in _make_taps and \
- mirror_interface not in netifaces.interfaces():
+ mirror_interface not in interfaces():
_make_taps[sys.platform](mirror_interface,
ovsdb.interface_mtu(interface))
- if mirror_interface not in netifaces.interfaces():
+ if mirror_interface not in interfaces():
print("ERROR: Please create an interface called `%s`" %
mirror_interface)
print("See your OS guide for how to do this.")

View File

@ -3,12 +3,13 @@ Summary: Production Quality, Multilayer Open Virtual Switch
URL: http://www.openvswitch.org/ URL: http://www.openvswitch.org/
Version: 2.12.0 Version: 2.12.0
License: ASL 2.0 License: ASL 2.0
Release: 9 Release: 10
Source: https://www.openvswitch.org/releases/openvswitch-%{version}.tar.gz Source: https://www.openvswitch.org/releases/openvswitch-%{version}.tar.gz
Buildroot: /tmp/openvswitch-rpm Buildroot: /tmp/openvswitch-rpm
Patch0000: 0000-openvswitch-add-stack-protector-strong.patch Patch0000: 0000-openvswitch-add-stack-protector-strong.patch
Patch0001: 0001-fix-dict-change-during-iteration.patch Patch0001: 0001-fix-dict-change-during-iteration.patch
Patch0002: 0002-Remove-unsupported-permission-names.patch Patch0002: 0002-Remove-unsupported-permission-names.patch
Patch0003: 0003-Fallback-to-read-proc-net-dev-on-linux.patch
Requires: logrotate hostname python >= 3.8 python3-six selinux-policy-targeted Requires: logrotate hostname python >= 3.8 python3-six selinux-policy-targeted
BuildRequires: python3-six, openssl-devel checkpolicy selinux-policy-devel autoconf automake libtool python-sphinx unbound-devel BuildRequires: python3-six, openssl-devel checkpolicy selinux-policy-devel autoconf automake libtool python-sphinx unbound-devel
Provides: openvswitch-selinux-policy = %{version}-%{release} Provides: openvswitch-selinux-policy = %{version}-%{release}
@ -93,6 +94,12 @@ install -m 0644 lib/*.h $RPM_BUILD_ROOT/%{_includedir}/openvs
install -D -m 0644 lib/.libs/libopenvswitch.a \ install -D -m 0644 lib/.libs/libopenvswitch.a \
$RPM_BUILD_ROOT/%{_libdir}/libopenvswitch.a $RPM_BUILD_ROOT/%{_libdir}/libopenvswitch.a
install -d -m 0755 $RPM_BUILD_ROOT%{python3_sitelib}
cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \
$RPM_BUILD_ROOT%{python3_sitelib}
rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
@ -164,7 +171,8 @@ exit 0
%{_libdir}/lib*.so.* %{_libdir}/lib*.so.*
/usr/sbin/ovs-vswitchd /usr/sbin/ovs-vswitchd
/usr/sbin/ovsdb-server /usr/sbin/ovsdb-server
/usr/share/openvswitch/python/ %{python3_sitelib}/ovs
%{python3_sitelib}/ovstest
/usr/share/openvswitch/scripts/ovs-check-dead-ifs /usr/share/openvswitch/scripts/ovs-check-dead-ifs
/usr/share/openvswitch/scripts/ovs-ctl /usr/share/openvswitch/scripts/ovs-ctl
/usr/share/openvswitch/scripts/ovs-kmod-ctl /usr/share/openvswitch/scripts/ovs-kmod-ctl
@ -196,6 +204,9 @@ exit 0
%doc README.rst NEWS rhel/README.RHEL.rst %doc README.rst NEWS rhel/README.RHEL.rst
%changelog %changelog
* Tue Sep 24 2020 luosuwang <oenetdev@huawei.com> - 2.12.0-10
- Fix ovs-tcpdump import error
* Tue Sep 22 2020 luosuwang <oenetdev@huawei.com> - 2.12.0-9 * Tue Sep 22 2020 luosuwang <oenetdev@huawei.com> - 2.12.0-9
- Remove openvswitch-kmod package - Remove openvswitch-kmod package