import os
import os.path
import re
import time
import sys
dir1 = "/etc/sysconfig/network-scripts/"
def get_net_list():
list_net=[]
for wangka in os.listdir(dir1):
r=re.search("^ifcfg-.*[0-9]$", wangka)
if r:
list_net.append(wangka)
return list_net
def get_bond():
list1=[]
list_bond=[]
list_wangka=[]
list_slave=[]
list_nouser=[]
for wangka_net in get_net_list():
bond_wangka=re.search("^ifcfg-b.*[0-9]",wangka_net)
if bond_wangka:
list_bond.append(wangka_net)
if not re.search("^ifcfg-b.*[0-9]",wangka_net):
list_wangka.append(wangka_net)
for i in list_wangka:
with open("%s%s" % (dir1,i))as wangka_file:
wangka_flag&
python获取/etc/sysconfig/network-scripts/网卡文件及bond名字
最新推荐文章于 2024-03-06 09:25:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)