Debian Codegraph @

doc/source/main.py

raw symbols SCIP
1 # Copyright 2018 Red Hat Inc.
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
15 """Example CLI command for running upgrade checks"""
16
17 import sys
18
19 from oslo_config import cfg
20 from oslo_upgradecheck import upgradecheck
21
22
23 class Checks(upgradecheck.UpgradeCommands):
24 def success(self):
25 return upgradecheck.Result(
26 upgradecheck.Code.SUCCESS, 'Always succeeds'
27 )
28
29 def failure(self):
30 return upgradecheck.Result(upgradecheck.Code.FAILURE, 'Always fails')
31
32 _upgrade_checks = (('always succeeds', success), ('always fails', failure))
33
34
35 def main():
36 return upgradecheck.main(
37 conf=cfg.CONF, project='myprojectname', upgrade_command=Checks()
38 )
39
40
41 if __name__ == '__main__':
42 sys.exit(main())