Creating Director and related codes.
[yardstick.git] / yardstick / benchmark / scenarios / availability / actionplayers.py
1 ##############################################################################
2 # Copyright (c) 2016 Juan Qiu and others
3 # juan_ qiu@tongji.edu.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10
11 class ActionPlayer(object):
12     """
13     Abstract the action functions of attacker,
14     monitor, operation, resultchecker and mybe others in future
15     """
16
17     def action(self):
18         pass
19
20
21 class AttackerPlayer(ActionPlayer):
22
23     def __init__(self, attacker):
24         self.underlyingAttacker = attacker
25
26     def action(self):
27         self.underlyingAttacker.inject_fault()
28
29
30 class OperationPlayer(ActionPlayer):
31
32     def __init__(self, operation):
33         self.underlyingOperation = operation
34
35     def action(self):
36         self.underlyingOperation.run()
37
38
39 class MonitorPlayer(ActionPlayer):
40
41     def __init__(self, monitor):
42         self.underlyingmonitor = monitor
43
44     def action(self):
45         self.underlyingmonitor.start_monitor()
46
47
48 class ResultCheckerPlayer(ActionPlayer):
49
50     def __init__(self, resultChecker):
51         self.underlyingresultChecker = resultChecker
52
53     def action(self):
54         self.underlyingresultChecker.verify()