1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

Merge branch 'dev' into release/cl-stable

This commit is contained in:
Roopa Prabhu
2016-05-15 11:00:03 -07:00
7 changed files with 63 additions and 35 deletions

View File

@@ -323,6 +323,14 @@ class addressvirtual(moduleBase):
av_idx += 1
continue
raddrs = raddrs.keys()
try:
av_attrs[0] = ':'.join([i if len(i) == 2 else '0%s' % i
for i in av_attrs[0].split(':')])
except:
self.logger.info('%s: %s: invalid value for address-virtual (%s)'
% (ifaceobj.name,
macvlan_ifacename,
' '.join(av_attrs)))
if (rhwaddress == av_attrs[0] and raddrs == av_attrs[1:] and
self._check_addresses_in_bridge(ifaceobj, av_attrs[0])):
ifaceobjcurr.update_config_with_status('address-virtual',

View File

@@ -63,7 +63,9 @@ class bridge(moduleBase):
# XXX: recheck values
{ 'help' : 'bridge garbage collection interval in secs',
'example' : ['bridge-gcint 4'],
'default' : '4'},
'default' : '4',
'compat' : True,
'deprecated': True},
'bridge-hello' :
{ 'help' : 'bridge set hello time',
'example' : ['bridge-hello 2'],
@@ -644,8 +646,6 @@ class bridge(moduleBase):
'bridge-bridgeprio'),
'fd' :
ifaceobj.get_attr_value_first('bridge-fd'),
'gcint' :
ifaceobj.get_attr_value_first('bridge-gcint'),
'hello' :
ifaceobj.get_attr_value_first('bridge-hello'),
'maxage' :

View File

@@ -350,15 +350,22 @@ class vrf(moduleBase):
def _up_vrf_slave(self, ifacename, vrfname, ifaceobj=None,
ifaceobj_getfunc=None, vrf_exists=False):
try:
master_exists = True
if vrf_exists or self.ipcmd.link_exists(vrfname):
upper = self.ipcmd.link_get_upper(ifacename)
if not upper or upper != vrfname:
self._handle_existing_connections(ifaceobj, vrfname)
self.ipcmd.link_set(ifacename, 'master', vrfname)
elif ifaceobj:
elif ifupdownflags.flags.ALL and ifaceobj:
self._up_vrf_slave_without_master(ifacename, vrfname, ifaceobj,
ifaceobj_getfunc)
rtnetlink_api.rtnl_api.link_set(ifacename, "up")
else:
master_exists = False
if master_exists:
rtnetlink_api.rtnl_api.link_set(ifacename, "up")
else:
self.log_error('vrf %s not around, skipping vrf config'
%(vrfname))
except Exception, e:
self.log_error('%s: %s' %(ifacename, str(e)))
@@ -454,6 +461,8 @@ class vrf(moduleBase):
if add_slaves:
for s in add_slaves:
try:
if not self.ipcmd.link_exists(s):
continue
sobj = None
if ifaceobj_getfunc:
sobj = ifaceobj_getfunc(s)
@@ -619,6 +628,9 @@ class vrf(moduleBase):
shell=False).split()[2]
self.logger.info("%s: killing active ssh sessions: %s"
%(ifacename, str(proc)))
if ifupdownflags.flags.DRYRUN:
return
for id in proc:
if id != pid:
try:

View File

@@ -9,6 +9,7 @@
class ifupdownFlags():
def __init__(self):
self.ALL = False
self.FORCE = False
self.DRYRUN = False
self.NOWAIT = False

View File

