Commit d56f5400 authored by Martín Ferrari's avatar Martín Ferrari

Renaming ForeignInterface -> ImportedInterface

parent e8386b9b
......@@ -53,7 +53,7 @@ link0.connect(if1)
# Add and connect a tap device (as if a external router were plugged into a
# switch)
if2 = netns.ForeignInterface('tap0')
if2 = netns.ImportedInterface('tap0')
link0.connect(if2)
link0.up = True
......
......@@ -3,7 +3,7 @@
import os, weakref
import netns.iproute
__all__ = ['NodeInterface', 'P2PInterface', 'ForeignInterface',
__all__ = ['NodeInterface', 'P2PInterface', 'ImportedInterface',
'ForeignNodeInterface', 'ImportedNodeInterface', 'Link']
class Interface(object):
......@@ -268,15 +268,17 @@ class SlaveInterface(ExternalInterface):
def destroy(self):
pass
class ForeignInterface(ExternalInterface):
"""Class to handle already existing interfaces. This kind of interfaces can
only be connected to Link objects and not assigned to a name space.
On destruction, the code will try to restore the interface to the state it
was in before being imported into netns."""
class ImportedInterface(ExternalInterface):
"""Class to handle already existing interfaces. Analogous to
ImportedNodeInterface, this class only differs in that the interface is not
migrated inside the name space. This kind of interfaces can only be
connected to Link objects and not assigned to a name space. On
destruction, the code will try to restore the interface to the state it was
in before being imported into netns."""
def __init__(self, iface):
iface = netns.iproute.get_if(iface)
self._original_state = iface.copy()
super(ForeignInterface, self).__init__(iface.index)
super(ImportedInterface, self).__init__(iface.index)
# FIXME: register somewhere for destruction!
def destroy(self): # override: restore as much as possible
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment