예제 #1
0
파일: nettestlib.py 프로젝트: kobihk/vdsm
def veth_pair(prefix='veth_', max_length=15):
    """
    Yield a pair of veth devices. This assumes root privileges (currently
    required by all tests anyway).

    Both sides of the pair have a pseudo-random suffix (e.g. veth_m6Lz7uMK9c).
    """
    left_side = random_iface_name(prefix, max_length)
    right_side = random_iface_name(prefix, max_length)
    try:
        linkAdd(left_side, linkType='veth', args=('peer', 'name', right_side))
        if nmstate.is_nmstate_backend():
            cmd.exec_sync(['nmcli', 'dev', 'set', left_side, 'managed', 'yes'])
            cmd.exec_sync(
                ['nmcli', 'dev', 'set', right_side, 'managed', 'yes'])
    except IPRoute2Error as e:
        pytest.skip('Failed to create a veth pair: %s', e)
    try:
        yield left_side, right_side
    finally:
        # the peer device is removed by the kernel
        linkDel(left_side)
        if nmstate.is_nmstate_backend():
            cmd.exec_sync(['nmcli', 'con', 'del', left_side])
            cmd.exec_sync(['nmcli', 'con', 'del', right_side])
예제 #2
0
파일: nettestlib.py 프로젝트: kobihk/vdsm
 def addDevice(self):
     linkAdd(
         self.devName,
         'vlan',
         link=self.backing_device_name,
         args=['id', str(self.tag)],
     )
     self.up()
예제 #3
0
 def create(self):
     try:
         linkAdd(self.devName, linkType='dummy')
     except IPRoute2Error as e:
         raise SkipTest('Failed to create a dummy interface %s: %s' %
                        (self.devName, e))
     else:
         return self.devName
예제 #4
0
 def create(self):
     try:
         linkAdd(self.devName, linkType='dummy')
     except IPRoute2Error as e:
         raise SkipTest('Failed to create a dummy interface %s: %s' %
                        (self.devName, e))
     else:
         return self.devName
예제 #5
0
 def create(self):
     linkAdd(
         self.dev_name,
         'vlan',
         link=self.backing_device_name,
         args=['id', str(self.tag)],
     )
     self.up()
     self.set_managed()
예제 #6
0
 def create(self):
     linkAdd(
         self.left_side.dev_name,
         linkType='veth',
         args=('peer', 'name', self.right_side.dev_name),
     )
     self.left_side.set_managed()
     self.right_side.set_managed()
     self.left_side.up()
     self.right_side.up()
예제 #7
0
 def create(self):
     try:
         linkAdd(self.dev_name, linkType='dummy')
         self.set_managed()
         self.up()
     except IPRoute2Error as e:
         pytest.skip(
             f'Failed to create a dummy interface {self.dev_name}: {e}')
     else:
         return self.dev_name
예제 #8
0
 def create(self):
     try:
         linkAdd(self.devName, linkType='dummy')
         cmd.exec_sync(
             ['nmcli', 'dev', 'set', self.devName, 'managed', 'yes'])
     except IPRoute2Error as e:
         pytest.skip('Failed to create a dummy interface %s: %s' %
                     (self.devName, e))
     else:
         return self.devName
예제 #9
0
파일: sampling_test.py 프로젝트: EdDev/vdsm
def vlan(name, link, vlan_id):
    ipwrapper.linkAdd(name, 'vlan', link=link, args=['id', str(vlan_id)])
    try:
        yield
    finally:
        try:
            ipwrapper.linkDel(name)
        except ipwrapper.IPRoute2Error:
            # faultyGetLinks is expected to have already removed the vlan
            # device.
            pass
예제 #10
0
 def create(self):
     try:
         linkAdd(self.devName, linkType='dummy')
         if nmstate.is_nmstate_backend():
             cmd.exec_sync(
                 ['nmcli', 'dev', 'set', self.devName, 'managed', 'yes'])
     except IPRoute2Error as e:
         raise SkipTest('Failed to create a dummy interface %s: %s' %
                        (self.devName, e))
     else:
         return self.devName
예제 #11
0
def vlan(name, link, vlan_id):
    ipwrapper.linkAdd(name, 'vlan', link=link, args=['id', str(vlan_id)])
    try:
        yield
    finally:
        try:
            ipwrapper.linkDel(name)
        except ipwrapper.IPRoute2Error:
            # faultyGetLinks is expected to have already removed the vlan
            # device.
            pass
예제 #12
0
def veth_pair(prefix='veth_', max_length=15):
    """
    Yield a pair of veth devices. This assumes root privileges (currently
    required by all tests anyway).

    Both sides of the pair have a pseudo-random suffix (e.g. veth_m6Lz7uMK9c).
    """
    left_side = random_iface_name(prefix, max_length)
    right_side = random_iface_name(prefix, max_length)
    try:
        linkAdd(left_side, linkType='veth', args=('peer', 'name', right_side))
    except IPRoute2Error as e:
        raise SkipTest('Failed to create a veth pair: %s', e)
    try:
        yield left_side, right_side
    finally:
        # the peer device is removed by the kernel
        linkDel(left_side)
예제 #13
0
def veth_pair(prefix='veth_', max_length=15):
    """
    Yield a pair of veth devices. This assumes root privileges (currently
    required by all tests anyway).

    Both sides of the pair have a pseudo-random suffix (e.g. veth_m6Lz7uMK9c).
    """
    left_side = random_iface_name(prefix, max_length)
    right_side = random_iface_name(prefix, max_length)
    try:
        linkAdd(left_side, linkType='veth',
                args=('peer', 'name', right_side))
    except IPRoute2Error as e:
        raise SkipTest('Failed to create a veth pair: %s', e)
    try:
        yield left_side, right_side
    finally:
        # the peer device is removed by the kernel
        linkDel(left_side)
예제 #14
0
 def addVlan(self, vlan):
     ipwrapper.linkAdd(name=vlan.name, linkType='vlan',
                       link=vlan.device.name, args=['id', str(vlan.tag)])
예제 #15
0
 def addDevice(self):
     linkAdd(self.devName, 'bridge')
     self.up()
예제 #16
0
 def create(self):
     linkAdd(self.dev_name, 'bond')
     self.set_managed()
     self.up()
예제 #17
0
 def addDevice(self):
     linkAdd(self.devName, 'vlan', link=self.backing_device_name,
             args=['id', str(self.tag)])
     self.up()
예제 #18
0
def _create_bridge(name):
    linkAdd(name, 'bridge')
    try:
        yield
    finally:
        linkDel(name)
예제 #19
0
 def addDevice(self):
     linkAdd(self.devName, 'bridge')
     self.up()