mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 23:58:44 +00:00
lib: topogen support for link_enable on other netns
In the case where vrf backend is based on NETNS, the link enable command switches from context so as to perform the command. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
e3060696ef
commit
0ab7733f7f
@ -449,7 +449,7 @@ class TopoGear(object):
|
|||||||
"""
|
"""
|
||||||
self.tgen.add_link(self, node, myif, nodeif)
|
self.tgen.add_link(self, node, myif, nodeif)
|
||||||
|
|
||||||
def link_enable(self, myif, enabled=True):
|
def link_enable(self, myif, enabled=True, netns=None):
|
||||||
"""
|
"""
|
||||||
Set this node interface administrative state.
|
Set this node interface administrative state.
|
||||||
myif: this node interface name
|
myif: this node interface name
|
||||||
@ -466,9 +466,12 @@ class TopoGear(object):
|
|||||||
logger.info('setting node "{}" link "{}" to state "{}"'.format(
|
logger.info('setting node "{}" link "{}" to state "{}"'.format(
|
||||||
self.name, myif, operation
|
self.name, myif, operation
|
||||||
))
|
))
|
||||||
return self.run('ip link set dev {} {}'.format(myif, operation))
|
extract=''
|
||||||
|
if netns is not None:
|
||||||
|
extract = 'ip netns exec {} '.format(netns)
|
||||||
|
return self.run('{}ip link set dev {} {}'.format(extract, myif, operation))
|
||||||
|
|
||||||
def peer_link_enable(self, myif, enabled=True):
|
def peer_link_enable(self, myif, enabled=True, netns=None):
|
||||||
"""
|
"""
|
||||||
Set the peer interface administrative state.
|
Set the peer interface administrative state.
|
||||||
myif: this node interface name
|
myif: this node interface name
|
||||||
@ -481,7 +484,7 @@ class TopoGear(object):
|
|||||||
raise KeyError('interface doesn\'t exists')
|
raise KeyError('interface doesn\'t exists')
|
||||||
|
|
||||||
node, nodeif = self.links[myif]
|
node, nodeif = self.links[myif]
|
||||||
node.link_enable(nodeif, enabled)
|
node.link_enable(nodeif, enabled, netns)
|
||||||
|
|
||||||
def new_link(self):
|
def new_link(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user