def testTogglePromisc(self): ipwrapper.getLink(self._bridge.devName).promisc = True self.assertTrue(ipwrapper.getLink(self._bridge.devName).promisc, "Could not enable promiscuous mode.") ipwrapper.getLink(self._bridge.devName).promisc = False self.assertFalse(ipwrapper.getLink(self._bridge.devName).promisc, "Could not disable promiscuous mode.")
def setPortMirroring(network, target): _qdisc_replace_ingress(network) _addTarget(network, QDISC_INGRESS, target) qdisc.replace(network, 'prio', parent=None) qdisc_id = _qdiscs_of_device(network).next() _addTarget(network, qdisc_id, target) ipwrapper.getLink(network).promisc = True
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 unsetPortMirroring(network, target): # TODO handle the case where we have partial definitions on device due to # vdsm crash acts = _delTarget(network, QDISC_INGRESS, target) try: qdisc_id = _qdiscs_of_device(network).next() 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 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 = _qdiscs_of_device(network).next() _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 = _qdiscs_of_device(network).next() 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 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 testGetLink(self): link = ipwrapper.getLink(self._bridge.devName) self.assertTrue(link.isBRIDGE) self.assertEqual(link.master, None) self.assertEqual(link.name, self._bridge.devName)