Coverage for watcher/applier/actions/nop.py: 96%

26 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-17 12:22 +0000

1# -*- encoding: utf-8 -*- 

2# Copyright (c) 2015 b<>com 

3# 

4# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com> 

5# 

6# Licensed under the Apache License, Version 2.0 (the "License"); 

7# you may not use this file except in compliance with the License. 

8# You may obtain a copy of the License at 

9# 

10# http://www.apache.org/licenses/LICENSE-2.0 

11# 

12# Unless required by applicable law or agreed to in writing, software 

13# distributed under the License is distributed on an "AS IS" BASIS, 

14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 

15# implied. 

16# See the License for the specific language governing permissions and 

17# limitations under the License. 

18# 

19 

20from oslo_log import log 

21 

22from watcher.applier.actions import base 

23 

24LOG = log.getLogger(__name__) 

25 

26 

27class Nop(base.BaseAction): 

28 """logs a message 

29 

30 The action schema is:: 

31 

32 schema = Schema({ 

33 'message': str, 

34 }) 

35 

36 The `message` is the actual message that will be logged. 

37 """ 

38 

39 MESSAGE = 'message' 

40 

41 @property 

42 def schema(self): 

43 return { 

44 'type': 'object', 

45 'properties': { 

46 'message': { 

47 'type': ['string', 'null'] 

48 } 

49 }, 

50 'required': ['message'], 

51 'additionalProperties': False, 

52 } 

53 

54 @property 

55 def message(self): 

56 return self.input_parameters.get(self.MESSAGE) 

57 

58 def execute(self): 

59 LOG.debug("Executing action NOP message: %s ", self.message) 

60 return True 

61 

62 def revert(self): 

63 LOG.debug("Revert action NOP") 

64 return True 

65 

66 def pre_condition(self): 

67 pass 

68 

69 def post_condition(self): 

70 pass 

71 

72 def get_description(self): 

73 """Description of the action""" 

74 return "Logging a NOP message" 

75 

76 def abort(self): 

77 LOG.debug("Abort action NOP") 

78 return True