mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
netlink: adding support for netlink vxlan call via nlmanager
Ticket: CM-8035 Reviewed By: CCR-4896 Testing Done: ifupdown smoke, -t vxlan tests Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
@ -5,7 +5,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
from ifupdownaddons.utilsbase import utilsBase
|
from ifupdownaddons.utilsbase import utilsBase
|
||||||
from nlmanager.nlmanager import NetlinkManager
|
from nlmanager.nlmanager import NetlinkManager
|
||||||
import ifupdown.ifupdownflags as ifupdownflags
|
import ifupdown.ifupdownflags as ifupdownflags
|
||||||
@ -14,6 +13,8 @@ except ImportError, e:
|
|||||||
|
|
||||||
|
|
||||||
class Netlink(utilsBase):
|
class Netlink(utilsBase):
|
||||||
|
VXLAN_UDP_PORT = 4789
|
||||||
|
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
utilsBase.__init__(self, *args, **kargs)
|
utilsBase.__init__(self, *args, **kargs)
|
||||||
self._nlmanager_api = NetlinkManager()
|
self._nlmanager_api = NetlinkManager()
|
||||||
@ -88,4 +89,21 @@ class Netlink(utilsBase):
|
|||||||
raise Exception('netlink: %s: cannot remove bridge vlan %s: %s'
|
raise Exception('netlink: %s: cannot remove bridge vlan %s: %s'
|
||||||
% (ifacename, vlanid, str(e)))
|
% (ifacename, vlanid, str(e)))
|
||||||
|
|
||||||
|
def link_add_vxlan(self, ifacename, vxlanid, local=None, dstport=VXLAN_UDP_PORT,
|
||||||
|
group=None, learning='on', ageing=None):
|
||||||
|
self.logger.info('netlink: %s: creating vxlan %s'
|
||||||
|
% (ifacename, vxlanid))
|
||||||
|
if ifupdownflags.flags.DRYRUN: return
|
||||||
|
try:
|
||||||
|
return self._nlmanager_api.link_add_vxlan(ifacename,
|
||||||
|
vxlanid,
|
||||||
|
dstport=dstport,
|
||||||
|
local=local,
|
||||||
|
group=group,
|
||||||
|
learning=learning,
|
||||||
|
ageing=ageing)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception('netlink: %s: cannot create vxlan %s: %s'
|
||||||
|
% (ifacename, vxlanid, str(e)))
|
||||||
|
|
||||||
netlink = Netlink()
|
netlink = Netlink()
|
||||||
|
Reference in New Issue
Block a user