-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from pbenas/host_discovery
client: plugable host discovery
- Loading branch information
Showing
7 changed files
with
311 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
graft etc | ||
include rc.d/init.d/smokerd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Example configuration file for the smoker client (/etc/smokercli.yaml) | ||
# plugin paths: Python modules containing the host discovery plugins. It has to | ||
# be valid python module path. | ||
|
||
plugin_paths: | ||
- smoker.client.plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2007-2015, GoodData(R) Corporation. All rights reserved | ||
# | ||
# Example plugin: | ||
# | ||
# from smoker.client.plugins import SpecificArgument, HostDiscoveryPluginBase | ||
# | ||
# | ||
# class HostDiscoveryPlugin(HostDiscoveryPluginBase): | ||
# """ | ||
# This is an example without any real world usability | ||
# """ | ||
# arguments = [ | ||
# SpecificArgument( | ||
# '-x', | ||
# '--example', | ||
# **{'dest': 'example', | ||
# 'help': 'Example parameter for host discovery'} | ||
# ), | ||
# SpecificArgument( | ||
# '-y', | ||
# '--example_prefix', | ||
# **{'dest': 'prefix', | ||
# 'help': 'Another example for host discovery'} | ||
# ) | ||
# ] | ||
# | ||
# def get_hosts(self, args): | ||
# if not args.example: | ||
# return [] | ||
# if not args.prefix: | ||
# return [args.example] | ||
# return ['%s-%s' % (args.prefix, args.example)] | ||
|
||
|
||
class SpecificArgument(object): | ||
""" | ||
Argparse argument to be added to the smoker CLI specific to this plugin | ||
""" | ||
def __init__(self, short, long, **kwargs): | ||
if short and long: | ||
self.args = [short, long] | ||
elif short: | ||
self.args = [short] | ||
else: | ||
self.args = [long] | ||
self.kwargs = kwargs | ||
|
||
|
||
class HostDiscoveryPluginBase(object): | ||
""" | ||
Host discovery plugin interface | ||
Inherit from this class when creating a host discovery plugin | ||
""" | ||
# List of Specific Argument instances to be added | ||
# to argparse.ArgumentParser | ||
arguments = [] | ||
|
||
def get_hosts(self, args): | ||
""" | ||
Override this method in your plugin | ||
:return: discovered hosts | ||
""" | ||
return [] |
Oops, something went wrong.