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 av_idx += 1
continue continue
raddrs = raddrs.keys() 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 if (rhwaddress == av_attrs[0] and raddrs == av_attrs[1:] and
self._check_addresses_in_bridge(ifaceobj, av_attrs[0])): self._check_addresses_in_bridge(ifaceobj, av_attrs[0])):
ifaceobjcurr.update_config_with_status('address-virtual', ifaceobjcurr.update_config_with_status('address-virtual',

View File

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

View File

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

View File

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

View File

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

View File

@@ -184,7 +184,7 @@ class ifaceScheduler():
not ifupdownobj.flags.ADDONS_ENABLE or not ifupdownobj.flags.ADDONS_ENABLE or
(not ifupdownobj.is_ifaceobj_noconfig(ifaceobj) and (not ifupdownobj.is_ifaceobj_noconfig(ifaceobj) and
ifupdownobj.config.get('warn_on_ifdown', '0') == '0' and ifupdownobj.config.get('warn_on_ifdown', '0') == '0' and
not ifupdownobj.flags.ALL)): not ifupdownflags.flags.ALL)):
return True return True
ulist = ifaceobj.upperifaces ulist = ifaceobj.upperifaces
@@ -201,7 +201,7 @@ class ifaceScheduler():
# return false to the caller to skip this interface # return false to the caller to skip this interface
for u in tmpulist: for u in tmpulist:
if ifupdownobj.link_exists(u): if ifupdownobj.link_exists(u):
if not ifupdownobj.flags.ALL: if not ifupdownflags.flags.ALL:
if ifupdownobj.is_ifaceobj_noconfig(ifaceobj): if ifupdownobj.is_ifaceobj_noconfig(ifaceobj):
ifupdownobj.logger.info('%s: skipping interface down,' ifupdownobj.logger.info('%s: skipping interface down,'
%ifaceobj.name + ' upperiface %s still around ' %u) %ifaceobj.name + ' upperiface %s still around ' %u)
@@ -423,7 +423,7 @@ class ifaceScheduler():
ifacenames_all_sorted = graph.topological_sort_graphs_all( ifacenames_all_sorted = graph.topological_sort_graphs_all(
dependency_graph, indegrees) dependency_graph, indegrees)
# if ALL was set, return all interfaces # if ALL was set, return all interfaces
if ifupdownobj.flags.ALL: if ifupdownflags.flags.ALL:
return ifacenames_all_sorted return ifacenames_all_sorted
# else return ifacenames passed as argument in sorted order # else return ifacenames passed as argument in sorted order
@@ -480,7 +480,7 @@ class ifaceScheduler():
for ifacename in dependency_graph.keys(): for ifacename in dependency_graph.keys():
indegrees[ifacename] = ifupdownobj.get_iface_refcnt(ifacename) indegrees[ifacename] = ifupdownobj.get_iface_refcnt(ifacename)
if not ifupdownobj.flags.ALL: if not ifupdownflags.flags.ALL:
if 'up' in ops[0]: if 'up' in ops[0]:
# If there is any interface that does not exist, maybe it # If there is any interface that does not exist, maybe it
# is a logical interface and we have to followupperifaces # is a logical interface and we have to followupperifaces
@@ -537,7 +537,7 @@ class ifaceScheduler():
if (not skipupperifaces and if (not skipupperifaces and
ifupdownobj.config.get('skip_upperifaces', '0') == '0' 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 followupperifaces) and
'up' in ops[0]): 'up' in ops[0]):
# If user had given a set of interfaces to bring up # 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, ifupdown_handle = ifupdownMain(config=configmap_g,
interfacesfile=interfacesfilename, interfacesfile=interfacesfilename,
withdepends=args.withdepends, withdepends=args.withdepends,
perfmode=args.perfmode) perfmode=args.perfmode,
dryrun=args.noact)
ifupdown_handle.reload(['pre-up', 'up', 'post-up'], ifupdown_handle.reload(['pre-up', 'up', 'post-up'],
['pre-down', 'down', 'post-down'], ['pre-down', 'down', 'post-down'],
auto=args.all, allow=args.CLASS, ifacenames=None, auto=args.all, allow=args.CLASS, ifacenames=None,
@@ -354,7 +355,8 @@ def update_ifreload_argparser(argparser):
argparser.add_argument('iflist', metavar='IFACE', argparser.add_argument('iflist', metavar='IFACE',
nargs='*', help=argparse.SUPPRESS) nargs='*', help=argparse.SUPPRESS)
argparser.add_argument('-n', '--no-act', dest='noact', 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', argparser.add_argument('-v', '--verbose', dest='verbose',
action='store_true', help='verbose') action='store_true', help='verbose')
argparser.add_argument('-d', '--debug', dest='debug', argparser.add_argument('-d', '--debug', dest='debug',