예제 #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.",
     )
예제 #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)
예제 #3
0
파일: ipwrapper_test.py 프로젝트: nirs/vdsm
 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)
예제 #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.")
예제 #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.'
예제 #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.")
예제 #7
0
파일: vlans.py 프로젝트: 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
예제 #8
0
파일: __init__.py 프로젝트: nirs/vdsm
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
예제 #9
0
파일: __init__.py 프로젝트: vjuranek/vdsm
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
예제 #10
0
파일: __init__.py 프로젝트: nirs/vdsm
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
예제 #11
0
파일: __init__.py 프로젝트: vjuranek/vdsm
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
예제 #12
0
파일: vlans.py 프로젝트: xiaojiongming/vdsm
def vlan_device(vlan_device_name):
    """ Return the device of the given VLAN. """
    vlanLink = getLink(vlan_device_name)
    return vlanLink.device
예제 #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)
예제 #14
0
파일: vlans.py 프로젝트: EdDev/vdsm
def vlan_id(vlan_device_name):
    """ Return the ID of the given VLAN. """
    vlanLink = getLink(vlan_device_name)
    return int(vlanLink.vlanid)
예제 #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
예제 #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.'
예제 #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))
예제 #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.")
예제 #19
0
파일: vlans.py 프로젝트: xiaojiongming/vdsm
def vlan_id(vlan_device_name):
    """ Return the ID of the given VLAN. """
    vlanLink = getLink(vlan_device_name)
    return int(vlanLink.vlanid)
예제 #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)
예제 #21
0
파일: vlans.py 프로젝트: EdDev/vdsm
def vlan_device(vlan_device_name):
    """ Return the device of the given VLAN. """
    vlanLink = getLink(vlan_device_name)
    return vlanLink.device
예제 #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))