summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Morin <arnaud.morin@gmail.com>2019-02-01 14:28:33 +0100
committerArnaud Morin <arnaud.morin@gmail.com>2019-02-01 14:28:33 +0100
commit062e02c612d1fdd8c40b9209319b32e04489c163 (patch)
treeb238b5d81e12c363e7d6277611da05a9acc77110
parentce2ac3dfc50ed7a0fa2d997a497d0c654ec0853a (diff)
downloadceilometer-062e02c612d1fdd8c40b9209319b32e04489c163.tar.gz
Add interfaceid and bridges parameters12.0.0.0rc112.0.0
Add interfaceid and bridge to parameters. These are sometimes needed to help figure out from which instance the meter is coming. Change-Id: Ic50adf5aee8d934d890ac90300e683c6762aefac Signed-off-by: Arnaud Morin <arnaud.morin@gmail.com>
-rwxr-xr-xceilometer/compute/virt/libvirt/inspector.py17
-rwxr-xr-xceilometer/tests/unit/compute/virt/libvirt/test_inspector.py4
2 files changed, 20 insertions, 1 deletions
diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py
index 80fc29e1..1ef5b58a 100755
--- a/ceilometer/compute/virt/libvirt/inspector.py
+++ b/ceilometer/compute/virt/libvirt/inspector.py
@@ -97,6 +97,23 @@ class LibvirtInspector(virt_inspector.Inspector):
params = dict((p.get('name').lower(), p.get('value'))
for p in iface.findall('filterref/parameter'))
+
+ # Extract interface ID
+ try:
+ interfaceid = iface.find('virtualport').find(
+ 'parameters').get('interfaceid')
+ except AttributeError:
+ interfaceid = None
+
+ # Extract source bridge
+ try:
+ bridge = iface.find('source').get('bridge')
+ except AttributeError:
+ bridge = None
+
+ params['interfaceid'] = interfaceid
+ params['bridge'] = bridge
+
dom_stats = domain.interfaceStats(name)
yield virt_inspector.InterfaceStats(name=name,
mac=mac_address,
diff --git a/ceilometer/tests/unit/compute/virt/libvirt/test_inspector.py b/ceilometer/tests/unit/compute/virt/libvirt/test_inspector.py
index ed30732c..e69d89eb 100755
--- a/ceilometer/tests/unit/compute/virt/libvirt/test_inspector.py
+++ b/ceilometer/tests/unit/compute/virt/libvirt/test_inspector.py
@@ -242,7 +242,9 @@ class TestLibvirtInspection(base.BaseTestCase):
self.assertEqual('vnet2', vnic2.name)
self.assertEqual('fa:16:3e:96:33:f0', vnic2.mac)
self.assertIsNone(vnic2.fref)
- self.assertEqual(dict(), vnic2.parameters)
+ self.assertEqual(
+ {'interfaceid': None, 'bridge': 'qbr420008b3-7c'},
+ vnic2.parameters)
self.assertEqual(9, vnic2.rx_bytes)
self.assertEqual(10, vnic2.rx_packets)
self.assertEqual(11, vnic2.tx_bytes)