blob: 420626413e89eb778f74025729a2961818002fb1 (
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
|
##############################################################################
# Copyright (c) 2016 Juan Qiu and others
# juan_ qiu@tongji.edu.cn
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
class ActionPlayer(object):
"""
Abstract the action functions of attacker,
monitor, operation, resultchecker and mybe others in future
"""
def action(self):
pass
class AttackerPlayer(ActionPlayer):
def __init__(self, attacker):
self.underlyingAttacker = attacker
def action(self):
self.underlyingAttacker.inject_fault()
class OperationPlayer(ActionPlayer):
def __init__(self, operation):
self.underlyingOperation = operation
def action(self):
self.underlyingOperation.run()
class MonitorPlayer(ActionPlayer):
def __init__(self, monitor):
self.underlyingmonitor = monitor
def action(self):
self.underlyingmonitor.start_monitor()
class ResultCheckerPlayer(ActionPlayer):
def __init__(self, resultChecker):
self.underlyingresultChecker = resultChecker
def action(self):
self.underlyingresultChecker.verify()
|