コード例 #1
0
ファイル: test_ipdb.py プロジェクト: 0x90/pyroute2
    def test_remove_secondaries(self):
        require_user('root')

        ifA = self.get_ifname()

        with self.ip.create(kind='dummy', ifname=ifA) as i:
            i.add_ip('172.16.0.1', 24)
            i.add_ip('172.16.0.2', 24)

        assert ifA in self.ip.interfaces
        assert ('172.16.0.1', 24) in self.ip.interfaces[ifA].ipaddr
        assert ('172.16.0.2', 24) in self.ip.interfaces[ifA].ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface=ifA)
        assert '172.16.0.2/24' in get_ip_addr(interface=ifA)

        if i._mode == 'explicit':
            i.begin()

        i.del_ip('172.16.0.1', 24)
        i.del_ip('172.16.0.2', 24)
        i.commit()

        assert ('172.16.0.1', 24) not in self.ip.interfaces[ifA].ipaddr
        assert ('172.16.0.2', 24) not in self.ip.interfaces[ifA].ipaddr
        assert '172.16.0.1/24' not in get_ip_addr(interface=ifA)
        assert '172.16.0.2/24' not in get_ip_addr(interface=ifA)
コード例 #2
0
    def test_remove_secondaries(self):
        require_user('root')

        ifA = self.get_ifname()

        with self.ip.create(kind='dummy', ifname=ifA) as i:
            i.add_ip('172.16.0.1', 24)
            i.add_ip('172.16.0.2', 24)

        assert ifA in self.ip.interfaces
        assert ('172.16.0.1', 24) in self.ip.interfaces[ifA].ipaddr
        assert ('172.16.0.2', 24) in self.ip.interfaces[ifA].ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface=ifA)
        assert '172.16.0.2/24' in get_ip_addr(interface=ifA)

        if i._mode == 'explicit':
            i.begin()

        i.del_ip('172.16.0.1', 24)
        i.del_ip('172.16.0.2', 24)
        i.commit()

        assert ('172.16.0.1', 24) not in self.ip.interfaces[ifA].ipaddr
        assert ('172.16.0.2', 24) not in self.ip.interfaces[ifA].ipaddr
        assert '172.16.0.1/24' not in get_ip_addr(interface=ifA)
        assert '172.16.0.2/24' not in get_ip_addr(interface=ifA)
コード例 #3
0
ファイル: test_ipdb.py プロジェクト: wavezhang/pyroute2
    def _create_master(self, kind, **kwarg):

        ifM = self.get_ifname()
        ifP1 = self.get_ifname()
        ifP2 = self.get_ifname()

        self.ip.create(kind='dummy', ifname=ifP1).commit()
        self.ip.create(kind='dummy', ifname=ifP2).commit()

        with self.ip.create(kind=kind, ifname=ifM, **kwarg) as i:
            i.add_port(self.ip.interfaces[ifP1])
            i.add_port(self.ip.interfaces[ifP2])
            i.add_ip('172.16.0.1/24')

        assert ('172.16.0.1', 24) in self.ip.interfaces[ifM].ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface=ifM)
        assert self.ip.interfaces[ifP1].if_master == \
            self.ip.interfaces[ifM].index
        assert self.ip.interfaces[ifP2].if_master == \
            self.ip.interfaces[ifM].index

        with self.ip.interfaces[ifM] as i:
            i.del_port(self.ip.interfaces[ifP1])
            i.del_port(self.ip.interfaces[ifP2])
            i.del_ip('172.16.0.1/24')

        assert ('172.16.0.1', 24) not in self.ip.interfaces[ifM].ipaddr
        assert '172.16.0.1/24' not in get_ip_addr(interface=ifM)
        assert self.ip.interfaces[ifP1].if_master is None
        assert self.ip.interfaces[ifP2].if_master is None
コード例 #4
0
    def _create_master(self, kind, **kwarg):
        require_user('root')
        assert 'bala' not in self.ip.interfaces
        assert 'bala_port0' not in self.ip.interfaces
        assert 'bala_port1' not in self.ip.interfaces

        self.ip.create(kind='dummy', ifname='bala_port0').commit()
        self.ip.create(kind='dummy', ifname='bala_port1').commit()

        with self.ip.create(kind=kind, ifname='bala', **kwarg) as i:
            i.add_port(self.ip.interfaces.bala_port0)
            i.add_port(self.ip.interfaces.bala_port1)
            i.add_ip('172.16.0.1/24')

        assert ('172.16.0.1', 24) in self.ip.interfaces.bala.ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface='bala')
        assert self.ip.interfaces.bala_port0.if_master == \
            self.ip.interfaces.bala.index
        assert self.ip.interfaces.bala_port1.if_master == \
            self.ip.interfaces.bala.index

        with self.ip.interfaces.bala as i:
            i.del_port(self.ip.interfaces.bala_port0)
            i.del_port(self.ip.interfaces.bala_port1)
            i.del_ip('172.16.0.1/24')

        assert ('172.16.0.1', 24) not in self.ip.interfaces.bala.ipaddr
        assert '172.16.0.1/24' not in get_ip_addr(interface='bala')
        assert self.ip.interfaces.bala_port0.if_master is None
        assert self.ip.interfaces.bala_port1.if_master is None
コード例 #5
0
ファイル: test_ipdb.py プロジェクト: skamithi/pyroute2
    def _create_master(self, kind):
        require_user('root')
        assert 'bala' not in self.ip.interfaces
        assert 'bala_port0' not in self.ip.interfaces
        assert 'bala_port1' not in self.ip.interfaces

        self.ip.create(kind='dummy', ifname='bala_port0').commit()
        self.ip.create(kind='dummy', ifname='bala_port1').commit()

        with self.ip.create(kind=kind, ifname='bala') as i:
            i.add_port(self.ip.interfaces.bala_port0)
            i.add_port(self.ip.interfaces.bala_port1)
            i.add_ip('172.16.0.1/24')

        assert ('172.16.0.1', 24) in self.ip.interfaces.bala.ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface='bala')
        assert self.ip.interfaces.bala_port0.if_master == \
            self.ip.interfaces.bala.index
        assert self.ip.interfaces.bala_port1.if_master == \
            self.ip.interfaces.bala.index

        with self.ip.interfaces.bala as i:
            i.del_port(self.ip.interfaces.bala_port0)
            i.del_port(self.ip.interfaces.bala_port1)
            i.del_ip('172.16.0.1/24')

        assert ('172.16.0.1', 24) not in self.ip.interfaces.bala.ipaddr
        assert '172.16.0.1/24' not in get_ip_addr(interface='bala')
        assert self.ip.interfaces.bala_port0.if_master is None
        assert self.ip.interfaces.bala_port1.if_master is None
コード例 #6
0
ファイル: test_ipdb.py プロジェクト: abn/pyroute2
    def test_remove_secondaries(self):
        require_user("root")

        ifA = self.get_ifname()

        with self.ip.create(kind="dummy", ifname=ifA) as i:
            i.add_ip("172.16.0.1", 24)
            i.add_ip("172.16.0.2", 24)

        assert ifA in self.ip.interfaces
        assert ("172.16.0.1", 24) in self.ip.interfaces[ifA].ipaddr
        assert ("172.16.0.2", 24) in self.ip.interfaces[ifA].ipaddr
        assert "172.16.0.1/24" in get_ip_addr(interface=ifA)
        assert "172.16.0.2/24" in get_ip_addr(interface=ifA)

        if i._mode == "explicit":
            i.begin()

        i.del_ip("172.16.0.1", 24)
        i.del_ip("172.16.0.2", 24)
        i.commit()

        assert ("172.16.0.1", 24) not in self.ip.interfaces[ifA].ipaddr
        assert ("172.16.0.2", 24) not in self.ip.interfaces[ifA].ipaddr
        assert "172.16.0.1/24" not in get_ip_addr(interface=ifA)
        assert "172.16.0.2/24" not in get_ip_addr(interface=ifA)
コード例 #7
0
 def test_create_plain(self):
     require_user('root')
     assert 'bala' not in self.ip.interfaces
     i = self.ip.create(kind='dummy', ifname='bala')
     i.add_ip('172.16.0.1/24')
     i.commit()
     assert ('172.16.0.1', 24) in self.ip.interfaces.bala.ipaddr
     assert '172.16.0.1/24' in get_ip_addr(interface='bala')
