Page MenuHomePhabricator

Replacing Vyatta::Interface perl
Open, Requires assessmentPublicFEATURE REQUEST

Description

As T1756 evolved, I basically ended up starting a rewrite of the old perl Vyatta::Interface module to make it a bit easier to work with in Python.

The attached pull request is the result of that work. Right now, only wireguard is supported, but as the scaffolding is now built, I think adding the rest of the interface types should go quickly

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible

Event Timeline

Example output. Note this is all programmatically generated in Python now instead of parsing the output of wg

interface: wg0
  description: KROY
  public key: RIbtUTCfgzNjnLNPQ/ulkGnnB2vMWHm7l2H/xUfbyjc=
  private key: (hidden)
  listening port: 2224

  peer: ERX-Test
    public key: CF1CsALd2x8KuN6uIMTAYs0ZMtc0rRMEqw4rU2qY5Co=
    allowed ips: 10.172.24.60/32, 2001:XXX:xxx:XXX::60/128
    persistent keepalive: every 15 seconds

  peer: MBP-kroy
    public key: HBbvhFP8+uR8KaS+O3mp1MQJn1bFKYpyPOHDILL8SHE=
    allowed ips: 10.172.24.40/32, 2001:XXX:xxx:XXX::40/128
    persistent keepalive: every 15 seconds

  peer: iMac-kroy
    public key: F5MbW7ye7DsoxdOacrdhLPQIksjxN5UdNV+pGFHqehc=
    latest handshake: 0:01:24
    status: active
    endpoint: xx.xx.xx.xx:53770
    allowed ips: 10.172.24.30/32, 2001:XXX:xxx:XXX::30/128
    transfer: 434 MB received, 5 GB sent
    persistent keepalive: every 15 seconds

  peer: iPhone-kroy
    public key: BknHcLFo8nOo8Dwq2CjaC/TedchKQ0ebxC7GYn7Al00=
    allowed ips: 10.172.24.20/32, 2001:XXX:xxx:XXX::20/128
    persistent keepalive: every 15 seconds

  RX:
      bytes    packets    errors    dropped    overrun    mcast
  455449452    3481153         0       5663          0        0

  TX:
       bytes    packets    errors    dropped    carrier    collisions
  5812316456    5555760         0       4408          0             0
hagbard assigned this task to kroy.Oct 22 2019, 8:06 PM
hagbard added a subscriber: hagbard.

looks neat. I merged in in already. Can you add some explanation to https://github.com/vyos/vyos-documentation please.

kroy added a comment.Oct 24 2019, 5:23 PM

PR153

This pull request rewrites all the functionality of ioctl.pm and lays the framework for the rest of Interface.pm

Example usage:

#!/usr/bin/env python3
from vyos.interface import Interface

intf = Interface("eth0.7")
print(intf.up())
c-po added a subscriber: c-po.Oct 24 2019, 7:42 PM

Why not single source also the op-mode part into ifconfig.py?

kroy added a comment.EditedOct 27 2019, 3:44 PM

PR155

This eliminates the redundant interfaces.py and merges the op_mode displaying code into ifconfig.py

Once the other interface types have their op_mode display code moved here, there will be a bit of refactoring needed to display the various types of interfaces differently.

pasik added a subscriber: pasik.Oct 27 2019, 5:41 PM