From 3e42c9d0bb9a7029a72bd63fa411dfbd6bfe71cf Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Thu, 15 Jan 2015 14:32:44 -0300 Subject: [PATCH] Distro plugin: add a new distro plugin and basic command At this stage, the distro plugin is very simplistic and prints the detected distribution of the current machine. One could algue that this is rather useless, but, with the component isolation work this command is going to be helpful for troubleshooting purposes. Also, this plugin is a placeholder where other functionality will live, including (but not limited to): * the ability to create "distro definition" files, akin to autotest's autotest-distro-def-create. * the ability to view "distro definition" files, akin to autotest's autotest-distro-def-view. * the ability to download "distro definition" files from a repository * (maybe) the ability to push a distro definition file to avocado-server. This may be delegated to a full blown REST client though. Signed-off-by: Cleber Rosa --- avocado/plugins/distro.py | 43 +++++++++++++++++++++++++++++++++++++++ man/avocado.rst | 11 ++++++++++ 2 files changed, 54 insertions(+) create mode 100644 avocado/plugins/distro.py diff --git a/avocado/plugins/distro.py b/avocado/plugins/distro.py new file mode 100644 index 00000000..89767198 --- /dev/null +++ b/avocado/plugins/distro.py @@ -0,0 +1,43 @@ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See LICENSE for more details. +# +# Copyright: Red Hat Inc. 2015 +# Author: Cleber Rosa + +from avocado.core import output +from avocado.plugins import plugin +from avocado.linux import distro as distro_utils + + +class DistroOptions(plugin.Plugin): + + """ + Implements the avocado 'distro' subcommand + """ + + name = 'distro' + enabled = True + + def configure(self, parser): + self.parser = parser.subcommands.add_parser( + 'distro', + help='Shows detected Linux distribution') + super(DistroOptions, self).configure(self.parser) + + def run(self, args): + view = output.View() + detected = distro_utils.detect() + msg = 'Detected distribution: %s (%s) version %s release %s' % ( + detected.name, + detected.arch, + detected.version, + detected.release) + view.notify(event="message", msg=msg) diff --git a/man/avocado.rst b/man/avocado.rst index 0b15469c..5f31db49 100644 --- a/man/avocado.rst +++ b/man/avocado.rst @@ -37,6 +37,7 @@ of avocado subcommands:: sysinfo Collect system information multiplex Generate a list of dictionaries with params from multiplex file(s) plugins List all plugins loaded + distro Shows detected Linux distribution datadir List all relevant directories used by avocado To get usage instructions for a given subcommand, run it with `--help`. Example:: @@ -478,6 +479,16 @@ The output should look like:: For more information, please consult the topic Remote Machine Plugin on Avocado's online documentation. +LINUX DISTRIBUTION UTILITIES +============================ + +Avocado has some planned features that depend on knowing the Linux Distribution being used on the sytem. +The most basic command prints the detected Linux Distribution:: + + $ avocado distro + Detected distribution: fedora (x86_64) version 21 release 0 + + FILES ===== -- GitLab