Start adding convenience functions for handling sites as places with
network setup with a simple helper which lists the network interface names
for a site.
Signed-off-by: David Gibson
---
avocado/tasst/site.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/avocado/tasst/site.py b/avocado/tasst/site.py
index 61e424c..841efbe 100644
--- a/avocado/tasst/site.py
+++ b/avocado/tasst/site.py
@@ -10,6 +10,8 @@
# Copyright Red Hat
# Author: David Gibson
+import json
+
import avocado
from avocado.utils.process import CmdError
@@ -52,6 +54,11 @@ class Site:
raise avocado.TestCancel("Missing commands {} on {}"
.format(', '.join(missing), self.name))
+ def ifs(self):
+ self.require_cmds('ip')
+ info = json.loads(self.output('ip -j link show'))
+ return [i['ifname'] for i in info]
+
class BaseSiteTasst(Tasst):
"""
@@ -94,6 +101,10 @@ class BaseSiteTasst(Tasst):
status = proc.wait()
self.assertNotEquals(status, 0)
+ def test_has_lo(self):
+ site = self.get_subsetup(BaseSiteTasst)
+ self.assertIn('lo', site.ifs())
+
# Represents the host on which the tests are running, as opposed to
# some simulated host created by the tests
--
2.40.1