Esempio n. 1
0
 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.",
     )
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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.")
Esempio n. 5
0
 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.'
Esempio n. 6
0
 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.")
Esempio n. 7
0
File: vlans.py Progetto: rexhsu/vdsm
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
Esempio n. 8
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
Esempio n. 9
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
Esempio n. 10
0
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
Esempio n. 11
0
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
Esempio n. 12
0
def vlan_device(vlan_device_name):
    """ Return the device of the given VLAN. """
    vlanLink = getLink(vlan_device_name)
    return vlanLink.device
Esempio n. 13
0
 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)
Esempio n. 14
0
File: vlans.py Progetto: EdDev/vdsm
def vlan_id(vlan_device_name):
    """ Return the ID of the given VLAN. """
    vlanLink = getLink(vlan_device_name)
    return int(vlanLink.vlanid)
Esempio n. 15
0
 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
Esempio n. 16
0
 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.'
Esempio n. 17
0
 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))
Esempio n. 18
0
 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.")
Esempio n. 19
0
def vlan_id(vlan_device_name):
    """ Return the ID of the given VLAN. """
    vlanLink = getLink(vlan_device_name)
    return int(vlanLink.vlanid)
Esempio n. 20
0
 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)
Esempio n. 21
0
File: vlans.py Progetto: EdDev/vdsm
def vlan_device(vlan_device_name):
    """ Return the device of the given VLAN. """
    vlanLink = getLink(vlan_device_name)
    return vlanLink.device
Esempio n. 22
0
 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))