• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.get_ip_addr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.get_ip_addr函数的典型用法代码示例。如果您正苦于以下问题:Python get_ip_addr函数的具体用法?Python get_ip_addr怎么用?Python get_ip_addr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_ip_addr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_remove_secondaries

    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)
开发者ID:0x90,项目名称:pyroute2,代码行数:26,代码来源:test_ipdb.py


示例2: _create_master

    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
开发者ID:skamithi,项目名称:pyroute2,代码行数:30,代码来源:test_ipdb.py


示例3: _create_master

    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
开发者ID:wavezhang,项目名称:pyroute2,代码行数:30,代码来源:test_ipdb.py


示例4: test_create_plain

 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')
开发者ID:skamithi,项目名称:pyroute2,代码行数:8,代码来源:test_ipdb.py


示例5: test_create_plain

    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)
开发者ID:0x90,项目名称:pyroute2,代码行数:9,代码来源:test_ipdb.py


示例6: test_create_and_remove

    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
开发者ID:skamithi,项目名称:pyroute2,代码行数:12,代码来源:test_ipdb.py


示例7: test_create_and_remove

    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
开发者ID:abn,项目名称:pyroute2,代码行数:13,代码来源:test_ipdb.py


示例8: _create_master

    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
开发者ID:abn,项目名称:pyroute2,代码行数:36,代码来源:test_ipdb.py


示例9: test_addr

 def test_addr(self):
     assert len(get_ip_addr()) == len(self.ip.get_addr())
开发者ID:jazzmes,项目名称:pyroute2,代码行数:2,代码来源:test_ipr.py


示例10: test_add_addr

 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()
开发者ID:jazzmes,项目名称:pyroute2,代码行数:4,代码来源:test_ipr.py


示例11: test_ips

 def test_ips(self):
     for name in self.ip.by_name:
         assert len(self.ip.interfaces[name]['ipaddr']) == \
             len(get_ip_addr(name))
开发者ID:0x90,项目名称:pyroute2,代码行数:4,代码来源:test_ipdb.py


示例12: test_addr_loaded

 def test_addr_loaded(self):
     for name in self.ip.by_name:
         assert len(self.ip.interfaces[name]["ipaddr"]) == len(get_ip_addr(name))
开发者ID:abn,项目名称:pyroute2,代码行数:3,代码来源:test_ipdb.py


示例13: ReplicaMusicService

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()
开发者ID:rush8192,项目名称:n-sync,代码行数:29,代码来源:replica.py


示例14: test_addr_add

 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()
开发者ID:svinota,项目名称:pyroute2,代码行数:5,代码来源:test_ipr.py


示例15: test_add_addr

 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()
开发者ID:chantra,项目名称:pyroute2,代码行数:5,代码来源:test_ipr.py



注:本文中的utils.get_ip_addr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_logger函数代码示例发布时间:2022-05-26
下一篇:
Python utils.get_ip函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap