Merge "Remove references to "dpdk_nic_bind" utility"
[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, intermediate_variables):
24         self.underlyingAttacker = attacker
25         self.underlyingAttacker.intermediate_variables \
26             = intermediate_variables
27
28     def action(self):
29         self.underlyingAttacker.inject_fault()
30
31
32 class OperationPlayer(ActionPlayer):
33
34     def __init__(self, operation, intermediate_variables):
35         self.underlyingOperation = operation
36         self.underlyingOperation.intermediate_variables \
37             = intermediate_variables
38
39     def action(self):
40         self.underlyingOperation.run()
41
42
43 class MonitorPlayer(ActionPlayer):
44
45     def __init__(self, monitor, intermediate_variables):
46         self.underlyingmonitor = monitor
47         self.underlyingmonitor.intermediate_variables \
48             = intermediate_variables
49
50     def action(self):
51         self.underlyingmonitor.start_monitor()
52
53
54 class ResultCheckerPlayer(ActionPlayer):
55
56     def __init__(self, resultChecker, intermediate_variables):
57         self.underlyingresultChecker = resultChecker
58         self.underlyingresultChecker.intermediate_variables \
59             = intermediate_variables
60
61     def action(self):
62         self.underlyingresultChecker.verify()