From 0f8e5c653691b4ee025483fedeff5a345173ee7c Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 1 Dec 2020 04:44:33 -0500 Subject: [PATCH] Add VNI to VM network API list Saves some processing on API clients. --- api-daemon/pvcapid/flaskapi.py | 3 +++ daemon-common/common.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/api-daemon/pvcapid/flaskapi.py b/api-daemon/pvcapid/flaskapi.py index 0e5aa1a5..31772c49 100755 --- a/api-daemon/pvcapid/flaskapi.py +++ b/api-daemon/pvcapid/flaskapi.py @@ -1046,6 +1046,9 @@ class API_VM_Root(Resource): source: type: string description: The parent network bridge on the node + vni: + type: integer + description: The VNI (PVC network) of the network bridge model: type: string description: The virtual network device model diff --git a/daemon-common/common.py b/daemon-common/common.py index 94df9507..61efa04d 100644 --- a/daemon-common/common.py +++ b/daemon-common/common.py @@ -27,6 +27,7 @@ import shlex import subprocess import kazoo.client from json import loads +from re import match as re_match from distutils.util import strtobool @@ -359,6 +360,7 @@ def getDomainNetworks(parsed_xml, stats_data): net_wr_drops = net_stats.get('wr_drops', 0) net_obj = { 'type': net_type, + 'vni': re_match(r'[vm]*br([0-9a-z]+)', net_bridge).group(1), 'mac': net_mac, 'source': net_bridge, 'model': net_model,