daemon/core/netns/nodes.py
def savestate(self):
        ''' Save the addresses and other interface state before using the
        interface for emulation purposes. TODO: save/restore the PROMISC flag
        '''
        self.old_up = False
        self.old_addrs = []
        cmd = [IP_BIN, "addr", "show", "dev", self.localname]
        try:
            tmp = subprocess.Popen(cmd, stdout = subprocess.PIPE)
        except OSError:
            self.warn("Failed to run %s command: %s" % (IP_BIN, cmd))
        if tmp.wait():
            self.warn("Command failed: %s" % cmd)
            return
        lines = tmp.stdout.read()
        tmp.stdout.close()
        for l in lines.split('\n'):
            items = l.split()
            if len(items) < 2:
                continue
            if items[1] == "%s:" % self.localname:
                flags = items[2][1:-1].split(',')
                if "UP" in flags:
                    self.old_up = True
            elif items[0] == "inet":
                self.old_addrs.append((items[1], items[3]))
            elif items[0] == "inet6":
                if items[1][:4] == "fe80":
                    continue
                self.old_addrs.append((items[1], None))
 Save the addresses and other interface state before using the
        interface for emulation purposes. TODO: save/restore the PROMISC flag
        
Save the addresses and other interface state before using the
interface for emulation purposes. TODO: save/restore the PROMISC flag
Save the addresses and other interface state before using the interface for emulation purposes . TODO : save / restore the PROMISC flag
def savestate(self):
        self.old_up = False
        self.old_addrs = []
        cmd = [IP_BIN, "addr", "show", "dev", self.localname]
        try:
            tmp = subprocess.Popen(cmd, stdout = subprocess.PIPE)
        except OSError:
            self.warn("Failed to run %s command: %s" % (IP_BIN, cmd))
        if tmp.wait():
            self.warn("Command failed: %s" % cmd)
            return
        lines = tmp.stdout.read()
        tmp.stdout.close()
        for l in lines.split('\n'):
            items = l.split()
            if len(items) < 2:
                continue
            if items[1] == "%s:" % self.localname:
                flags = items[2][1:-1].split(',')
                if "UP" in flags:
                    self.old_up = True
            elif items[0] == "inet":
                self.old_addrs.append((items[1], items[3]))
            elif items[0] == "inet6":
                if items[1][:4] == "fe80":
                    continue
                self.old_addrs.append((items[1], None))
def savestate ( self ) : self . old_up = False self . old_addrs = [ ] cmd = [ IP_BIN , "addr" , "show" , "dev" , self . localname ] try : tmp = subprocess . Popen ( cmd , stdout = subprocess . PIPE ) except OSError : self . warn ( "Failed to run %s command: %s" % ( IP_BIN , cmd ) ) if tmp . wait ( ) : self . warn ( "Command failed: %s" % cmd ) return lines = tmp . stdout . read ( ) tmp . stdout . close ( ) for l in lines . split ( '\n' ) : items = l . split ( ) if len ( items ) < 2 : continue if items [ 1 ] == "%s:" % self . localname : flags = items [ 2 ] [ 1 : - 1 ] . split ( ',' ) if "UP" in flags : self . old_up = True elif items [ 0 ] == "inet" : self . old_addrs . append ( ( items [ 1 ] , items [ 3 ] ) ) elif items [ 0 ] == "inet6" : if items [ 1 ] [ : 4 ] == "fe80" : continue self . old_addrs . append ( ( items [ 1 ] , None ) )
Save the addresses and other interface state before using the
interface for emulation purposes.
Save the addresses and other interface state before using the interface for emulation purposes .
''' Save the addresses and other interface state before using the
        interface for emulation purposes. TODO: save/restore the PROMISC flag
        '''
self