tunattrs['ttl'] = citems[j + 1]
elif citems[j] == 'dev':
tunattrs['physdev'] = citems[j + 1]
+ elif citems[j] in ['vti', 'vti6', 'ip6gre', 'ipip6', 'ip6ip6']:
+ tunattrs['mode'] = citems[j]
linkattrs['linkinfo'] = tunattrs
break
elif citems[i] == 'link/ppp':
return self._cache_get('link', [ifacename, 'ifflag'], refresh=True)
@staticmethod
- def route_add_gateway(ifacename, gateway, vrf=None, metric=None):
+ def route_add_gateway(ifacename, gateway, vrf=None, metric=None, onlink=True):
if not gateway:
return
if not vrf:
if metric:
cmd += 'metric %s' % metric
cmd += ' dev %s' % ifacename
+
+ if onlink:
+ cmd += " onlink"
+
utils.exec_command(cmd)
@staticmethod
if '6' in mode:
cmd = ' -6 '
- cmd += 'tunnel add'
- cmd += ' %s mode %s' %(tunnelname, mode)
+ if mode in ['gretap']:
+ cmd += 'link add %s type %s' % (tunnelname, mode)
+ else:
+ cmd += 'tunnel add %s mode %s' % (tunnelname, mode)
+
if attrs:
for k, v in attrs.iteritems():
- cmd += ' %s' %k
+ cmd += ' %s' % k
if v:
- cmd += ' %s' %v
+ cmd += ' %s' % v
if self.ipbatch and not self.ipbatch_pause:
self.add_to_batch(cmd)
else:
self.add_to_batch(cmd)
else:
utils.exec_command('ip %s' % cmd)
- self._cache_update([tunnelname], {})
def link_create_vxlan(self, name, vxlanid,
localtunnelip=None,
if not bridgeout: return brvlaninfo
try:
- vlan_json_dict = json.loads(bridgeout, encoding="utf-8")
+ vlan_json = json.loads(bridgeout, encoding="utf-8")
except Exception, e:
self.logger.info('json loads failed with (%s)' % str(e))
return {}
- return vlan_json_dict
+
+ try:
+ if isinstance(vlan_json, list):
+ # newer iproute2 version changed the bridge vlan show output
+ # ifupdown2 relies on the previous format, we have the convert
+ # data into old format
+ bridge_port_vids = dict()
+
+ for intf in vlan_json:
+ bridge_port_vids[intf["ifname"]] = intf["vlans"]
+
+ return bridge_port_vids
+ else:
+ # older iproute2 version have different ways to dump vlans
+ # ifupdown2 prefers the following syntax:
+ # {
+ # "vx-1002": [{
+ # "vlan": 1002,
+ # "flags": ["PVID", "Egress Untagged"]
+ # }
+ # ],
+ # "vx-1004": [{
+ # "vlan": 1004,
+ # "flags": ["PVID", "Egress Untagged"]
+ # }]
+ # }
+ return vlan_json
+ except Exception as e:
+ self.logger.debug("bridge vlan show: Unknown json output: %s" % str(e))
+ return vlan_json
@staticmethod
def get_bridge_vlan_nojson():