| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
import abc |
| 14 |
|
| 15 |
|
| 16 |
class IpCommand(metaclass=abc.ABCMeta): |
| 17 |
|
| 18 |
TYPE_VETH = 'veth' |
| 19 |
TYPE_VLAN = 'vlan' |
| 20 |
TYPE_BRIDGE = 'bridge' |
| 21 |
TYPE_TUNTAP = 'tuntap' |
| 22 |
|
| 23 |
@abc.abstractmethod |
| 24 |
def set(self, device, check_exit_code=None, state=None, mtu=None, |
| 25 |
address=None, promisc=None, master=None): |
| 26 |
"""Method to set a parameter in an interface. |
| 27 |
|
| 28 |
:param device: A network device (string) |
| 29 |
:param check_exit_code: List of integers of allowed execution exit |
| 30 |
codes |
| 31 |
:param state: String network device state |
| 32 |
:param mtu: Integer MTU value |
| 33 |
:param address: String MAC address |
| 34 |
:param promisc: Boolean promiscuous mode |
| 35 |
:param master: String the master device that this device belongs to |
| 36 |
:return: status of the command execution |
| 37 |
""" |
| 38 |
|
| 39 |
@abc.abstractmethod |
| 40 |
def add(self, device, dev_type, check_exit_code=None, peer=None, link=None, |
| 41 |
vlan_id=None, ageing=None, mode=None, multiqueue=False): |
| 42 |
"""Method to add an interface. |
| 43 |
|
| 44 |
:param device: A network device (string) |
| 45 |
:param dev_type: String network device type (TYPE_VETH, TYPE_VLAN, |
| 46 |
TYPE_BRIDGE, TYPE_TUNTAP) |
| 47 |
:param check_exit_code: List of integers of allowed execution exit |
| 48 |
codes |
| 49 |
:param peer: String peer name, for veth interfaces |
| 50 |
:param link: String root network interface name, 'device' will be a |
| 51 |
VLAN tagged virtual interface |
| 52 |
:param vlan_id: Integer VLAN ID for VLAN devices |
| 53 |
:param ageing: integer value in seconds before learned |
| 54 |
mac addresses are forgotten. |
| 55 |
:param mode: String mode for tuntap devices ('tap' or 'tun') |
| 56 |
:param multiqueue: Boolean to enable multiqueue for tuntap devices |
| 57 |
:return: status of the command execution |
| 58 |
""" |
| 59 |
|
| 60 |
@abc.abstractmethod |
| 61 |
def delete(self, device, check_exit_code=None): |
| 62 |
"""Method to delete an interface. |
| 63 |
|
| 64 |
:param device: A network device (string) |
| 65 |
:param dev_type: String network device type (TYPE_VETH, TYPE_VLAN) |
| 66 |
:return: status of the command execution |
| 67 |
""" |
| 68 |
|
| 69 |
@abc.abstractmethod |
| 70 |
def exists(self, device): |
| 71 |
"""Method to dectect if a device exists. |
| 72 |
|
| 73 |
:param device: A network device (string) |
| 74 |
:return: True if device exists else False |
| 75 |
""" |