def testDisablePromisc(self): ipwrapper.getLink(self._bridge.devName).promisc = True ipwrapper.getLink(self._bridge.devName).promisc = False self.assertFalse( ipwrapper.getLink(self._bridge.devName).promisc, "Could not disable promiscuous mode.", )
def testGetLink(self): with bridge_device() as bridge: link = ipwrapper.getLink(bridge.devName) self.assertTrue(link.isBRIDGE) self.assertTrue(link.oper_up) self.assertEqual(link.master, None) self.assertEqual(link.name, bridge.devName)
def testEnablePromisc(self): link = ipwrapper.getLink(self._bridge.devName) with monitor.Monitor(timeout=2, silent_timeout=True) as mon: link.promisc = True for event in mon: if (event['event'] == 'new_link' and event.get('flags', 0) & ipwrapper.Link.IFF_PROMISC): return self.fail("Could not enable promiscuous mode.")
def test_enable_promisc(self, bridge0): link = ipwrapper.getLink(bridge0) with monitor.object_monitor(timeout=2, silent_timeout=True) as mon: link.promisc = True for event in mon: if (event['event'] == 'new_link' and event.get('flags', 0) & IfaceStatus.IFF_PROMISC): return assert False, 'Could not enable promiscuous mode.'
def testEnablePromisc(self): link = ipwrapper.getLink(self._bridge.devName) with monitor.Monitor(timeout=2, silent_timeout=True) as mon: link.promisc = True for event in mon: if (event['event'] == 'new_link' and event.get('flags', 0) & IfaceStatus.IFF_PROMISC): return self.fail("Could not enable promiscuous mode.")
def speed(vlan_device_name): """Returns the vlan's underlying device speed.""" vlanDevName = vlan_device(vlan_device_name) vlanDev = getLink(vlanDevName) if vlanDev.isNIC(): return nics.speed(vlanDevName) elif vlanDev.isBOND(): return bonding.speed(vlanDevName) else: return 0
def setPortMirroring(network, target): ''' Copy networkName traffic of a bridge to an interface :param networkName: networkName bridge name to capture the traffic from :type networkName: string :param ifaceName: ifaceName to copy (mirror) the traffic to :type ifaceName: string this commands mirror all 'networkName' traffic to 'ifaceName' ''' _qdisc_replace_ingress(network) _addTarget(network, QDISC_INGRESS, target) qdisc.replace(network, 'prio', parent=None) qdisc_id = next(_qdiscs_of_device(network)) _addTarget(network, qdisc_id, target) ipwrapper.getLink(network).promisc = True
def unsetPortMirroring(network, target): ''' Release captured mirror networkName traffic from networkName bridge :param networkName: networkName to release the traffic capture :type networkName: string :param target: target device to release :type target: string # TODO handle the case where we have partial definitions on device due to # vdsm crash ''' acts = _delTarget(network, QDISC_INGRESS, target) try: qdisc_id = next(_qdiscs_of_device(network)) acts += _delTarget(network, qdisc_id, target) except StopIteration: pass if not acts: _qdisc_del(network) _qdisc_del(network, kind='ingress') ipwrapper.getLink(network).promisc = False
def vlan_device(vlan_device_name): """ Return the device of the given VLAN. """ vlanLink = getLink(vlan_device_name) return vlanLink.device
def testGetLink(self): link = ipwrapper.getLink(self._bridge.devName) self.assertTrue(link.isBRIDGE) self.assertTrue(link.oper_up) self.assertEqual(link.master, None) self.assertEqual(link.name, self._bridge.devName)
def vlan_id(vlan_device_name): """ Return the ID of the given VLAN. """ vlanLink = getLink(vlan_device_name) return int(vlanLink.vlanid)
def test_get_link(self, bridge0): link = ipwrapper.getLink(bridge0.devName) assert link.isBRIDGE() assert link.oper_up assert link.master is None assert link.name == bridge0.devName
def test_disable_promisc(self, bridge0): ipwrapper.getLink(bridge0.devName).promisc = True ipwrapper.getLink(bridge0.devName).promisc = False assert not ipwrapper.getLink( bridge0.devName ).promisc, 'Could not disable promiscuous mode.'
def testDiff(self): lo = ipwrapper.getLink('lo') s0 = sampling.InterfaceSample(lo) s1 = sampling.InterfaceSample(lo) s1.operstate = 'x' self.assertEquals('operstate:x', s1.connlog_diff(s0))
def testDisablePromisc(self): ipwrapper.getLink(self._bridge.devName).promisc = True ipwrapper.getLink(self._bridge.devName).promisc = False self.assertFalse(ipwrapper.getLink(self._bridge.devName).promisc, "Could not disable promiscuous mode.")