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 from __future__ import absolute_import
12 LOG = logging.getLogger(__name__)
15 class ActionRollbacker(object):
17 Abstract the rollback functions of attacker, operation
18 and mybe others in future
25 class AttackerRollbacker(ActionRollbacker):
27 def __init__(self, attacker):
28 self.underlyingAttacker = attacker
32 "\033[93m recovering attacker %s \033[0m",
33 self.underlyingAttacker.key)
34 self.underlyingAttacker.recover()
37 class OperationRollbacker(ActionRollbacker):
39 def __init__(self, operation):
40 self.underlyingOperation = operation
44 "\033[93m rollback operation %s \033[0m",
45 self.underlyingOperation.key)
46 self.underlyingOperation.rollback()