iproute2 — PyCI iproute2 Module

class IP

A class to represent the output of the ‘ip’ command.

ip_addr_info(ifname)
Parses ‘ip addr show dev <iface>’ and updates self.interfaces with the result
parse_ip_command()

Uses the ‘ip’ command to assemble the self.interfaces dict.

self.interfaces is laid out like so:
{
‘lo’: {
‘num’: 1, ‘mtu’: 1500, ‘qdisc’: ‘noqueue’, ‘qlen’: None, ‘state’: ‘UNKNOWN’, ‘link’: ‘loopback’, ‘mac’: ‘00:00:00:00:00:00’, ‘inets’: [‘127.0.0.1/8’], ‘inet6s’: [‘::1/128’], ‘flags’: ‘valid_lft forever preferred_lft forever’

}

}

class Inet(iface, inet, broadcast, scope)
A class to store IPv4 addresses and related info (i.e. broadcast, scope)
class Inet6(iface, inet6, scope, valid_lft, preferred_lft)
A class to store IPv6 addresses and related info (i.e. broadcast, scope)
keyword_value(keyword, text)

Scans ‘text’ and returns the word immediately following ‘keyword’. Example:

>>>text = “1: lo inet 127.0.0.1/8 brd 127.255.255.255 scope host lo” >>>keyword_value(‘scope’, text) ‘host’

Previous topic

group — PyCI /etc/group Module

Next topic

iptables — PyCI iptables Module

This Page

Quick search