本文整理汇总了Python中pyroute2.IPRoute.release方法的典型用法代码示例。如果您正苦于以下问题:Python IPRoute.release方法的具体用法?Python IPRoute.release怎么用?Python IPRoute.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyroute2.IPRoute
的用法示例。
在下文中一共展示了IPRoute.release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestProxyData
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
class TestProxyData(TestData):
def setup(self):
create_link('dummyX', 'dummy')
t_url = 'unix://\0%s' % (uuid.uuid4())
p_url = 'unix://\0%s' % (uuid.uuid4())
self.uplink = IPRoute()
self.uplink.serve(t_url)
self.proxy = IPRoute(host=t_url)
self.proxy.serve(p_url)
self.ip = IPRoute(host=p_url)
service = self.ip.discover(self.ip.default_target,
addr=self.proxy.default_peer)
self.ip.default_peer = self.proxy.default_peer
self.ip.default_dport = service
self.dev = self.ip.link_lookup(ifname='dummyX')
def teardown(self):
TestData.teardown(self)
self.proxy.release()
self.uplink.release()
示例2: test_simple
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def test_simple(self):
ip = IPRoute()
_assert_uplinks(ip, 1)
ip.monitor()
ip.monitor(False)
ip.release()
_assert_uplinks(ip, 0)
示例3: BasicTest
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
class BasicTest(object):
def setup(self):
require_user('root')
self.ip = IPRoute()
self.ip.link('add',
index=0,
ifname='dummyX',
linkinfo={'attrs': [['IFLA_INFO_KIND', 'dummy']]})
self.interface = self.ip.link_lookup(ifname='dummyX')[0]
def teardown(self):
self.ip.link('delete', index=self.interface)
self.ip.release()
def get_qdiscs(self):
return [x for x in self.ip.get_qdiscs() if
x['index'] == self.interface]
def get_qdisc(self):
# get qdiscs list and filter out our interface
qds = self.get_qdiscs()
if qds:
return qds[0]
else:
return None
示例4: _test_remote
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def _test_remote(self, url):
uplink = IPRoute()
uplink.serve(url)
ip = IPRoute(host=url)
ip.release()
uplink.release()
示例5: _run_remote_uplink
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def _run_remote_uplink(url, connect, release,
key=None, cert=None, ca=None):
ip = IPRoute()
ip.serve(url, key=key, cert=cert, ca=ca)
ip.iothread.secret = 'bala'
connect.set()
release.wait()
ip.release()
示例6: _test_noautoconnect
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def _test_noautoconnect(self):
ip = IPRoute(do_connect=False)
_assert_uplinks(ip, 0)
addr = ip.connect()
_assert_uplinks(ip, 1)
ip.disconnect(addr)
_assert_uplinks(ip, 0)
ip.release()
示例7: testServer
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def testServer(self):
url = 'unix://\0%s' % (uuid.uuid4())
ip = IPRoute()
ip.serve(url)
target = Process(target=_run_remote_client,
args=(url, 'get_links'))
target.start()
target.join()
ip.release()
示例8: test_server
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def test_server(self):
url = 'unix://\0%s' % (uuid.uuid4())
ip = IPRoute()
ip.serve(url)
client = IPRoute(host=url)
client.release()
ip.release()
示例9: _test_remote
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def _test_remote(self, url):
connect = Event()
release = Event()
target = Process(target=_run_remote_uplink,
args=(url, connect, release))
target.daemon = True
target.start()
connect.wait()
ip = IPRoute(host=url)
ip.release()
release.set()
示例10: TestMisc
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
class TestMisc(object):
def setup(self):
self.ip = IPRoute()
def teardown(self):
self.ip.release()
def test_addrpool_expand(self):
# see coverage
for i in range(100):
self.ip.get_addr()
示例11: test_ssl_fail
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def test_ssl_fail(self):
url = 'localhost:9824'
uplink = IPRoute()
uplink.serve('ssl://%s' % (url),
key='server.key',
cert='server.crt',
ca='ca.crt')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 9824))
s.send(b'test')
s.close()
uplink.release()
示例12: TestRemoteData
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
class TestRemoteData(TestData):
def setup(self):
create_link('dummyX', 'dummy')
url = 'unix://\0%s' % (uuid.uuid4())
self.uplink = IPRoute()
self.uplink.serve(url)
self.ip = IPRoute(host=url)
self.dev = self.ip.link_lookup(ifname='dummyX')
def teardown(self):
TestData.teardown(self)
self.uplink.release()
示例13: test_multiple_instances
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
def test_multiple_instances(self):
# run two instances from parent
# and two instances from child
ip1 = IPRoute()
ip2 = IPRoute()
ip3 = IPRoute(fork=True)
ip4 = IPRoute(fork=True)
ip1.release()
ip2.release()
ip3.release()
ip4.release()
示例14: TestSSLData
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
class TestSSLData(TestData):
ssl_proto = 'ssl'
def setup(self):
create_link('dummyX', 'dummy')
url = 'unix+%s://\0%s' % (self.ssl_proto, uuid.uuid4())
self.uplink = IPRoute()
self.uplink.serve(url,
key='server.key',
cert='server.crt',
ca='ca.crt')
self.ip = IPRoute(host=url,
key='client.key',
cert='client.crt',
ca='ca.crt')
self.dev = self.ip.link_lookup(ifname='dummyX')
def teardown(self):
TestData.teardown(self)
self.uplink.release()
示例15: TestMisc
# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import release [as 别名]
class TestMisc(object):
def setup(self):
self.ip = IPRoute()
def teardown(self):
self.ip.release()
def test_addrpool_expand(self):
# see coverage
for i in range(100):
self.ip.get_addr()
def test_nla_compare(self):
lvalue = self.ip.get_links()
rvalue = self.ip.get_links()
assert lvalue is not rvalue
if lvalue == rvalue:
pass
if lvalue != rvalue:
pass
assert lvalue != 42