mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: support for new addon module for vrf
This patch adds initial support for vrf in ifupdown2. Example interfaces file section: auto swp1.100 iface swp1.100 vrf blue auto blue iface blue vrf-table 10 iproute2 vrf map is generated under: /etc/iproute2/rt_tables.d/ifupdown2.vrf_map this patch also adds prelimnary support for 'vrf-table auto'. But this needs more work. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
@@ -585,6 +585,9 @@ class iproute2(utilsBase):
|
||||
def get_vxlandev_attrs(self, ifacename):
|
||||
return self._cache_get('link', [ifacename, 'linkinfo'])
|
||||
|
||||
def link_get_linkinfo_attrs(self, ifacename):
|
||||
return self._cache_get('link', [ifacename, 'linkinfo'])
|
||||
|
||||
def link_get_mtu(self, ifacename):
|
||||
return self._cache_get('link', [ifacename, 'mtu'])
|
||||
|
||||
@@ -600,13 +603,17 @@ class iproute2(utilsBase):
|
||||
%ifacename)
|
||||
return address
|
||||
|
||||
def link_create(self, ifacename, type, link=None):
|
||||
def link_create(self, ifacename, type, attrs={}):
|
||||
""" generic link_create function """
|
||||
if self.link_exists(ifacename):
|
||||
return
|
||||
cmd = 'link add'
|
||||
if link:
|
||||
cmd += ' link %s' %link
|
||||
cmd += ' name %s type %s' %(ifacename, type)
|
||||
if attrs:
|
||||
for k, v in attrs.iteritems():
|
||||
cmd += ' %s' %k
|
||||
if v:
|
||||
cmd += ' %s' %v
|
||||
if self.ipbatch and not self.ipbatch_pause:
|
||||
self.add_to_batch(cmd)
|
||||
else:
|
||||
@@ -623,6 +630,17 @@ class iproute2(utilsBase):
|
||||
self.exec_command('ip %s' %cmd)
|
||||
self._cache_invalidate()
|
||||
|
||||
def link_get_master(self, ifacename):
|
||||
sysfs_master_path = '/sys/class/net/%s/master' %ifacename
|
||||
if os.path.exists(sysfs_master_path):
|
||||
link_path = os.readlink(sysfs_master_path)
|
||||
if link_path:
|
||||
return os.path.basename(link_path)
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
return self._cache_get('link', [ifacename, 'master'])
|
||||
|
||||
def bridge_port_vids_add(self, bridgeportname, vids):
|
||||
[self.exec_command('bridge vlan add vid %s dev %s'
|
||||
%(v, bridgeportname)) for v in vids]
|
||||
|
Reference in New Issue
Block a user