[libvirt] [jenkins-ci PATCH 5/8] lcitool: Implement the 'list' action

Andrea Bolognani abologna at redhat.com
Wed Jul 11 15:54:33 UTC 2018


Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 guests/lcitool | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/guests/lcitool b/guests/lcitool
index 3564eb8..1dd1ec8 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -237,6 +237,7 @@ class Application:
             description = "libvirt CI guest management tool",
             epilog = textwrap.dedent("""
                 supported actions:
+                  list  list all known hosts
                 """),
         )
         self._parser.add_argument(
@@ -245,15 +246,25 @@ class Application:
             required = True,
             help = "action to perform (see below)",
         )
+        self._parser.add_argument(
+            "-h",
+            metavar = "HOSTS",
+            help = "list of hosts to act on (glob patterns are supported)",
+        )
+
+    def _action_list(self, hosts):
+        for host in self._inventory.expand_pattern("all"):
+            print(host)
 
     def run(self):
         cmdline = self._parser.parse_args()
         action = cmdline.a
+        hosts = cmdline.h
 
         method = "_action_{}".format(action.replace("-", "_"))
 
         if hasattr(self, method):
-            getattr(self, method).__call__()
+            getattr(self, method).__call__(hosts)
         else:
             raise Error("Invalid action '{}'".format(action))
 
-- 
2.17.1




More information about the libvir-list mailing list