提交 3e42c9d0 编写于 作者: C Cleber Rosa

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: NCleber Rosa <crosa@redhat.com>
上级 4ee8e7c2
# 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 <cleber@redhat.com>
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)
......@@ -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
=====
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册