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:
@@ -20,16 +20,18 @@ class Netlink(utilsBase):
|
||||
self._nlmanager_api = NetlinkManager()
|
||||
|
||||
def get_iface_index(self, ifacename):
|
||||
self.logger.info('netlink: %s: get iface index' % ifacename)
|
||||
self.logger.info('%s: netlink: %s: get iface index'
|
||||
% (ifacename, ifacename))
|
||||
if ifupdownflags.flags.DRYRUN: return
|
||||
try:
|
||||
return self._nlmanager_api.get_iface_index(ifacename)
|
||||
except Exception as e:
|
||||
raise Exception('netlink: %s: cannot get ifindex: %s'
|
||||
% (ifacename, str(e)))
|
||||
raise Exception('%s: netlink: %s: cannot get ifindex: %s'
|
||||
% (ifacename, ifacename, str(e)))
|
||||
|
||||
def link_add_vlan(self, vlanrawdevice, ifacename, vlanid):
|
||||
self.logger.info('netlink: %s: creating vlan %s' % (vlanrawdevice, vlanid))
|
||||
self.logger.info('%s: netlink: ip link add link %s name %s type vlan id %s'
|
||||
% (ifacename, vlanrawdevice, ifacename, vlanid))
|
||||
if ifupdownflags.flags.DRYRUN: return
|
||||
ifindex = self.get_iface_index(vlanrawdevice)
|
||||
try:
|
||||
@@ -39,8 +41,8 @@ class Netlink(utilsBase):
|
||||
% (vlanrawdevice, vlanid, str(e)))
|
||||
|
||||
def link_add_macvlan(self, ifacename, macvlan_ifacename):
|
||||
self.logger.info('netlink: %s: creating macvlan %s'
|
||||
% (ifacename, macvlan_ifacename))
|
||||
self.logger.info('%s: netlink: ip link add link %s name %s type macvlan mode private'
|
||||
% (ifacename, ifacename, macvlan_ifacename))
|
||||
if ifupdownflags.flags.DRYRUN: return
|
||||
ifindex = self.get_iface_index(ifacename)
|
||||
try:
|
||||
@@ -50,7 +52,8 @@ class Netlink(utilsBase):
|
||||
% (ifacename, macvlan_ifacename, str(e)))
|
||||
|
||||
def link_set_updown(self, ifacename, state):
|
||||
self.logger.info('netlink: set link %s %s' % (ifacename, state))
|
||||
self.logger.info('%s: netlink: ip link set dev %s %s'
|
||||
% (ifacename, ifacename, state))
|
||||
if ifupdownflags.flags.DRYRUN: return
|
||||
try:
|
||||
return self._nlmanager_api.link_set_updown(ifacename, state)
|
||||
@@ -59,7 +62,8 @@ class Netlink(utilsBase):
|
||||
% (ifacename, state, str(e)))
|
||||
|
||||
def link_set_protodown(self, ifacename, state):
|
||||
self.logger.info('netlink: set link %s protodown %s' % (ifacename, state))
|
||||
self.logger.info('%s: netlink: set link %s protodown %s'
|
||||
% (ifacename, ifacename, state))
|
||||
if ifupdownflags.flags.DRYRUN: return
|
||||
try:
|
||||
return self._nlmanager_api.link_set_protodown(ifacename, state)
|
||||
@@ -68,8 +72,8 @@ class Netlink(utilsBase):
|
||||
% (ifacename, state, str(e)))
|
||||
|
||||
def link_add_bridge_vlan(self, ifacename, vlanid):
|
||||
self.logger.info('netlink: %s: creating bridge vlan %s'
|
||||
% (ifacename, vlanid))
|
||||
self.logger.info('%s: netlink: bridge vlan add vid %s dev %s'
|
||||
% (ifacename, vlanid, ifacename))
|
||||
if ifupdownflags.flags.DRYRUN: return
|
||||
ifindex = self.get_iface_index(ifacename)
|
||||
try:
|
||||
@@ -79,8 +83,8 @@ class Netlink(utilsBase):
|
||||
% (ifacename, vlanid, str(e)))
|
||||
|
||||
def link_del_bridge_vlan(self, ifacename, vlanid):
|
||||
self.logger.info('netlink: %s: removing bridge vlan %s'
|
||||
% (ifacename, vlanid))
|
||||
self.logger.info('%s: netlink: bridge vlan del vid %s dev %s'
|
||||
% (ifacename, vlanid, ifacename))
|
||||
if ifupdownflags.flags.DRYRUN: return
|
||||
ifindex = self.get_iface_index(ifacename)
|
||||
try:
|
||||
@@ -91,8 +95,14 @@ class Netlink(utilsBase):
|
||||
|
||||
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))
|
||||
cmd = 'ip link add %s type vxlan id %s dstport %s' % (ifacename,
|
||||
vxlanid,
|
||||
dstport)
|
||||
cmd += ' local %s' % local if local else ''
|
||||
cmd += ' ageing %s' % ageing if ageing else ''
|
||||
cmd += ' remote %s' % group if group else ' noremote'
|
||||
cmd += ' nolearning' if learning == 'off' else ''
|
||||
self.logger.info('%s: netlink: %s' % (ifacename, cmd))
|
||||
if ifupdownflags.flags.DRYRUN: return
|
||||
try:
|
||||
return self._nlmanager_api.link_add_vxlan(ifacename,
|
||||
|
@@ -57,6 +57,8 @@ class moduleBase(object):
|
||||
if ifaceobj:
|
||||
ifaceobj.set_status(ifaceStatus.ERROR)
|
||||
raise Exception(str)
|
||||
else:
|
||||
self.logger.error(str)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user