Coverage for watcher/cmd/status.py: 86%

19 statements  

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

1# Copyright (c) 2018 NEC, Corp. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); you may 

4# not use this file except in compliance with the License. You may obtain 

5# a copy of the License at 

6# 

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

8# 

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

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

11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

12# License for the specific language governing permissions and limitations 

13# under the License. 

14 

15import sys 

16 

17from oslo_upgradecheck import common_checks 

18from oslo_upgradecheck import upgradecheck 

19 

20from watcher._i18n import _ 

21from watcher.common import clients 

22from watcher import conf 

23 

24CONF = conf.CONF 

25 

26 

27class Checks(upgradecheck.UpgradeCommands): 

28 

29 """Contains upgrade checks 

30 

31 Various upgrade checks should be added as separate methods in this class 

32 and added to _upgrade_checks tuple. 

33 """ 

34 

35 def _minimum_nova_api_version(self): 

36 """Checks the minimum required version of nova_client.api_version""" 

37 try: 

38 clients.check_min_nova_api_version(CONF.nova_client.api_version) 

39 except ValueError as e: 

40 return upgradecheck.Result( 

41 upgradecheck.Code.FAILURE, str(e)) 

42 return upgradecheck.Result(upgradecheck.Code.SUCCESS) 

43 

44 _upgrade_checks = ( 

45 # Added in Train. 

46 (_('Minimum Nova API Version'), _minimum_nova_api_version), 

47 # Added in Wallaby. 

48 (_("Policy File JSON to YAML Migration"), 

49 (common_checks.check_policy_json, {'conf': CONF})), 

50 

51 ) 

52 

53 

54def main(): 

55 return upgradecheck.main( 

56 CONF, project='watcher', upgrade_command=Checks()) 

57 

58 

59if __name__ == '__main__': 59 ↛ 60line 59 didn't jump to line 60 because the condition on line 59 was never true

60 sys.exit(main())