コード例 #1
0
 def test_get_interface(self):
     assert_equal(get_interface(''), None)
     assert_equal(get_interface('notreal'), None)
     assert_is_instance(get_interface(self.iface_name,
                                      address_family=4),
                        IPv4Address)
     # can't enable this until there's a v6 address on the ci hosts
     # assert_is_instance(get_interface(
     #                       self.iface_name,
     #                       address_family=6), IPv6Address)
     assert_raises(IPUtilsException,
                   get_interface, self.iface_name, 0)
コード例 #2
0
def find_ip(args):
    """
    Get and print the IP from a specific interface

    Args:
    - interface: string
      network interface name
    - address_family: int
      4 or 6, respective to ipv4 or ipv6
    """
    interface = ip_utils.get_interface(args.interface, args.address_family)
    if interface:
        print(interface.ip)
コード例 #3
0
ファイル: apex_python_utils.py プロジェクト: radez/apex
def find_ip(args):
    """
    Get and print the IP from a specific interface

    Args:
    - interface: string
      network interface name
    - address_family: int
      4 or 6, respective to ipv4 or ipv6
    """
    interface = ip_utils.get_interface(args.interface, args.address_family)
    if interface:
        print(interface.ip)
コード例 #4
0
 def test_find_gateway(self):
     assert_is_instance(find_gateway(self.iface), str)
     iface_virbr0 = get_interface('virbr0')
     assert_equal(find_gateway(iface_virbr0), None)
コード例 #5
0
 def setup_class(klass):
     """This method is run once for each class before any tests are run"""
     klass.iface_name = get_default_gateway_linux()
     iface = get_interface(klass.iface_name)
     klass.iface = iface