@@ -40,8 +40,6 @@ _success_sym = '(%s)' %_tickmark
_error_sym = '(%s)' %_crossmark
class ifupdownMainFlags():
WITH_DEPENDS = False
ALL = False
IFACE_CLASS = False
COMPAT_EXEC_SCRIPTS = False
STATEMANAGER_ENABLE = True
@@ -112,7 +110,8 @@ class ifupdownMain(ifupdownBase):
# there is no real interface behind it
if ifaceobj.type == ifaceType.BRIDGE_VLAN:
return
if ifaceobj.link_kind & ifaceLinkKind.VRF:
if ((ifaceobj.link_kind & ifaceLinkKind.VRF) or
(ifaceobj.link_privflags & ifaceLinkPrivFlags.VRF_SLAVE)):
return
if (ifaceobj.addr_method and
ifaceobj.addr_method == 'manual'):
@@ -131,7 +130,8 @@ class ifupdownMain(ifupdownBase):
self.link_up(ifaceobj.name)
def run_down(self, ifaceobj):
if ifaceobj.link_kind & ifaceLinkKind.VRF:
if ((ifaceobj.link_kind & ifaceLinkKind.VRF) or
(ifaceobj.link_privflags & ifaceLinkPrivFlags.VRF_SLAVE)):
return
# Skip link sets on ifaceobjs of type 'vlan' (used for l2 attrs)
# there is no real interface behind it
@@ -195,13 +195,13 @@ class ifupdownMain(ifupdownBase):
ifupdownflags.flags.NOWAIT = nowait
ifupdownflags.flags.PERFMODE = perfmode
ifupdownflags.flags.CACHE = cache
ifupdownflags.flags.WITH_DEPENDS = withdepends
# Can be used to provide hints for caching
ifupdownflags.flags.CACHE_FLAGS = 0x0
self.flags = ifupdownMainFlags()
self.flags.WITH_DEPENDS = withdepends
self.flags.STATEMANAGER_ENABLE = statemanager_enable
self.interfacesfile = interfacesfile
self.interfacesfileiobuf = interfacesfileiobuf
@@ -1103,8 +1103,8 @@ class ifupdownMain(ifupdownBase):
if not self.flags.ADDONS_ENABLE:
self.flags.STATEMANAGER_UPDATE = False
if auto:
self.flags.ALL = True
self.flags.WITH_DEPENDS = True
ifupdownflags.flags.ALL = True
ifupdownflags.flags.WITH_DEPENDS = True
try:
iface_read_ret = self.read_iface_config()
except Exception:
@@ -1143,7 +1143,8 @@ class ifupdownMain(ifupdownBase):
ret = self._sched_ifaces(filtered_ifacenames, ops,
skipupperifaces=skipupperifaces,
followdependents=True
if self.flags.WITH_DEPENDS else False)
if ifupdownflags.flags.WITH_DEPENDS
else False)
finally:
self._process_delay_admin_state_queue('up')
if not ifupdownflags.flags.DRYRUN and self.flags.ADDONS_ENABLE:
@@ -1164,8 +1165,8 @@ class ifupdownMain(ifupdownBase):
if not self.flags.ADDONS_ENABLE:
self.flags.STATEMANAGER_UPDATE = False
if auto:
self.flags.ALL = True
self.flags.WITH_DEPENDS = True
ifupdownflags.flags.ALL = True
ifupdownflags.flags.WITH_DEPENDS = True
# For down we need to look at old state, unless usecurrentconfig
# is set
if (not usecurrentconfig and self.flags.STATEMANAGER_ENABLE and
@@ -1210,7 +1211,7 @@ class ifupdownMain(ifupdownBase):
try:
self._sched_ifaces(filtered_ifacenames, ops,
followdependents=True
if self.flags.WITH_DEPENDS else False)
if ifupdownflags.flags.WITH_DEPENDS else False)
finally:
self._process_delay_admin_state_queue('down')
if not ifupdownflags.flags.DRYRUN and self.flags.ADDONS_ENABLE:
@@ -1236,8 +1237,8 @@ class ifupdownMain(ifupdownBase):
self.flags.STATEMANAGER_UPDATE = False
if auto:
self.logger.debug('setting flag ALL')
self.flags.ALL = True
self.flags.WITH_DEPENDS = True
ifupdownflags.flags.ALL = True
ifupdownflags.flags.WITH_DEPENDS = True
if ops[0] == 'query-syntax':
self._modules_help()
@@ -1285,7 +1286,7 @@ class ifupdownMain(ifupdownBase):
ret = self._sched_ifaces(filtered_ifacenames, ops,
followdependents=True
if self.flags.WITH_DEPENDS else False)
if ifupdownflags.flags.WITH_DEPENDS else False)
if ops[0] == 'query' and ifupdownflags.flags.WITHDEFAULTS:
return self.print_ifaceobjs_pretty(filtered_ifacenames, format)
@@ -1371,8 +1372,8 @@ class ifupdownMain(ifupdownBase):
# Now, run 'up' with new config dict
# reset statemanager update flag to default
if auto:
self.flags.ALL = True
self.flags.WITH_DEPENDS = True
ifupdownflags.flags.ALL = True
ifupdownflags.flags.WITH_DEPENDS = True
if new_ifaceobjdict:
# and now, ifaceobjdict is back to current config
self.ifaceobjdict = new_ifaceobjdict
@@ -1384,7 +1385,7 @@ class ifupdownMain(ifupdownBase):
%str(interfaces_to_up))
ret = self._sched_ifaces(interfaces_to_up, upops,
followdependents=True
if self.flags.WITH_DEPENDS else False)
if ifupdownflags.flags.WITH_DEPENDS else False)
if ifupdownflags.flags.DRYRUN:
return
self._save_state()
@@ -1557,8 +1558,8 @@ class ifupdownMain(ifupdownBase):
return
if auto:
self.flags.ALL = True
self.flags.WITH_DEPENDS = True
ifupdownflags.flags.ALL = True
ifupdownflags.flags.WITH_DEPENDS = True
# and now, we are back to the current config in ifaceobjdict
self.ifaceobjdict = new_ifaceobjdict
self.dependency_graph = new_dependency_graph
@@ -1569,7 +1570,8 @@ class ifupdownMain(ifupdownBase):
try:
ret = self._sched_ifaces(new_filtered_ifacenames, upops,
followdependents=True
if self.flags.WITH_DEPENDS else False)
if ifupdownflags.flags.WITH_DEPENDS
else False)
except Exception, e:
ret = None
self.logger.error(str(e))
@@ -1625,7 +1627,8 @@ class ifupdownMain(ifupdownBase):
continue
ifaceobj.dump_raw(self.logger)
print '\n'
if self.flags.WITH_DEPENDS and not self.flags.ALL:
if (ifupdownflags.flags.WITH_DEPENDS and
not ifupdownflags.flags.ALL):
dlist = ifaceobj.lowerifaces
if not dlist: continue
self.print_ifaceobjs_raw(dlist)
@@ -1639,7 +1642,8 @@ class ifupdownMain(ifupdownBase):
(running and not ifaceobj.is_config_present())):
continue
ifaceobjs.append(ifaceobj)
if self.flags.WITH_DEPENDS and not self.flags.ALL:
if (ifupdownflags.flags.WITH_DEPENDS and
not ifupdownflags.flags.ALL):
dlist = ifaceobj.lowerifaces
if not dlist: continue
self._get_ifaceobjs_pretty(dlist, ifaceobjs, running)
@@ -1675,7 +1679,8 @@ class ifupdownMain(ifupdownBase):
if self.is_ifaceobj_noconfig(ifaceobj):
continue
ifaceobjs.append(ifaceobj)
if self.flags.WITH_DEPENDS and not self.flags.ALL:
if (ifupdownflags.flags.WITH_DEPENDS and
not ifupdownflags.flags.ALL):
dlist = ifaceobj.lowerifaces
if not dlist: continue
dret = self._get_ifaceobjscurr_pretty(dlist, ifaceobjs)

View File

@@ -184,7 +184,7 @@ class ifaceScheduler():
not ifupdownobj.flags.ADDONS_ENABLE or
(not ifupdownobj.is_ifaceobj_noconfig(ifaceobj) and
ifupdownobj.config.get('warn_on_ifdown', '0') == '0' and
not ifupdownobj.flags.ALL)):
not ifupdownflags.flags.ALL)):
return True
ulist = ifaceobj.upperifaces
@@ -201,7 +201,7 @@ class ifaceScheduler():
# return false to the caller to skip this interface
for u in tmpulist:
if ifupdownobj.link_exists(u):
if not ifupdownobj.flags.ALL:
if not ifupdownflags.flags.ALL:
if ifupdownobj.is_ifaceobj_noconfig(ifaceobj):
ifupdownobj.logger.info('%s: skipping interface down,'
%ifaceobj.name + ' upperiface %s still around ' %u)
@@ -423,7 +423,7 @@ class ifaceScheduler():
ifacenames_all_sorted = graph.topological_sort_graphs_all(
dependency_graph, indegrees)
# if ALL was set, return all interfaces
if ifupdownobj.flags.ALL:
if ifupdownflags.flags.ALL:
return ifacenames_all_sorted
# else return ifacenames passed as argument in sorted order
@@ -480,7 +480,7 @@ class ifaceScheduler():
for ifacename in dependency_graph.keys():
indegrees[ifacename] = ifupdownobj.get_iface_refcnt(ifacename)
if not ifupdownobj.flags.ALL:
if not ifupdownflags.flags.ALL:
if 'up' in ops[0]:
# If there is any interface that does not exist, maybe it
# is a logical interface and we have to followupperifaces
@@ -537,7 +537,7 @@ class ifaceScheduler():
if (not skipupperifaces and
ifupdownobj.config.get('skip_upperifaces', '0') == '0' and
((not ifupdownobj.flags.ALL and followdependents) or
((not ifupdownflags.flags.ALL and followdependents) or
followupperifaces) and
'up' in ops[0]):
# If user had given a set of interfaces to bring up

View File

@@ -143,7 +143,8 @@ def run_reload(args):
ifupdown_handle = ifupdownMain(config=configmap_g,
interfacesfile=interfacesfilename,
withdepends=args.withdepends,
perfmode=args.perfmode)
perfmode=args.perfmode,
dryrun=args.noact)
ifupdown_handle.reload(['pre-up', 'up', 'post-up'],
['pre-down', 'down', 'post-down'],
auto=args.all, allow=args.CLASS, ifacenames=None,
@@ -354,7 +355,8 @@ def update_ifreload_argparser(argparser):
argparser.add_argument('iflist', metavar='IFACE',
nargs='*', help=argparse.SUPPRESS)
argparser.add_argument('-n', '--no-act', dest='noact',
action='store_true', help=argparse.SUPPRESS)
action='store_true', help='print out what would happen,' +
'but don\'t do it')
argparser.add_argument('-v', '--verbose', dest='verbose',
action='store_true', help='verbose')
argparser.add_argument('-d', '--debug', dest='debug',