mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Fix a few minor ifquery check failures
Ticket: CM-3346 Reviewed By: Testing Done: Tested ifupdown2 sanity and query check failures.
This commit is contained in:
@@ -259,6 +259,7 @@ class address(moduleBase):
|
|||||||
if not self.ipcmd.link_exists(ifaceobj.name):
|
if not self.ipcmd.link_exists(ifaceobj.name):
|
||||||
self.logger.debug('iface %s not found' %ifaceobj.name)
|
self.logger.debug('iface %s not found' %ifaceobj.name)
|
||||||
return
|
return
|
||||||
|
addr_method = ifaceobj.addr_method
|
||||||
self.query_n_update_ifaceobjcurr_attr(ifaceobj, ifaceobjcurr,
|
self.query_n_update_ifaceobjcurr_attr(ifaceobj, ifaceobjcurr,
|
||||||
'mtu', self.ipcmd.link_get_mtu)
|
'mtu', self.ipcmd.link_get_mtu)
|
||||||
hwaddress = ifaceobj.get_attr_value_first('hwaddress')
|
hwaddress = ifaceobj.get_attr_value_first('hwaddress')
|
||||||
@@ -278,6 +279,8 @@ class address(moduleBase):
|
|||||||
self.query_n_update_ifaceobjcurr_attr(ifaceobj, ifaceobjcurr,
|
self.query_n_update_ifaceobjcurr_attr(ifaceobj, ifaceobjcurr,
|
||||||
'alias', self.ipcmd.link_get_alias)
|
'alias', self.ipcmd.link_get_alias)
|
||||||
# compare addresses
|
# compare addresses
|
||||||
|
if addr_method == 'dhcp':
|
||||||
|
return
|
||||||
addrs = self._get_iface_addresses(ifaceobj)
|
addrs = self._get_iface_addresses(ifaceobj)
|
||||||
runningaddrsdict = self.ipcmd.addr_get(ifaceobj.name)
|
runningaddrsdict = self.ipcmd.addr_get(ifaceobj.name)
|
||||||
|
|
||||||
@@ -320,7 +323,6 @@ class address(moduleBase):
|
|||||||
def _query_running(self, ifaceobjrunning):
|
def _query_running(self, ifaceobjrunning):
|
||||||
if not self.ipcmd.link_exists(ifaceobjrunning.name):
|
if not self.ipcmd.link_exists(ifaceobjrunning.name):
|
||||||
self.logger.debug('iface %s not found' %ifaceobjrunning.name)
|
self.logger.debug('iface %s not found' %ifaceobjrunning.name)
|
||||||
ifaceobjrunning.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
dhclientcmd = dhclient()
|
dhclientcmd = dhclient()
|
||||||
if (dhclientcmd.is_running(ifaceobjrunning.name) or
|
if (dhclientcmd.is_running(ifaceobjrunning.name) or
|
||||||
|
@@ -1084,7 +1084,6 @@ class bridge(moduleBase):
|
|||||||
return
|
return
|
||||||
if not self.brctlcmd.bridge_exists(ifaceobj.name):
|
if not self.brctlcmd.bridge_exists(ifaceobj.name):
|
||||||
self.logger.info('%s: bridge: does not exist' %(ifaceobj.name))
|
self.logger.info('%s: bridge: does not exist' %(ifaceobj.name))
|
||||||
ifaceobjcurr.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
|
|
||||||
ifaceattrs = self.dict_key_subset(ifaceobj.config,
|
ifaceattrs = self.dict_key_subset(ifaceobj.config,
|
||||||
|
@@ -119,6 +119,7 @@ class bridgevlan(moduleBase):
|
|||||||
else:
|
else:
|
||||||
ifaceobjcurr.update_config_with_status(
|
ifaceobjcurr.update_config_with_status(
|
||||||
'bridge-igmp-querier-src', attrval, 0)
|
'bridge-igmp-querier-src', attrval, 0)
|
||||||
|
ifaceobjcurr.status = ifaceStatus.SUCCESS
|
||||||
return
|
return
|
||||||
|
|
||||||
def _query_running(self, ifaceobjrunning):
|
def _query_running(self, ifaceobjrunning):
|
||||||
|
@@ -61,19 +61,19 @@ class dhcp(moduleBase):
|
|||||||
if ifaceobj.addr_family != 'inet':
|
if ifaceobj.addr_family != 'inet':
|
||||||
ifaceobjcurr.status = ifaceStatus.ERROR
|
ifaceobjcurr.status = ifaceStatus.ERROR
|
||||||
ifaceobjcurr.addr_method = 'dhcp'
|
ifaceobjcurr.addr_method = 'dhcp'
|
||||||
|
ifaceobjcurr.status = ifaceStatus.SUCCESS
|
||||||
elif self.dhclientcmd.is_running6(ifaceobjcurr.name):
|
elif self.dhclientcmd.is_running6(ifaceobjcurr.name):
|
||||||
ifaceobjcurr.addr_family = 'inet6'
|
ifaceobjcurr.addr_family = 'inet6'
|
||||||
if ifaceobj.addr_family != 'inet6':
|
if ifaceobj.addr_family != 'inet6':
|
||||||
ifaceobjcurr.status = ifaceStatus.ERROR
|
ifaceobjcurr.status = ifaceStatus.ERROR
|
||||||
ifaceobjcurr.addr_method = 'dhcp'
|
ifaceobjcurr.addr_method = 'dhcp'
|
||||||
|
ifaceobjcurr.status = ifaceStatus.SUCCESS
|
||||||
else:
|
else:
|
||||||
ifaceobjcurr.addr_family = None
|
ifaceobjcurr.addr_family = None
|
||||||
ifaceobjcurr.status = ifaceStatus.ERROR
|
ifaceobjcurr.status = ifaceStatus.ERROR
|
||||||
|
|
||||||
def _query_running(self, ifaceobjrunning):
|
def _query_running(self, ifaceobjrunning):
|
||||||
if not self.ipcmd.link_exists(ifaceobjrunning.name):
|
if not self.ipcmd.link_exists(ifaceobjrunning.name):
|
||||||
self.logger.debug('iface %s not found' %ifaceobjrunning.name)
|
|
||||||
ifaceobjrunning.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
if self.dhclientcmd.is_running(ifaceobjrunning.name):
|
if self.dhclientcmd.is_running(ifaceobjrunning.name):
|
||||||
ifaceobjrunning.addr_family = 'inet'
|
ifaceobjrunning.addr_family = 'inet'
|
||||||
|
@@ -259,7 +259,6 @@ class ifenslave(moduleBase):
|
|||||||
if not self.ifenslavecmd.bond_exists(ifaceobj.name):
|
if not self.ifenslavecmd.bond_exists(ifaceobj.name):
|
||||||
self.logger.debug('bond iface %s' %ifaceobj.name +
|
self.logger.debug('bond iface %s' %ifaceobj.name +
|
||||||
' does not exist')
|
' does not exist')
|
||||||
ifaceobjcurr.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
|
|
||||||
ifaceattrs = self.dict_key_subset(ifaceobj.config,
|
ifaceattrs = self.dict_key_subset(ifaceobj.config,
|
||||||
|
@@ -36,7 +36,6 @@ class loopback(moduleBase):
|
|||||||
|
|
||||||
def _query_check(self, ifaceobj, ifaceobjcurr):
|
def _query_check(self, ifaceobj, ifaceobjcurr):
|
||||||
if not self.ipcmd.link_exists(ifaceobj.name):
|
if not self.ipcmd.link_exists(ifaceobj.name):
|
||||||
ifaceobjcurr.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
|
|
||||||
_run_ops = {'pre-up' : _up,
|
_run_ops = {'pre-up' : _up,
|
||||||
|
@@ -510,7 +510,6 @@ class mstpctl(moduleBase):
|
|||||||
|
|
||||||
bridgeattrdict.update({k : [v] for k, v in portconfig.items()
|
bridgeattrdict.update({k : [v] for k, v in portconfig.items()
|
||||||
if v})
|
if v})
|
||||||
self.logger.debug(bridgeattrdict)
|
|
||||||
return bridgeattrdict
|
return bridgeattrdict
|
||||||
|
|
||||||
def _query_check_bridge(self, ifaceobj, ifaceobjcurr):
|
def _query_check_bridge(self, ifaceobj, ifaceobjcurr):
|
||||||
@@ -519,7 +518,6 @@ class mstpctl(moduleBase):
|
|||||||
'mstpctl-treeportprio', 'mstpctl-treeportcost']
|
'mstpctl-treeportprio', 'mstpctl-treeportcost']
|
||||||
if not self.brctlcmd.bridge_exists(ifaceobj.name):
|
if not self.brctlcmd.bridge_exists(ifaceobj.name):
|
||||||
self.logger.debug('bridge %s does not exist' %ifaceobj.name)
|
self.logger.debug('bridge %s does not exist' %ifaceobj.name)
|
||||||
ifaceobjcurr.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
ifaceattrs = self.dict_key_subset(ifaceobj.config,
|
ifaceattrs = self.dict_key_subset(ifaceobj.config,
|
||||||
self.get_mod_attrs())
|
self.get_mod_attrs())
|
||||||
@@ -617,8 +615,8 @@ class mstpctl(moduleBase):
|
|||||||
return
|
return
|
||||||
bridgename = self.ipcmd.bridge_port_get_bridge_name(ifaceobj.name)
|
bridgename = self.ipcmd.bridge_port_get_bridge_name(ifaceobj.name)
|
||||||
# list of attributes that are not supported currently
|
# list of attributes that are not supported currently
|
||||||
blacklistedattrs = ['mstpctl-pathcost',
|
blacklistedattrs = ['mstpctl-portpathcost',
|
||||||
'mstpctl-treeprio', 'mstpctl-treecost']
|
'mstpctl-treeportprio', 'mstpctl-treeportcost']
|
||||||
ifaceattrs = self.dict_key_subset(ifaceobj.config,
|
ifaceattrs = self.dict_key_subset(ifaceobj.config,
|
||||||
self._port_attrs_map.keys())
|
self._port_attrs_map.keys())
|
||||||
if not ifaceattrs:
|
if not ifaceattrs:
|
||||||
@@ -630,11 +628,9 @@ class mstpctl(moduleBase):
|
|||||||
# for all mstpctl options
|
# for all mstpctl options
|
||||||
# get the corresponding ifaceobj attr
|
# get the corresponding ifaceobj attr
|
||||||
v = ifaceobj.get_attr_value_first(k)
|
v = ifaceobj.get_attr_value_first(k)
|
||||||
if not v:
|
if not v or k in blacklistedattrs:
|
||||||
ifaceobjcurr.update_config_with_status(k, v, -1)
|
ifaceobjcurr.update_config_with_status(k, v, -1)
|
||||||
continue
|
continue
|
||||||
if k in blacklistedattrs:
|
|
||||||
continue
|
|
||||||
currv = self.mstpctlcmd.get_bridgeport_attr(bridgename,
|
currv = self.mstpctlcmd.get_bridgeport_attr(bridgename,
|
||||||
ifaceobj.name, self._port_attrs_map.get(k))
|
ifaceobj.name, self._port_attrs_map.get(k))
|
||||||
if currv:
|
if currv:
|
||||||
|
@@ -156,7 +156,6 @@ class vlan(moduleBase):
|
|||||||
|
|
||||||
def _query_check(self, ifaceobj, ifaceobjcurr):
|
def _query_check(self, ifaceobj, ifaceobjcurr):
|
||||||
if not self.ipcmd.link_exists(ifaceobj.name):
|
if not self.ipcmd.link_exists(ifaceobj.name):
|
||||||
ifaceobjcurr.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
if not '.' in ifaceobj.name:
|
if not '.' in ifaceobj.name:
|
||||||
# if vlan name is not in the dot format, check its running state
|
# if vlan name is not in the dot format, check its running state
|
||||||
@@ -176,8 +175,6 @@ class vlan(moduleBase):
|
|||||||
|
|
||||||
def _query_running(self, ifaceobjrunning):
|
def _query_running(self, ifaceobjrunning):
|
||||||
if not self.ipcmd.link_exists(ifaceobjrunning.name):
|
if not self.ipcmd.link_exists(ifaceobjrunning.name):
|
||||||
if self._is_vlan_by_name(ifaceobjrunning.name):
|
|
||||||
ifaceobjcurr.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
if not self.ipcmd.get_vlandev_attrs(ifaceobjrunning.name):
|
if not self.ipcmd.get_vlandev_attrs(ifaceobjrunning.name):
|
||||||
return
|
return
|
||||||
|
@@ -76,7 +76,6 @@ class vxlan(moduleBase):
|
|||||||
|
|
||||||
def _query_check(self, ifaceobj, ifaceobjcurr):
|
def _query_check(self, ifaceobj, ifaceobjcurr):
|
||||||
if not self.ipcmd.link_exists(ifaceobj.name):
|
if not self.ipcmd.link_exists(ifaceobj.name):
|
||||||
ifaceobjcurr.status = ifaceStatus.NOTFOUND
|
|
||||||
return
|
return
|
||||||
# Update vxlan object
|
# Update vxlan object
|
||||||
vxlanattrs = self.ipcmd.get_vxlandev_attrs(ifaceobj.name)
|
vxlanattrs = self.ipcmd.get_vxlandev_attrs(ifaceobj.name)
|
||||||
|
@@ -1221,7 +1221,6 @@ class ifupdownMain(ifupdownBase):
|
|||||||
ifaceobjs = []
|
ifaceobjs = []
|
||||||
ret = self._get_ifaceobjscurr_pretty(ifacenames, ifaceobjs)
|
ret = self._get_ifaceobjscurr_pretty(ifacenames, ifaceobjs)
|
||||||
if not ifaceobjs: return
|
if not ifaceobjs: return
|
||||||
self.logger.debug(ifaceobjs)
|
|
||||||
if format == 'json':
|
if format == 'json':
|
||||||
print json.dumps(ifaceobjs, cls=ifaceJsonEncoder, indent=2,
|
print json.dumps(ifaceobjs, cls=ifaceJsonEncoder, indent=2,
|
||||||
separators=(',', ': '))
|
separators=(',', ': '))
|
||||||
|
@@ -53,6 +53,13 @@ class ifaceScheduler():
|
|||||||
if not ifupdownobj.ADDONS_ENABLE: return
|
if not ifupdownobj.ADDONS_ENABLE: return
|
||||||
if op == 'query-checkcurr':
|
if op == 'query-checkcurr':
|
||||||
query_ifaceobj=ifupdownobj.create_n_save_ifaceobjcurr(ifaceobj)
|
query_ifaceobj=ifupdownobj.create_n_save_ifaceobjcurr(ifaceobj)
|
||||||
|
# If not type bridge vlan and the object does not exist,
|
||||||
|
# mark not found and return
|
||||||
|
if (not ifupdownobj.link_exists(ifaceobj.name) and
|
||||||
|
ifaceobj.type != ifaceType.BRIDGE_VLAN):
|
||||||
|
query_ifaceobj.set_state_n_status(ifaceState.from_str(op),
|
||||||
|
ifaceStatus.NOTFOUND)
|
||||||
|
return
|
||||||
for mname in ifupdownobj.module_ops.get(op):
|
for mname in ifupdownobj.module_ops.get(op):
|
||||||
m = ifupdownobj.modules.get(mname)
|
m = ifupdownobj.modules.get(mname)
|
||||||
err = 0
|
err = 0
|
||||||
@@ -104,7 +111,8 @@ class ifaceScheduler():
|
|||||||
# if interface exists in the system
|
# if interface exists in the system
|
||||||
ifacename = ifaceobjs[0].name
|
ifacename = ifaceobjs[0].name
|
||||||
ifupdownobj.logger.info('%s: running ops ...' %ifacename)
|
ifupdownobj.logger.info('%s: running ops ...' %ifacename)
|
||||||
if ('down' in ops[0] and ifaceobjs[0].type != ifaceType.BRIDGE_VLAN and
|
if ('down' in ops[0] and
|
||||||
|
ifaceobjs[0].type != ifaceType.BRIDGE_VLAN and
|
||||||
not ifupdownobj.link_exists(ifacename)):
|
not ifupdownobj.link_exists(ifacename)):
|
||||||
ifupdownobj.logger.debug('%s: does not exist' %ifacename)
|
ifupdownobj.logger.debug('%s: does not exist' %ifacename)
|
||||||
# run posthook before you get out of here, so that
|
# run posthook before you get out of here, so that
|
||||||
|
Reference in New Issue
Block a user