summaryrefslogtreecommitdiff
path: root/python/vyos/interface.py
diff options
context:
space:
mode:
authorhagbard-01 <39653662+hagbard-01@users.noreply.github.com>2019-10-23 14:11:04 -0700
committerGitHub <noreply@github.com>2019-10-23 14:11:04 -0700
commit8ccf3900d4962a855cd3cbafda90566fad4794b8 (patch)
tree4b7e22f4ebf0eedd89f3a6df32f20296cc7d4083 /python/vyos/interface.py
parentbbb3a9ecdf2cf76b6336414928030798007dc1c7 (diff)
parent517fa8da7260c753776505b069cd44c622ec02b2 (diff)
downloadvyos-1x-8ccf3900d4962a855cd3cbafda90566fad4794b8.tar.gz
vyos-1x-8ccf3900d4962a855cd3cbafda90566fad4794b8.zip
Merge pull request #152 from kroy-the-rabbit/intf-rewrite1bf
T1759: bug fixes, missing interface IP
Diffstat (limited to 'python/vyos/interface.py')
-rw-r--r--python/vyos/interface.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/python/vyos/interface.py b/python/vyos/interface.py
index 6d57d972b..1aae6db60 100644
--- a/python/vyos/interface.py
+++ b/python/vyos/interface.py
@@ -32,12 +32,19 @@ class Interface():
intf = None
intf_type = None
+ valid = False
def __init__(self,intf):
self.intf = intf
self.intf_type = vyos.interfaces.get_type_of_interface(self.intf)
+ self.valid = (self.intf in vyos.interfaces.list_interfaces())
def print_interface(self):
+
+ if not self.valid:
+ print("Invalid interface [{}]".format(self.intf))
+ return
+
if (self.intf_type == 'wireguard'):
self.print_wireguard_interface()
@@ -66,21 +73,24 @@ class Interface():
data = open(metric_path, 'r').read()[:-1]
dev_dict[metric] = int(data)
interface_stats[dev] = dev_dict
+
return interface_stats[self.intf]
def print_wireguard_interface(self):
- output = subprocess.check_output(["wg", "show", self.intf], universal_newlines=True)
- wgdump = vyos.interfaces.wireguard_dump()[self.intf]
+
+ wgdump = vyos.interfaces.wireguard_dump().get(self.intf,None)
+
c = Config()
c.set_level("interfaces wireguard {}".format(self.intf))
description = c.return_effective_value("description")
+ ips = c.return_effective_values("address")
print ("interface: {}".format(self.intf))
- """ if the interface has a description, modify the output to include it """
if (description):
print (" description: {}".format(description))
- output = re.sub(r"interface: {}".format(re.escape(self.intf)),"interface: {}\n Description: {}".format(self.intf,description),output)
+ if (ips):
+ print (" address: {}".format(", ".join(ips)))
print (" public key: {}".format(wgdump['public_key']))
print (" private key: (hidden)")
print (" listening port: {}".format(wgdump['listen_port']))