diff options
author | makkalot <makkalot@gmail.com> | 2008-08-20 12:05:51 +0300 |
---|---|---|
committer | makkalot <makkalot@gmail.com> | 2008-08-20 12:05:51 +0300 |
commit | a07ef03e52427fa26f8990031705a86fdd7c9291 (patch) | |
tree | 94a805c7f373ba706d980becf279c2855e55efd2 /func | |
parent | 4005973a517189036a98175f61ae1006914ef323 (diff) | |
parent | cc10cfa9b4e39e901128749cf034d64c4db47ad7 (diff) | |
download | func-a07ef03e52427fa26f8990031705a86fdd7c9291.tar.gz func-a07ef03e52427fa26f8990031705a86fdd7c9291.tar.xz func-a07ef03e52427fa26f8990031705a86fdd7c9291.zip |
Merge branch 'export_methods'
Diffstat (limited to 'func')
26 files changed, 997 insertions, 20 deletions
diff --git a/func/minion/func_arg.py b/func/minion/func_arg.py index 5025e17..b405223 100644 --- a/func/minion/func_arg.py +++ b/func/minion/func_arg.py @@ -51,6 +51,7 @@ class ArgCompatibility(object): 'float':('range','min','max'), 'hash':('validator',), 'list':('validator',), + 'list*':('validator',), } diff --git a/func/minion/modules/certmastermod.py b/func/minion/modules/certmastermod.py index 73f1468..a8a37e8 100644 --- a/func/minion/modules/certmastermod.py +++ b/func/minion/modules/certmastermod.py @@ -25,19 +25,17 @@ class CertMasterModule(func_module.FuncModule): api_version = "0.0.1" description = "Administers certs on an overlord." - def get_hosts_to_sign(self, list_of_hosts): + def get_hosts_to_sign(self): """ ... """ - list_of_hosts = self.__listify(list_of_hosts) cm = certmaster.CertMaster() return cm.get_csrs_waiting() - def get_signed_certs(self, list_of_hosts): + def get_signed_certs(self): """ Returns a list of all signed certs on this minion """ - list_of_hosts = self.__listify(list_of_hosts) cm = certmaster.CertMaster() return cm.get_signed_certs() @@ -65,5 +63,38 @@ class CertMasterModule(func_module.FuncModule): if type(list_of_hosts) is type([]): return list_of_hosts else: - return [ list_of_hosts ] + return [ list_of_hosts ] + + def register_method_args(self): + """ + Export certmaster module + """ + + list_of_hosts = { + 'type':'list', + 'optional':False, + 'description':'A list of hosts to apply the operation' + } + return { + 'get_hosts_to_sign':{ + 'args':{}, + 'description':"Returns a list of hosts to sign" + }, + 'get_signed_certs':{ + 'args':{}, + 'description':"Get the certs you signed" + }, + 'sign_hosts':{ + 'args':{ + 'list_of_hosts':list_of_hosts + }, + 'description':"Sign a list of hosts" + }, + 'cleanup_hosts':{ + 'args':{ + 'list_of_hosts':list_of_hosts + }, + 'description':"Clean the certs for specified hosts" + } + } diff --git a/func/minion/modules/command.py b/func/minion/modules/command.py index cc463cf..b41dd9b 100644 --- a/func/minion/modules/command.py +++ b/func/minion/modules/command.py @@ -14,7 +14,7 @@ Abitrary command execution module for func. """ import func_module -import sub_process +from func.minion import sub_process class Command(func_module.FuncModule): @@ -42,3 +42,29 @@ class Command(func_module.FuncModule): if os.access(command, os.X_OK): return True return False + + def register_method_args(self): + """ + The argument export method + """ + #common type in both descriptions + command = { + 'type':'string', + 'optional':False, + 'description':'The command that is going to be used', + } + + return { + 'run':{ + 'args':{ + 'command':command + }, + 'description':'Run a specified command' + }, + 'exists':{ + 'args':{ + 'command':command + }, + 'description':'Check if specific command exists' + } + } diff --git a/func/minion/modules/echo.py b/func/minion/modules/echo.py index 97afe42..471820d 100644 --- a/func/minion/modules/echo.py +++ b/func/minion/modules/echo.py @@ -40,14 +40,24 @@ class EchoTest(func_module.FuncModule): Run a list """ return command + + + def run_list_star(self,*command): + """ + Run a star list :) + """ + return command + def run_hash(self,command): """ Run hash """ return command - + + + def run_boolean(self,command): """ Run boolean @@ -109,6 +119,17 @@ class EchoTest(func_module.FuncModule): }, 'description':'Returns back a list' }, + 'run_list_star':{ + 'args': + { + 'command':{ + 'type':'list*', + 'optional':False + } + }, + 'description':'Prototype for *args' + }, + 'run_hash':{ 'args': { @@ -119,6 +140,8 @@ class EchoTest(func_module.FuncModule): }, 'description':'Returns back a hash' }, + + 'run_boolean':{ 'args': { diff --git a/func/minion/modules/filetracker.py b/func/minion/modules/filetracker.py index f5f9dbb..6883fc1 100644 --- a/func/minion/modules/filetracker.py +++ b/func/minion/modules/filetracker.py @@ -190,3 +190,54 @@ class FileTracker(func_module.FuncModule): break m.update(d) return m.hexdigest() + + def register_method_args(self): + """ + Implementing the argument getter part + """ + + return { + 'inventory':{ + 'args':{ + 'flatten':{ + 'type':'boolean', + 'optional':True, + 'default':True, + 'description':"Show info in clean diffs" + }, + 'checksum_enabled':{ + 'type':'boolean', + 'optional':True, + 'default':True, + 'description':"Enable the checksum" + } + }, + 'description':"Returns information on all tracked files" + }, + 'track':{ + 'args':{ + 'file_name':{ + 'type':'string', + 'optional':False, + 'description':"The file name to track (full path)" + }, + 'full_scan':{ + 'type':'int', + 'optional':True, + 'default':0, + 'description':"The 0 is for off and 1 is for on" + } + }, + 'description':"Adds files to keep track of" + }, + 'untrack':{ + 'args':{ + 'file_name':{ + 'type':'string', + 'optional':False, + 'description':"The file name to untrack (full path)" + } + }, + 'description':"Remove the track from specified file name" + } + } diff --git a/func/minion/modules/hardware.py b/func/minion/modules/hardware.py index 46b1821..5a72da4 100644 --- a/func/minion/modules/hardware.py +++ b/func/minion/modules/hardware.py @@ -72,6 +72,32 @@ class HardwareModule(func_module.FuncModule): """ return hw_info(with_devices) + def register_method_args(self): + """ + Implementing the argument getter + """ + + return{ + 'hal_info':{ + 'args':{}, + 'description':'Returns the output of lshal'}, + 'inventory':{ + 'args':{}, + 'description':"The inventory part" + }, + 'info':{ + 'args':{ + 'with_devices':{ + 'type':'boolean', + 'optional':True, + 'default':True, + 'description':'All devices' + } + }, + 'description':"A struct of hardware information" + } + } + # ================================= def hw_info(with_devices=True): diff --git a/func/minion/modules/iptables/__init__.py b/func/minion/modules/iptables/__init__.py index 937fe4b..db11a23 100644 --- a/func/minion/modules/iptables/__init__.py +++ b/func/minion/modules/iptables/__init__.py @@ -147,3 +147,124 @@ class Iptables(func_module.FuncModule): self.policy("INPUT", "DROP") self.policy("OUTPUT", "DROP") self.policy("FORWARD", "DROP") + + def register_method_args(self): + """ + Implmenting the export arguments + """ + ip={ + 'type':'string', + 'optional':False, + 'default':'0.0.0.0' + } + chain={ + 'type':'string', + 'optional':False, + 'default':'INPUT', + 'options':['INPUT','OUTPUT','FORWARD'], + 'description':"The chain to apply policy" + } + + return { + 'run':{ + 'args':{ + 'args':{ + 'type':'string', + 'optional':False, + 'default':"-L", + 'description':"The iptables command to send" + } + }, + 'description':"Runs a iptables command" + }, + 'policy':{ + 'args':{ + 'chain':chain, + 'policy':{ + 'type':'string', + 'optional':True, + 'description':"The policy to apply (optional)" + } + + }, + 'description':"Change/set the policy of the given chain,if no policy is given it checks the chain status" + }, + 'flush':{ + 'args':{ + 'chain':chain + }, + 'description':"Flush the given chain" + }, + 'zero':{ + 'args':{ + 'chain':chain + }, + 'description':"Zero counters in selected chain (or INPUT if none given)" + }, + 'drop_from':{ + 'args':{ + 'ip':ip + }, + 'description':"Drop all incomming traffic from IP" + }, + 'reject_from':{ + 'args':{ + 'ip':ip + }, + 'description':"Reject all incoming traffic from IP" + }, + 'accept_from':{ + 'args':{ + 'ip':ip + }, + 'description':"Accept all incoming traffic from IP" + }, + 'drop_to':{ + 'args':{ + 'ip':ip + }, + 'description':"Drop all outgoing traffic to IP." + }, + 'reject_to':{ + 'args':{ + 'ip':ip + }, + 'description':"Reject all outgoing traffic to IP" + }, + 'accept_to':{ + 'args':{ + 'ip':ip + }, + 'description':"Accept all outgoing traffic to IP." + }, + 'inventory':{ + 'args':{}, + 'description':"The inventory part for that module" + }, + 'dump':{ + 'args':{ + 'counters':{ + 'type':'boolean', + 'optional':True, + 'default':False, + 'description':"Dump also the counters?" + } + }, + 'description':"Dump iptables configuration in iptables-save format" + }, + 'save':{ + 'args':{ + 'counters':{ + 'type':'boolean', + 'optional':True, + 'default':False, + 'description':"Save also the counters?" + } + }, + 'description':"Save iptables state using '/sbin/iptables-save'. If counters=True, save counters too." + }, + 'panic':{ + 'args':{}, + 'description':"Drop all traffic (similar to 'service iptables panic')." + } + } diff --git a/func/minion/modules/iptables/common.py b/func/minion/modules/iptables/common.py index c5214f5..ab65ae0 100644 --- a/func/minion/modules/iptables/common.py +++ b/func/minion/modules/iptables/common.py @@ -10,7 +10,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # other modules -import sub_process +from func.minion import sub_process def run_iptables(args): cmd = sub_process.Popen(["/sbin/iptables"] + args.split(), diff --git a/func/minion/modules/jboss.py b/func/minion/modules/jboss.py index 58d4756..a7a3fa2 100644 --- a/func/minion/modules/jboss.py +++ b/func/minion/modules/jboss.py @@ -13,8 +13,8 @@ import func_module -import sub_process -import codes +from func.minion import sub_process +from func.minion import codes import process import networktest import command @@ -174,6 +174,76 @@ class JBoss(func_module.FuncModule): return founded + def register_method_args(self): + """ + Implementin the method argument getter part + """ + + return { + 'status':{ + 'args':{}, + 'description':"Get jboss information" + }, + 'check':{ + 'args':{ + 'status':{ + 'type':'string', + 'optional':True, + 'description':"The status of instance to check (optional)" + } + }, + 'description':"Check if jboss instances works" + }, + 'search_by_port':{ + 'args':{ + 'port':{ + 'type':'int', + 'optional':False, + 'min':0, + 'max':65535, + 'description':'The port to search for' + }, + 'status':{ + 'type':'string', + 'optional':True, + 'description':"The status of instance to check (optional)" + } + }, + 'description':"Search instance by listening port" + }, + 'search_by_instance':{ + 'args':{ + 'instance':{ + 'type':'string', + 'optional':False, + 'description':"The name of the instance" + }, + 'status':{ + 'type':'string', + 'optional':True, + 'description':"The status of the instance to search (optional)" + } + }, + 'description':"Search instance by instance name" + }, + 'search_by_address':{ + 'args':{ + 'address':{ + 'type':'string', + 'optional':False, + 'description':"The bind adress to check" + }, + 'status':{ + 'type':'string', + 'optional':True, + 'description':"The status of the instance to search (optional)" + } + }, + 'description':"Search instance by bind address" + + } + } + ''' def start(self, address="127.0.0.1", instance="default"): """ diff --git a/func/minion/modules/mount.py b/func/minion/modules/mount.py index 0db914f..3c4abcc 100644 --- a/func/minion/modules/mount.py +++ b/func/minion/modules/mount.py @@ -12,8 +12,9 @@ ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## -import sub_process, os +import os import func_module +from func.minion import sub_process class MountModule(func_module.FuncModule): @@ -82,3 +83,79 @@ class MountModule(func_module.FuncModule): def inventory(self, flatten=True): return self.list() + + + def register_method_args(self): + """ + Implementing the method arg getter + """ + + return{ + 'list':{'args':{}, + 'description':"Listing the mounting points" + }, + 'mount':{ + 'args':{ + 'device':{ + 'type':'string', + 'optional':False, + 'description':'The device to be mounted', + }, + 'dir':{ + 'type':'string', + 'optional':False, + 'description':'The directory which will the device mounted under' + }, + 'type':{ + 'type':'string', + 'optional':True, + 'default':'auto', + 'description':'The type of the mount' + }, + 'options':{ + 'type':'list', + 'optional':True, + 'description':"Some extra options to be added to mount command" + }, + 'createdir':{ + 'type':'boolean', + 'optional':True, + 'description':'Check if you want to create the dir place if not exist' + } + }, + 'description':"Mount the specified device under some directory" + }, + 'umount':{'args':{ + 'dir':{ + 'type':'string', + 'optional':False, + 'description':'The directory which will be unmounted' + }, + 'killall':{ + 'type':'boolean', + 'optional':True, + 'description':'The killal option' + }, + 'force':{ + 'type':'boolean', + 'optional':True, + 'description':'To force operation check it' + }, + 'lazy':{ + 'type':'boolean', + 'optional':True, + 'description':'The lazy option' + } + }, + 'description':"Unmounting the specified directory." + }, + 'inventory':{'args':{ + 'flatten':{ + 'type':'boolean', + 'optional':True, + 'description':"To flatten check." + } + }, + 'description':"Th einventory part of that module" + } + } diff --git a/func/minion/modules/nagios-check.py b/func/minion/modules/nagios-check.py index f1c0714..89f2c61 100644 --- a/func/minion/modules/nagios-check.py +++ b/func/minion/modules/nagios-check.py @@ -32,3 +32,21 @@ class Nagios(func_module.FuncModule): cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False) data = cmdref.communicate() return (cmdref.returncode, data[0], data[1]) + + def register_method_args(self): + """ + Implementing argument getter part + """ + + return{ + 'run':{ + 'args':{ + 'check_command':{ + 'type':'string', + 'optional':False, + 'description':"The command to be checked" + } + }, + 'description':"Runs a nagios check returning the return code" + } + } diff --git a/func/minion/modules/netapp/common.py b/func/minion/modules/netapp/common.py index 979c95c..9f664b0 100644 --- a/func/minion/modules/netapp/common.py +++ b/func/minion/modules/netapp/common.py @@ -13,7 +13,7 @@ ## import re -import sub_process +from func.minion import sub_process SSH = '/usr/bin/ssh' SSH_USER = 'root' diff --git a/func/minion/modules/netapp/snap.py b/func/minion/modules/netapp/snap.py index 8f3f209..ee113f7 100644 --- a/func/minion/modules/netapp/snap.py +++ b/func/minion/modules/netapp/snap.py @@ -47,3 +47,50 @@ class Snap(func_module.FuncModule): """ return True + def register_method_args(self): + """ + Implementing the method argument getter part + """ + vol = { + 'type':'string', + 'optional':False, + 'description':"The name of the volume" + } + snap = { + 'type':'string', + 'optional':False, + 'description':"The name of the snapshot" + } + + filer = { + 'type':'string', + 'optional':False, + 'description':"Resolvable name of the target filer" + } + + return { + 'create':{ + 'args':{ + 'filer':filer, + 'vol':vol, + 'snap':snap + }, + 'description':"Returns True if snapshot is created successfully" + }, + 'delete':{ + 'args':{ + 'filer':filer, + 'vol':vol, + 'snap':snap + }, + 'description':"Returns True if snapshot is delete successfully" + }, + 'list':{ + 'args':{ + 'filer':filer, + 'vol':vol, + }, + 'description':"" + } + } + diff --git a/func/minion/modules/netapp/vol/__init__.py b/func/minion/modules/netapp/vol/__init__.py index 14ce0ac..5cd4898 100644 --- a/func/minion/modules/netapp/vol/__init__.py +++ b/func/minion/modules/netapp/vol/__init__.py @@ -126,3 +126,82 @@ class Vol(func_module.FuncModule): TODO: Document me ... """ pass + + def register_method_args(self): + """ + Implementing the method argument getter + """ + vol = { + 'type':'string', + 'optional':False, + 'description':"The name of the volume" + } + + filer = { + 'type':'string', + 'optional':False, + 'description':"Resolvable name of the target filer" + } + + return { + + 'create':{ + 'args':{ + 'filer':filer, + 'vol':vol, + 'aggr':{ + 'type':'string', + 'optional':False, + 'description':'Aggregate in which to create the new volume (e.g. aggr0)' + }, + 'size':{ + 'type':'string', + 'optional':False, + 'description':'Size of the new volume (e.g. 500g)' + } + }, + 'description':"Returns True if volume is created successfully" + + }, + 'destroy':{ + 'args':{ + 'filer':filer, + 'vol':vol + }, + 'description':"Returns True if volume is successfully destroyed" + + }, + 'offline':{ + 'args':{ + 'filer':filer, + 'vol':vol + }, + 'description':"Returns True if volume is successfully offlined" + }, + 'online':{ + 'args':{ + 'filer':filer, + 'vol':vol + }, + 'description':"Returns True if volume is successfully onlined" + }, + 'status':{ + 'args':{ + 'filer':filer, + 'vol':vol + }, + 'description':"If vol is not given, returns a list of dictionaries containing the status information of each volume in the system If vol is given, return just the dictionary for the given volume " + }, + 'size':{ + 'args':{ + 'filer':filer, + 'vol':vol, + 'delta':{ + 'type':'string', + 'optional':True, + 'description':'Optional change in size (e.g. +200g or -50g)' + } + }, + 'description':"If delta is not given, return the size of the given volume (e.g. '500g') If delta is given, return True if volume is successfully resized " + } + } diff --git a/func/minion/modules/netapp/vol/clone.py b/func/minion/modules/netapp/vol/clone.py index 715d8a8..ff924d0 100644 --- a/func/minion/modules/netapp/vol/clone.py +++ b/func/minion/modules/netapp/vol/clone.py @@ -42,5 +42,48 @@ class Clone(func_module.FuncModule): output = ssh(filer, cmd_opts) return check_output(regex, output) + + def register_method_args(self): + """ + Implementing netapp.clone export + """ + vol = { + 'type':'string', + 'optional':False, + 'description':"The name of the volume" + } + + filer = { + 'type':'string', + 'optional':False, + 'description':"Resolvable name of the target filer" + } + + snap = { + 'type':'string', + 'optional':False, + 'description':"The name of the snapshot" + } - + return { + 'create':{ + 'args':{ + 'filer':filer, + 'vol':vol, + 'snap':snap, + 'parent':{ + 'type':'string', + 'optional':False, + 'description':"The parent to clone" + } + }, + 'description':"Create a clone" + }, + 'split':{ + 'args':{ + 'filer':filer, + 'vol':vol + }, + 'description':"Split the vol" + } + } diff --git a/func/minion/modules/networktest.py b/func/minion/modules/networktest.py index 0e6fbb2..53fd453 100644 --- a/func/minion/modules/networktest.py +++ b/func/minion/modules/networktest.py @@ -10,9 +10,8 @@ import func_module -from codes import FuncException - -import sub_process +from func.minion.codes import FuncException +from func.minion import sub_process class NetworkTest(func_module.FuncModule): @@ -62,3 +61,67 @@ class NetworkTest(func_module.FuncModule): full_cmd = [command] + opts cmd = sub_process.Popen(full_cmd, stdout=sub_process.PIPE) return [line for line in cmd.communicate()[0].split('\n')] + + def register_method_args(self): + """ + Implementing method getter part + """ + + return{ + 'ping':{ + 'args':{ + 'args':{ + 'type':'list*', + 'optional':False, + 'description':"Options for ping command" + } + }, + 'description':"Ping command utility" + }, + 'netstat':{ + 'args':{ + 'args':{ + 'type':'list*', + 'optional':False, + 'description':"Options for netstat command" + }}, + 'description':"The unix netstat command utility" + }, + 'traceroute':{ + 'args':{ + 'args':{ + 'type':'list*', + 'optional':False, + 'description':"Options for traceroute command" + + }}, + 'description':"Traceroute network utility" + }, + 'dig':{ + 'args':{ + 'args':{ + 'type':'list*', + 'optional':False, + 'description':"Options for dig command" + + }}, + 'description':"Dig command utility" + }, + 'isportopen':{ + 'args':{ + 'host':{ + 'type':'string', + 'optional':False, + 'description':"The name of the host to be checked" + }, + 'port':{ + 'type':'int', + 'optional':False, + 'min':0, + 'max':65535, + 'description':'The port to be checked on specified host' + } + }, + 'description':"Checks if port is open for specified host" + } + } diff --git a/func/minion/modules/overlord.py b/func/minion/modules/overlord.py index 743c672..7195019 100644 --- a/func/minion/modules/overlord.py +++ b/func/minion/modules/overlord.py @@ -45,5 +45,23 @@ class OverlordModule(func_module.FuncModule): else: maphash[current_minion] = {} return maphash + + def register_method_args(self): + """ + Export overlord + """ + return { + 'map_minions':{ + 'args':{ + 'get_only_alive':{ + 'type':'boolean', + 'optional':True, + 'default':True, + 'description':"Get only online ones" + } + }, + 'description':"Builds a recursive map of the minions currently assigned to this minion overlord" + } + } diff --git a/func/minion/modules/process.py b/func/minion/modules/process.py index 22141c3..80e76fd 100644 --- a/func/minion/modules/process.py +++ b/func/minion/modules/process.py @@ -14,8 +14,8 @@ ## # other modules -import sub_process -import codes +from func.minion import sub_process +from func.minion import codes # our modules import func_module @@ -218,3 +218,55 @@ class ProcessModule(func_module.FuncModule): rc = sub_process.call(["/usr/bin/pkill", name, level], executable="/usr/bin/pkill", shell=False) return rc + + def register_method_args(self): + """ + Implementing the argument getter + """ + return{ + 'info':{ + 'args':{ + 'flags':{ + 'type':'string', + 'default':'-auxh', + 'optional':True, + 'description':"Flags for ps command" + } + }, + 'description':'Get the process info for system' + }, + 'mem':{ + 'args':{}, + 'description':"Returns a list of per-program memory usage." + }, + 'kill':{ + 'args':{ + 'pid':{ + 'type':'int', + 'optional':False, + 'description':"The pid for process to be killed" + }, + 'signal':{ + 'type':'string', + 'optional':True, + 'default':"TERM", + 'description':"Signal to send before killing" + } + }, + "description":"Kill a process with proper signal" + }, + 'pkill':{ + 'args':{ + 'name':{ + 'type':'string', + 'optional':False, + 'description':"The name of the app but with full path info ." }, + 'level':{ + 'type':'string', + 'optional':True, + 'description':"Level of killing" + } + }, + "description":"Kill an app with supplying a name and level" + } + } diff --git a/func/minion/modules/reboot.py b/func/minion/modules/reboot.py index c4fb275..70a4db0 100644 --- a/func/minion/modules/reboot.py +++ b/func/minion/modules/reboot.py @@ -9,7 +9,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import func_module -import sub_process +from func.minion import sub_process class Reboot(func_module.FuncModule): @@ -19,3 +19,28 @@ class Reboot(func_module.FuncModule): def reboot(self, when='now', message=''): return sub_process.call(["/sbin/shutdown", '-r', when, message]) + + def register_method_args(self): + """ + Implementing method getter part + """ + + return { + 'reboot':{ + 'args':{ + 'when':{ + 'type':'string', + 'optional':True, + 'default':'now', + 'description':"When to reboot (optional)" + }, + 'message':{ + 'type':'string', + 'optional':True, + 'description':"The shutdown message" + } + }, + 'description':"Rebooting the minions" + } + } + diff --git a/func/minion/modules/rpms.py b/func/minion/modules/rpms.py index 66d9129..f271406 100644 --- a/func/minion/modules/rpms.py +++ b/func/minion/modules/rpms.py @@ -67,3 +67,38 @@ class RpmModule(func_module.FuncModule): else: results.append([name, epoch, version, release, arch]) return results + + def register_method_args(self): + """ + Implementing the method argument getter + """ + + return { + 'inventory':{ + 'args':{ + 'flatten':{ + 'type':'boolean', + 'optional':True, + 'default':True, + 'description':"Print clean in difss" + } + }, + 'description':"Returns information on all installed packages" + }, + 'glob':{ + 'args':{ + 'pattern':{ + 'type':'string', + 'optional':False, + 'description':"The glob packet pattern" + }, + 'flatten':{ + 'type':'boolean', + 'optional':True, + 'default':True, + 'description':"Print clean in difss" + } + }, + 'description':"Return a list of installed packages that match a pattern" + } + } diff --git a/func/minion/modules/smart.py b/func/minion/modules/smart.py index f410f09..e8e4844 100644 --- a/func/minion/modules/smart.py +++ b/func/minion/modules/smart.py @@ -45,3 +45,22 @@ class SmartModule(func_module.FuncModule): results.append(x) return (cmd.returncode, results) + + def register_method_args(self): + """ + Implementing method argument getter + """ + + return { + 'info':{ + 'args':{ + 'flags':{ + 'type':'string', + 'optional':True, + 'default':'-q onecheck', + 'description':"Flags for smart command" + } + }, + 'description':"Grabs status from SMART to see if your hard drives are ok." + } + } diff --git a/func/minion/modules/snmp.py b/func/minion/modules/snmp.py index c992db1..c06655d 100644 --- a/func/minion/modules/snmp.py +++ b/func/minion/modules/snmp.py @@ -14,7 +14,7 @@ Abitrary command execution module for func. """ import func_module -import sub_process +from func.minion import sub_process base_snmp_command = '/usr/bin/snmpget -v2c -Ov -OQ' class Snmp(func_module.FuncModule): @@ -32,7 +32,35 @@ class Snmp(func_module.FuncModule): cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False) data = cmdref.communicate() return (cmdref.returncode, data[0], data[1]) + + def register_method_args(self): + """ + Implementing the argument getter + """ + return { + 'get':{ + 'args':{ + 'oid':{ + 'type':'string', + 'optional':False, + 'description':'The oid' + }, + 'rocommunity':{ + 'type':'string', + 'optional':False, + 'description':"The rocommunity" + }, + 'hostname':{ + 'type':'string', + 'optional':True, + 'default':'localhost', + 'description':"The hostname tobe apllied on" + } + }, + 'description':"Runs an snmpget on a specific oid returns the output of the call" + } + } #def walk(self, oid, rocommunity): #def table(self, oid, rocommunity): diff --git a/func/minion/modules/sysctl.py b/func/minion/modules/sysctl.py index 1f11d55..36b5605 100644 --- a/func/minion/modules/sysctl.py +++ b/func/minion/modules/sysctl.py @@ -29,3 +29,41 @@ class SysctlModule(func_module.FuncModule): def set(self, name, value): return self.__run("/sbin/sysctl -w %s=%s" % (name, value)) + + def register_method_args(self): + """ + Implementing the method argument getter + """ + + return { + 'list':{ + 'args':{}, + 'description':"Display all values currently available." + }, + 'get':{ + 'args':{ + 'name':{ + 'type':'string', + 'optional':False, + 'description':"The name of a key to read from. An example is kernel.ostype" + } + }, + 'description':"Use this option to disable printing of the key name when printing values" + }, + 'set':{ + 'args':{ + 'name':{ + 'type':'string', + 'optional':False, + 'description':"The name of a key to read from. An example is kernel.ostype" + }, + 'value':{ + 'type':'string', + 'optional':False, + 'description':"The name value to be set." + } + + }, + 'description':"Use this option when you want to change a sysctl setting" + } + } diff --git a/func/minion/modules/test.py b/func/minion/modules/test.py index 77324c4..4006f8a 100644 --- a/func/minion/modules/test.py +++ b/func/minion/modules/test.py @@ -33,3 +33,55 @@ class Test(func_module.FuncModule): Returns whatever was passed into it """ return data + + def register_method_args(self): + """ + Implementing method argument getter + """ + + return { + 'add':{ + 'args':{ + 'numb1':{ + 'type':'int', + 'optional':False, + 'description':'An int' + }, + 'numb2':{ + 'type':'int', + 'optional':False, + 'description':'An int' + } + + }, + 'description':'Gives back the sum of 2 integers' + }, + 'ping':{ + 'args':{}, + 'description':"Ping the minion" + }, + 'sleep':{ + 'args':{ + 't':{ + 'type':'int', + 'optional':False, + 'description':'Num of sec' + } + }, + 'description':"Sleep for a while" + }, + 'explode':{ + 'args':{}, + 'description':"Raises an exception" + }, + 'echo':{ + 'args':{ + 'data':{ + 'type':'string', + 'optional':False, + 'description':"The message to send" + } + }, + 'description':"Echoes back the sent data " + } + } diff --git a/func/minion/modules/yumcmd.py b/func/minion/modules/yumcmd.py index 072b907..a35b104 100644 --- a/func/minion/modules/yumcmd.py +++ b/func/minion/modules/yumcmd.py @@ -69,3 +69,36 @@ class Yum(func_module.FuncModule): pkg_list = exactmatch + matched return map(str, pkg_list) + + def register_method_args(self): + """ + Implementing the argument getter + """ + + return{ + 'update':{ + 'args':{ + 'pkg':{ + 'type':'string', + 'optional':True, + 'description':"The yum pattern for updating package" + } + }, + 'description':"Updating system according to a specified pattern" + }, + 'check_update':{ + 'args':{ + 'filter':{ + 'type':'list', + 'optional':True, + 'description':"A list of what you want to update" + }, + 'repo':{ + 'type':'string', + 'optional':True, + 'description':'Repo name to use for that update' + } + }, + 'description':"Cheking for updates with supplied filter patterns and repo" + } + } diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py index 0743442..e1674fe 100644 --- a/func/overlord/cmd_modules/call.py +++ b/func/overlord/cmd_modules/call.py @@ -160,6 +160,7 @@ class Call(base_command.BaseCommand): print "JOB_ID:", pprint.pformat(results) return results else: + return self.overlord_obj.local.utils.async_poll(results, self.print_results) # dump the return code stuff atm till we figure out the right place for it |