コード例 #8
0
ファイル: test_ipdb.py プロジェクト: skamithi/pyroute2
 def test_create_plain(self):
     require_user('root')
     assert 'bala' not in self.ip.interfaces
     i = self.ip.create(kind='dummy', ifname='bala')
     i.add_ip('172.16.0.1/24')
     i.commit()
     assert ('172.16.0.1', 24) in self.ip.interfaces.bala.ipaddr
     assert '172.16.0.1/24' in get_ip_addr(interface='bala')
コード例 #9
0
ファイル: test_ipdb.py プロジェクト: abn/pyroute2
    def test_create_plain(self):
        require_user("root")
        ifA = self.get_ifname()

        i = self.ip.create(kind="dummy", ifname=ifA)
        i.add_ip("172.16.0.1/24")
        i.commit()
        assert ("172.16.0.1", 24) in self.ip.interfaces[ifA].ipaddr
        assert "172.16.0.1/24" in get_ip_addr(interface=ifA)
コード例 #10
0
    def test_create_plain(self):
        require_user('root')
        ifA = self.get_ifname()

        i = self.ip.create(kind='dummy', ifname=ifA)
        i.add_ip('172.16.0.1/24')
        i.commit()
        assert ('172.16.0.1', 24) in self.ip.interfaces[ifA].ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface=ifA)
コード例 #11
0
ファイル: test_ipdb.py プロジェクト: 0x90/pyroute2
    def test_create_plain(self):
        require_user('root')
        ifA = self.get_ifname()

        i = self.ip.create(kind='dummy', ifname=ifA)
        i.add_ip('172.16.0.1/24')
        i.commit()
        assert ('172.16.0.1', 24) in self.ip.interfaces[ifA].ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface=ifA)
コード例 #12
0
ファイル: test_ipdb.py プロジェクト: skamithi/pyroute2
    def test_create_and_remove(self):
        require_user('root')
        assert 'bala' not in self.ip.interfaces

        with self.ip.create(kind='dummy', ifname='bala') as i:
            i.add_ip('172.16.0.1/24')
        assert ('172.16.0.1', 24) in self.ip.interfaces.bala.ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface='bala')

        with self.ip.interfaces.bala as i:
            i.remove()
        assert 'bala' not in self.ip.interfaces
コード例 #13
0
    def test_create_and_remove(self):
        require_user('root')
        assert 'bala' not in self.ip.interfaces

        with self.ip.create(kind='dummy', ifname='bala') as i:
            i.add_ip('172.16.0.1/24')
        assert ('172.16.0.1', 24) in self.ip.interfaces.bala.ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface='bala')

        with self.ip.interfaces.bala as i:
            i.remove()
        assert 'bala' not in self.ip.interfaces
コード例 #14
0
    def test_create_and_remove(self):
        require_user('root')

        ifA = self.get_ifname()

        with self.ip.create(kind='dummy', ifname=ifA) as i:
            i.add_ip('172.16.0.1/24')
        assert ('172.16.0.1', 24) in self.ip.interfaces[ifA].ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface=ifA)

        with self.ip.interfaces[ifA] as i:
            i.remove()
        assert ifA not in self.ip.interfaces
コード例 #15
0
ファイル: test_ipdb.py プロジェクト: abn/pyroute2
    def test_create_and_remove(self):
        require_user("root")

        ifA = self.get_ifname()

        with self.ip.create(kind="dummy", ifname=ifA) as i:
            i.add_ip("172.16.0.1/24")
        assert ("172.16.0.1", 24) in self.ip.interfaces[ifA].ipaddr
        assert "172.16.0.1/24" in get_ip_addr(interface=ifA)

        with self.ip.interfaces[ifA] as i:
            i.remove()
        assert ifA not in self.ip.interfaces
コード例 #16
0
ファイル: test_ipdb.py プロジェクト: 0x90/pyroute2
    def test_create_and_remove(self):
        require_user('root')

        ifA = self.get_ifname()

        with self.ip.create(kind='dummy', ifname=ifA) as i:
            i.add_ip('172.16.0.1/24')
        assert ('172.16.0.1', 24) in self.ip.interfaces[ifA].ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface=ifA)

        with self.ip.interfaces[ifA] as i:
            i.remove()
        assert ifA not in self.ip.interfaces
