summaryrefslogtreecommitdiffstats
path: root/func/minion/modules/test.py
blob: efcfde6694cdf70e61239c37f6ad78f414d57793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import func_module
import time
import exceptions

class Test(func_module.FuncModule):
    version = "11.11.11"
    api_version = "0.0.1"
    description = "Just a very simple example module"

    def add(self, numb1, numb2):
        return numb1 + numb2

    def ping(self):
        return 1

    def sleep(self,t):
        """
        Sleeps for t seconds, and returns time of day.
        Simply a test function for trying out async and threaded voodoo.
        """
        t = int(t)
        time.sleep(t)
        return time.time()

    def explode(self):
        """
        Testing remote exception handling is useful
        """
        raise exceptions.Exception("khhhhhhaaaaaan!!!!!!")

    def echo(self, data):
        """
        Returns whatever was passed into it
        """
        return data

    def bigint(self):
        """
        Returns an integer greater than 2^32-1
        """
        return 2**32


    def configfoo(self):
        """
        Returns the options config
        """
        return self.options

    def config_save(self):
	"""
	Saves the options config
	"""
	self.save_config()
	return self.options

    def config_set(self, key_name, value):
        setattr(self.options,key_name, value)
        self.save_config()
        return self.options


    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 "
                    },
                'bigint':{
                    'args':{},
                    'description':"Returns a number greater than 2^32-1"
                    }
                }