def _waitForKnownOperstate(device, timeout=1): with monitor.Monitor(groups=('link', ), timeout=timeout) as mon: if operstate(device) == OPERSTATE_UNKNOWN: for event in mon: if (event['name'] == device and event['state'] != OPERSTATE_UNKNOWN): break
def configure(self, **opts): # in a limited condition, we should not touch the nic config if (self.vlan and nics.operstate(self.name) == nics.OPERSTATE_UP and self.configurator.net_info.ifaceUsers(self.name) and self.mtu <= link_iface.iface(self.name).mtu()): return self.configurator.configureNic(self, **opts)
def _waitForOperstate(device, state, timeout=1): """ :param state: please use OPERSTATE_* from lib/vdsm/network/netinfo """ with monitor.Monitor(groups=('link', ), timeout=timeout) as mon: if state != operstate(device): for event in mon: if event['name'] == device and event['state'] == state: break
def configure(self, **opts): # in a limited condition, we should not touch the nic config if (self.vlan and nics.operstate(self.name) == nics.OPERSTATE_UP and ifaceUsed(self.name) and self.mtu <= mtus.getMtu(self.name)): return self.configurator.configureNic(self, **opts)
def configure(self, **opts): # in a limited condition, we should not touch the nic config if (self.vlan and nics.operstate(self.name) == nics.OPERSTATE_UP and ifaceUsed(self.name) and self.mtu <= mtus.getMtu(self.name)): return self.configurator.configureNic(self, **opts)
def configure(self, **opts): # in a limited condition, we should not touch the nic config if (self.vlan and nics.operstate(self.name) == nics.OPERSTATE_UP and self.configurator.net_info.ifaceUsers(self.name) and self.mtu <= link_iface.iface(self.name).mtu()): return self.configurator.configureNic(self, **opts)
def assertLinksUp(self, net, attrs): switch = attrs.get('switch', 'legacy') if switch == 'legacy': expected_links = _gather_expected_legacy_links( net, attrs, self.netinfo) elif switch == 'ovs': expected_links = _gather_expected_ovs_links( net, attrs, self.netinfo) if expected_links: for dev in expected_links: # Links are sometimes marked as UNKNOWN after turned UP. self.assertIn(operstate(dev).upper(), ('UP', 'UNKNOWN'))
def assertLinksUp(self, net, attrs): switch = attrs.get('switch', 'legacy') if switch == 'legacy': expected_links = _gather_expected_legacy_links( net, attrs, self.netinfo) elif switch == 'ovs': expected_links = _gather_expected_ovs_links( net, attrs, self.netinfo) if expected_links: for dev in expected_links: # Links are sometimes marked as UNKNOWN after turned UP. self.assertIn(operstate(dev).upper(), ('UP', 'UNKNOWN'))
def nonChangingOperstate(device): """Raises an exception if it detects that the device link state changes.""" originalState = operstate(device).lower() try: with monitor.Monitor(groups=('link', )) as mon: yield finally: changes = [(event['name'], event['state']) for event in mon if event['name'] == device] for _, state in changes: if state != originalState: raise OperStateChangedError('%s operstate changed: %s -> %r' % (device, originalState, changes))
def configure(self, **opts): # When the bond is up and we are not changing the configuration that # is already applied in any way, we can skip the configuring. if (self.vlan and self.name in bonding.bondings() and (not self.configurator.unifiedPersistence or self.name in self.configurator.runningConfig.bonds) and nics.operstate(self.name) == nics.OPERSTATE_UP and ifaceUsed(self.name) and self.mtu <= mtus.getMtu(self.name) and self.areOptionsApplied() and frozenset(slave.name for slave in self.slaves) == frozenset( bonding.slaves(self.name))): return self.configurator.configureBond(self, **opts)
def configure(self, **opts): # When the bond is up and we are not changing the configuration that # is already applied in any way, we can skip the configuring. if (self.vlan and self.name in bonding.bondings() and (not self.configurator.unifiedPersistence or self.name in self.configurator.runningConfig.bonds) and nics.operstate(self.name) == nics.OPERSTATE_UP and ifaceUsed(self.name) and self.mtu <= mtus.getMtu(self.name) and self.areOptionsApplied() and frozenset(slave.name for slave in self.slaves) == frozenset(bonding.slaves(self.name))): return self.configurator.configureBond(self, **opts)
def test_dpdk_operstate_always_up(self): assert nics.operstate('dpdk0') == nics.OPERSTATE_UP
def test_dpdk_operstate_always_up(self): self.assertEqual(nics.operstate('dpdk0'), nics.OPERSTATE_UP)
def test_dpdk_operstate_always_up(self): self.assertEqual(nics.operstate('dpdk0'), nics.OPERSTATE_UP)