コード例 #17
0
    def _create_master(self, kind, **kwarg):

        ifM = self.get_ifname()
        ifP1 = self.get_ifname()
        ifP2 = self.get_ifname()

        self.ip.create(kind='dummy', ifname=ifP1).commit()
        self.ip.create(kind='dummy', ifname=ifP2).commit()

        with self.ip.create(kind=kind, ifname=ifM, **kwarg) as i:
            i.add_port(self.ip.interfaces[ifP1])
            i.add_ip('172.16.0.1/24')

        with self.ip.interfaces[ifM] as i:
            i.add_port(self.ip.interfaces[ifP2])
            i.add_ip('172.16.0.2/24')

        assert ('172.16.0.1', 24) in self.ip.interfaces[ifM].ipaddr
        assert ('172.16.0.2', 24) in self.ip.interfaces[ifM].ipaddr
        assert '172.16.0.1/24' in get_ip_addr(interface=ifM)
        assert '172.16.0.2/24' in get_ip_addr(interface=ifM)
        assert self.ip.interfaces[ifP1].if_master == \
            self.ip.interfaces[ifM].index
        assert self.ip.interfaces[ifP2].if_master == \
            self.ip.interfaces[ifM].index

        with self.ip.interfaces[ifM] as i:
            i.del_port(self.ip.interfaces[ifP1])
            i.del_port(self.ip.interfaces[ifP2])
            i.del_ip('172.16.0.1/24')
            i.del_ip('172.16.0.2/24')

        assert ('172.16.0.1', 24) not in self.ip.interfaces[ifM].ipaddr
        assert ('172.16.0.2', 24) not in self.ip.interfaces[ifM].ipaddr
        assert '172.16.0.1/24' not in get_ip_addr(interface=ifM)
        assert '172.16.0.2/24' not in get_ip_addr(interface=ifM)
        assert self.ip.interfaces[ifP1].if_master is None
        assert self.ip.interfaces[ifP2].if_master is None
コード例 #18
0
ファイル: test_ipdb.py プロジェクト: abn/pyroute2
    def _create_master(self, kind, **kwarg):

        ifM = self.get_ifname()
        ifP1 = self.get_ifname()
        ifP2 = self.get_ifname()

        self.ip.create(kind="dummy", ifname=ifP1).commit()
        self.ip.create(kind="dummy", ifname=ifP2).commit()

        with self.ip.create(kind=kind, ifname=ifM, **kwarg) as i:
            i.add_port(self.ip.interfaces[ifP1])
            i.add_ip("172.16.0.1/24")

        with self.ip.interfaces[ifM] as i:
            i.add_port(self.ip.interfaces[ifP2])
            i.add_ip("172.16.0.2/24")

        assert ("172.16.0.1", 24) in self.ip.interfaces[ifM].ipaddr
        assert ("172.16.0.2", 24) in self.ip.interfaces[ifM].ipaddr
        assert "172.16.0.1/24" in get_ip_addr(interface=ifM)
        assert "172.16.0.2/24" in get_ip_addr(interface=ifM)
        assert self.ip.interfaces[ifP1].if_master == self.ip.interfaces[ifM].index
        assert self.ip.interfaces[ifP2].if_master == self.ip.interfaces[ifM].index

        with self.ip.interfaces[ifM] as i:
            i.del_port(self.ip.interfaces[ifP1])
            i.del_port(self.ip.interfaces[ifP2])
            i.del_ip("172.16.0.1/24")
            i.del_ip("172.16.0.2/24")

        assert ("172.16.0.1", 24) not in self.ip.interfaces[ifM].ipaddr
        assert ("172.16.0.2", 24) not in self.ip.interfaces[ifM].ipaddr
        assert "172.16.0.1/24" not in get_ip_addr(interface=ifM)
        assert "172.16.0.2/24" not in get_ip_addr(interface=ifM)
        assert self.ip.interfaces[ifP1].if_master is None
        assert self.ip.interfaces[ifP2].if_master is None
コード例 #19
0
ファイル: test_ipr.py プロジェクト: xxfuma85xx/pyroute2
 def test_addr(self):
     assert len(get_ip_addr()) == len(self.ip.get_addr())
