-
Notifications
You must be signed in to change notification settings - Fork 484
Open
Labels
Milestone
Description
Describe the feature:
Sometimes, we want to use some 3rd tools (like ethotool and demicode) to do some test. On current stage we can use Command to test. But I think it's better to implement plugins so that user can define their own test method.
Describe the solution you'd like
- a plugin (in this situtation is binary file) should follow rules as below
./plugin name
will output plugin's name./plugin options
will output a list with plugin's options for goss to call. Like a ethtool plugin should outputspeed, is-bond, is-virtual
etc./plugin test-method test-target
will output the test result. E.g: ethtool plugin,./ethotool_plugin.sh is-virtual etho0
will output true
- the plugin pass should be passed via cli args or config file, like: ./goss --plugins /usr/local/bin/ethotool_plugins then when goss start, it will create struct via
./plugin name
and./plugin options
output.
Describe alternatives you've considered
For the implement of plugins, I have an idea. I use python to explain the code logic. We can talk about the implement and then I can create a new PR for this.
plugin:
/tmp/test.sh:
eth0:
is-virtual: false
is-bond: false
import yaml
import pprint
import json
import get_command_output
with open("test.yml") as f:
data = yaml.load(f)
def get_options(executable_file):
return get_command_output("%s options" % executable_file).strip().split(",")
def get_output_by_option(executable_file, option, target):
return get_command_output("%s %s %s" % (executable_file, option, target)).strip()
for executable_file in data["plugin"]:
for execute_target in data["plugin"][executable_file]:
for k,v in data["plugin"][executable_file][execute_target].items():
print "k=%s, v=%s, result=%s" % (k,v,json.loads(get_output_by_option(executable_file, k, execute_target)))
print(get_output_by_option(executable_file, k, execute_target) == v)
check_virtual() {
echo "false"
}
check_bond() {
echo "false"
}
case $1 in
is-virtual)
check_virtual $2
exit 0
;;
is-bond)
check_bond $3
exit 0
;;
options)
echo "is-virtual, is-bond"
exit 0
;;
name)
echo "ethtool-plugin"
exit 0
;;
*)
echo "Usage: $0 {options|is-virtual|is-bond}"
exit 0
;;
esac