def remove(self): """ Remove the dummy interface. This assumes root privileges. """ try: linkDel(self.devName) except IPRoute2Error as e: raise SkipTest("Unable to delete the dummy interface %s: %s" % (self.devName, e))
def remove(dummyName): """ Removes dummy interface dummyName. Assumes root privileges. """ try: linkDel(dummyName) except IPRoute2Error as e: raise SkipTest("Unable to delete dummy interface %s because %s" % (dummyName, e))
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
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)) yield left_side, right_side except IPRoute2Error: raise SkipTest('Failed to create a veth pair.') finally: # the peer device is removed by the kernel linkDel(left_side)
def faultyGetLinks(): all_links = list(original_getLinks()) ipwrapper.linkDel(self.NEW_VLAN) return iter(all_links)
def removeVlan(self, vlan): ipwrapper.linkDel(vlan.name)
def delDevice(self): self._down() linkDel(self.devName)