コード例 #20
0
ファイル: test_ipdb.py プロジェクト: 0x90/pyroute2
 def test_ips(self):
     for name in self.ip.by_name:
         assert len(self.ip.interfaces[name]['ipaddr']) == \
             len(get_ip_addr(name))
コード例 #21
0
ファイル: replica.py プロジェクト: rush8192/n-sync
import pygame
import time
import flask
import multiprocessing
import Queue
import socket
import sys
import threading
from flask import Flask
from flask import request
from constants import *
import utils
import os
import pickle
import collections
from replica_music_service import ReplicaMusicService
from election_service import ReplicaElectionService

if __name__ == "__main__":
    # start replica service
    ip_addr = utils.get_ip_addr()

    response_queue = multiprocessing.Queue()
    state_queue = multiprocessing.Queue()
    replica_service = ReplicaMusicService(collections.deque([]), ip_addr,
                                          state_queue, response_queue)
    election_service = ReplicaElectionService(ip_addr, state_queue,
                                              response_queue)
    replica_service.start()
    election_service.start()
コード例 #22
0
 def test_addr_add(self):
     require_user('root')
     ifaddr = self.ifaddr()
     self.ip.addr('add', self.ifaces[0], address=ifaddr, mask=24)
     assert '{0}/24'.format(ifaddr) in get_ip_addr()
コード例 #23
0
ファイル: replica.py プロジェクト: rush8192/n-sync
import pygame
import time
import flask
import multiprocessing
import Queue
import socket
import sys
import threading
from flask import Flask
from flask import request
from constants import *
import utils
import os
import pickle
import collections
from replica_music_service import ReplicaMusicService
from election_service import ReplicaElectionService


if __name__ == "__main__":
    # start replica service
    ip_addr = utils.get_ip_addr()

    response_queue = multiprocessing.Queue()
    state_queue = multiprocessing.Queue()
    replica_service = ReplicaMusicService(collections.deque([]), ip_addr, state_queue, response_queue)
    election_service = ReplicaElectionService(ip_addr, state_queue, response_queue)
    replica_service.start()
    election_service.start()
コード例 #24
0
ファイル: test_ipr.py プロジェクト: svinota/pyroute2
 def test_addr_add(self):
     require_user('root')
     ifaddr = self.ifaddr()
     self.ip.addr('add', self.ifaces[0], address=ifaddr, mask=24)
     assert '{0}/24'.format(ifaddr) in get_ip_addr()
コード例 #25
0
ファイル: test_ipr.py プロジェクト: chantra/pyroute2
 def test_add_addr(self):
     require_user('root')
     dev = self.dev[0]
     self.ip.addr('add', dev, address='172.16.0.1', mask=24)
     assert '172.16.0.1/24' in get_ip_addr()
コード例 #26
0
ファイル: test_ipr.py プロジェクト: jazzmes/pyroute2
 def test_add_addr(self):
     require_user('root')
     self.ip.addr('add', self.ifaces[0], address='172.16.0.1', mask=24)
     assert '172.16.0.1/24' in get_ip_addr()
コード例 #27
0
ファイル: test_ipdb.py プロジェクト: abn/pyroute2
 def test_addr_loaded(self):
     for name in self.ip.by_name:
         assert len(self.ip.interfaces[name]["ipaddr"]) == len(get_ip_addr(name))
コード例 #28
0
ファイル: test_ipr.py プロジェクト: jazzmes/pyroute2
 def test_addr(self):
     assert len(get_ip_addr()) == len(self.ip.get_addr())
コード例 #29
0
 def test_ips(self):
     for name in self.ip.by_name:
         assert len(self.ip.interfaces[name]['ipaddr']) == \
             len(get_ip_addr(name))
コード例 #30
0
ファイル: test_ipr.py プロジェクト: xxfuma85xx/pyroute2
 def test_addr_add(self):
     require_user('root')
     self.ip.addr('add', self.ifaces[0], address='172.16.0.1', mask=24)
     assert '172.16.0.1/24' in get_ip_addr()
コード例 #31
0
 def test_add_addr(self):
     require_user('root')
     dev = self.dev[0]
     self.ip.addr('add', dev, address='172.16.0.1', mask=24)
     assert '172.16.0.1/24' in get_ip_addr()