blob: 38f57d47642c5e1f6c6a0a31d02b5c2e199c75d7 (
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
|
##############################################################################
# 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
##############################################################################
import logging
LOG = logging.getLogger(__name__)
class ActionRollbacker(object):
"""
Abstract the rollback functions of attacker, operation
and mybe others in future
"""
def rollback(self):
pass
class AttackerRollbacker(ActionRollbacker):
def __init__(self, attacker):
self.underlyingAttacker = attacker
def rollback(self):
LOG.debug(
"\033[93m recovering attacker %s \033[0m",
self.underlyingAttacker.key)
self.underlyingAttacker.recover()
class OperationRollbacker(ActionRollbacker):
def __init__(self, operation):
self.underlyingOperation = operation
def rollback(self):
LOG.debug(
"\033[93m rollback operation %s \033[0m",
self.underlyingOperation.key)
self.underlyingOperation.rollback()
|