mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Merge branch 'CumulusLinux-2.0_br'
Conflicts: build-config/conf/linux.vci.config build-config/conf/snapshot-manifest-powerpc build-config/make/images.make build-config/make/kernel.make packages/cl-utilities/dist-packages/cumulus/platformdb.py packages/cl-utilities/dist-packages/cumulus/platforms/accton.py packages/ifupdown2/pkg/ifupdownmain.py packages/mstpd/debian/mstpd.postinst packages/mstpd/debian/mstpd.postrm packages/mstpd/debian/mstpd.preinst packages/mstpd/debian/mstpd.prerm patches/bridge-utils/igmp_snoop_support.patch patches/bridge-utils/series patches/kernel/network-bridge-igmp-ifupdown-fixes.patch patches/kernel/platform-cel-p2020.patch patches/kernel/platform-powerpc-85xx-Makefile.patch patches/kernel/platform-quanta-ly6.patch patches/kernel/series patches/mstpd/igmp_snooop_ifupdown.patch patches/mstpd/series tests/portconfig/test_vectors/cel,redstone@None/default/portsbcm utilities/packages/autolib/netobjects.py
This commit is contained in:
4
debian/python-ifupdown2.postinst
vendored
4
debian/python-ifupdown2.postinst
vendored
@ -13,7 +13,9 @@ case "$1" in
|
||||
[ -d /run/network ] || mkdir -p /run/network
|
||||
|
||||
# for backward compatibility
|
||||
ln -sf /run/network /etc/network/run
|
||||
if [ ! -f /etc/network/run ]; then
|
||||
ln -sf /run/network /etc/network/run
|
||||
fi
|
||||
|
||||
[ -d /etc/network/if-pre-up.d ] || mkdir -p /etc/network/if-pre-up.d
|
||||
[ -d /etc/network/if-up.d ] || mkdir -p /etc/network/if-up.d
|
||||
|
@ -22,6 +22,8 @@ CONFIGURE_INTERFACES=yes
|
||||
EXCLUDE_INTERFACES=
|
||||
VERBOSE=no
|
||||
|
||||
verbose=
|
||||
|
||||
[ -f /etc/default/networking ] && . /etc/default/networking
|
||||
|
||||
[ "$VERBOSE" = yes ] && verbose=-v
|
||||
@ -128,7 +130,7 @@ start)
|
||||
set -f
|
||||
exclusions=$(process_exclusions)
|
||||
log_action_begin_msg "Configuring network interfaces"
|
||||
if ifup -a $exclusions $verbose && ifup_hotplug $exclusions $verbose
|
||||
if ifup -a $verbose --perfmode
|
||||
then
|
||||
log_action_end_msg $?
|
||||
else
|
||||
@ -144,7 +146,7 @@ stop)
|
||||
check_network_swap
|
||||
|
||||
log_action_begin_msg "Deconfiguring network interfaces"
|
||||
if ifdown -a --exclude=lo $verbose; then
|
||||
if ifdown -a --exclude=lo $verbose --perfmode --force; then
|
||||
log_action_end_msg $?
|
||||
else
|
||||
log_action_end_msg $?
|
||||
@ -156,7 +158,7 @@ reload)
|
||||
|
||||
log_action_begin_msg "Reloading network interfaces configuration"
|
||||
state=$(cat /run/network/ifstate)
|
||||
ifdown -a --exclude=lo $verbose || true
|
||||
ifdown -a --exclude=lo $verbose --perfmode --force || true
|
||||
if ifup --exclude=lo $state $verbose ; then
|
||||
log_action_end_msg $?
|
||||
else
|
||||
@ -172,10 +174,10 @@ force-reload|restart)
|
||||
|
||||
#log_warning_msg "Running $0 $1 is deprecated because it may not re-enable some interfaces"
|
||||
log_action_begin_msg "Reconfiguring network interfaces"
|
||||
ifdown -a --exclude=lo $verbose || true
|
||||
ifdown -a --exclude=lo $verbose --perfmode --force || true
|
||||
set -f
|
||||
exclusions=$(process_exclusions)
|
||||
if ifup -a --exclude=lo $exclusions $verbose && ifup_hotplug $exclusions $verbose
|
||||
if ifup -a --exclude=lo $verbose --perfmode
|
||||
then
|
||||
log_action_end_msg $?
|
||||
else
|
||||
|
@ -8,6 +8,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import json
|
||||
|
||||
class ifaceFlags():
|
||||
|
||||
@ -340,3 +341,7 @@ class iface():
|
||||
# ' %s' %self.get_status_str())
|
||||
|
||||
print outbuf
|
||||
|
||||
|
||||
def dump_json(self, logger):
|
||||
json.dumps(self)
|
||||
|
@ -202,7 +202,6 @@ class ifupdownMain():
|
||||
# XXX: Ideally this should be a call-back into the vlan module.
|
||||
vlan_iface_obj = iface()
|
||||
vlan_iface_obj.set_name(vlan_ifname)
|
||||
vlan_iface_obj.set_dependents(self.get_dependents(vlan_iface_obj, op))
|
||||
|
||||
return vlan_iface_obj
|
||||
|
||||
@ -260,20 +259,22 @@ class ifupdownMain():
|
||||
continue
|
||||
dlist = module.get_dependent_ifacenames(ifaceobj,
|
||||
self.ifaceobjdict.keys())
|
||||
if dlist:
|
||||
if dlist is not None:
|
||||
self.logger.debug('%s: ' %ifaceobj.get_name() +
|
||||
'got dependency list: %s' %str(dlist))
|
||||
break
|
||||
|
||||
return dlist
|
||||
|
||||
|
||||
def generate_dependency_info(self, ifacenames, dependency_graph, op):
|
||||
""" recursive function to generate iface dependency info """
|
||||
|
||||
self.logger.debug('generating dependency info for %s' %str(ifacenames))
|
||||
|
||||
for i in ifacenames:
|
||||
iqueue = deque(ifacenames)
|
||||
while iqueue:
|
||||
i = iqueue.popleft()
|
||||
|
||||
# Go through all modules and find dependent ifaces
|
||||
dlist = None
|
||||
ifaceobj = self.get_iface_obj_first(i)
|
||||
@ -289,13 +290,12 @@ class ifupdownMain():
|
||||
if dlist is not None:
|
||||
self.preprocess_dependency_list(dlist, op)
|
||||
ifaceobj.set_dependents(dlist)
|
||||
for d in dlist:
|
||||
iqueue.append(d)
|
||||
|
||||
if dependency_graph.get(i) is None:
|
||||
dependency_graph[i] = dlist
|
||||
|
||||
if dlist is not None:
|
||||
self.generate_dependency_info(dlist, dependency_graph, op)
|
||||
|
||||
def is_valid_state_transition(self, ifname, to_be_state):
|
||||
return self.statemanager.is_valid_state_transition(ifname,
|
||||
to_be_state)
|
||||
@ -560,7 +560,8 @@ class ifupdownMain():
|
||||
|
||||
|
||||
def run(self, op, auto=False, allow_classes=None,
|
||||
ifacenames=None, query_state=None, excludepats=None):
|
||||
ifacenames=None, query_state=None, excludepats=None,
|
||||
format=None):
|
||||
""" main ifupdown run method """
|
||||
|
||||
if auto == True:
|
||||
@ -678,7 +679,7 @@ class ifupdownMain():
|
||||
io.dump_raw(self.logger)
|
||||
print '\n'
|
||||
|
||||
def print_ifaceobjscurr_pretty(self, ifacenames):
|
||||
def print_ifaceobjscurr_pretty(self, ifacenames, format):
|
||||
""" Dumps current running state of interfaces.
|
||||
|
||||
returns 1 if any of the interface has an error,
|
||||
@ -695,11 +696,10 @@ class ifupdownMain():
|
||||
continue
|
||||
elif ifaceobj.get_status() == ifaceStatus.ERROR:
|
||||
ret = 1
|
||||
ifaceobj.dump_pretty(self.logger)
|
||||
if ifaceobj.get_status() == ifaceStatus.ERROR:
|
||||
ret = 1
|
||||
|
||||
return ret
|
||||
if format is None or format == 'nwifaces':
|
||||
ifaceobj.dump_pretty(self.logger)
|
||||
else:
|
||||
ifaceobj.dump_json(self.logger)
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -89,6 +89,7 @@ class networkInterfaces():
|
||||
|
||||
def process_iface(self, lines, cur_idx, lineno):
|
||||
lines_consumed = 0
|
||||
line_idx = cur_idx
|
||||
|
||||
ifaceobj = iface()
|
||||
|
||||
@ -174,47 +175,64 @@ class networkInterfaces():
|
||||
|
||||
return classes
|
||||
|
||||
|
||||
def read_file(self, filename=None):
|
||||
def process_filedata(self, filedata):
|
||||
lineno = 0
|
||||
line_idx = 0
|
||||
lines_consumed = 0
|
||||
|
||||
raw_lines = filedata.split('\n')
|
||||
lines = [l.strip(' \n') for l in raw_lines]
|
||||
|
||||
while (line_idx < len(lines)):
|
||||
lineno = lineno + 1
|
||||
|
||||
if self.ignore_line(lines[line_idx]):
|
||||
line_idx += 1
|
||||
continue
|
||||
|
||||
words = lines[line_idx].split()
|
||||
|
||||
# Check if first element is a supported keyword
|
||||
if self.is_keyword(words[0]):
|
||||
keyword_func = self.get_keyword_func(words[0])
|
||||
lines_consumed = keyword_func(self, lines, line_idx, lineno)
|
||||
line_idx += lines_consumed
|
||||
else:
|
||||
self.logger.warning('could not process line %s' %l + ' at' +
|
||||
' lineno %d' %lineno)
|
||||
|
||||
line_idx += 1
|
||||
|
||||
return 0
|
||||
|
||||
def run_template_engine(self, textdata):
|
||||
try:
|
||||
from mako.template import Template
|
||||
except:
|
||||
self.logger.warning('template engine mako not found ' +
|
||||
'skipping template parsing');
|
||||
return textdata
|
||||
|
||||
t = Template(text=textdata, output_encoding='utf-8')
|
||||
return t.render()
|
||||
|
||||
def read_file(self, filename=None):
|
||||
ifaces_file = filename
|
||||
if ifaces_file == None:
|
||||
ifaces_file=self.ifaces_file
|
||||
|
||||
self.logger.debug('reading ifaces_file %s' %ifaces_file)
|
||||
f = open(ifaces_file)
|
||||
filedata = f.read()
|
||||
f.close()
|
||||
|
||||
with open(ifaces_file) as f:
|
||||
raw_lines = f.readlines()
|
||||
lines = [l.strip(' \n') for l in raw_lines]
|
||||
# process line continuations
|
||||
filedata = ' '.join(d.strip() for d in filedata.split('\\'))
|
||||
|
||||
while (line_idx < len(lines)):
|
||||
lineno = lineno + 1
|
||||
# run through template engine
|
||||
filedata = self.run_template_engine(filedata)
|
||||
|
||||
if self.ignore_line(lines[line_idx]):
|
||||
line_idx += 1
|
||||
continue
|
||||
|
||||
words = lines[line_idx].split()
|
||||
|
||||
# Check if first element is a supported keyword
|
||||
if self.is_keyword(words[0]):
|
||||
keyword_func = self.get_keyword_func(
|
||||
words[0])
|
||||
lines_consumed = keyword_func(self,
|
||||
lines, line_idx, lineno)
|
||||
|
||||
line_idx += lines_consumed
|
||||
else:
|
||||
self.logger.warning('could not ' +
|
||||
'process line %s' %l + ' at' +
|
||||
' lineno %d' %lineno)
|
||||
|
||||
line_idx += 1
|
||||
|
||||
return 0
|
||||
self.process_filedata(filedata)
|
||||
|
||||
|
||||
def load(self, filename=None):
|
||||
|
@ -25,7 +25,8 @@ def run(args, op):
|
||||
elif op == 'query':
|
||||
ifupdown_handle = ifupdownMain(nodepends=args.nodepends,
|
||||
perfmode=args.perfmode,
|
||||
njobs=args.jobs)
|
||||
njobs=args.jobs,
|
||||
format=args.format)
|
||||
|
||||
iflist = args.iflist
|
||||
if len(args.iflist) == 0:
|
||||
@ -134,6 +135,9 @@ def update_ifquery_argparser(argparser):
|
||||
dest='presumedstatedetailed',
|
||||
action='store_true', help=argparse.SUPPRESS)
|
||||
|
||||
group.add_argument('--format', dest='format', default='nwifaces',
|
||||
choices=['nwifaces', 'json'], help=argparse.SUPPRESS)
|
||||
|
||||
|
||||
def parse_args(argsv, op):
|
||||
descr = 'interface management'
|
||||
|
Reference in New Issue
Block a user